problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03073
s875455253
Accepted
s = str(input()) ans1=0 for i in range(len(s)): if(i%2==0 and s[i]!='0'):ans1+=1 if(i%2==1 and s[i]!='1'):ans1+=1 ans2=0 for i in range(len(s)): if(i%2==0 and s[i]!='1'):ans2+=1 if(i%2==1 and s[i]!='0'):ans2+=1 ans=min(ans1,ans2) print(ans)
p03103
s950501313
Accepted
N, M = map(int, input().split()) D = [tuple(map(int, input().split())) for _ in range(N)] D.sort(key=lambda t:t[0]) s = 0 c = 0 for i in range(N): s += D[i][1] c += D[i][0] * D[i][1] if s >= M: c -= (s - M) * D[i][0] break print(c)
p03759
s898311560
Accepted
a,b,c = map(int,input().split()) if b-a == c-b: print("YES") else: print("NO")
p03711
s035698082
Accepted
x,y=map(int,input().split()) a=[4,6,9,11] b=[1,3,5,7,8,10,12] print('Yes' if (x in a and y in a) or (x in b and y in b) else 'No')
p02994
s593187810
Wrong Answer
n,l= map(int,input().split()) if l == -1: count = 0 for i in range(n): count += l l += 1 print(count) elif l < 0: count = 0 for i in range(n-1): count += l l += 1 print(count) else: print(((2*l+n)*(n-1))//2)
p03408
s288365983
Accepted
from collections import Counter N = int(input()) S = Counter([input() for _ in range(N)]) M = int(input()) T = Counter([input() for _ in range(M)]) ans = 0 for key in S.keys(): ans = max(S.get(key) - T.get(key, 0), ans) print(ans)
p03721
s536896582
Wrong Answer
import sys def main(): input = sys.stdin.readline N, K = map(int, input().split()) count = 0 l = [] for _ in range(N): a, b = map(int, input().split()) count += b l.append(a) if count >= K: break l.sort() print(l[-1]) if __name_...
p02690
s070976466
Accepted
x = int(input()) for i in range(400): for j in range(i - 800, i): if i ** 5 - j ** 5 == x: print(i, j) exit()
p02646
s996399553
Wrong Answer
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if A < B and A + T * V >= B + T * W: print('YES') else: print('NO')
p02683
s563830947
Wrong Answer
from itertools import combinations N, M, X = map(int, input().split()) books = [list(map(int, input().split())) for _ in range(N)] res = float('inf') for r in range(N): for c in combinations(range(N), r): skills = [0] * M price = 0 for i in c: price += books[i][0] f...
p02621
s288449320
Accepted
import math a = int(input()) print(a + ( a ** 2) + ( a ** 3))
p02817
s722111945
Wrong Answer
s,t=map(str,input().split()) if s>=t: print(t+s) else: print(s+t)
p03001
s598018559
Wrong Answer
w, h, x, y = map(int, input().split()) s = w*h/2 if x == w//2 and y == h//2: print(s, 1) else: print(s, 0)
p02677
s962091519
Wrong Answer
A,B,H,M = map(float, raw_input().split()) x = 12.0/360.0*H y = 60.0/360.0*M if x < y: x,y = y,x C = (A**2.0+B**2.0)**(0.5) print C
p03417
s011475203
Accepted
N,M = map(int,input().split()) if N >= 3 and M >= 3: print((N-2)*(M-2)) elif N == 2 or M == 2: print(0) else: print(max(1,N-2)*max(1,M-2))
p02829
s788461964
Accepted
A = int(input()) B = int(input()) candidates = [1, 2, 3] candidates.remove(A) candidates.remove(B) print(candidates[0])
p02647
s600587262
Accepted
import numpy as np from numba import jit N,K=map(int,input().split()) A=list(map(int,input().split())) @jit def imos(A): B=np.zeros_like(A) for i,x in enumerate(A): a=max(0,i-x) b=min(i+x,N-1) B[a]+=1 if b+1<=N-1: B[b+1]-=1 B=np.cumsum(B) return B for i in r...
p03239
s165514788
Accepted
import sys def MI(): return map(int,sys.stdin.readline().rstrip().split()) N,T = MI() ans = 10000 for i in range(N): c,t = MI() if t <= T: ans = min(ans,c) print(ans if ans != 10000 else 'TLE')
p02754
s333249903
Wrong Answer
X = list(map(int,input().split())) N = X[0] b = X[1] r = X[2] if b == 0: print(0) elif r == 0: print(N) elif b + r >= N: print(b) else: if N % (r + b) == 0: print(b * (N // (r + b))) else: print(b * (N // (r + b)) + 1)
p02795
s526605924
Accepted
from math import ceil h = int(input()) w = int(input()) n = int(input()) print(ceil(n/max(h, w)))
p03471
s873225869
Accepted
N, Y = map(int, input().split()) resx, resy, resz = (-1, -1, -1) xmax = min(N, Y//10000) for x in range(xmax+1): for y in range(N-x+1): z = N - x - y total = 10000*x + 5000*y + 1000*z if total == Y: resx, resy, resz = (x, y, z) break else: contin...
p02612
s055042412
Accepted
N = int(input()) if N%1000==0: print(0) else: print(1000-N%1000)
p04044
s133066865
Accepted
n,l=map(int,input().split()) S=[] for i in range(n): s=input() S.append(s) S.sort() ans="" for j in range(n): ans+=S[j] print(ans)
p03721
s231477301
Accepted
n,k=map(int,input().split()) ab=[] for i in range(n): a,b=map(int,input().split()) ab.append([a,b]) abc=sorted(ab,key=lambda x:x[0]) temp=0 for j in abc: temp+=j[1] if temp>=k: print(j[0]) exit()
p02989
s572622504
Accepted
n = int(input()) d = sorted(list(map(int, input().split()))) print(d[n // 2] - d[n // 2 - 1])
p02577
s964378248
Accepted
N = int(input()) if N % 9 ==0: print('Yes') else: print('No')
p03324
s077407558
Accepted
d,n = map(int,input().split()) if n != 100: print(100**d*n) else: print(100**d*101)
p02646
s736129569
Wrong Answer
A ,V = map(int, input().split()) B ,W = map(int, input().split()) T = int(input()) if V <= W: print("No") else: if (max(A, B) - min(A, B)) / (V - W) <= T: print("Yes") else: print("No")
p02612
s491243824
Accepted
n=int(input()) print((1000-n%1000)%1000)
p03854
s147665622
Accepted
import re if re.match("(dream|dreamer|erase|eraser)*$",input()): print("YES") else: print("NO")
p02796
s755706848
Accepted
n = int(input()) x = [list(map(int, input().split())) for i in range (n)] grid = [list([0,0]) for i in range(n)] for i in range(n): grid[i][0] = x[i][0] - x[i][1] grid[i][1] = x[i][0] + x[i][1] new_grid = sorted(grid,key=lambda x:x[1]) cnt = 1 a = new_grid[0][1] for i in range(n): if a <= new_grid[i][0...
p03767
s162744040
Accepted
N = int(input()) array = sorted(list(map(int, input().split())),reverse = True) a = [] for i in range(N): a.append(array[i*2+1]) print(sum(a))
p02731
s924816284
Accepted
#k = int(input()) #s = input() #a, b = map(int, input().split()) #s, t = map(str, input().split()) #l = list(map(int, input().split())) #l = [list(map(int,input().split())) for i in range(n)] #a = [input() for _ in range(n)] l = int(input()) tmp = l / 3 print(tmp**3)
p02848
s071386900
Accepted
N = int(input()) S = input() res = '' for c in S: res += chr((ord(c) - ord('A') + N) % 26 + ord('A')) print(res)
p02684
s520368865
Accepted
n, k = map(int, input().split()) a = list(map(lambda x: int(x) - 1, input().split())) tel = [[0] * n for _ in range(63)] tel[0] = a for i in range(62): for j in range(n): tel[i + 1][j] = tel[i][tel[i][j]] now = 0 for i in range(62, -1, -1): if k >> i & 1: now = tel[i][now] print(now + 1)
p03449
s601544915
Accepted
n = int(input()) a = [list(map(int, input().split())) for i in range(2)] s = [] for i in range(n): s.append(sum(a[0][:i+1] + a[1][i:])) print(max(s))
p03854
s263543042
Accepted
S=input() while len(S)>=5: if len(S)>=7 and S[-7:]=="dreamer": S=S[:-7] continue if len(S)>=6 and S[-6:]=="eraser": S=S[:-6] continue elif S[-5:]=="dream" or S[-5:]=="erase": S=S[:-5] continue else: break if len(S)==0: print("YES") else: pr...
p02765
s925905866
Accepted
n, r = map(int, input().split()) if n < 10: print(r + 100 * (10 - n)) else: print(r)
p03251
s983687065
Accepted
n,m,x,y=map(int,input().split()) xn=list(map(int,input().split())) yn=list(map(int,input().split())) sxn=sorted(xn,reverse=True) syn=sorted(yn,reverse=True) if sxn[0]<syn[-1] and sxn[0]<y and x<syn[-1]: print("No War") else : print("War")
p02910
s369294198
Accepted
s = input() s = '0' + s odd = ['R','U','D'] even = ['L','U','D'] flag = True for i in range(1,len(s)): if i%2!=0 and s[i] not in odd:#奇数 flag = False if i%2==0 and s[i] not in even:#偶数 flag = False if flag==True: print('Yes') else: print('No')
p03059
s927533859
Accepted
a, b, t = map(int, input().split()) print((t // a) * b)
p03998
s402126720
Wrong Answer
a=list(input()) b=list(input()) c=list(input()) turn="a" while 1: if turn=="a": turn=a.pop() if len(a)==0:print("A");exit() elif turn=="b": turn=b.pop() if len(b)==0:print("B");exit() else: turn=c.pop() if len(c)==0:print("C");exit()
p02939
s044802578
Accepted
s = input() i = res = 0 tmp = '' while i < len(s): if tmp == s[i]: if i == len(s) - 1: break else: tmp = s[i] + s[i+1] i += 2 else: tmp = s[i] i += 1 res += 1 print(res)
p02623
s156799645
Wrong Answer
def main(): M, N, K = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) spent_time = 0 count = 0 AB = A + B AB.sort() while(True): if count == M + N: break temp = AB[count] if spent_time + temp > K: break spent_time = spent_t...
p03607
s462192702
Wrong Answer
n,a,*b=open(0).read().split() s=set(a) for i in b: s^=set(i) print(len(s))
p03437
s006953663
Wrong Answer
X, Y = map(int, input().split()) if X % Y == 0: print(-1) else: print(X * X)
p02696
s151845608
Accepted
def resolve(): A,B,N = map(int,input().split()) x = min(N,B-1) ans = int(A * x / B) print(ans) resolve()
p02880
s204394964
Accepted
def main(): n = int(input()) flag = 0 for i in range(1, 10): for j in range(1, 10): if n == i*j: print("Yes") flag += 1 break else: continue break if not flag: print("No") if __name__ == "__main__":...
p02971
s136580743
Wrong Answer
n = int(input()) a = list() for x in range(n): a.append(int(input())) sumNum = sum(a) for x in range(n): print(sumNum-x)
p03131
s723955285
Wrong Answer
k, a, b = map(int, input().split()) if k > a+1 and b > a+1: x = 1 + k t = (k-a+1)//2 y = t * (b-a) + (k-t*2) + 1 print(max(x,y)) exit() else: z = 1 + k print(z)
p02829
s218667080
Accepted
e=input print(int(e())^int(e()))
p03339
s719189052
Accepted
N = int(input()) S = list(input()) W_count = [0]*(N)#左から累積を数えていく E_count = [0]*(N)#右からry for i in range(1,N,1): W_count[i]=W_count[i-1] if S[i-1]=="W": W_count[i]+=1 for i in range(N-2,-1,-1): E_count[i]=E_count[i+1] if S[i+1]=="E": E_count[i]+=1 ans = [0]*(N) for i in range(0,N,1): ...
p02696
s236254138
Accepted
A,B,N=map(int,input().split()) if N>=B-1: x=B-1 else: x=N print(int(A*x/B)-A*int(x/B))
p02582
s254115052
Wrong Answer
from math import * import sys,bisect,copyreg,copy,statistics,os def inp(): return sys.stdin.readline().strip() def IIX(): return (int(x) for x in sys.stdin.readline().split()) def II(): return (int(inp())) def LI(): return list(map(int, inp().split())) def LS(): return list(map(str, inp().split())) def L(x):return list...
p03319
s660935938
Accepted
N, K = map(int, input().split()) A = list(map(int, input().split())) count = 1 N -= K count += N //(K-1) if N % (K-1)== 0: print(count) exit() print(count+1)
p02658
s284676551
Accepted
def solve(): N = int(input()) A = [int(i) for i in input().split()] ans = 1 for i in range(N): if ans == -1 and A[i] != 0: continue ans *= A[i] if ans > 10**18: ans = -1 print(ans) if __name__ == "__main__": solve()
p03814
s353442858
Accepted
s = str(input()) a=0 z=0 for i in range(len(s)): if s[i]=='A': a=i break for i in range(len(s)): if s[i]=='Z': z=i print(z-a+1)
p03380
s679683042
Accepted
n = int(input()) a = set(map(int, input().split())) x = max(a) z = 10 ** 9 for i in a: if abs(i - x / 2) < z: y = i z = abs(i - x / 2) print(x, y)
p04011
s216957250
Accepted
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) ans = 0 if N > K: ans = (X * K) + (Y * (N - K)) else: ans = X * N print(ans)
p03779
s341623441
Wrong Answer
import sys def input(): return sys.stdin.readline().strip() def mapint(): return map(int, input().split()) sys.setrecursionlimit(10**9) X = int(input()) fac = {} fac[0] = 0 for i in range(1, 15): fac[i] = fac[i-1]+i for i in range(15): f = fac[i] if f==X: print(i) break if f>X: ...
p02987
s368203434
Accepted
S=input() T=sorted(S) if S.count(S[0])==2 and S.count(S[2])==2: print('Yes') else: print('No')
p02613
s448135506
Accepted
N=int(input()) S = [] for _ in range(N): S.append(input()) a=0 b=0 c=0 d=0 for i in S: if i=='AC': a+=1 elif i=='WA': b+=1 elif i=='TLE': c+=1 else: d+=1 print('AC x '+str(a)) print('WA x '+str(b)) print('TLE x '+str(c)) print('RE x '+str(d))
p02842
s534260192
Accepted
import math N = float(input()) for i in range(50000): if math.floor(i * 1.08) == N: print(i) exit() print(':(')
p03485
s396183397
Wrong Answer
a, b = (int(x) for x in input().split()) x = (a+b)/2 if x % 2 == 0: print(int(x)) else: print(int(1+(a+b)//2))
p03745
s406306562
Wrong Answer
N = int(input()) A = list(map(int, input().split())) status = 0 # 0 = defalt 1 = up 2 = down cnt = 0 pre = A[0] for i in range(1,N): if pre < A[i]: #up petern if status == 0: status = 1 elif status == 2: status = 0 cnt += 1 elif pre > A[i]: if status ...
p03284
s488446551
Accepted
n,k= map(int,input().split()) if n%k == 0: print("0") else: print("1")
p03254
s939048217
Wrong Answer
n,x = map(int,input().split()) a = list(map(int,input().split())) Slist = sorted(a) cnt = 0 Sum = 0 for i in range(len(Slist)): Sum += Slist[i] if x>=Sum: cnt +=1 else: break print(cnt)
p02835
s817092437
Accepted
a,b,c=map(int,input().split()) if a+b+c>=22: print("bust") else: print("win")
p02718
s880278993
Accepted
n,m=map(int,input().split()) a=list(map(int,input().split())) a.sort() k=sum(a)/(4*m) s=0 for i in range(m): if a[-i-1]>=k: pass else: s=1 break if s==1: print("No") else: print("Yes")
p02606
s319638445
Accepted
l, r, d = map(int, input().split()) a = [] for i in range(l, r + 1): if i % d == 0: a.append(i) print(len(a))
p03417
s131800324
Wrong Answer
N,M = map(int, input().split()) if min(N,M)>1: print(N*M-N*2-M*2) elif max(N,M)==1: print(1) elif min(N,M)==1: print(max(N,M)-2)
p02786
s574418652
Accepted
h = int(input()) ans = 0 t = 1 while h > 0: h //= 2 ans += t t *= 2 print(ans)
p04045
s531152826
Accepted
nk=list(map(int,input().split())) d=list(map(int,input().split())) i=nk[0] ans=0 while ans==0: flag=0 for j in range(len(str(i))): if int(str(i)[j]) in d: flag=1 break if flag==0: ans=i i+=1 print(ans)
p02779
s020083145
Accepted
#!/usr/bin/evn python3 N = int(input()) A = list(map(int, input().split())) A_set = len(set(A)) if N == A_set: print("YES") else: print("NO")
p03387
s340432032
Accepted
sorted_list = list(map(int, input().strip().split())) count = 0 while True: sorted_list = sorted(sorted_list, reverse=True) if sorted_list[0] == sorted_list[1] and sorted_list[1] == sorted_list[2]: break count += 1 if sorted_list[0] > sorted_list[1]: sorted_list[1] += 1 sorted_...
p03785
s464337207
Accepted
N, C, K = list(map(int, input().split())) T = [int(input()) for _ in range(N)] T.sort() ans = 1 cnt = 1 t = T[0] for i in range(1, N): if T[i] - t > K or cnt >= C: ans += 1 cnt = 1 t = T[i] else: cnt += 1 print(ans)
p02646
s723707574
Accepted
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if a == b: print("YES") elif a < b: a_new = a + v * t b_new = b + w * t if a_new >= b_new: print("YES") else: print("NO") else: a_new = a - v * t b_new = b - w * t if a_new <= b_new: print("YES") else: ...
p04029
s231264516
Wrong Answer
n = int(input()) print(n*(n+1)/2)
p02982
s315131703
Accepted
from math import sqrt n,d = map(int,input().split()) x = [list(map(int,input().split())) for i in range(n)] ans = 0 for i in range(n): for j in range(i+1,n): t = 0 for k in range(d): t += (x[i][k] - x[j][k]) ** 2 if float.is_integer(sqrt(t)): ans += 1 print(ans)
p03836
s313493295
Accepted
sx,sy,tx,ty=map(int,input().split()) x1,y1=tx-sx,ty-sy x2,y2=x1+2,y1+2 s="U"*y1 s+="R"*x1 s+="D"*y1 s+="L"*x1 s+="L" s+="U"*(y2-1) s+="R"*(x2-1) s+="D" s+="R" s+="D"*(y2-1) s+="L"*(x2-1) s+="U" print(s)
p02555
s006820739
Accepted
N = int(input()) M = 10**9 + 7 if N < 3: print(0) elif N < 6: print(1) else: dp = [0] * (N + 1) dp[3] = 1 dp[4] = 1 dp[5] = 1 for i in range(6, N + 1): dp[i] = sum(dp[3:i - 3 + 1]) + 1 dp[i] %= M print(dp[-1] % M)
p02860
s411632380
Accepted
N = int(input()) S = input() T = S[0:N//2] print("Yes" if S == T + T else "No")
p03475
s164056358
Accepted
N = int(input()) c = [0]*(N-1) s = [0]*(N-1) f = [0]*(N-1) for i in range(N-1): c[i],s[i],f[i] = list(map(int,(input().split()))) for i in range(N): time = 0 for j in range(i,N-1): if time < s[j]: time = s[j] time += (-time) % f[j] time += c[j] print(time)
p02756
s368967486
Wrong Answer
S = input() Q = int(input()) reverse = False front = "" end = "" for i in range(Q): inp = input() if inp[0] == "1": reverse = ~reverse else: _, F, C = inp.split() if (F == "1") ^ reverse: front =front+C else: end =end+C if reverse: print(end[::-1...
p03331
s668683116
Accepted
N = int(input()) temp_min = sum(map(int, str(1))) + sum(map(int, str(N - 1))) for A in range (2, N): x = sum(map(int, str(A))) + sum(map(int, str(N - A))) if x < temp_min: temp_min = x print(temp_min)
p02630
s796693651
Wrong Answer
n = int(input()) ans = 0 for i in range(1, n+1): count = 0 for j in (1, i+1): if i % j == 0: count += 1 ans = i * count print(ans)
p02729
s218964903
Accepted
import sys import collections import heapq import math n,m = map(int,sys.stdin.readline().split()) def combinations_count(n, r): return math.factorial(n) // (math.factorial(max(n - r,0)) * math.factorial(r)) print(combinations_count(n,2)+combinations_count(m,2))
p03860
s660731489
Accepted
s = input() print(s[0]+s[8]+s[-7])
p03699
s028212951
Wrong Answer
a=int(input()) b=[int(input()) for i in range(a)] b.sort() ans=0 for i in range(a): if b[i]%10!=0 and sum(b)%10==0: ans=sum(b)-b[i] break print(ans)
p04030
s898654165
Accepted
s=input() l=[] for i in s: if(i=='1'): l.append('1') elif(i=='0'): l.append('0') else: if(l!=[]): l.pop() print(''.join(l))
p02861
s400959839
Accepted
import math N = int(input()) xy = [list(map(int,input().split())) for i in range(N)] ave = 0 cnt = 0 import itertools for v in itertools.permutations([int(x) for x in range(N)],N) : for i in range(1,len(v)) : ave += math.sqrt((xy[v[i-1]][0]-xy[v[i]][0])**2+(xy[v[i-1]][1]-xy[v[i]][1])**2) cnt += 1 ave ...
p03043
s226641133
Wrong Answer
import math from sys import stdin n, k = map(int, stdin.readline().rstrip().split()) ans = 0 for i in range(1, n + 1): if k / i <= 1: ans += (1 / n) else: ans += (1 / n) / 2 ** (int(math.log2(k / i)) + 1) print(ans)
p03711
s271899580
Wrong Answer
print(' YNeos'[len(set([2 if i==2 else 1 if i==[4,6,9,11] else 0 for i in list(map(int,input().split()))]))::2])
p02939
s050641475
Accepted
""" aabbaa aa b ba a a ab b aa """ s = list(input()) n = len(s) hst = [] sk = "" for i in range(n): sk += s[i] if i == 0: hst.append(sk) sk = "" elif hst[-1] != sk: hst.append(sk) sk = "" print(len(hst))
p03435
s503412780
Wrong Answer
c = [list(map(int,input().split())) for _ in range(3)] a1 = sum(c[0]) a2 = sum(c[1]) a3 = sum(c[2]) ans = "No" for i in range(101): if (a1-i)%3 == 0 and (a2-i)%3 == 0 and (a3-i)%3 == 0: ans = "Yes" break print(ans)
p03773
s913599921
Accepted
def main(): a, b = map(int, input().split()) print((a + b) % 24) if __name__ == '__main__': main()
p03075
s528670063
Accepted
lis = [] for _ in range(5): lis.append(int(input())) k = int(input()) for i in range(5): for j in range(i+1, 5): if (lis[j] - lis[i]) > k: print(":(") exit() print("Yay!")
p02963
s874536078
Accepted
import math S = int(input()) t = math.sqrt(S) a = b = math.ceil(t) if a*(b-1) >= S: b -= 1 d = a*b - S if d == 0: c = 0 else: c = 1 print("0 0 {} {} {} {}".format(a, c, d, b))
p02880
s566210681
Accepted
n=int(input()) for i in range(10): for s in range (10): result=i*s if n==result: print('Yes') exit() elif result<81: continue else: print('No')
p02628
s323516592
Wrong Answer
import math from itertools import combinations n,k=map(int,input().split()) l=list(map(int,input().split())) min1=min(list(combinations(l,k))) sum1=int(math.fsum(min1)) print(sum1)