problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02554
s180951526
Accepted
n=int(input()) a= pow(10,n,10**9+7) b = pow(8,n,10**9+7) c = pow(9,n,10**9+7) print((a-2*c+b)%(10**9+7))
p03481
s290522618
Accepted
x, y = map(int, input().split()) cnt = 1 while x *2 <= y: #print(x*2) cnt+=1 x=x*2 print(cnt)
p02814
s543044151
Wrong Answer
n,m = map(int,input().split()) a = [int(i) for i in input().split()] a = sorted(list(set(a))) from fractions import gcd lc = a[0] if n != 1: for num,i in enumerate(a[1:]): if lc == 0: break lc = lc * i // gcd(lc, i) if gcd(lc, i) == min(i,lc): for j in a[:num]: if (i//j)%2 == 0: lc = 0 break if lc == 0: print(0) else: print((m+lc//2)//lc)
p03107
s408652296
Wrong Answer
S = input().strip() cnt0 = 0 cnt1 = 1 for i in range(len(S)): if S[i]=="0": cnt0 += 1 else: cnt1 += 1 print(min(cnt0,cnt1)*2)
p03427
s819475787
Accepted
s = input() if len(s) == 1: print(int(s[0])) elif s[1:] == "9"*(len(s)-1): print(int(s[0])+9*len(s)-9) else: print(int(s[0])+9*len(s)-10)
p03041
s696770116
Accepted
N, K = map(int, input().split()) S = list(input()) S[K - 1] = S[K - 1].lower() print("".join(S))
p03962
s301721834
Accepted
import sys import math import bisect def main(): A = list(map(int, input().split())) print(len(set(A))) if __name__ == "__main__": main()
p03146
s270886239
Accepted
# coding: utf-8 # Your code here! S=int(input()) List=[S] i=1 while 1==1: i+=1 if S%2==0: S=S/2 else: S=(S*3)+1 List.append(S) if len(List) != len(set(List)): break #i+=1 print(i)
p02627
s876055610
Accepted
a = input() if a.isupper(): print("A") else: print("a")
p02957
s051508971
Wrong Answer
A, B = map(int, input().split()) print(A + B // 2 if (A + B) % 2 == 0 else "IMPOSSIBLE")
p02795
s945420542
Wrong Answer
h = int(input()) w = int(input()) n = int(input()) print(int(n / max(h,w)))
p03323
s341609699
Wrong Answer
a,b = map(int,input().split()) if a<9 & b<9: print("Yay!") else: print(":(")
p02598
s858783862
Accepted
from math import ceil n, k = map(int, input().split()) a = list(map(int, input().split())) def c(x): cnt=0 for i in a: cnt += i // x return cnt<=k l, r = 0, max(a) for i in range(100): mid = (l + r) / 2 if c(mid): r = mid else: l = mid print(ceil(l))
p02663
s649763346
Accepted
h1, m1, h2, m2, k = list(map(int, input().split())) result = (h2 * 60 + m2) - (h1 * 60 + m1) - k print(result)
p02630
s840409438
Accepted
from collections import Counter N = int(input()) A = list(map(int, input().split())) Q = int(input()) BC = [list(map(int, input().split())) for _ in range(Q)] d = Counter(A) sub_s = sum(A) for b, c in BC: sub_s += d[b] * (c - b) d[c] += d[b] d[b] = 0 print(sub_s)
p03427
s366396072
Accepted
N = input() if N[1:] == (len(N)-1)*'9': print(int(N[0]) + (len(N)-1)*9) else: print((int(N[0])-1) + (len(N)-1)*9)
p02678
s389813506
Accepted
from collections import deque N, M = map(int, input().split()) graph = [[] for i in range(N+1)] for i in range(M): a, b = map(int, input().split()) graph[a].append(b); graph[b].append(a) d = deque([[1, 0]]) par = [0] * (N+1) while d: node, p = d.popleft() children = graph[node] for child in children: if child == p or par[child] != 0: continue par[child] = node d.append([child, node]) print('Yes') print(*par[2:], sep='\n')
p02583
s336422822
Accepted
import itertools n = int(input()) data = list(map(int, input().split())) data1=sorted(data) a = list(itertools.combinations(data1,3)) ans=0 for m in range(len(a)): if a[m][0]!=a[m][1] and a[m][1]!=a[m][2]: if a[m][0]+a[m][1]>a[m][2]: ans=ans+1 print(ans)
p02951
s758958312
Accepted
a,b,c=map(int,input().split()) print(max([0,c-a+b]))
p02787
s854429651
Accepted
import sys def input(): return sys.stdin.readline()[:-1] h, n = map(int, input().split()) a=[0]*n b=[0]*n for i in range(n): a[i], b[i] = map(int, input().split()) dp = [float('inf')]*(h+max(a)) dp[0] = 0 for i in range(1, h+max(a)): for j in range(n): dp[i] = min(dp[i], dp[i-a[j]]+b[j]) print(min(dp[h:]))
p03548
s868012508
Accepted
x,y,z = map(int,input().split()) x=x-z print(x//(y+z))
p03448
s687550348
Accepted
a=int(input()) b=int(input()) c=int(input()) x=int(input()) count=0 for i in range(0,a+1): for j in range(0,b+1): for k in range(0,c+1): if 500*i+100*j+50*k==x: count+=1 print(count)
p02823
s697953844
Accepted
N,A,B= map(int,input().split()) if (B-A)%2 == 0: print((B-A)//2) else: print(min(A-1,N-B)+1+(B-A-1)//2)
p02726
s776889416
Accepted
N, X, Y = map(int, input().split()) d = [[0] * (N+1) for _ in range(N)] ans = [0] * N for i in range(1, N+1): for j in range(i+1, N+1): a = j - i b = 1 + abs(i - X) + abs(j - Y) d[i][j] = min(a, b) ans[d[i][j]] += 1 for i in range(1, N): print(ans[i])
p02972
s378388588
Accepted
n = int(input()) a = list(map(int, input().split())) b = [None]*n for i in range(n, 0, -1): s = 0 for j in range(2*i, n+1, i): s += b[j-1] b[i-1] = a[i-1]^(s%2) print(sum(b)) print(*[ind+1 for ind, i in enumerate(b) if i])
p02916
s205011811
Accepted
n = int(input()) aa = list(map(int, input().split())) bb = list(map(int, input().split())) cc = list(map(int, input().split())) score = bb[aa[0]-1] for i in range(1,n): score += bb[aa[i]-1] if aa[i] == aa[i-1] +1: score += cc[aa[i-1]-1] print(score)
p03067
s064108169
Wrong Answer
a, b, c = map(int, input().split()) print('Yes' if a <= c and c <= b else "No")
p02881
s088990063
Accepted
import sys import math import itertools import collections import heapq import re import numpy as np rr = lambda: sys.stdin.buffer.readline().rstrip() rs = lambda: sys.stdin.buffer.readline().split() ri = lambda: int(sys.stdin.buffer.readline()) rm = lambda: map(int, sys.stdin.buffer.readline().split()) rl = lambda: list(map(int, sys.stdin.buffer.readline().split())) n = ri() for i in range(int(n**0.5), 0, -1): if not n%i: print(n//i + i - 2) exit()
p02677
s671328390
Wrong Answer
import math A, B, H, M = map(int,input().split()) degunit1 = 360/720 degunit2 = 360/60 currentHM = 60*H+M deg1 = degunit1*currentHM deg2 = degunit2*M diff = abs(deg1-deg2) if diff <=180: diff = diff*math.pi/180 else: diff = (diff-180)*math.pi/180 L = (A**2+B**2 -2*A*B*math.cos(diff))**0.5 print(L)
p03696
s006441709
Accepted
N = int(input()) S = input() left = 0 for i in range(N - 1, -1, -1): if S[i] == ")": left += 1 else: left = max(0, left - 1) right = 0 for i in range(N): if S[i] == "(": right += 1 else: right = max(0, right - 1) print("(" * left + S + ")" * right)
p03109
s224882480
Wrong Answer
# https://atcoder.jp/contests/abc119/tasks/abc119_a y, m, d = map(int, input().split('/')) if y > 2019: print('TBD') elif m > 5: print('TBD') else: print('Heisei')
p03351
s629868903
Wrong Answer
arr = input().split() arr = list(map(int,arr)) a = arr[0] b = arr[1] c = arr[2] d = arr[3] if b - a <= d and c - b <= d: print('Yes') else: print('No')
p03852
s073616349
Wrong Answer
s=input().replace('eraser',"").replace('eraser',"").replace('erase',"").replace('dreamer',"").replace('dream',"") if s: print("No") else: print("Yes")
p04045
s898465522
Wrong Answer
def dfs(A: list): if len(A) > nn: return if len(A) and (x := int("".join(A))) >= n and ans[0] > x: ans[0] = x return for v in d: if v == "0" and len(A) == 0: next A.append(v) dfs(A) A.pop() n, k = map(int, input().split()) d = sorted(list(set([str(i) for i in range(10)]) - set(input().split()))) nn = len(str(n))+1 ans = [10**7] dfs([]) print(ans)
p02778
s033696694
Accepted
S = input("") for i in range(len(S)): print("x",end="")
p03951
s733281101
Accepted
N = int(input()) s = input() t = input() c = None # i文字一致している for i in range(N+1): sp = s[i:] tp = t[:N-i] # print(sp, tp) if sp == tp: c = i break match = N - c ans = 2 * N - match # print(c, match, ans) print(ans)
p03730
s563032187
Accepted
A = list(map(int, input().split())) ans = 'NO' for i in range(1, A[1] + 1): if i * A[0] % A[1] == A[2]: ans = 'YES' print(ans)
p03487
s554291142
Accepted
from collections import Counter n = int(input()) a = list(map(int, input().split())) s = 0 A = Counter(a) l = len(A) for key, value in A.items(): if key <= value: s+= value - key else: s += value print(s)
p03385
s844702855
Wrong Answer
s = input() if len(set(s)) == 3: print('Yes') else: print('NO')
p03162
s053423915
Wrong Answer
N = int(input()) arr=[] for i in range(N): arr.append(list(map(int, input().split()))) max_ind=arr[0].index(max(arr[0])) max_sum=max(arr[0]) for i in range(1,len(arr)): temp=arr[i] temp.pop(max_ind) max_sum+=max(temp) max_ind=temp.index(max(temp)) print(max_sum)
p03835
s493848821
Accepted
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import math import collections MAX = 10**18 MIN = -10**18 MOD = 998244353 k,s = map(int,input().split()) cnt = 0 for i in range(k+1): for j in range(k+1): l = s-i-j if l>=0 and l<=k: cnt += 1 print(cnt)
p02797
s217937653
Wrong Answer
def solve(N,K,S): for i in range(0, K): print(S) for i in range(K+1, N): print(S+1) N ,K ,S = map(int,input().split()) solve(N,K,S)
p03479
s438916790
Accepted
x,y=map(int,input().split()) n=y//x print(len(bin(n))-2)
p02787
s485509882
Accepted
h,n=map(int,input().split()) dp=[10**10]*(h+1) dp[0]=0 X=[] for i in range(n): a,b=map(int,input().split()) X.append([a,b]) for i in range(h): for j in range(n): k=min(i+X[j][0],h) dp[k]=min(dp[k],dp[i]+X[j][1]) print(dp[h])
p02718
s119395011
Accepted
n, m = map(int, input().split()) a = list(map(int, input().split())) u = sum(a) / (4*m) l = 0 for i in a: if i >= u: l += 1 print("Yes") if l >= m else print("No")
p03645
s352904313
Wrong Answer
N, M = map(int, input().split()) first = set() second = set() for i in range(M): a, b = map(int, input().split()) if a == 1: first.add(b) if b == N: second.add(a) if first & second: print("POSSIBLE") else: print("IMPOSSOBLE")
p03485
s586660732
Accepted
a, b = map(int, input().split()) print((a + b + 1) // 2)
p03351
s074713274
Accepted
a, b, c, d = map(int, input().split()) if abs(b-a) <= d and abs(c-b) <= d: print('Yes') elif abs(a-c) <= d: print('Yes') else: print('No')
p03087
s133236154
Accepted
n,q = map(int,input().split()) s = input() Query = [list(map(int,input().split())) for _ in range(q)] x = [ 0 for _ in range(n) ] for i in range(n-1): if s[i:i+2] == "AC": x[i+1] = x[i] + 1 else: x[i+1] = x[i] for l,r in Query: print(x[r-1]-x[l-1])
p02831
s474043805
Accepted
a, b = map(int, input().split()) if a < b: small = a big = b else: small = b big = a i = 2 while True: if (small * i) % big == 0: print(small * i) break i += 1
p03545
s496817092
Accepted
import itertools S=input() sum1=0 for i in itertools.product(["+","-"],repeat=3): ans="" for j in range(3): if i[j]=="+": ans+=S[j]+i[j] elif i[j]=="-": ans+=S[j]+"-" ans+=S[-1] sum1=eval(ans) if sum1==7: print(ans+"="+str(7)) exit()
p02897
s023563802
Wrong Answer
N=int(input()) x=N//2 print(x/N)
p02897
s255601945
Accepted
N = int(input()) print(((N//2) if N%2 == 0 else (N//2)+1)/N)
p02859
s227526623
Accepted
print(int(input()) ** 2)
p02555
s201995011
Wrong Answer
s=2000 dp=[0]*(2001) dp[0]=1 dp[1]=0 dp[2]=0 dp[3]=1 dp[4]=1 m=1000000007 for i in range(5,s+1): for j in range(3,10): if i>=j: dp[i]=(dp[i]+dp[i-j])%m n=int(input()) print(dp[n])
p02958
s559429362
Accepted
# ABC 135: B – 0 or 1 Swap N = int(input()) p = [int(s) for s in input().split()] p_sorted = sorted(p) diff = 0 for i in range(N): if p[i] != p_sorted[i]: diff += 1 print('YES' if diff == 2 or diff == 0 else 'NO')
p02796
s764018671
Wrong Answer
n = int(input()) xl = sorted([tuple(map(int, input().split())) for _ in range(n)]) tmp = sum(xl[0]) res = 0 for i in range(1, n): x, l = xl[i] if tmp > x-l: res += 1 else: tmp = x+l print(n-res)
p02633
s857152437
Accepted
x = int(input()) x_max = 179 for i in range(1,x_max+1): if((360 * i) % x == 0): tmp = (360 * i) / x print(int(tmp)) break
p03073
s245628161
Accepted
# coding: utf-8 start_col = ["0", "1"] s = input().rstrip() def get_next(prev: str): if prev == "0": return "1" else: return "0" ans = len(s) for i in start_col: current = i cnt = 0 for j in range(len(s)): if s[j] != current: cnt += 1 current = get_next(current) ans = min(ans, cnt) print(ans)
p02836
s776649404
Accepted
s=input() print(sum(a>b for a,b in zip(s,s[::-1])))
p03221
s940007923
Accepted
n,m=map(int,input().split()) x=[[] for _ in range(n+1)] ans=[-1]*m for i in range(m): p,y=map(int,input().split()) x[p].append([y,i]) for p in range(1,n+1): tmp=sorted(x[p]) for j in range(len(tmp)): ans[tmp[j][1]]=str(p).zfill(6)+str(j+1).zfill(6) for i in range(m): print(ans[i])
p03417
s613212029
Accepted
n,m = map(int, input().split()) ans = 0 if n == 1: if m == 1: ans = 1 elif m == 2: ans = 0 else: ans = m - 2 if n == 2: ans = 0 if n > 2: if m == 1: ans = n-2 elif m == 2: ans = 0 else: ans = (n-2)*(m-2) print(ans)
p03030
s701508706
Accepted
n = int(input()) x = [input().split() for i in range(n)] for i in range(n): x[i][1] = int(x[i][1]) x[i].append(i+1) x.sort(key= lambda a: a[1]) x.reverse() x.sort(key= lambda b: b[0]) for i in range(n): print(x[i][2])
p02785
s281719493
Accepted
n, k = map(int, input().split()) h = list(map(int, input().split())) h.sort(reverse=True) if len(h) >= k: ans = sum(h[k:]) else: ans = 0 print(ans)
p02702
s642115600
Accepted
s = input()[::-1] n = len(s) cnt = [0] * 2019 cnt[0] = 1 total = 0 ans = 0 x = 1 for i in range(n): total += int(s[i]) * x total %= 2019 x *= 10 x %= 2019 ans += cnt[total] cnt[total] += 1 print(ans)
p03387
s843414714
Accepted
*A,=sorted(map(int,input().split())) ans=0 if (A[1]-A[0])%2==0: ans=(A[1]-A[0])//2 ans+=A[2]-A[1] else: ans=(A[1]-A[0])//2+1 ans+=A[2]+1-A[1] print(ans)
p03324
s921327221
Accepted
nums = [int(e) for e in input().split()] if(nums[1] == 100): print(pow(100,nums[0])*(nums[1]+1)) else: print(pow(100,nums[0])*nums[1])
p02880
s708574654
Accepted
N = int(input()) lst = [] for i in range(10): for j in range(10): lst.append(i*j) if N in lst: print('Yes') else: print('No')
p03417
s394988020
Accepted
n, m = [int(x) for x in input().split()] if n == 1 and m == 1: ans = 1 elif n == 1 or m == 1: ans = max(n, m) - 2 else: ans = n * m - 2 * n - 2 * m + 4 print(ans)
p02759
s562141077
Wrong Answer
x = input() page = int(x) // 2 print(page+1)
p02918
s737943261
Wrong Answer
n,k=map(int,input().split()) S=input() c=0 d=0 for i in range(n-1): if S[i]==S[i+1]: c+=1 if S[i]!=S[i+1]: d+=1 print(c+2*k-1 if (d<=k and S[0]!=S[-1]) else c+2*k)
p02725
s724771789
Accepted
def main(): import sys input = sys.stdin.readline K, N = map(int, input().split()) A = list(map(int, input().split())) d = [] for i in range(N-1): d.append(A[i+1] - A[i]) d.append(K-A[-1]+A[0]) print(K - max(d)) if __name__ == '__main__': main()
p02718
s112705273
Wrong Answer
mn = input().split() ob = input().split() n = int(mn[0]) m = int(mn[1]) votes = 0 for i in range(len(ob)): ob[i] = int(ob[i]) votes += ob[i] ob.sort() line = votes//(4*m) ans = 0 for i in range(m): if ob[-1*(i+1)] <= line: ans += 1 if ans == 0: print("Yes") else: print("No")
p03852
s008690990
Accepted
c = input() if (c=='a')or(c=='i')or(c=='u')or(c=='e')or(c=='o'): print('vowel') else: print('consonant')
p04043
s693412349
Accepted
num=list(map(int,input().split())) num.sort() print('YES' if num==[5,5,7] else 'NO')
p02723
s956865085
Accepted
S = input() if S[2]==S[3] and S[4]==S[5]: print("Yes") else: print("No")
p02631
s442964781
Accepted
n = int(input()) a = list(map(int,input().split())) S = 0 for i in a: S = S^i ans = [] for i in a: ans.append(S^i) print(*ans)
p03605
s742931107
Accepted
num=str(input()) char=list(num) if char[0]=="9": print("Yes") elif char[1]=="9": print("Yes") else: print("No")
p02641
s142463496
Accepted
X,N=map(int, input().split()) NL=list(map(int, input().split())) BL=[i for i in range(-1,102)] for i in NL: BL.remove(i) ANS=1000 out=1000 for i in BL: temp=abs(X-i) if ANS>temp: ANS=temp out=i print(out)
p03472
s592962455
Wrong Answer
import math n,k = map(int,input().split()) lst1 = [list(map(int,input().split())) for i in range(n)] ans = 0 x = 0 for i in range(n): x = max(x,lst1[i][0]) sum1 = 0 for i in range(n): if lst1[i][1] > x: sum1 += lst1[i][1] ans += 1 k -= sum1 print(ans + math.ceil(k/x) )
p03693
s677191106
Wrong Answer
r, g, b = map(int, input().split()) print('Yes' if (100 * r + 10 * g + b) % 4 == 0 else 'N0')
p02953
s447738849
Accepted
n = int(input()) h = list(map(int,input().split())) h = h[::-1] for i in range(n-1): if h[i+1] - h[i] == 1: h[i+1] = h[i+1] - 1 elif h[i+1] - h[i] > 1: print("No") exit() else: print("Yes")
p02923
s053833008
Accepted
N = int(input()) H = tuple(map(int, input().split())) c = m = 0 for i in range(N-1): if H[i] >= H[i+1]: c += 1 else: m = c if c > m else m c = 0 print(max(c, m))
p03109
s817718886
Accepted
S = input() y, m, d = S.split('/') ans = 'TBD' if int(m)<=4: ans = 'Heisei' print(ans) #print(*ans, sep='\n')
p02946
s940933076
Wrong Answer
k,x=map(int,input().split()) if x-k+1<=-1000000: a=-1000000 else: a=x-k+1 if x+k-1>=1000000: b=1000000 else:b=x+k-1 print([i for i in range(a,b+1)])
p02963
s683105450
Wrong Answer
import sys sys.setrecursionlimit(10 ** 8) input = sys.stdin.readline def main(): N = int(input()) print(0, 0, 1, 0, 0, N) if __name__ == '__main__': main()
p02842
s063024104
Wrong Answer
from math import floor n = int(input()) for i in range(1,n): if floor(i*1.08) == n: print(i) break else: print(":(")
p03252
s474321383
Accepted
S = input() T = input() S_cnt = sorted(S.count(c) for c in set(S)) T_cnt = sorted(T.count(c) for c in set(T)) print("Yes") if S_cnt == T_cnt else print("No")
p02699
s123003350
Accepted
i = list(map(int, input().split())) if i[0] > i[1]: print("safe") else: print("unsafe")
p04020
s799298745
Wrong Answer
n,*a=map(int,open(0).read().split()) ans=0 for i in range(n): p,a[i]=divmod(a[i],2) ans+=p i=0 while i+1<n: if a[i]==1 and a[i+1]==1: ans+=1 i+=1 i+=1 print(ans)
p03698
s188639353
Accepted
s = input() n = len(s) x = dict() for i in range(n): x[s[i]] = 1 count = 0 for idx in x: count += 1 if count == n: print("yes") else: print("no")
p03385
s196348761
Accepted
s = list(input()) if s.count("a") == 1 and s.count("b") == 1 and s.count("c") == 1: print("Yes") else: print("No")
p03106
s819966710
Accepted
a, b, k = map(int, input().split()) ma = max(a, b) mi = min(a, b) ans = [] if ma == mi: ans.append(ma) for i in range(ma // 2, 0, -1): if ma % i == 0 and mi % i == 0: ans.append(i) ans.append(1) print(ans[k - 1])
p02836
s576982997
Wrong Answer
S = list(input()) N = len(S) if N % 2 == 0: m = int(N/2) LS = S[:m] RS = S[N:m-1:-1] else: m = int((N+1)/2) LS = S[:m-1] RS = S[N:m-1:-1] ans = 0 for i in range(m-1): if LS == RS: pass else: ans += 1 print(ans)
p03486
s280396511
Accepted
S = sorted(input()) T = sorted(input(), reverse=True) print("Yes" if T > S else "No")
p03632
s623492913
Accepted
a,b,c,d = map(int,input().split()) s = [a,c] e = [b,d] s.sort() e.sort() print(max(0, e[0]-s[1]))
p02629
s475180140
Accepted
from collections import deque N = int(input()) amari = [] if N <= 26: print(chr(96+N)) else: while True: N -= 1 am = N % 26 N = N // 26 amari.append(am) if N == 0: break answer = deque() for i in amari: answer.appendleft(chr(97+i)) for i in answer: print(i, end='')
p02603
s937004367
Accepted
import sys input = sys.stdin.readline def main(): N = int(input()) A = list(map(int, input().split())) m = 1000 k = 0 for i in range(N-1): if A[i+1] - A[i] <= 0: continue k += m // A[i] m -= k * A[i] m += k * A[i+1] k = 0 print(m) main()
p02725
s098265192
Accepted
k , n = map(int, input().split()) a_list = list(map(int, input().split())) a_last = a_list[0] + k a_list.append(a_last) distance = -1 for i in range(n): distance_btw = a_list[i + 1] - a_list[i] if distance_btw > distance: distance = distance_btw print(k - distance)
p02639
s139123038
Wrong Answer
x1, x2, x3, x4, x5 = input().split() if x1 == 0: print(int(1)) if x2 == 0: print(int(2)) if x3 == 0: print(int(3)) if x4 == 0: print(int(4)) if x5 == 0: print(int(5))