problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02995
s826168527
Wrong Answer
import math A, B, C, D = map(int, input().split()) CD = int(C * D / math.gcd(C, D)) B_in_C = int(B/C) B_in_D = int(B/D) B_in_CD = int(B/(CD)) B_con = B - (B_in_C + B_in_D - B_in_CD) A = A-1 A_in_C = int(A/C) A_in_D = int(A/D) A_in_CD = int(A/(CD)) A_con = A - (A_in_C + A_in_D - A_in_CD) print(B_con - A_con)
p03329
s412342401
Wrong Answer
from functools import * @lru_cache(maxsize=None) def f(x): if x==1:return 1 s=10000000000000000 for u in [1]+[6**i for i in range(1,11)]+[9**i for i in range(1,11)]: if x-u>=1: s=min(s,f(x-u)+1) return s for i in range(1,100001):f(i) print(f(int(input())))
p02765
s216583947
Accepted
n,r=map(int,input().split()) if n>=10: print(r) else: print(r+100*(10-n))
p03617
s716499763
Accepted
q, h, s, d = [int(i) for i in input().split()] n = int(input()) d = min(min(d, s*2), min(h*4, q*8)) s = min(s, min(h*2, q*4)) print((n // 2) * d + (n % 2) * s)
p03544
s106889569
Accepted
N = int(input()) if N == 1: ans = 1 else: l = [2,1] for i in range(2, N+1): l.append(l[-2]+l[-1]) ans = l[-1] print(ans)
p03448
s983941886
Accepted
a=int(input()) b=int(input()) c=int(input()) x=int(input()) n=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: n+=1 print(n)
p04012
s596793085
Accepted
w = input() s = set(list(w)) flag = True for ss in s: if w.count(ss) % 2 != 0: flag = False break if flag: print("Yes") else: print("No")
p03804
s752454955
Accepted
a,b = map(int,input().split()) l= [] L = [] for i in range(a): t= input() l.append(t) for i in range(b): t = input() L.append(t) f = 'No' for i in range(a-b+1): for j in range(a-b+1): s = 0 for I in range(b): for J in range(b): if l[i+I][j+J] == L[I][J] :s+=1 if s==b**2:f='Yes' print(f)
p02613
s852122641
Wrong Answer
n=int(input("Test cases")) d={"AC":0,"WA":0,"TLE":0,"RE":0} for i in range(n): x=input() d[x]=d[x]+1 for k,v in d.items(): print(k,"x",v)
p03861
s785380060
Accepted
a, b, x = map(int, input().split()) a_div = (a - 1) // x + 1 b_div = b // x + 1 print(b_div - a_div)
p03206
s207218887
Wrong Answer
a=input() if a==25: print("Christmas") if a==24: print("Christmas Eve") if a==23: print("Christmas Eve Eve") if a==22: print("Christmas Eve Eve Eve")
p02697
s724869446
Wrong Answer
n,m=map(int,input().split()) for i in range(m): print(m-i,m+1+i)
p04030
s829158791
Accepted
s=input() ans='' for i in range(len(s)): if s[i]=='0': ans+='0' elif s[i]=='1': ans+='1' elif s[i]=='B' and len(s)!=0: ans=ans[:-1] print(ans)
p03852
s725184132
Accepted
c = str(input()) vowel = ['a','i','u','e','o'] if c in vowel: print('vowel') else: print('consonant')
p02916
s120059970
Accepted
N=int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) d=0 ab=0 for i in range(N): d+=b[a[i]-1] if i != 0: if ab+1==a[i]: d+=c[ab-1] ab=a[i] print(d)
p02742
s333507549
Accepted
import math h,w = map(int,input().split()) if(h == 1 or w == 1): print(1) else: print(math.ceil((h*w)/2))
p03665
s131239460
Accepted
N,P=map(int, input().split()) *A,=map(int, input().split()) p = [0,0] for a in A: p[a&1] += 1 even,odd=p[0],p[1] def comb(n, r): p, q = 1, 1 for i in range(r): p = p * (n-i) q = q * (i+1) return p // q ans = 2**even tmp = 0 if P: for i in range(1,odd+1,2): tmp += comb(odd, i) else: for i in range(0,odd+1,2): tmp += comb(odd, i) print(ans*tmp)
p02718
s869094402
Wrong Answer
n, m = map(int, input().split()) a = list(map(int, input().split())) a.sort(reverse=True) sum_ = 0 for i in a: sum_ +=i if(a[m-1]>(sum_/4*m)): print('Yes') else: print('No')
p02646
s287497727
Accepted
import sys a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if v <= w: print('NO') sys.exit() V = v - w R = abs(a-b) if V*t >= R: print('YES') else: print('NO')
p03145
s664676505
Wrong Answer
a, b, c = map(int, input().split()) ans = a * b / 2 print(ans)
p03220
s280652037
Accepted
n =int(input()) t,a =map(int,input().split()) h = list(map(int,input().split())) ans = 0 near = 10000 for i in range(n): if abs(t-h[i]*0.006 - a) < near: ans = i near = abs(t-h[i]*0.006-a) print(ans+1)
p03136
s755305277
Wrong Answer
N= int(input()) L = list(map(int, input().split())) if sum(L) - max(L) < max(L): print("Yes") else: print("No")
p03475
s712242381
Wrong Answer
import sys readline = sys.stdin.readline N = int(readline()) C = [0] * (N-1) S = [0] * (N-1) F = [0] * (N-1) for i in range(N-1): C[i], S[i], F[i] = map(int, readline().split()) for i in range(N): time = 0 for c, s, f in zip(C[i:N-1], S[i:N-1], F[i:N-1]): if time < s: time = s else: time += (time-s) % f time += c print(time)
p03416
s771052506
Accepted
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify import sys,bisect,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, sys.stdin.readline().split())) a,b = inpl() res = 0 for x in range(a,b+1): tmp = str(x) if tmp == tmp[::-1]: res += 1 print(res)
p02598
s005500340
Wrong Answer
#二分探査かぁ… from math import * import fractions import collections import itertools import pprint from collections import deque from heapq import * N,K=map(int,input().split()) A=list(map(int,input().split())) maxnum=10**9+20 minnum=1 while maxnum-minnum>1: cnt=0 piv=(maxnum+minnum)//2 for i in range(N): cnt=cnt+(ceil(A[i]/piv)-1) #print(cnt,piv) if cnt>K: minnum=piv else: maxnum=piv #print(maxnum,minnum) #input() print(min(maxnum,max(A)))
p02797
s097523620
Accepted
n, k, s = map(int, input().split()) a = [s] * k + [1 if n < s else s + 1] * (n - k) print(*a)
p02959
s278401894
Accepted
N=int(input()) *A,=map(int,input().split()) *B,=map(int,input().split()) i=0 ans=0 while i<N: if A[i]+A[i+1]>=B[i]: ans+=B[i] A[i+1]-=max(B[i]-A[i],0) else: ans+=A[i]+A[i+1] A[i+1]=0 i+=1 print(ans)
p03637
s193884636
Accepted
n = int(input()) a = list(map(int,input().split())) cnt2 = 0 cnt4 = 0 for i in range(n): if a[i] % 4 == 0: cnt4 += 1 elif a[i] % 2 == 0: cnt2 += 1 if cnt2 % 2 == 1: if cnt2 > 2: cnt2 -= 1 else: cnt2 = 0 if n - ((cnt4*3)-(cnt4-1))-cnt2 <= 0: print('Yes') else: print('No')
p02607
s091290437
Accepted
N=int(input()) a=list(map(int,input().split())) ans=0 for i in range(0,N,2): if a[i]%2==1: ans+=1 print(ans)
p03416
s060763598
Wrong Answer
a, b = map(int, input().split()) cnt = 0 for i in range(a, b + 1): flag = True si = str(i) for j in range(len(si) // 2): if si[j] != si[-(j + 1)]: flag = False if flag: cnt += 1
p02785
s274661584
Accepted
import sys n, k = map(int, input().split()) hp_list = list(map(int, input().split())) hp_list.sort(reverse=True) if k >= len(hp_list): print(0) sys.exit() hp_list = hp_list[k:] print(sum(hp_list))
p03001
s324893546
Accepted
#C w,h,x,y = map(int,input().split()) if w / 2 == x and h / 2 == y: flg = True else: flg = False S = w * h / 2 if flg: print(S,1) else: print(S,0)
p02831
s232734253
Accepted
import fractions a,b=map(int,input().split()) ans = a*b//fractions.gcd(a,b) print(ans)
p03285
s529020074
Accepted
n = int(input()) for cake in range(27): for donut in range(16): val = cake * 4 + donut * 7 if val == n: print('Yes') exit() print('No')
p02882
s620483754
Accepted
a,b,x = map(int,input().split()) import math if 2*x >= b*a**2: rad = math.atan(2*(b*a**2-x)*a**(-3)) print(math.degrees(rad)) else: rad = math.atan(a*b**2/(x*2)) print(math.degrees(rad))
p03639
s798538161
Accepted
# author: Taichicchi # created: 29.09.2020 22:35:47 import sys n = int(input()) a = list(map(int, input().split())) cnt = 0 for l in a: if l % 2: pass elif l % 4: cnt += 1 else: cnt += 2 # print(f"{cnt=}") if cnt // 2 >= n // 2: print("Yes") else: print("No")
p03814
s147835479
Accepted
#!/usr/bin/env python3 s = input() idx_a = 0 idx_z = 0 for i in range(len(s)): if s[i] == "A": idx_a = i break for i in range(len(s)-1,0,-1): if s[i] == "Z": idx_z = i break print(idx_z - idx_a + 1)
p02608
s949837579
Accepted
n = int(input()) ans = [0 for _ in range(10050)] for i in range(1, 105): for j in range(1, 105): for k in range(1, 105): v = i*i+j*j+k*k+i*j+j*k+k*i if v < 10050: ans[v] += 1 for i in range(n): print(ans[i+1])
p03071
s586894409
Accepted
a,b = map(int,input().split()) if a==b: print(2*b) else: x = max(a,b) print(2*x-1)
p02755
s231876841
Wrong Answer
ret = -1 A, B = [int(i) for i in input().split()] for i in range(2000): if int(i*0.08) == A and int(i * 0.1) == B: ret = i break print(i)
p02594
s291030755
Accepted
# A - Air Conditioner X = int(input()) if X >= 30: print('Yes') else: print('No')
p03632
s871239476
Wrong Answer
a, b, c, d = map(int, input().split()) print(b - c) if b - c >= 0 else print(0)
p02576
s527902647
Accepted
n,x,t = map(int,input().split()) if(n%x==0): print((n//x)*t) else: print((n//x)*t+t)
p02688
s494865611
Accepted
N,K=map(int,input().split()) arr=[] ans=[str(i) for i in range(1,N+1)] for i in range(K): _=input() arr.extend((input().split())) arr=list(set(arr)) p=0 for n in ans: if(not(n in arr) ) : p=p+1 print(p)
p02675
s354462789
Accepted
N = input() if N[-1] == '3': print('bon') elif N[-1] == '0' or N[-1] == '1' or N[-1] == '6' or N[-1] == '8': print('pon') else: print('hon')
p03077
s470915455
Accepted
import math n = int(input()) l = [int(input()) for _ in range(5)] x = min(l) print(math.ceil(n/x) + 4)
p02747
s524279186
Wrong Answer
s = input() hi = True for i in range(len(s)): if i % 2 == 0 and s[i] != "h": hi = False break elif i % 2 == 1 and s[i] != "i": hi = False break if hi: print("Yes") else: print("No")
p02639
s208452611
Wrong Answer
x = input().split() for i, a in enumerate(x): if(a == "0"): print(i)
p02951
s235050238
Accepted
# coding: utf-8 # Your code here! a, b, c = map(int, input().split()) if c-a+b < 0: print(0) else: print(c-a+b)
p02689
s723157376
Accepted
N,M=(int(x) for x in input().split()) T=[1]*N H=list(map(int,(input().split()))) while 1: try: A,B=(int(x) for x in input().split()) except: break if(H[A-1]<H[B-1]): T[A-1]=0 elif(H[B-1]<H[A-1]): T[B-1]=0 else: T[A-1]=0 T[B-1]=0 print(T.count(1))
p03162
s984397921
Accepted
n = int(input()) l = [list(map(int,input().split())) for i in range(n)] dp = [[0 for i in range(3)] for i in range(n)] dp[0] = l[0] for i in range(1,n): dp[i][0] = max(dp[i-1][1]+l[i][0], dp[i-1][2]+l[i][0]) dp[i][1] = max(dp[i-1][0]+l[i][1], dp[i-1][2]+l[i][1]) dp[i][2] = max(dp[i-1][0]+l[i][2], dp[i-1][1]+l[i][2]) print(max(dp[-1]))
p02829
s101291208
Accepted
print(6-sum([int(input())for _ in range(2)]))
p02633
s815577953
Wrong Answer
X = int(input()) print(360 // X)
p03323
s569990768
Wrong Answer
A,B=map(int,input().split()) if A<=8 or B<=8: print("Yay!") else: print(":(")
p02773
s767367242
Accepted
n = int(input()) dict = {} for _ in range(n): s = input() if s in dict: dict[s] += 1 else: dict[s] = 0 max_val = max(dict.values()) max_list = [k for k, v in dict.items() if v == max_val] max_list.sort() for i in max_list: print(i)
p02594
s422911993
Accepted
X = int(input()) if X >= 30: print("Yes") else: print("No")
p02681
s384083780
Wrong Answer
S=input() T=input() l=len(S) if S==T[:-1] and S.islower()==True and 1<=l and l<=10: print("Yes") else: print("NO")
p02697
s846289921
Accepted
n,m=map(int,input().split());[print(i+1,n-i-((i>=m/2)&~n)) for i in range(m)]
p02621
s503376859
Wrong Answer
a=int(input()) a+a**2+a**3
p02779
s967873768
Accepted
N = int(input()) A = input().split() if N == len(list(set(A))): print('YES') else: print('NO')
p03469
s173523953
Wrong Answer
a,b,c = map(int,input().split("/")) print("2018/01/{}".format(c))
p03695
s724666910
Accepted
import bisect n = int(input()) a = list(map(int,input().split())) a.sort() sect = 0 col = 0 for i in range(400,3201,400): nsect = bisect.bisect_left(a,i) if nsect>sect: sect = nsect col += 1 print(max(col,1),col+n-nsect)
p03835
s345602408
Accepted
K, S = map(int, input().split()) Y = 0 for i in range(K+1): for j in range(K+1): if 0 <= S-i-j and S-i-j <= K: Y = Y+1 print(Y)
p03150
s479389322
Wrong Answer
import re s = input() pat = "key.*ence" if re.findall(pat, s): print("YES") else: print("NO")
p03338
s299106861
Wrong Answer
n = int(input()) s = list(input()) ans = 0 c = 0 fh = [] lh = s for i in range(n): tmp = lh.pop(0) if tmp not in fh: if tmp in lh: c += 1 else: c -= 1 fh.append(tmp) ans = max(ans, c) print(ans)
p02633
s126944750
Wrong Answer
x=int(input()) print(360//x)
p02772
s206089789
Accepted
N = int(input()) A = list(map(int, input().split())) flag = 1 for a in A: if a % 2 == 0: if ((a % 3 == 0) or (a % 5 == 0)): 1 else: print("DENIED") exit() print("APPROVED")
p03380
s176173122
Wrong Answer
N = int(input()) A = list(map(int, input().split())) A.sort() import bisect ncand = A[-1] ix = bisect.bisect_left(A[:-1], ncand//2) # print(A[:-1], ix) if A[ix] == ncand: ix -= 1 ccand = A[ix] print(ncand, ccand)
p02957
s262399362
Accepted
print((lambda x:('IMPOSSIBLE' if (x[0]+x[1])%2==1 else (x[0]+x[1])//2))(list(map(int,input().split()))))
p03109
s042222398
Accepted
S = input() print('Heisei' if S <= '2019/04/30' else 'TBD')
p03524
s545432080
Accepted
import math import sys s = sys.stdin.readline().rstrip() d = {'a': 0, "b": 0, "c": 0} for si in s: if si in d: d[si] += 1 else: d[si] = 1 x = (len(s)-1) // 3+1 if d['a'] <= x and d['b'] <= x and d['c'] <= x: print("YES") else: print("NO")
p02796
s937354912
Accepted
def solve(): n = int(input()) query =[] for i in range(n): x,l = (int(i) for i in input().split()) query.append((x+l,max(0,x-l))) query.sort() nowr = 0 ans = 0 for i in range(n): r,l = query[i] #print(nowr) if nowr <= l: nowr = r ans += 1 print(ans) solve()
p02547
s291067211
Wrong Answer
n = int(input()) d = [tuple(map(int, input().split())) for _ in range(n)] ans=0 for k in d: if ans >= 3: print("Yes") raise SystemExit(0) if k[0] == k[1]: ans+=1 else: ans = 0 print("No")
p03211
s622229807
Accepted
import itertools import math import fractions import functools s = list(input()) subs = 10**6 for i in range(len(s)-2): subs = min(subs,abs(int(''.join(s[i:i+3]))-753)) print(subs)
p03719
s981789652
Accepted
a, b, c = [int(x) for x in input().split()] if c >= a and c <= b: print('Yes') else: print('No')
p02719
s748953690
Accepted
n, k = map(int,input().split()) moded = n%k print(int(min(k-moded,moded)))
p03262
s785180487
Accepted
n, x = map(int, input().split()) X = list(map(int, input().split())) Y = [abs(x_ - x) for x_ in X] import fractions #import math from functools import reduce def gcd(*numbers): return reduce(fractions.gcd, numbers) #return reduce(math.gcd, numbers) def gcd_list(numbers): return reduce(fractions.gcd, numbers) #return reduce(math.gcd, numbers) print(gcd_list(Y))
p03243
s118963851
Accepted
n = int(input()) for i in range(n,1000): i = str(i) if i[0] == i[1] == i[2]: print(i) break
p02948
s306551693
Wrong Answer
N, M = map(int, input().split()) jobs = [] for i in range(N): A, B = map(int, input().split()) jobs.append((A-1, B)) jobs = sorted(jobs, key=lambda x: x[1], reverse=True) used = [0] * M ans = 0 cnt = 0 for job in jobs: if job[0] >= M: continue if used[job[0]] >= M - job[0]: continue else: used[job[0]] += 1 ans += job[1] cnt += 1 if cnt == M: break print(ans)
p03416
s307513980
Wrong Answer
a,b = map(int, input().split()) ans = 0 for i in range(a, b+1): if str(a+i) == str(a+i)[::-1]: ans += 1 print(ans)
p03962
s295551873
Wrong Answer
a = list(map(int,input().split())) counter = 0 if a[0] != a[1]: counter += 1 if a[1] != a[2]: counter += 1 if a[0] != a[2]: counter += 1 print(counter)
p02881
s169052721
Wrong Answer
N = int(input()) i = 2 r = N while i < N/2: if (N % i == 0): r = min(i+int(N/i), r) i += 1 print(r-2)
p03474
s143111892
Accepted
num=list("0123456789") a,b=map(int,input().split()) s=input() for i in range(a+b+1): if i!=a: if s[i] not in num: print("No") break else: if s[i]!="-": print("No") break else: print("Yes")
p02818
s161017732
Accepted
A, B, K = map(int, input().split()) A_ = min(A, K) print(A-A_, max(0, B-(K-A_)))
p03711
s762260521
Wrong Answer
A={1, 3, 5, 7, 8, 10, 12} B={4, 6, 9, 11} C={2} print("Yes" if {map(int, input().split())} <= A or B or C \ else "No")
p02719
s791296771
Wrong Answer
n,k=map(int,input().split()) print(min(n%k,k-n))
p02848
s533912779
Accepted
N = int(input()) S = input() newS = '' A = ord('A') Z = ord('Z') for k in range(len(S)): if ord(S[k]) + N > Z: newS += chr(ord(S[k]) + N - Z + A - 1) else: newS += chr(ord(S[k]) + N) print(newS)
p02576
s710367665
Wrong Answer
N, X, T = map(int, input().split()) print(int(-(-N/X)*T))
p03720
s463731828
Accepted
# import sys # import math # import decimal # import queue # import bisect # import heapq # priolity-queue # import time # import itertools # import collections # queue # from operator import itemgetter # from fractions import Fraction mod = int(1e9+7) INF = 1<<29 lINF = 1<<35 def main(): n,m = map(int,input().split()) city = [0] * n for i in range(m): a,b = map(int,input().split()) city[a-1] += 1 city[b-1] += 1 for i in range(n): print(city[i]) return if __name__=='__main__': main()
p03329
s767588289
Accepted
from functools import reduce N = int(input()) amounts = sorted(sum(([6 ** (i + 1), 9 ** i] for i in range(6)), [])) account = 1 << N times = 0 while (times := times + 1) and not (account := reduce(lambda a, b: a | b, [account >> amount for amount in amounts])) & 1: pass print(times)
p02767
s133280334
Accepted
import numpy as np N = int(input()) X = np.array(list(map(int, input().split()))) average = np.mean(X) m1 = int(average) m2 = m1 + 1 ans1 = np.dot(X - m1, X - m1) ans2 = np.dot(X - m2, X - m2) print(min(ans1, ans2))
p03289
s364234682
Accepted
s = input() if s[0] == "A" and s[2:-1].count("C") == 1: if s.replace("A", "a", 1).replace("C", "c", 1).islower(): print("AC") exit() print("WA")
p03163
s583500062
Accepted
n, w = [int(i) for i in input().split()] wv = [[int(i) for i in input().split()] for _ in range(n)] dp = [[0]*(w+1) for _ in range(n+1)] for i in range(1, n+1): wi, vi = wv[i-1] for j in range(1, w+1): if j < wi: dp[i][j] = dp[i-1][j] else: dp[i][j] = max(dp[i-1][j], dp[i-1][j-wi] + vi) print(dp[-1][-1])
p03485
s086196108
Accepted
L=list(map(int,input().split())) print((sum(L)+1)//2)
p02811
s584280989
Accepted
k, x = map(int, input().split()) if 500 * k >= x: print('Yes') else: print('No')
p02629
s965733752
Accepted
n = int(input()) al=["z"]+[chr(ord('a') + i) for i in range(25)] result = "" while n>0: if n%26 !=0: result = al[n%26]+result n //= 26 else: result = al[n%26]+result n //= 26 n -= 1 print(result)
p02923
s442172204
Wrong Answer
N = int(input()) Hs = list(map(int, input().split())) res = [0] * N for index, h in enumerate(Hs): l = 0 if index > 0: l = max(res[index - 1] - 1, 0) tmp = h while index + l + 1 < N and tmp >= Hs[index + l + 1]: tmp = Hs[index + l + 1] l += 1 res[index] = l print(max(res))
p02888
s385490168
Accepted
from bisect import * n,*l=map(int,open(0).read().split()) l.sort() ans=0 for i in range(1,n): for j in range(i+1,n): ans+=max(i-bisect_right(l,l[j]-l[i]),0) print(ans)
p03438
s085297212
Accepted
n,*a=map(int,open(0).read().split()) print("Yes" if sum((j-i)//2*2 if j-i>0 else 2*(j-i)for i,j in zip(a[:n],a[n:]))>=0 else "No")
p03778
s434758725
Accepted
w,a,b=map(int, input().split()) A=min(a,b) B=max(a,b) if A+w<B: print(B-A-w) else: print(0)