problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02786
s568752742
Wrong Answer
h = int(input()) print((2**(int(h/2)+1))-1)
p03282
s428096041
Accepted
s=input() k=int(input()) tmp=len(s) for i in range(len(s)): if s[i]!='1': tmp=i num=s[i] break if k>tmp: print(num) else: print('1')
p02983
s364979918
Accepted
l,r=map(int,input().split()) ans=10**9+7 if l==0 or (r-l>=2019): print(0) else: for i in range(l,r+1): for j in range(i+1,r+1): ans=min(ans,(i%2019)*(j%2019)%2019) print(ans)
p03943
s574681313
Accepted
a, b, c = map(int,input().split()) sum = a+b+c flag = False if sum/2 == a + b: flag = True if sum/2 == b + c: flag = True if sum/2 == c + a: flag = True if flag == True: print("Yes") else: print("No")
p04019
s806814078
Accepted
s = set(list(input())) ans = 'Yes' if ('N' in s)!=('S' in s) or ('W' in s)!=('E' in s):ans = 'No' print(ans)
p02829
s231890763
Wrong Answer
A=int(input()) B=int(input()) if A==2 and B==3: print(1) elif A==3 and B==1: print(2) elif A==1 and B==3: print(2) elif A==3 and B==1: print(1) else: print(3)
p03030
s733529532
Accepted
N = int(input()) my_list = [] for i in range(N): sp = input().split() sp[1] = int(sp[1]) sp.insert(0, i+1) my_list.append(sp) my_list.sort(key = lambda x: x[2], reverse=True) my_list.sort(key = lambda x: x[1]) for i in my_list: print(i[0])
p03625
s370904274
Accepted
import collections n = int(input()) a = list(map(int, input().split())) a = collections.Counter(a) ans = [] for i, j in a.items(): if j >= 2: for _ in range(j): ans.append(i) ans.sort(reverse=True) if len(ans) <= 3: print(0) else: print(ans[0]*ans[3])
p03633
s609663429
Accepted
from functools import reduce #!/usr/bin/env python3 import math def lcm_base(x, y): return (x * y) // math.gcd(x, y) def lcm(*numbers): return reduce(lcm_base, numbers, 1) def lcm_list(numbers): return reduce(lcm_base, numbers, 1) def main(): N = int(input()) T = [int(input()) for i in rang...
p02790
s130332167
Wrong Answer
a,b=map(int, input().split()) if a<b : for i in range(b) : print(a) else : for i in range(a) : print(b)
p02786
s602690934
Wrong Answer
j = 1 a = 1 i = int(input()) while i > 1: i /= 2 j *= 2 a += j print(a)
p02767
s740146014
Accepted
N = int(input()) X = list(map(int, input().split())) minX = min(X) maxX = max(X) if minX==maxX: print(0) quit() HP = [] for p in range(minX, maxX): hp = 0 for x in X: hp += (x-p)**2 HP.append(hp) print(min(HP))
p03386
s652259157
Accepted
a, b, k = map(int, input().split()) m = set(range(a, min(a+k, b))) n = set(range(max(a, b-k+1), b+1)) l = m | n for i in sorted(l): print(i)
p03210
s759061691
Wrong Answer
X = int(input()) if X % 3 == 0 or X % 3 == 0 or X % 7 == 0: print("YES") else: print("NO")
p03317
s170486506
Accepted
n, k = (int(x) for x in input().split()) a = [int(x) for x in input().split()] if n == k: print(1) elif k == 2: print(n-1) else: rem = n % (k-1) m = (n - rem) / (k-1) if rem <= 1: print(int(m)) else: print(int(m+1))
p03371
s901918125
Accepted
a, b, c, x, y = map(int, input().split()) ans = 0 min_ = min(x, y) res = abs(x-y) if a+b < 2*c: ans += min_*(a+b) else: ans += min_*2*c if x>y and res*a < res*2*c: ans += res*a elif x<y and res*b < res*2*c: ans += res*b else: ans += res*2*c print(ans)
p03481
s841640976
Wrong Answer
X ,Y = map(int, input().split()) l = [] ans = 0 for i in range(Y-X): if i == 0: t = X l.append(t) else: t = t * 2 if t <=Y: l.append(t) else: break ans = len(l) print(ans)
p02695
s063314393
Wrong Answer
import itertools n, m, q = map(int, input().split()) list_score = [ list(map(int,input().split(" "))) for i in range(q)] list_NUM = [i for i in range(1, m+1)] ans = 0 if q < n: for l in list_score: ans += l[3] else: for l in itertools.product(list_NUM, repeat=n): cnt = 0 for h in list_s...
p03478
s176873945
Accepted
n,a,b = map(int,input().split()) cnt = 0 for i in range(n+1): ans = 0 tmp = i while(tmp>0): ans += tmp%10 tmp = tmp//10 #print(ans, tmp) if(a<=ans and ans<=b): cnt+=i print(cnt)
p02725
s374195805
Accepted
k,n,*a=map(int,open(0).read().split()) a+=[k+a[0]] print(k-max(y-x for x,y in zip(a,a[1:])))
p03324
s926560987
Accepted
d, n = map(int,input().split()) i = 0 count = 0 beki = 0 beki = 100 ** d while not count == n: i += 1 if i % 100 == 0: continue count += 1 print(i * beki)
p03986
s393721453
Accepted
a=[] for i in input(): if i=="S": a+=i if a: if i=="T" and a[-1]=="T": a+=i if i=="T" and a[-1]=="S": a.pop(-1) elif i=="T" and len(a)==0: a+=i print(len(a))
p03331
s816413723
Accepted
N=input() ans=0 for n in N: ans+=int(n) if ans==1: ans=10 print(ans)
p02743
s580692430
Wrong Answer
import numpy a,b,c = map(int,input().split()) chka= numpy.sqrt(a) + numpy.sqrt(b) chkc = numpy.sqrt(c) if chka < chkc: print('Yes') else: print('No')
p02705
s092419097
Accepted
import numpy as np r = int(input()) print(2 * np.pi * r)
p03457
s643635957
Accepted
N = int(input()) t = 0 x = 0 y = 0 for i in range(N): t1,x1,y1 = map(int,input().split()) if abs(x1-x) + abs(y1-y) > t1-t or (abs(x1-x) + abs(y1-y) - (t1-t)) % 2 != 0: print('No') exit(0) t,x,y = t1,x1,y1 print('Yes')
p03386
s744153770
Accepted
A, B, K = map(int, input().split()) ans1 = [i for i in range(A, A + K) if A <= i and i <= B] ans2 = [i for i in range(B, B - K, -1) if A <= i and i <= B] ans = ans1 + ans2 ans = list(set(ans)) ans.sort() for ans in ans: print(ans)
p02994
s997239244
Accepted
N,L = map(int,input().split()) c = 0 if L >= 0: skip = 0 else: if N - (-L) > 0: skip = L*-1 else: skip = N-1 for i in range(N): if i == skip: continue c += L+i print(c)
p03385
s236278300
Accepted
S = str(input()) abc = [S[0], S[1], S[2]] if "a" in abc and "b" in abc and "c" in abc: print("Yes") else: print("No")
p03324
s129364282
Accepted
d, n = map(int, input().split()) print(100**d * n if n!=100 else 100**d * 101)
p02547
s856209031
Accepted
def main(): count=0 n=int(input()) x = [list(map(int, input().split())) for i in range(n)] for i in range(n): if x[i][0]==x[i][1]: count=count+1 else: count=0 if count==3: print("Yes") break if count!=3: print("No") ...
p02923
s241673472
Accepted
N = int(input()) H = list(map(int, input().split())) q = 0 s = [0] for i in range(N-1): if H[i] >= H[i+1]: p = q + 1 s.append(p) q = q + 1 else: s.append(0) q = 0 s.sort() ans = s[-1] print(ans)
p02973
s581642787
Accepted
N = int(input()) A = [int(input()) for i in range(N)] arr = [] from bisect import bisect for a in A: i = bisect(arr, -a) if i == len(arr): arr.append(-a) else: arr[i] = -a print(len(arr))
p02646
s594323183
Accepted
A,V = input().split() B,W = input().split() A = int(A) V = int(V) B = int(B) W = int(W) T = int(input()) def solve(): distance = abs(B-A) closer = abs(V-W) if V <= W: print("NO") return time = distance/closer if time <= T: print("YES") return else: ...
p03767
s568287310
Accepted
n = int(input()) a = list(map(int, input().split())) a.sort() print(sum(a[n:3*n-1:2]))
p02899
s751594210
Accepted
n = int(input()) a = list(map(int,input().split())) b = [0]*n for i,j in enumerate(a): b[j-1] = str(i+1) print(" ".join(b))
p02879
s572186917
Accepted
A, B = map(int, input().split(' ')) if A >= 10 or B >= 10: print('-1') else: print(A*B)
p02912
s483844533
Accepted
import heapq N, M = map(int, input().split()) A = list(map(int, input().split())) A = [a * -1 for a in A] heapq.heapify(A) for _ in range(M): a = heapq.heappop(A) heapq.heappush(A, (-a // 2) * (-1)) print(-sum(A))
p02556
s522977601
Accepted
n = int(input()) k = [0] * n l = [0] * n for i in range(n): x, y = [int(i) for i in input().split()] k[i] = x + y l[i] = x - y print(max(max(k)-min(k), max(l)-min(l)))
p03835
s360030319
Wrong Answer
k, s = 5, 15 count = 0 for x in range(k+1): for y in range(k+1): for z in range(k+1): if x + y + z == s: count += 1 print(count)
p03105
s959750124
Accepted
a,b,c = map(int,input().split()) if (b//a) <= c: print(int(b//a)) else: print(c)
p03327
s565547076
Accepted
N = input() if int(N)>= 1000: print("ABD") else: print("ABC")
p03673
s075605128
Accepted
import sys def input(): return sys.stdin.readline().strip() def resolve(): n=int(input()) a=list(input().split()) akisu=a[0::2] agusu=a[1::2][::-1] b=agusu+akisu if n%2==0: print(*b) else: print(*b[::-1]) resolve()
p02624
s493918234
Wrong Answer
n=int(input()) c=1 for i in range(1,n+1): if i>1: y=0 for j in range(1,i+1): if i%j ==0: y=y+1 print(y) c=c+(i*y) print(c) print(c)
p02684
s761580092
Accepted
n,k = map(int, input().split()) a = list(map(int, input().split())) visit = [0] * n visit[0] = 1 keiro = [1] s = 1 now = 1 while True: x = a[now - 1] if visit[x - 1] == 1: break now = x visit[x - 1] = 1 keiro.append(x) l1 = len(keiro) l2 = keiro.index(x) if k < l1: print(keiro[k]) e...
p02602
s098356517
Wrong Answer
import numpy as np n, k = map(int, input().split()) a = list(map(int, input().split())) cum_a = np.cumprod(a) cum_a = np.hstack([np.ones(1), cum_a]) for i in range(n - k): s = cum_a[i + k] / cum_a[i] t = cum_a[i + k + 1] / cum_a[i + 1] if s < t: print("Yes") else: print("No")
p02548
s739965175
Wrong Answer
n = int(input()) s=(n-1) #ab = n//2 if n%2==0 else n//2 + 1 for x in range(2,n//2): if n%x==0: s+=(n//x - 1) else: s+=(n//x) print(s + n//2)
p02663
s569126143
Accepted
sh, sm, eh, em, K = map(int, input().split()) time = 60*(eh-sh) + em - sm print(time - K)
p02598
s291227320
Accepted
N,K = map(int,input().split()) A = list(map(int,input().split())) def f(n): now = 0 for i in range(N): now += (A[i]-1)//x if now <= K: return True else: return False l = 0; r = 10**10 while r-l > 1: x = (l+r)//2 if f(x): r = x else: l = x print(r)
p02623
s874339850
Wrong Answer
import math import time from collections import defaultdict, deque from sys import stdin, stdout from bisect import bisect_left, bisect_right,bisect n,m,k=map(int,stdin.readline().split()) a=list(map(int,stdin.readline().split())) b=list(map(int,stdin.readline().split())) prea=[] ans=0 for i in a: ans+=i prea....
p03160
s827504862
Wrong Answer
N = int( input() ) h = [int(x) for x in input().split()] h = [0] + h dp = [0]*( len(h) ) for ii in range( 2, len(dp) ): from_1 = abs(h[ii] - h[ii-1]) from_2 = abs(h[ii] - h[ii-2]) dp[ii] = min( dp[ii-1] + from_1, dp[ii-2] + from_2 ) print(dp[-1])
p03478
s730982230
Wrong Answer
N,A,B = map(int,input().split()) K = 0 for i in range(1,N+1): if A <= sum(list(map(int,str(i)))) <= B: K += 1 print(K)
p03106
s872541273
Wrong Answer
a,b,k=map(int,input().split()) n=0 for i in range(min(a,b),0,-1): if (a/i==a//i) and (b/i==b//i): print(i) n+=1 if n==k: print(i) exit()
p02933
s599157814
Wrong Answer
a = int(input()) s = input() if a >= 3200: print("s") elif a <= 3200: print("red")
p04012
s630484641
Accepted
n = [0 for _ in range(26)] S = list(input()) ans = "Yes" for i in S: n[ord(i) - ord('a')] += 1 for i in n: if i % 2 != 0: ans = "No" print(ans)
p03565
s216233569
Accepted
S = input()[::-1] T = input()[::-1] flag = False for i in range(len(S) - len(T) + 1): matched = True for j in range(len(T)): if S[i + j] != "?" and S[i + j] != T[j]: matched = False if matched: S = S[:i] + T + S[i + len(T):] flag = True break if flag: ...
p03815
s633293676
Accepted
x = int(input()) #6,5,6,5...で何回加算されていくか。 #余りの部分は後で処理 ans = x // 11 * 2 if x % 11 > 6: print(ans + 2) elif x % 11 > 0: print(ans + 1) else: print(ans)#余りなし=割り切れる時
p03565
s982642197
Wrong Answer
s = input() t = input() ls = len(s) lt = len(t) def match(k): for i in range(lt): if t[i] != s[i+k] and s[i+k] != '?': return False return True c = -1 for i in range(ls-lt+1): if match(i): c = i if c == -1: print('UNRESTORABLE') exit() ans = s[:c].replace('?', 'a') an...
p02633
s534943529
Accepted
N = int(input()) for i in range(360): if not N * (i + 1) % 360: print(i + 1) break
p02817
s149102813
Accepted
s,t=map(str,input().split()) print(t+s)
p03760
s071827579
Accepted
O = input() E = input() ans = "" for i in range(len(O)+len(E)): if i%2 == 0: ans += O[i//2] else: ans += E[i//2] print(ans)
p02659
s622799083
Accepted
import sys readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prn = lambda x: print(*x, sep='\n') a, b = input().split() a = int(a) p, q = map(int, b.spl...
p03419
s068423949
Accepted
n, m = map(int, input().split()) if min(n, m) == 1: if max(n, m) == 1: print(1) else: print(max(n, m)-2) elif min(n, m) == 2: print(0) else: print((n-2)*(m-2))
p03681
s233509301
Wrong Answer
n, m = map(int, input().split()) def lp(animal, row): for i in range(1, n+1): row *= i return row result = abs(n-m) limit = 10**9+7 row = 1 if result >= 2: print(0) exit() elif result == 1: row = lp(n, row) row = lp(m, row) elif n == m: row = lp(n, row) row = lp(m, row) ro...
p03419
s237346551
Accepted
n,m=map(int,input().split()) n,m=min(n,m),max(n,m) if n==1: if m==1: print(1) else: print(max(0,m-2)) exit() else: print(max(0,(n-2)*(m-2)))
p02780
s453277578
Accepted
N, K = map(int, input().split()) A = list(map(int, input().split())) P = pow(1 / 6, K) now = sum(map(lambda a: a * (a + 1) // 2 / a, A[:K - 1])) ans = 0 for left, right in zip(A, A[K - 1:]): now += right * (right + 1) // 2 / right ans = max(ans, now) now -= left * (left + 1) // 2 / left print('{:.10f}'.fo...
p03795
s602993192
Wrong Answer
n = int(input()) s = int(800 * n - 200 * n//15) print(s)
p03838
s577040501
Wrong Answer
x,y=map(int,input().split()) X=abs(x) Y=abs(y) if x<y: if x*y>0: print(y-x) elif x*y==0: print(abs(X-Y)) else: print(abs(X-Y)+1) else: if x*y>=0: print(abs(X-Y)+2) elif x*y==0: print(abs(X-Y)+1) else: print(abs(X-Y)+1)
p02705
s732019243
Accepted
import math r = int(input()) print(2*r*math.pi)
p03657
s474293138
Accepted
a,b=map(int,input().split()) if a%3==0 or b%3==0 or (a+b)%3==0: print("Possible") else: print("Impossible")
p02833
s712137520
Accepted
n = int(input()) if n % 2 != 0: print(0) else: ans = 0 tmp = 10 while tmp <= n: ans += n//tmp tmp *= 5 print(int(ans))
p03761
s692408216
Accepted
import string n = int(input()) #a, b = map(int,input().split()) #l = list(map(int,input().split())) #l = [list(map(int,input().split())) for i in range(n)] sl = [list(input()) for i in range(n)] alpha = list(string.ascii_lowercase) dic = {si: sl[0].count(si) for si in alpha} for s in sl: for ch in alpha: ...
p02933
s508606755
Wrong Answer
a = 2000 if a >= 3200: print("s") if a < 3200: print("red")
p02717
s956408257
Accepted
X, Y, Z = map(int, input().split()) print(Z,X,Y)
p02910
s782218608
Accepted
odd_step=["R","U","D"] even_step=["L","U","D"] s=input() ans="Yes" for i in range(len(s)): if i%2 != 0: if not s[i] in even_step: ans="No" else: if not s[i] in odd_step: ans="No" print(ans)
p02744
s016810392
Accepted
n=int(input()) def dfs(s,mx): #print("s",s) if len(s)==n: print(s) return for i in range(ord("a"),mx+2): #print(i) #print(s+chr(i)) dfs(s+chr(i),max(mx,i)) dfs("a",ord("a"))
p02694
s924979255
Accepted
# 金利1% X = int(input()) ans = 0 now = 100 while X > now: ans += 1 now = int(now * 1.01) print(ans)
p03011
s993822949
Accepted
p,q,r=map(int,input().split()) a=min(p,q) b=max(p,q) c=min(b,r) print("{}".format(a+c))
p02595
s382641245
Wrong Answer
N,D = map(int,input().split()) a = 0 for num in range(1,N) : X,Y = map(int,input().split()) if X*X + Y*Y <= D*D : a += 1 print(a)
p03109
s199331164
Accepted
s=input() if s<="2019/04/30": print("Heisei") else: print("TBD")
p03339
s094880303
Accepted
n=int(input()) s=input() t=s[1:].count('E') a=t for i in range(n-1): t+=(s[i]=='W')-(s[i+1]=='E') a=min(a,t) print(a)
p02642
s733640951
Accepted
n = int(input()) a_list = list(map(int,input().split())) a_list = sorted(a_list) flag = [0]*n ans = 0 m = max(a_list) b_list = [0]*(m+1) for i in a_list: b_list[i] += 1 for i in a_list: if b_list[i] == 1: ans += 1 for j in range(i , m+1 ,i): b_list[j]+= 1 print(ans)
p02556
s132489221
Wrong Answer
N = int(input()) A = [list(map(int, input().split())) for _ in range(N)] tail = 0 head = float('inf') for i in range(N): tail = max(tail, sum(A[i])) head = min(head, sum(A[i])) ans_1 = tail - head tmp_h, tmp_t = 0, 0 tail = A[i] head = A[i] for i in range(N): tail = A[i] if tmp_h < A[i][0]-A[i][1] else tai...
p02917
s897504238
Wrong Answer
N=int(input()) B=[int(x) for x in input().rstrip().split()] A=[B[0]] for i in range(1,N-1): if i+1<N-1: A.append(min(B[i-1],B[i],B[i+1])) else: A.append(min(B[i],B[i-1])) A.append(B[N-2]) print(sum(A))
p02817
s377108295
Wrong Answer
S, T = input().split() print(S+T)
p02755
s106064807
Accepted
import sys #read = sys.stdin.read from math import floor def main(): a, b = map(int, input().split()) for i1 in range(1251): if floor(i1 * 0.08) == a and floor(i1 * 0.1) == b: print(i1) sys.exit() print(-1) if __name__ == '__main__': main()
p02953
s665528160
Accepted
n = int(input()) h = list(map(int,input().split())) h = [0]+h+[10**9+1] for i in range(1,n+1): if h[i] > h[i+1]+1: print("No") exit() elif h[i] == h[i+1]+1: h[i] -= 1 if h[i-1] > h[i]: print("No") exit() else: if h[i-1] < h[i]: h[i] -= 1 print("Yes")
p02659
s144404729
Wrong Answer
Input = input().split() A = Input[0] A = float(A) B = Input[1] B = float(B) AB = A*B AB = int(AB) print(AB)
p02836
s258514199
Accepted
s = input() n = len(s) ans = 0 for i in range(n // 2): if s[i] != s[-( i + 1)]: ans += 1 print(ans)
p02971
s334797588
Accepted
N = int(input()) A = [int(input()) for i in range(N)] ans = [0]*N first = sorted(A)[-1] second = sorted(A)[-2] for i in range(N): if A[i]==first: ans[i] = second else: ans[i] = first print(*ans, sep="\n")
p02618
s392017755
Accepted
d = int(input()) #日にちは-1indexで c = list(map(int, input().split())) csum = 0 for i in range(26): csum += c[i] s = [ [] for _ in range(d)] for i in range(d): s[i] = list(map(int, input().split())) t = [0 for _ in range(d)] for i in range(d): maxp = -2 for j in range(26): if (s[i][j] > maxp): ...
p02606
s966851141
Wrong Answer
l,r,d=map(int,input().split()) ans = (r-l)//d if ans == 0: print(0) else: print(ans)
p02675
s142349872
Accepted
n = int(input()) np = n % 10 if (np - 2)*(np - 4)*(np - 5)*(np - 7)*(np - 9) == 0: print('hon') elif np*(np-1)*(np-6)*(np-8) == 0: print('pon') else: print('bon')
p02726
s767792744
Accepted
N,X,Y = map(int, input().split()) c = [0 for _ in range(N)] for i in range(1,N): for j in range(i+1,N+1): x = abs(X-i) y = abs(Y-j) a = min(x+y+1, j-i) c[a] += 1 for i in range(1,N): ans = c[i] print(ans)
p03286
s943805387
Accepted
n = int(input()) ans = '' if n == 0: print('0') while n != 0: r = n % 2 if r < 0: r = r + 2 n = (n-r) / (-2) ans = ans + str(int(r)) ans = list(ans) ans.reverse() print(''.join(ans))
p03745
s240583510
Accepted
#!/usr/bin/env python n = int(input()) a = list(map(int, input().split())) d = [0 for _ in range(n-1)] for i in range(n-1): d[i] = a[i+1]-a[i] ans = 1 flg = [False, False] for i in range(n-1): if d[i] > 0: flg[0] = True elif d[i] < 0: flg[1] = True if flg[0] == flg[1] == True: ...
p02790
s337377480
Accepted
a, b = map(int, input().split()) if a < b: print(''.join([str(a) for _ in range(b)])) else: print(''.join([str(b) for _ in range(a)]))
p02642
s499728455
Accepted
def resolve(): N = int(input()) A = list(map(int, input().split())) a_max = max(A)+1 B = {} for i in range(N): a = A[i] if a not in B.keys(): for j in range(a, a_max, a): B[j] = False B[a] = True else: B[a] = False Y = list(B.values()).count(True) print(Y) resolve()
p03778
s595624538
Accepted
w,a,b=map(int,input().split()) if a<=b<=a+w or a<=b+w<=a+w: print(0) else: print(min(abs(b-(a+w)),abs(a-(b+w))))
p02753
s547217510
Wrong Answer
s = input() if s == "AAA" or s == "BBB": print("Yes") else: print("No")