problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03556
s850961522
Accepted
import math N=int(input()) c=int(math.sqrt(N)) print(c**2)
p02777
s535257180
Accepted
S,T = input().split() A,B = map(int,input().split()) U = input() if S ==U: print(A-1,B) else: print(A,B-1)
p02631
s169124365
Accepted
n = int(input()) ai = [int(i) for i in input().split()] ans = ai[0] for i in range(n-1): ans = ans ^ ai[i+1] ans_li = [] for i in range(n): ans_li.append(ans^ai[i]) print(*ans_li)
p03705
s962786022
Accepted
import math #import numpy as np import queue from collections import deque,defaultdict import heapq as hpq from sys import stdin,setrecursionlimit #from scipy.sparse.csgraph import dijkstra #from scipy.sparse import csr_matrix ipt = stdin.readline setrecursionlimit(10**7) def main(): n,a,b = map(int,ipt().split()) if a > b: print(0) else: print(max(0,(n-2)*b-(n-2)*a+1)) return if __name__ == '__main__': main()
p03035
s375770934
Accepted
import sys import math import bisect def main(): a, b = map(int, input().split()) if a <= 5: ans = 0 elif a <= 12: ans = b // 2 else: ans = b print(ans) if __name__ == "__main__": main()
p03001
s943126938
Accepted
def main(): W, H, x, y = map(int, input().split()) if x * 2 == W and y * 2 == H: print(W * H / 2, 1) else: print(W * H / 2, 0) if __name__ == '__main__': main()
p03796
s130493428
Wrong Answer
N = int(input()) mod = 10**9+7 for i in range(1, N+1): N *= i N %= mod print(N % mod)
p03695
s547402203
Wrong Answer
N = int(input()) A = [int(i) for i in input().split()] ans = 0 for i in range(1,3200,400): flag = False for j in range(i - 1, i + 398 + 1): if j in A: flag = True if flag: ans += 1 ans1 = ans ans2 = ans + len([a for a in A if a >= 3200]) print(ans1,ans2)
p03493
s975981654
Accepted
print(input().count('1'))
p03860
s260837132
Accepted
s = list(input().split()) print(s[0][0],s[1][0],s[2][0],sep='')
p02701
s492129542
Wrong Answer
import collections N = int(input()) S_list = set(list(map(str,input().split()))) print(len(S_list))
p03087
s243833947
Wrong Answer
N,Q = map(int,input().split()) S = input() AC = [] for i in range(N-1): if S[i]+S[i+1] == "AC": AC.append(i+1.5) print(AC) for j in range(Q): l,r = map(int,input().split()) cnt = 0 for k in AC: if l < k < r: cnt += 1 if r < k: break print(cnt)
p02578
s758576921
Accepted
n = int(input()) a = list(map(int,input().split())) bmax = a[0] st = 0 for i in range(1,n): if a[i] < bmax: st += bmax - a[i] else: bmax = a[i] print(st)
p03282
s913050120
Accepted
s=input() k=int(input()) l=0 for i in s: if i=="1": l+=1 else: break print("1" if k<=l else s[l])
p02601
s788282720
Accepted
r, g, b = map(int, input().split()) op = int(input()) while op > 0 and g <= r: g *= 2 op -= 1 while op > 0 and b <= g: b *= 2 op -=1 if r < g and g < b: print("Yes") else: print("No")
p03827
s642935493
Accepted
n=int(input()) s=input() x=0 Mx=x for i in range(n): if s[i]=='I': x+=1 else: x-=1 Mx=max(Mx, x) print(Mx)
p04034
s008216425
Wrong Answer
n,m = map(int,input().split()) dic = {} ls = [1]*(n+1) ls[0] = 0 cnt = 0 for i in range(m): a,b = map(int,input().split()) a -= 1 b -= 1 ls[a] -= 1 ls[b] += 1 if dic.get(b,0) == 0: cnt += 1 dic[b] = 1 print(sum([1 for e in range(1,n+1) if ls[e] > 0 and dic.get(e,0)!= 0]))
p03416
s722091851
Accepted
A, B = map(int,input().split()) r = B - A +1 ans = 0 for i in range(r): n = str(A + i) l = len(n)//2 count = 0 for j in range(l): if n[j] == n[-(j+1)]: count +=1 if count == l: ans += 1 print(ans)
p02796
s908931038
Accepted
import sys input = sys.stdin.readline n = int(input()) ll = [] for i in range(n): x, l = map(int, input().split()) ll.append([x-l, x+l]) ll.sort(key=lambda x:x[1]) ans = 0 tmp = -10**9 for s, t in ll: if s >= tmp: ans += 1 tmp = t print(ans)
p02792
s321236693
Wrong Answer
n = int(input()) r = range(1, 10) a = [[0] * 9 for _ in r] for i in r: if i <= n: a[i - 1][i - 1] += 1 for i in r: for j in r: k = 1 while 10 * k * i + j <= n: a[i - 1][j - 1] += min(k, (n - 10 * k * i + j) // 10) k *= 10 print(sum(a[i][j] * a[j][i] for i in range(9) for j in range(9)))
p03611
s302534592
Wrong Answer
N = int(input()) a = list(map(int,input().split())) g = [0]*10 for i in range(10): g[i] = a.count(i) ans = 1 for i in range(10): if i == 0: tmp = g[i] + g[i+1] elif i == 9: tmp = g[i-1] + g[i] else: tmp = g[i-1] + g[i] + g[i+1] ans = max(ans,tmp) print(ans)
p03131
s055749662
Accepted
import bisect,collections,copy,heapq,itertools,math,string import sys def input() : return sys.stdin.readline().strip() def INT() : return int(input()) def MAP() : return map(int,input().split()) def LIST() : return list(MAP()) k,a,b = MAP() if(b-a<=1): ans = 1 + k else: n = (1+k-a)//2 ans = 1 + k - 2*n + (b-a)*n print(ans)
p03105
s741036922
Accepted
a, b, c = map(int, input().split()) print(min(c, b // a))
p02594
s562589670
Accepted
x = int(input()) if x >= 30: print("Yes") else: print("No")
p02724
s330666422
Wrong Answer
X = int(input()) a, b = 0, 0 a = X // 500 b = (X - 500 * a) % 5 print(1000 * a + 5 * b)
p03672
s930756785
Accepted
s = input() rs = s[::-1] n = len(s) // 2 for i in range(1, n): r = rs[i*2:] rn = len(r) if r[:rn//2] == r[rn//2:]: print(rn) exit() print(0)
p02918
s708747510
Wrong Answer
N, K = map(int, input().split()) S = input() cnt =0 for i in range(N-1): p = S[i]+S[i+1] if p =='RL': cnt += 1 cnt2 = 0 if S[0] == 'L': cnt2 += 1 if S[-1] == 'R': cnt2 += 1 n =N- cnt *2-cnt2 if cnt - 1 >= K: print(n+2*K) else: print(N-1)
p04034
s566929831
Wrong Answer
n,m=map(int,input().split()) xy = [list(map(int, input().split())) for _ in range(m)] l=[1]*n out_=[0]*n in_=[0]*n#入れられたことがある履歴。0番目だけは初期値1 in_[0]=1 c=0 #print(in_) for i in range(m): l[xy[i][0]-1]-=1 l[xy[i][1]-1]+=1 if in_[xy[i][0]-1]!=0: c+=1 in_[xy[i][1]-1]+=1 #print(l,in_,c) c2=0 for i in l: if i!=0: c2+=1 print(min(c,c2))
p03835
s598930654
Wrong Answer
k, s =map(int,input().split()) cnt = 0 for i in range(k+1): for j in range(k+1): if 0<=s-i-j<=k: cnt += 1 print(i,j,s-i-j) print(cnt)
p02754
s891984923
Wrong Answer
n, a, b = list(map(int, input().split())) print (a* (n//(a+b)) + n%(a+b))
p02947
s037023609
Accepted
from collections import Counter import math n = int(input()) s_list = ["".join(map(str,sorted(input()))) for i in range(n)] s_counter = Counter(s_list) s_len = len(s_counter) s_most = s_counter.most_common() #print(s_counter) ans = 0 for i in range(s_len): if s_most[i][1] != 1: dum = s_most[i][1] ans += (dum * (dum-1)) // 2 else: break print(ans)
p03695
s987598983
Wrong Answer
def resolve(): N = int(input()) A = list(map(int, input().split())) cnt = [False] * 8 tuyo = 0 for i in range(N): if 1 <= A[i] <= 3199: cnt[A[i] // 400] = True else: tuyo += 1 val = 0 for i in cnt: if i: val += 1 if val==0 and tuyo>0: val=1 print(val, val + tuyo) resolve()
p03680
s207026433
Accepted
n = int(input()) A = [int(input()) for _ in range(n)] #%% idx = 0 visited = set() count = 0 flag = False for i in range(n): next_idx = A[idx] next_idx -= 1 visited.add(idx) if idx == 1: flag = True break elif next_idx in visited: break count += 1 idx = next_idx if flag: print(count) else: print(-1)
p03106
s001351414
Accepted
a, b, k = map(int, input().split()) res = [] for i in range(1, 101): if a%i == 0 and b%i == 0: res.append(i) print(res[-k])
p03556
s946288605
Accepted
import math N = int(input()) for x in range(N, 0, -1): sq = math.sqrt(x) div, mod = divmod(sq, 1) if mod == 0: print(x) break
p02723
s775747593
Accepted
s = input() if s[2]==s[3] and s[4]==s[5]: print("Yes") else: print("No")
p03720
s963467235
Wrong Answer
import collections def main(): n, m = map(int, input().split()) ab = [list(map(int, input().split())) for i in range(m)] ab_f = [flatten for inner in ab for flatten in inner] c = collections.Counter(ab_f) c_s = sorted(c.items()) for i in (c_s): print(i[1]) if __name__ == '__main__': main()
p03331
s365441955
Wrong Answer
import sys input = sys.stdin.readline # A - Digits Sum def digits_sum(num): sum = 0 for s in str(num): sum += int(s) return sum N = int(input()) ans = sys.maxsize for A in range(1, N//2): B = N - A sum = digits_sum(A) + digits_sum(B) ans = min(ans, sum) print(ans)
p03030
s616156978
Accepted
n = int(input()) sp = [] for i in range(n): s, p = input().split() sp.append((i+1, s, int(p))) sp.sort(key=lambda x: (x[1], -int(x[2]))) for i, _, _ in sp: print(i)
p02983
s628991096
Accepted
L, R = map(int, input().split()) # R-L>=2019なら、[L,R]に2019の倍数が必ず存在する if R - L >= 2019: print(0) else: ans = 10**9 for i in range(L, R + 1): # L<=i<=R for j in range(i + 1, R + 1): # i<j<=R ans = min(ans, (i * j) % 2019) print(ans)
p02690
s590675942
Accepted
import sys x=int(input()) for a in range(-1000,1000): for b in range(-1000,1000): if a**5 - b**5 == x: print(a,b) sys.exit()
p03494
s603224190
Accepted
N = int(input()) A = list(map(int,input().split())) flg = True cnt = 0 total = 0 while flg: for i in range(N): if A[i] % 2 == 0: A[i] = A[i] // 2 cnt += 1 if cnt == N: total += 1 else: flg = False cnt = 0 print(total)
p02832
s113257489
Accepted
N = int(input()) a = list(map(int, input().split())) count = 1 broke = 0 if 1 not in a: print(-1) exit() for x in range(N): if a[x] == count: count += 1 print(N - count + 1)
p02860
s412812732
Wrong Answer
N = int(input()) S = input() if S[:3] == S[3:]: print('Yes') else: print('No')
p02814
s924320700
Accepted
from fractions import gcd from functools import reduce N, M, *A = map(int, open(0).read().split()) Y = reduce(lambda a, b: a * b // gcd(a, b), A) if any((Y // a) % 2 == 0 for a in A): print(0) quit() print(M // (Y // 2) - (M // Y))
p03073
s351315871
Accepted
n = str(input()) a = "10" * int(len(n)/2) b = "01" * int(len(n)/2) if int(len(n)) % 2 !=0: a +="1" b +="0" s = int(n) + int(a) t = int(n) + int(b) p = str(s) q = str(t) print(min(p.count("1"),q.count("1")))
p02765
s668833161
Accepted
N, R = map(int, input().split()) if N >= 10: print(R) else: print(R+100*(10-N))
p03001
s906959828
Accepted
W,H,x,y = map(int,input().split()) if ((W/2 == x) and (H/2 == y)) or ((W/2 == y) and (H/2 == x)): print(W*H/2,end="") print(" ",end="") print(1) else: print(W*H/2,end="") print(" ",end="") print(0)
p02765
s724965805
Accepted
N,R=map(int,input().split()) if N<10: print(R+(100*(10-N))) else: print(R)
p02597
s485356992
Accepted
n = int(input()) a = list(input()) #print(a) w = a.count("W") r = a.count("R") aa = a[:r] #print(aa) r2 = aa.count("R") print(r-r2)
p03485
s314365819
Wrong Answer
a, b = map(int, input().split()) print(-((-a+b)//2))
p02693
s284402591
Wrong Answer
if __name__ == '__main__': k = input() k = int(k) ab = input() ab = ab.split() a = int(ab[0]) b = int(ab[1]) flag = False sum = k while k<b: if a<=k and k<=b: flag = True k += sum if flag: print("OK") else: print("NG")
p03380
s872172122
Accepted
import bisect N = int(input()) A = list(map(int, input().split())) A.sort() # 組み合わせの片方は最大値 n = A[-1] # もう片方はnの半分に近い値 # 二分探索で最も近い値を見つける mid = bisect.bisect(A, n/2) # 一つ手前の値とどちらが近いかチェックして、近い方を出力する if abs(n/2-A[mid-1]) > abs(n/2-A[mid]): print(n, A[mid]) else: print(n, A[mid-1])
p02814
s975660632
Accepted
from fractions import gcd from functools import reduce # 2つの数の最小公倍数 def lcm(x,y): return (x*y) // gcd(x,y) # リストを引数にして最小公倍数を表示 def lcm_of_list(a): return reduce(lcm, a) def waruni(a): return a//2 n,m = map(int, input().split()) b = list(map(waruni, map(int, input().split()))) L = lcm_of_list(b) for i in range(n): if (L//b[i])%2==0: print(0) exit() ans = (m//L+1)//2 print(ans)
p02631
s330729268
Accepted
n = int(input()) a = list(map(int, input().split())) ans = [0] * n allsum = 0 for i in a: allsum = allsum ^ i for i in range(n): ans[i] = allsum ^ a[i] print(*ans)
p02684
s375664560
Accepted
N, K = map(int,input().split()) t = list(map(int,input().split())) visited = [0] * N idx = 0 town = 0 if K <= N: for i in range(K): idx = t[idx] -1 print(idx+1) else: for i in range(K): if visited[idx]: cycle = i - visited[idx] rem_step = (K - i) % cycle town = visited.index(visited[idx] + rem_step) break visited[idx] = i idx = t[idx] - 1 print(town+1)
p02862
s713363318
Accepted
mod = 10**9+7 def comb(n, k): c = 1 for i in range(k): c *= n - i c %= mod d = 1 for i in range(1, k + 1): d *= i d %= mod return (c * pow(d, mod - 2, mod)) % mod x,y=map(int,input().split()) ans=0 z=x//2 for q in range(z,x+1): w=2*q-x if w*2+(q-w)==y: t=comb(q,w) ans+=t print(ans)
p02811
s641280697
Accepted
s = input().split() k = int(s[0]) x = int(s[1]) if(k*500>=x): print('Yes') else: print('No')
p02607
s592415064
Accepted
N = int(input()) la = list(map(int,input().split())) cnt=0 for i in range(N): if (i+2)%2==0 and la[i]%2==1: cnt+=1 print(cnt)
p03637
s077544036
Accepted
n = int(input()) a = list(map(int,input().split())) codd = 0 cfour = 0 for i in range(n): if a[i]%2 != 0: codd += 1 if a[i]%4 == 0: cfour += 1 ceven = n - cfour - codd if cfour >= codd: print('Yes') elif ceven == 0 and cfour + 1 == codd: print('Yes') else: print('No')
p02935
s019599658
Accepted
N = int(input()) v = list(map(int, input().split())) v = sorted(v) total = v[0] for i in range(1, N): total = (total + v[i])/2 print(total)
p03986
s853944465
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines X = read().rstrip().decode() s, t = 0, 0 for x in X: if x == 'S': s += 1 else: if s == 0: t += 1 else: s -= 1 print(s+t)
p02631
s419947935
Accepted
N = int(input()) a = list(map(int, input().split())) if N == 2: print(*a[::-1]) else: product = a[0] for i in range(N): if i == 0: product = a[i] else: product = product ^ a[i] ans = [] for i in range(N): product = product ^ a[i] ans.append(product) product = product ^ a[i] print(*ans)
p02630
s547567301
Accepted
N = int(input()) A = list(map(int,input().split())) summary = sum(A) d = {} for a in A: if a in d: d[a] += 1 else: d[a] = 1 Q = int(input()) for _ in range(Q): B, C = list(map(int,input().split())) if B not in d: b = 0 else: b = d[B] d[B] = 0 if C in d: d[C] += b else: d[C] = b summary = summary + b * (C - B) print(summary)
p03252
s510184041
Accepted
from collections import Counter s=Counter(list(input())) t=Counter(list(input())) s, t=list(s.values()),list(t.values()) print("Yes" if sorted(s)==sorted(t) else "No")
p02689
s796703100
Accepted
N,M = map(int,input().split()) H = list(map(int,input().split())) T = [[] for i in range(N+1)] for i in range(M): a,b = map(int,input().split()) T[a].append(b) T[b].append(a) ans = [1]*(N+1) for i in range(1,N+1): h = H[i-1] for c in T[i]: if h<=H[c-1]: ans[i] = 0 break print(sum(ans)-1)
p03695
s892386082
Wrong Answer
n = int(input()) A = tuple(map(int, input().split())) CO = [0] * 8 o32 = 0 for a in A: for i in range(8): if 4*i*100 <= a < 4*(i+1)*100: CO[i] += 1 else: if a >= 3200: o32 += 1 ans = 0 for count in CO: if count > 0: ans += 1 print(ans, ans+o32 if ans+o32 <= 8 else 8)
p02729
s004121701
Wrong Answer
# ここにコード書く n, m = map(int, input().split()) # combination nC2 mC2 ans = n * (n - 1) / 2 + m * (m - 1) / 2 print(ans)
p03061
s006873856
Wrong Answer
n = int(input()) a = list(map(int, input().split())) count = 0 ans, mina = a[0], abs(a[0]) flag = False for i in range(1, n): ans += abs(a[i]) mina = min(mina, abs(a[i])) if a[i]<0: count += 1 if count%2 or a.count(0): print(ans-mina*2) else: print(ans)
p02576
s636873663
Accepted
n, x, t = map(int, input().split()) m = (n+x-1)//x print(t*m)
p02773
s414559783
Wrong Answer
from collections import Counter n = int(input()) lst = [input() for i in range(n)] c = Counter(lst) c2 = c.most_common() m = c2[0][1] ans = [i[0] for i in c2 if i[1] == m] print('\n'.join(sorted(ans, key=lambda x:x[0])))
p02747
s976938049
Accepted
S = input() N = S.count("hi") L = len(S) if int(N)*2 == int(L): print("Yes") else: print("No")
p03427
s759960400
Accepted
N = input() keta = len(N) N = list(N) c = int(N[0]) if all(c=="9" for c in N[1:keta]): print(c+9*(keta-1)) else: print(c-1+9*(keta-1))
p02623
s381603060
Wrong Answer
from collections import deque n,m,k=map(int,input().split()) a=deque(list(map(int,input().split()))) b=deque(list(map(int,input().split()))) cost=0 ans=0 while (a and cost+a[0]<=k) or (b and cost+b[0]<=k): if a and b: if a[0]<b[0]: cost+=a[0] ans+=1 a.popleft() else: cost+=b[0] ans+=1 b.popleft() elif a: cost+=a[0] ans+=1 a.popleft() else: cost+=b[0] ans+=1 b.popleft() print(ans)
p02983
s361202804
Accepted
l,r = map(int, input().split()) if r-l >= 2019: print(0) else: ans = float("inf") for i in range(l, r): for j in range(i+1, r+1): t = i*j%2019 if t < ans: ans = t print(ans)
p04005
s144850114
Accepted
a,b,c = map(int,input().split()) if (a*b*c)%2 == 1: print(min(a*b,b*c,a*c)) else: print(0)
p02744
s126297338
Wrong Answer
n = int(input()) def dfs(s): if len(s) == n: print(s) else: for i in range(ord(s[len(s) - 1]) - ord('a') + 2): dfs(s + chr(i + ord('a'))) s = 'a' dfs(s)
p02879
s242897985
Accepted
A, B = map(int, input().split()) if A < 10 and B <10: print(A*B) else: print('-1')
p03632
s641893787
Accepted
a, b, c, d = map(int, input().split()) if a>c: if d<a: print(0) elif a<=d<b: print(d-a) else: print(b-a) elif a==c: if d<b: print(d-c) else: print(b-a) else: if b<c: print(0) elif c<=b<d: print(b-c) else: print(d-c)
p03971
s094909503
Wrong Answer
N, A, B = map(int, input().split()) S = input() for x in S: # print(x) if x == "a" and A > 0: A -= 1 print("Yes") elif x == "b" and B > 0: B -= 1 print("Yes") else: print("No")
p03448
s681954911
Accepted
from sys import stdin data = stdin.read().splitlines() a = int(data[0]) b = int(data[1]) c = int(data[2]) x = int(data[3]) count = 0 l = min(x//500, a) while l >= 0: x = x - 500*l m = min(x//100, b) while m >= 0: x = x - 100*m if c >= x//50: count += 1 x = x + 100*m m -= 1 x = x + 500*l l -= 1 print(count)
p03699
s757668563
Accepted
N = int(input()) ans = 0 min_v = 10 ** 4 + 1 for i in range(N): s = int(input()) ans += s if s % 10 != 0 and min_v > s: min_v = s if ans % 10 == 0: print(max(0, ans - min_v)) else: print(ans)
p02923
s858072962
Wrong Answer
import sys def solve(): n = int(input()) h = list(map(int, input().split())) up_h = [0] for i in range(len(h)-1): if h[i] < h[i+1]: up_h.append(i+1) up_h.append(len(h)-1) h_max = 0 for i in range(len(up_h)-1): if h_max < up_h[i+1]-up_h[i]-1: h_max = up_h[i+1]-up_h[i] print(up_h) print(h_max) solve()
p02983
s151801062
Accepted
l, r = map(int, input().split()) if r//2019 != l//2019: print(0) else: lm = list() for i in range(l, r): for j in range(i+1, r+1): lm.append((i*j)%2019) print(min(lm))
p02597
s270071286
Wrong Answer
n = int(input()) c = input() count = 0 while "WR" in c: c = c.replace("W", "R", 1) c = c.replace("WR", "WW", 1) count += 1 print(count)
p03524
s514027019
Wrong Answer
S=input() N=len(S) from collections import Counter C=Counter(S) mn=N mx=0 for c in ['a','b','c']: mx=max(mx,C[c]) mn=min(mx,C[c]) print('YES' if mx-mn<=1 else 'NO')
p03407
s575395556
Wrong Answer
a,b,c = map(int, input().split()) if a+2*b >= c: print('Yes') else: print('No')
p02640
s970053411
Wrong Answer
X,Y=map(int,input().split()) flg=False for i in range(1,X+1): for j in range(X+1-i): if i*2+j*4 == Y or j*2+i*4 == Y: print("Yes") flg=True break if flg: break if flg==False: print('No')
p03073
s470626500
Accepted
S = input() if S[0::2].count('0') > S[1::2].count('0'): print(S[0::2].count('1') + S[1::2].count('0')) else: print(S[0::2].count('0') + S[1::2].count('1'))
p03455
s207808502
Accepted
a,b=map(int, input().split()) c=a*b if c%2==0: print("Even") else: print("Odd")
p02918
s198944805
Accepted
n, k = map(int, input().split()) s = input() score = 0 for i in range(len(s) - 1): if s[i] == s[i + 1]: score += 1 print(min(score + 2*k, len(s) - 1))
p02918
s690087326
Wrong Answer
n,k=map(int,input().split()) s=input() x=s.count('RL') y=0 cnt=0 for i in range(n-1): if s[i]==s[i+1]: cnt+=1 if s[0]=='L' and s[n-1]=='R': y+=1 while k>0: if x>0: x-=1 cnt+=2 k-=1 else: if y>0: cnt+=1 y-=1 k-=1 else: break print(cnt)
p02995
s967642656
Accepted
a,b,c,d = list(map(int, input().split())) def num_fact_in(begin, end): def f(div): return end//div - (begin-1)//div return f import math lcm = c * d // math.gcd(c, d) f = num_fact_in(a, b) print(b - a + 1 - (f(c) + f(d) - f(lcm)))
p03827
s024466887
Wrong Answer
m,c = 0,0 for l in raw_input(): c += 1 if l == 'I' else -1 m = max(c,m) print m
p02880
s059660749
Wrong Answer
N = int(input()) ans = False for i in range(2,10): if N % i == 0 and N / i <= 9: ans = True if ans: print("Yes") else: print("No")
p03071
s014600506
Wrong Answer
A,B = (int(x) for x in input().split()) ans = 0 for i in range(2): if A > B: ans += A A -= 1 else: ans += B B -= B print(ans)
p02793
s180419513
Accepted
def gcd(a, b): if b == 0: return a return gcd(b, a%b) def lcm(a, b): return a*b//gcd(a,b) MOD = 1000000000 + 7 N = int(input()) A = list(map(int,input().split())) L = 1 for a in A: L = lcm(L, a) ans = 0 for a in A: ans += L // a ans %= MOD print(ans)
p02759
s420780433
Accepted
n = int(input()) if n%2 == 0: print(n//2) else: print(n//2 + 1)
p03971
s327994274
Accepted
n,a,b=map(int,input().split()) s=input() cnt=0 foreign=0 for i in range(n): if s[i]=="a": if cnt<a+b: print("Yes") cnt+=1 else: print("No") elif s[i]=="b": foreign+=1 if cnt<a+b and foreign<=b: print("Yes") cnt+=1 else: print("No") elif s[i]=="c": print("No")
p03612
s705096687
Accepted
n=int(input()) p=list(map(int,input().split())) cnt=0 if p[0]==1: p[1],p[0]=p[0],p[1] cnt+=1 for i in range(1,n-1): if p[i]==i+1: p[i],p[i+1]=p[i+1],p[i] cnt+=1 else: continue if p[-1]==n: cnt+=1 print(cnt)