problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02711
s559344934
Wrong Answer
# A Lucky 7 N = input() for n in N: if n == "7": print("Yes") else: print("No")
p03623
s278927687
Accepted
x, a, b = map(int, input().split()) if abs(x-a) > abs(x-b): print('B') else: print('A')
p02946
s583498690
Wrong Answer
k, x = map(int, input().split()) ','.join([str(i) for i in range(x-k+1, x+k-1+1)]).replace(',', ' ')
p02939
s692358059
Accepted
S = input().strip() ans = [""] prev = "" for i, s in enumerate(S): prev += s if ans[-1] != prev: ans.append(prev) prev = "" else: if i == len(S) - 1: ans.append(prev) result = len(ans) - 1 if ans[-1] == ans[-2]: result -= 1 print(result)
p03543
s266836201
Accepted
S=input() if S[0]==S[1]==S[2] or S[1]==S[2]==S[3]: print("Yes") else: print("No")
p02687
s430502141
Wrong Answer
S = input() if S == "ABC": print("ABC") if S == "ARC": print("ARC")
p03145
s143311599
Wrong Answer
x, y, z = map(int,input().split()) print(x*y/2)
p03145
s681845661
Wrong Answer
A = sorted(list(map(int, input().split()))) print(A[0]*A[1]/2)
p02744
s952180410
Wrong Answer
N = int(input()) ans = ["a"] for i in range(N-1): new = [] for j in range(len(ans)): l = ord(ans[j][-1])-95 add = [chr(ord("a") + idx) for idx in range(l)] for k in add : new.append(ans[j] + k) ans = new for p in ans: print(p)
p03145
s181950414
Accepted
a,b,c=map(int,input().split()) print(a*b//2)
p03711
s675732395
Accepted
x,y=list(map(int,input().split())) a=[1,3,5,7,8,10,12] b=[4,6,9,11] c=2 if x in a and y in a: print("Yes") exit() if x in b and y in b: print("Yes") exit() if x==c and y==c: print("Yes") exit() print("No")
p02766
s986848234
Accepted
n,k = map(int,input().split()) ans = 1 while n >= k**ans: ans += 1 print(ans)
p03860
s487631340
Accepted
x, y, z = input().split() print(x[0] + y[0] + z[0])
p03796
s762510610
Accepted
n = int(input()) power = 1 for i in range(1,n+1): power *= i power = power % (10**9 + 7) print(power)
p03548
s780839404
Accepted
x, y, z = map(int, input().split()) ans = 0 x -= z for i in range(100000): if x >= y + z: ans += 1 x -= y + z else: break print(ans)
p02924
s389325514
Accepted
N = int(input()) print(N * (N - 1) // 2)
p04031
s503989074
Wrong Answer
import numpy as np def main(): n = int(input()) As = list(map(int, input().split())) As_set = list(set(As)) std = int(np.around(np.mean(As_set))) ans = 0 for a in As: ans += (std - a) ** 2 print(ans) if __name__ == "__main__": main()
p03328
s847184160
Wrong Answer
icase=0 if icase==0: import sys a,b=map(int,input().split()) for i in range(1,999): isum=(i*(i+1))//2-a for j in range(i,1000): jsum=(j*(j+1))//2-b if jsum==isum and 1<=jsum: print(jsum) sys.exit()
p02622
s434318956
Accepted
c = 0 s = input() t = input() for i in range(0,len(s)): if s[i]!=t[i]: c = c+1 print(c)
p02600
s834744431
Accepted
x = int(input()) if 400 <= x <= 599: print('8') elif 600 <= x <= 799: print('7') elif 800 <= x <= 999: print('6') elif 1000 <= x <= 1199: print('5') elif 1200 <= x <= 1399: print('4') elif 1400 <= x <= 1599: print('3') elif 1600 <= x <= 1799: print('2') elif 1800 <= x <= 1999: print('1')
p03239
s478967614
Accepted
n, t = map(int, input().split()) ans = 100000 for i in range(n): c, tt = map(int, input().split()) if tt <= t: ans = min(ans, c) if ans == 100000: print("TLE") else: print(ans)
p03673
s378815943
Accepted
from collections import deque n = int(input()) a = list(map(int, input().split())) b = deque([a[0]]) rev = 1 for i in range(1, n): if rev % 2 == 0: b.append(a[i]) else: b.appendleft(a[i]) rev += 1 if rev % 2 == 1: b.reverse() print(*b)
p03433
s342522107
Accepted
def main(): N = int(input()) A = int(input()) if N % 500 <= A : print("Yes") else: print("No") if __name__ == "__main__": main()
p02606
s775241745
Wrong Answer
a, b, c = list(map(int, input().split())) s = a / c + 1 n = 1 while True: if s * c < b: n += 1 s += 1 else: break print(n + 1)
p03998
s153245595
Accepted
A,B,C=[list(input()) for i in range(3)] now="a" while True: if now=="a": if len(A)==0: print("A") break now=A.pop(0) elif now=="b": if len(B)==0: print("B") break now=B.pop(0) else: if len(C)==0: print("C") break now=C.pop(0)
p02682
s479870134
Wrong Answer
we = str(input()) r = we.split(" ", -1) A = r[0] B = r[1] C = r[2] K = r[3] A = int(A) B = int(B) C = int(C) K = int(K) def max_sum(A, B, C, K): if (A and B and C and K) >= 0: if A >= K: print(A) elif A < K: R = K - A if B >= R: print(A) elif B < R: S = R - B print(A + S*(-1)) max_sum(A, B, C, K)
p03827
s842924229
Accepted
input() x=0 a=[0] for i in input():a+=a[-1]+1-2*(i=='D'), print(max(a))
p03998
s046304427
Wrong Answer
import re Sa = list(input()) Sb = list(input()) Sc = list(input()) player = 'a' while True: if player == 'a': if len(Sa) == 0: print('A') break player = Sa.pop() elif player == 'b': if len(Sb) == 0: print('B') break player = Sb.pop() elif player == 'c': if len(Sc) == 0: print('C') break player = Sc.pop()
p02813
s064912937
Wrong Answer
n = int(input()) def bub(n,l): tot = 0 for _ in range(n): for i in range(n-1): if l[i+1] > l[i]: l[i],l[i+1] = l[i+1],l[i] tot += 1 return tot p = list(map(int, input().split())) q = list(map(int, input().split())) print(abs(bub(n,p)-bub(n,q)))
p02663
s835022379
Wrong Answer
h1, m1, h2, m2, K = list(map(int, input().split())) if abs(h1-h2)*60 + abs(m1-m2) <= 120: print('{}'.format(0)) else: print('{}'.format(abs(h1-h2)*60 + abs(m1-m2) - K))
p02699
s147155670
Accepted
S, W = map(int, input().split()) if S <= W: print("unsafe") else: print("safe")
p03997
s332434483
Accepted
a = int(input()) b = int(input()) h = int(input()) s = (a + b) * h / 2 print(int(s))
p02771
s198551540
Wrong Answer
A,B,C = input().split() A = int(A) B = int(B) C = int(C) if A == B == C : print('No') else : print('Yes')
p02775
s639363814
Wrong Answer
N = ("0"+input())[::-1] ans = 0 carry = 0 for i in range(len(N)-1): n = int(N[i]) nextn = int(N[i+1]) if carry == 1: carry = 0 n += 1 if n <=4: ans += n elif n >= 6: ans += 10-n carry = 1 else: # n==5 if nextn <= 4: ans += n else: ans += 10-n carry = 1 print(ans)
p04012
s913724953
Accepted
w = input() from collections import Counter wc = Counter(w) for c in wc.values(): if c%2 == 1: print('No') break else: print('Yes')
p03803
s932606450
Wrong Answer
import sys import heapq, math from itertools import zip_longest, permutations, combinations, combinations_with_replacement from itertools import accumulate, dropwhile, takewhile, groupby from functools import lru_cache from copy import deepcopy A, B = map(int, input().split()) if A == B: print("Draw") elif B == 1 or A < B: print("Bob") else: print("Alice")
p03804
s571710082
Wrong Answer
n, m = map(int, input().split()) for i in range(n): a = list(input()) for j in range(m): b = list(input()) for x in range(n-m+1): for y in range(n-m+1): for z in range(m): if a[x+z][y:y+m] != b[z]: break else: print('Yes') exit() print('No')
p03289
s647135863
Accepted
import re print(re.match("A[a-z]+C[a-z]+$", input()) and "AC" or "WA")
p04020
s262776897
Wrong Answer
N = int(input()) A = [int(input()) for _ in range(N)] ans = 0 for i in range(N): ans += A[i] // 2 N %= 2 if N == 1 and i < N-1 and A[i+1] > 0: A[i+1] -= 1 ans += 1 print(ans)
p03323
s225054818
Accepted
A,B = map(int, input().split()) if A <= 8 and B <= 8: print('Yay!') else: print(':(')
p03067
s805015849
Wrong Answer
s = list(map(int, input().split())) ss = sorted(s) ssr = sorted(s, reverse=True) if s==ss or s==ssr: print("No") else: print("Yes")
p02553
s660098139
Wrong Answer
a,b,c,d=map(int,input().split()) print(max(a*c,b*c,a*d,b*d,0))
p03105
s406456897
Accepted
a, b, c = (int(n) for n in input().split()) if b // a <= c: print(b // a) else: print(c)
p02699
s591205547
Accepted
import sys sys.setrecursionlimit(10**7) input = lambda: sys.stdin.readline().strip() def main(): S,W = map(int,input().split()) print("unsafe" if S<=W else "safe") main()
p02747
s230355694
Accepted
s = input() cont = len(s)//2 if s == "hi"*cont: print("Yes") else: print("No")
p03250
s209182147
Accepted
num = list(map(int, input().split())) i = sorted(num) print(i[2]*10+i[1]+i[0])
p03448
s700849242
Accepted
a=int(input()) b=int(input()) c=int(input()) x=int(input()) ans=0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 500*i+100*j+50*k==x: ans+=1 print(ans)
p02719
s132603320
Accepted
n,k=map(int,input().split()) a1=n%k a2=abs(a1-k) print(min(a1,a2))
p03360
s147811237
Accepted
a,b,c = map(int,input().split()) k = int(input()) print(a+b+c+max(a,b,c)*(2**k-1))
p02836
s639204741
Wrong Answer
S = input() S_inv = S[::-1] out = 0 for i in range(len(S)): print(S[:-i]) #if S[i] != S[:-i]: # out = out + 1 # #out = out // 2 #print(out)
p03836
s777490907
Accepted
SX,SY,TX,TY=map(int,input().split()) NX=TX-SX NY=TY-SY ans=[] for i in range(NX): ans.append('R') for i in range(NY): ans.append('U') for i in range(NX): ans.append('L') for i in range(NY): ans.append('D') ans.append('D') for i in range(NX+1): ans.append('R') for i in range(NY+1): ans.append('U') ans.append('L') ans.append('U') for i in range(NX+1): ans.append('L') for i in range(NY+1): ans.append('D') ans.append('R') print(''.join(ans))
p02881
s222085790
Wrong Answer
n = int(input()) now_answer = 0 upper = int(n**0.5) for i in range(1, upper): if n % i == 0: now_answer = i + n//i - 2 print(now_answer)
p02628
s576610488
Wrong Answer
import numpy as np s = list(map(int,input().split())) n=s[0] k=s[1] s = list(map(int, input().split())) s.sort() print(s) s=np.array(s[0:k]) print(np.sum(s))
p02793
s830061940
Accepted
from fractions import gcd def lcm(c,d): return c//gcd(c,d)*d mod=10**9+7 n=int(input()) a=[int(i) for i in input().split()] l=a[0] for i in range(1,n): l=lcm(l,a[i]) ans=0 for i in range(n): ans+=l//a[i] #ans%=mod print(ans%mod)
p02785
s869252140
Wrong Answer
N,K = map(int,input().split()) H = list(map(int,input().split())) H.sort() H.reverse() if K==0: pass elif K==1: del H[0] else: del H[0:K-1] a = 0 for i in H: a+=i print(a)
p03281
s027411370
Accepted
# -*- coding: utf-8 -*- import sys N = int(input().strip()) #----- if N <= 104: print(0) sys.exit() elif N == 105: print(1) sys.exit() else: ans_list=[105] for i in range(107,N+1,2): cnt=0 for j in range(1,N+1): if i % j == 0: cnt += 1 if cnt == 8: ans_list.append(i) print(len(ans_list))
p02577
s223706413
Accepted
n = list(map(int, input())) if sum(n) % 9 == 0: print("Yes") else: print("No")
p03556
s669943081
Wrong Answer
N=int(input()) C=0 for i in range(N): if i**2<=N: C=i**2 elif i**2>N: break print(C)
p03625
s453127952
Accepted
from collections import Counter N = int(input()) A = list(map(int,input().split())) cnt = Counter(A) rect = [] for i,j in zip(cnt.keys(),cnt.values()): if j >= 2: rect.append([i,j]) rect.sort(reverse=True) ##print(rect) ans = 0 flag = False finished = False for i,j in rect: if flag: ans *= i finished = True break elif j < 4: ans = i flag = True else: ans = i**2 finished = True break print(0 if not finished else ans)
p02784
s638893849
Wrong Answer
H, N = map(int, input().split()) count = 0 A = list(map(int, input().split())) for i in range(N): Ai = A[i] count += Ai if H <= Ai: print('Yes') else: print('No')
p02784
s246426238
Accepted
def main(): h, n = [int(i) for i in input().split()] num = [int(i) for i in input().split()] for j in range(n): h -= num[j] if h <= 0: return "Yes" if h > 0: return "No" print(main())
p02556
s086737335
Wrong Answer
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9+7 #mod = 998244353 INF = 10**18 eps = 10**-7 n = int(readline()) p = [list(map(int,readline().split())) for i in range(n)] xmin = INF ymin = INF for (x,y) in p: xmin = min(x,xmin) ymin = min(y,ymin) for i in range(n): p[i][0] -= xmin p[i][1] -= ymin dmax = -INF dmin = INF for (x,y) in p: dmax = max(dmax, x+y) dmin = min(dmin, x+y) print(dmax-dmin)
p02786
s124517143
Accepted
print(2**int(input()).bit_length()-1)
p03136
s593570051
Accepted
input() a = list(map(int, input().split())) print("Yes" if sum(a) > max(a)*2 else"No")
p02712
s883983868
Wrong Answer
N = int(input()) _sum = 0 for i in range(1, N): if i % 3 != 0 and i % 5 != 0: _sum += i print(_sum)
p03210
s066376002
Accepted
print("YES" if input() in "357" else "NO")
p03545
s996878164
Wrong Answer
A = list(input()) sign = ['+','-'] for i in range(2): for j in range(2): for k in range(2): if eval(A[0]+sign[i]+A[1]+sign[j]+A[2]+sign[k]+A[3]) == 7: print('{}{}{}{}{}{}{}'.format(A[0],sign[i],A[1],sign[j],A[2],sign[k],A[3])) exit()
p02817
s099752517
Accepted
s, t = input().split() print(t+s)
p02595
s159084185
Accepted
import math N, D = map(int, input().split()) x = [0] * N y = [0] * N count = 0 for i in range(N): x[i], y[i] = map(int, input().split()) if math.sqrt(x[i] * x[i] + y[i] * y[i]) <= D: count += 1 else: pass print(count)
p02693
s025545352
Accepted
K = int(input()) A,B = map(int,input().split()) for i in range(A,B+1): if i % K == 0: print("OK") exit() print("NG")
p02615
s043759664
Accepted
n = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = a[0] if n >2: for i in range(2,n,1): j = i//2 ans += a[j] print (ans)
p03076
s305801291
Accepted
from math import ceil a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) x = min((a - 1) % 10, (b - 1) % 10, (c - 1) % 10, (d - 1) % 10, (e - 1) % 10) + 1 ans = ceil(a / 10) * 10 + ceil(b / 10) * 10 + ceil(c / 10) * 10 + ceil(d / 10) * 10 + ceil(e / 10) * 10 ans -= (10 - x) print(ans)
p03760
s277689515
Wrong Answer
o=str(input()) e=str(input()) r=[] if len(o)==len(e): for i in range(len(o)): r.append(o[i]+e[i]) i+=1 else: for i in range(len(e)): r.append(o[i]+e[i]) i+=1 r.append(o[len(o)-1]) print(''.join(r))
p02647
s648289239
Wrong Answer
n,k = map(int, input().split()) A = list(map(int, input().split())) def f(X): L = [0] * len(X) for k in range(len(X)): for j in range(len(X)): if max(0,j-X[j]) <= k <= max(j+X[j],n-1): L[k] += 1 else: pass return [L[i]+X[i] for i in range(len(X))] X = A for i in range(k): X = f(X) P = [str(X[i]) for i in range(n)] print(" ".join(P))
p02970
s458109558
Accepted
N,X=map(int,input().split()) if N%(X*2+1)==0: ans=N//(X*2+1) else: ans=N//(X*2+1)+1 print(ans)
p03254
s531417671
Wrong Answer
n,x = map(int,input().split()) a = sorted(map(int,input().split())) c=0 d=0 for i in a: if c+i<x: c+=i d+=1 else: if c<x: d-=1 print(d)
p02676
s986619583
Accepted
k=input() n=int(k) s=input() a=len(s) if a>n: print(s[0:n] +"...") else: print(s)
p03210
s029329765
Accepted
import sys # \n def input(): return sys.stdin.readline().rstrip() def main(): X =int(input()) if X==1: print("NO") exit() if 105 % X ==0: print("YES") else: print("NO") if __name__ == "__main__": main()
p02761
s804219027
Accepted
n,m = map(int,input().split()) s = [0]*n for i in range(m): keta, num = map(int,input().split()) if keta == 1 and num == 0 and n != 1: print(-1) exit() if s[keta-1] == 0 or s[keta-1] == num: s[keta-1] = num else: print(-1) exit() if s[0] != 0: print(*s, sep ="") elif s[0] == 0 and n == 1: print(0) elif s[0] == 0 and n != 1: s[0] = 1 print(*s, sep ="") else: print(-1)
p03035
s601131778
Accepted
a, b = map(int, input().split()) if a >= 13: print(b) elif 6 <= a <= 12: print(int(b/2)) else: print(0)
p03043
s189427746
Wrong Answer
n,k=(int(x) for x in input().split()) total=0 j=0 count=0 while k>(2**j): j=j+1 for i in range(j,1,-1): pro=(1/n)*((1/2)**i) total=total+pro count=count+1 while(count!=n): total=total+1/n count=count+1 print(round(total,12))
p03612
s059119038
Accepted
n = int(input()) a = list(map(int, input().split())) l = [0] * (n + 1) for i in range(n): if a[i] == i + 1: l[i] = 1 count = 0 for i in range(n): if l[i] == 1: l[i] = 0 l[i + 1] = 0 count += 1 print(count)
p03387
s800889991
Wrong Answer
A,B,C=map(int,input().split()) L=[A,B,C] L=sorted(L) ans=0 ans+=L[2]-L[1] L[0]+=L[2]-L[1] ans+=(L[2]-L[0])//2 print(ans)
p04045
s822414374
Accepted
N, K = map(int, input().split()) A = set(map(int, input().split())) while 1: B = set(map(int, list(str(N)))) if len(A & B) == 0: print(N) break N += 1
p03035
s428905136
Wrong Answer
a,b=map(int,input().split()) if a>=13: print(b) elif 6<a<=12: print(b//2) else: print(0)
p03136
s278856307
Wrong Answer
N=int(input()) L=list(map(int,input().split())) for i in range(N): if max(L)<sum(L)-max(L): print('Yes') else: print('No')
p03696
s886679523
Accepted
N = int(input()) S = list(input()) c = 0 l = [] for i in S: if i == "(": c += 1 else: c -= 1 l.append(c) m = min(l) if m < 0: for i in range(N): l[i] += (-m) M = l[-1] ans = ["("] *(-m) + S + [")"] *M else: M = l[-1] ans = S + [")"] *M output = "".join(ans) print(output)
p02719
s917119766
Accepted
n, k = map(int, input().split()) n1=n-(k*(n//k)) n2=abs(n1-k) if n1<n2: print(n1) else: print(n2)
p02973
s997132211
Wrong Answer
N = int(input()) l = [(i+1, int(input())) for i in range(N)] l.sort(key=lambda x:(x[1],x[0])) v = 0 a = 0 for i in range(N-1): if l[i][0] >= l[i+1][0] or l[i][1] == l[i+1][1]: a += 1 else: a = 0 v = max(v, a) print(v+1)
p03803
s044089634
Accepted
a,b=map(int,input().split()) if a==b: print('Draw') elif a > b and b != 1: print('Alice') elif a==1: print('Alice') else: print('Bob')
p03416
s935601674
Accepted
A, B = map(int, input().split()) cnt = 0 for n in range(A, B+1): if str(n) == str(n)[::-1]: cnt += 1 print(cnt)
p03639
s479089677
Accepted
N = int(input()) A = list(map(int, input().split())) c2 = sum([a % 2 == 0 and a % 4 != 0 for a in A]) c4 = sum([a % 4 == 0 for a in A]) cp = sum([a % 2 != 0 for a in A]) print('Yes' if cp+c4 == N and cp - c4 == 1 or cp <= c4 and c4+cp+c2 == N else 'No')
p03761
s483586141
Wrong Answer
n = int(input()) com=[] for i in range(n): s=list(input()) if com: tmp = com.copy() for j in s: if j in tmp: tmp.remove(j) for k in tmp: com.remove(k) else: com=s com.sort() print(''.join(com))
p02847
s548958246
Wrong Answer
s = input() l = ['SUN', 'MON', 'TUR', 'WED', 'THU', 'FRI', 'SAT'] m = [7, 6, 5, 4, 3, 2, 1] for i in range(7): if s == l[i]: print(m[i])
p02847
s604554915
Wrong Answer
s = input() x = [ '0', 'SAT', 'SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI'] for i in range(len(x)): if s == x[i]: print(i)
p02842
s774721193
Wrong Answer
# -*- coding: utf-8 -*- import math N = int(input()) for x in range(N,1,-1): val = int(x * 1.08) if val == N: print(x) exit() print(':(')
p02916
s999597714
Wrong Answer
n = int(input()) a = list(map(int, input().split(" "))) b = list(map(int, input().split(" "))) c = list(map(int, input().split(" "))) b_sum = sum(b) c_sum = 0 for i in range(n-1): ai = a[i] if ai != n: c_sum += c[ai-1] print(b_sum + c_sum)
p02922
s200340249
Wrong Answer
import math a,b=map(int,input().split()) print(math.ceil(b/a))
p03438
s219969522
Accepted
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) cnt = 0 for i in range(n): if a[i] > b[i]: k = a[i] - b[i] b[i] += k cnt += k for i in range(n): if a[i] < b[i]: k = (b[i] - a[i]) // 2 a[i] += 2 * k cnt -= k if a[i] < b[i]: a[i] += 2 b[i] += 1 print('Yes') if cnt <= 0 else print('No')
p02866
s696902066
Accepted
n = int(input()) D = tuple(map(int, input().split())) maxd = max(D) mod = 998244353 cd = [0] * (maxd+1) for d in D: cd[d] += 1 pre_nodes = cd[0] if pre_nodes != 1 or D[0] != 0: print(0) exit(0) ans = 1 for i in range(1, maxd+1): nodes = cd[i] ans *= pow(pre_nodes, nodes, mod) ans %= mod pre_nodes = nodes else: print(ans)