problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p04029
s419663849
Accepted
n = int(input()) print((n*(n+1))//2)
p02700
s383760586
Accepted
A,B,C,D=map(int, input().split()) print('Yes' if (C+B-1)//B <= (A+D-1)//D else 'No')
p02660
s751278832
Accepted
from collections import Counter def p_factorization(n): p=[] for i in range(2,int(n**0.5)+1): while n%i==0: p.append(i) n//=i if n>1: p.append(n) return p n=int(input()) ans=0 for pi in Counter(p_factorization(n)).items(): x=pi[1] for i in range(50): if i*(i+1)//2<=x<(i+1)*(i+2)//2: ...
p02555
s890722446
Accepted
import sys input = sys.stdin.readline INF = 10**18 sys.setrecursionlimit(10**6) import math D = 10 ** 9 + 7 # 組み合わせの総数 nCr def combinations_count(n, r): return math.factorial(n) // (math.factorial(n - r) * math.factorial(r)) S = int(input()) max_length = S // 3 total = 0 for i in range(max_length): N = (S ...
p03795
s591059805
Accepted
n = int(input()) x = n y = n//15 print(800*x - 200*y)
p03433
s671834809
Accepted
n, a = map(int,open(0)) print("YNeos"[n % 500 > a :: 2])
p02693
s132658888
Accepted
import sys k=int(input()) a,b=map(int,input().split()) for i in range(a,b+1): if i%k==0: print("OK") sys.exit() else: print("NG")
p03719
s090706469
Accepted
# coding: utf-8 # Your code here! a, b, c = map(int,input().split()) if a <= c <= b: print('Yes') else: print('No')
p02600
s466075867
Wrong Answer
x = int(input()) sum = 600 for i in range(8, 0, -1): if x < sum: print(i) break sum += 20
p02688
s709030995
Accepted
n,k=map(int,input().split()) check=[0]*n ans=0 for i in range (k): d=int(input()) l=list(map(int,input().split())) for j in range(d): h=l[j] check[h-1]+=1 for k in range(n): if check[k]==0: ans+=1 print(ans)
p03910
s732819551
Accepted
n = int(input()) l, r = 0, n**2 while r-l > 1: k = (r+l)//2 if k*(k+1)//2 < n: l = k else: r = k if n == 1: r = 1 key = [] for i in range(r, 0, -1): if n-i >= 0: key.append(i) n -= i if not n: break key.reverse() for value in key: print(value)
p02835
s237315599
Wrong Answer
A = map(int, input().split()) if sum(A) > 22: print('bust') else: print('win')
p02578
s633083972
Accepted
n = int(input()) a = list(map(int,input().split())) hight_sum = 0 for i in range(n-1): hight = 0 diff = a[i+1] - a[i] if diff < 0: hight -= diff a[i+1] -= diff hight_sum += hight print(hight_sum)
p02958
s668355690
Accepted
n = int(input()) p_l = list(map(int,input().split())) p_sort = sorted(p_l) cnt = 0 for i in range(n): if(p_l[i]!=p_sort[i]): cnt += 1 if(cnt <= 2): print('YES') else: print('NO')
p02623
s847064019
Accepted
import bisect def Csum(a): b,c=[0],0 for i in range(len(a)): c+=a[i] b.append(c) return b n,m,k=map(int,input().split()) a=list(map(int,input().split())) b=list(map(int,input().split())) c,d=Csum(a),Csum(b) d.pop(0) ans=0 for i in range(n+1): if k-c[i]<0: break ans=max(ans,...
p03241
s392262313
Wrong Answer
n,m = map(int,input().split()) ans = 0 for i in range(1,int(m**0.5)+1): if m%i==0: x = m//i if x>=n: ans = i print(ans)
p03493
s273169204
Wrong Answer
s = int(input()) if s == 0: print(0) elif s == 1 or 10 or 100: print(1) elif s == 11 or 101 or 110: print(2) else: print(3)
p03210
s983853743
Accepted
x = int(input()) if x == 3 or x == 5 or x == 7: print('YES') else: print('NO')
p02909
s591547658
Accepted
num = input() num_list = ["Sunny","Cloudy","Rainy","Sunny"] counter = num_list.index(num) print(num_list[counter + 1])
p03427
s541537777
Accepted
n=int(input()) k=len(str(n)) c=n//10**(k-1) print(c+9*(k-1) if n==(c+1)*10**(k-1)-1 else c+9*(k-1)-1)
p03106
s876282071
Accepted
a, b, k = map(int, input().split()) j = 0 if a >= b: a, b = b, a ans = [0] * a for i in range(1, a + 1): if a % i == 0 and b % i == 0: ans[j] = i j = j + 1 ans.sort(reverse = True) print(ans[k - 1])
p02621
s040969665
Wrong Answer
a = int(input()) n1 = int( "%s" % a ) n2 = int( "%s%s" % (a,a) ) n3 = int( "%s%s%s" % (a,a,a) ) print (n1+n2+n3)
p02724
s906401611
Accepted
x = int(input()) ans = (x // 500) * 1000 + ((x % 500) // 5) * 5 print(ans)
p02771
s944716565
Accepted
data=[int(x) for x in input().split()] if data.count(data[0])==2 or data.count(data[1])==2: print("Yes") else: print("No")
p02630
s453988219
Accepted
I=lambda:list(map(int,input().split())) n=I()[0];arr=I();q=I()[0]; cnt={}; for i in arr:cnt[i]=0; for i in arr:cnt[i]+=1; s=sum(arr) while(q): q-=1;b,c=I(); if(b not in cnt or not cnt[b]):print(s);continue; s-=(cnt[b]*b);s+=(cnt[b]*c); if(c not in cnt):cnt[c]=0; cnt[c]+=cnt[b];cnt[b]=0; print(s)
p03797
s870283136
Accepted
S,C=map(int,input().split()) x=min(S, C//2) if S>x: print(x) else: x+=(C-2*x)//4 print(x)
p03345
s608585199
Accepted
A, B, C, K = map(int, input().split()) if K%2==1: print(-A+B) else: print(A-B)
p03495
s396341451
Accepted
n,k=map(int,input().split()) a=list(map(int,input().split())) sa=set(a) nums=len(sa) if nums<=k: print(0) else: num=[0]*n for i in range(n): num[a[i]-1]+=1 num.sort() ans=0 for i in range(n-k): ans+=num[i] print(ans)
p04012
s308694973
Accepted
w = input() wl = [] for i in range(len(w)): wl.append(w[i]) from collections import Counter W = Counter(wl) answer = 'Yes' for i in range(len(w)): if W[w[i]]%2 != 0: answer = 'No' break print(answer)
p03469
s666136934
Accepted
yymmdd = list(input()) yymmdd[3] = "8" print("".join(yymmdd))
p02888
s725668314
Accepted
from bisect import bisect_left N = int(input()) L = list(map(int,input().split())) L.sort() ans = 0 for i in range(N-2): for j in range(i+1, N-1): k = bisect_left(L, L[i]+L[j]) ans += (k-j-1) print(ans)
p03557
s532231060
Accepted
N = int(input()) A = [int(x) for x in input().split()] B = [int(x) for x in input().split()] C = [int(x) for x in input().split()] import bisect as bs import numpy as np A.sort() C.sort() #B_a:b未満のAのパーツ数、B_c:b超のCのパーツ数 B_a = np.array([bs.bisect_left(A,b) for b in B]) B_c = np.array([N-bs.bisect_right(C,b) for b in B])...
p02696
s629066744
Wrong Answer
A, B, N = map(int, input().split()) lo = 0 hi = N ans = 0 def f(x): return int(A*x/B)-A*int(x/B) while lo < hi: mid = (lo + hi) // 2 if f(lo) < f(hi): lo = mid + 1 else: hi = mid print(f(lo))
p03471
s199719127
Accepted
N, Y = map(int, input().split()) for x in range(N+1): for y in range(N - x + 1): z = N - x - y if x*10000+y*5000+z*1000 == Y: print(x, y, z) exit() print("-1 -1 -1")
p02683
s540024393
Accepted
n,m,x=map(int,input().split()) a=[list(map(int,input().split())) for _ in range(n)] minc=float("inf") for i in range(2**n): lst=[0]*(m+1) for bit in range(n): if (i>>bit)&1==1: for ii,aa in enumerate(a[bit]): lst[ii]+=aa if min(lst[1:]) >= x: minc=min(minc,lst[0]) print(-1 if minc == f...
p04029
s163358445
Accepted
n=int(input()) print(int(n*(n+1)/2))
p02765
s646716512
Wrong Answer
n,r = map(int,input().split()) print(r+100*(10-n))
p02814
s779596732
Accepted
import functools import fractions def lcm(a, b): return a * b // fractions.gcd(a, b) # xが2で何回割れるか def div2count(x): count=0 while x%2==0: x=x//2 count+=1 return count N,M=map(int,input().split()) A=list(map(int,input().split())) if len(set(map(div2count,A)))!=1: print(0) exit(...
p03331
s510860336
Wrong Answer
N = int(input()) def digit_sum(A): S = 0 while A > 0: S += A % 10 A //= 10 return S ans = 10e+6 for A in range(N): cand = digit_sum(A) + digit_sum(N - A) ans = min(ans, cand) print(ans)
p02748
s578523288
Accepted
import sys input = sys.stdin.buffer.readline A, B, M = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) ans = min(a) + min(b) for _ in range(M): x, y, c = map(int, input().split()) ans = min(ans, a[x-1] + b[y-1] - c) print(ans)
p02731
s074255667
Wrong Answer
l = int(input()) res = 0 for i in range(1, l): for j in range(i, l): if l > i+j: k = l - (i+j) res = max(res, k*i*j) print(res)
p02970
s442762632
Accepted
import math n, d = map(int, input().split()) print(math.ceil(n/(1 + 2*d)))
p03612
s452991350
Accepted
n = int(input()) p = list(map(int, input().split())) ans = 0 for i in range(n-1): if p[i] == i+1: p[i], p[i+1] = p[i+1], p[i] ans += 1 if p[n-1] == n: p[n-1], p[n-2] = p[n-2], p[n-1] ans += 1 print(ans)
p03944
s073558911
Wrong Answer
W, H, N = map(int, input().split()) x0, y0 = 0, 0 for _ in range(N): xi, yi, a = map(int, input().split()) if a == 1: x0 = max(xi, x0) elif a == 2: W = min(xi, W) elif a == 3: y0 = max(yi, y0) elif a == 4: H = min(yi, H) ans = (W-x0)*(H-y0) if ans < 0: ans = 0 p...
p03416
s353567128
Accepted
a, b = map(int, input().split()) result = 0 for i in range(a, b+1): if str(i) == str(i)[::-1]: result += 1 print(result)
p02629
s035600154
Wrong Answer
n = int(input())-1 a = "abcdefghijklmnopqrstuvwxyz" s = a[n % 26] n = n//26 while n: s = s + a[n % 26-1] n = n // 26 print(s[::-1])
p03377
s659758983
Wrong Answer
A, B, X = map(int, input().split()) if A <= X: print('YES') elif X <= A + B: print('YES') else: print('NO')
p03592
s542688644
Accepted
n, m, k= map(int, input().split()) for p in range(m+1): for q in range(n+1): t = n*p + m*q - 2*p*q if t == k: print('Yes') exit() else: print('No')
p02711
s129762555
Accepted
N = input() l = [int(x) for x in list(str(N))] if int(7) in l: print('Yes') else: print('No')
p03239
s831853066
Wrong Answer
n, t = map(int, input().split()) c_t = [list(map(int, input().split())) for i in range(n)] min_c = t + 1 for i in c_t: if i[1] <= t and i[0] < min_c: min_c = i[0] if min_c == t+1: print("TLE") else: print(min_c)
p02594
s520704627
Accepted
tem = int(input("")) if tem >= 30: print("Yes") else: print("No")
p03998
s011658056
Accepted
dic = {} dic.setdefault('a',str(input())+'E') dic.setdefault('b',str(input())+'E') dic.setdefault('c',str(input())+'E') dare = dic['a'][0] dic['a'] = dic['a'][1:] while len(dic['a'])>0 and len(dic['b'])>0 and len(dic['c'])>0: tmp = dic[dare][0] dic[dare] = dic[dare][1:] if tmp=='E': ans = dare.upper...
p02957
s708592629
Accepted
import sys input = sys.stdin.readline import math import collections def I(): return int(input()) def MI(): return map(int, input().split()) def LI(): return list(map(int, input().split())) a,b=MI() if (a+b)%2==0: print((a+b)//2) else: print("IMPOSSIBLE")
p03448
s384623115
Wrong Answer
a = int(input()) b = int(input()) c = int(input()) x = int(input()) count = 0 for i in range(a): for j in range(b): for k in range(c): total = 500 * i + 100 * j + 50 * k if total == x: count += 1 print(count)
p02854
s101690027
Accepted
N=int(input()) A=list(map(int,input().split())) S=sum(A) minx=S sum=0 for x in A: sum+=x minx=min(minx,abs(sum-(S-sum))) print(minx)
p03545
s462582843
Wrong Answer
s = input() l = len(s) for i in range(2**(l-1)): ans = 0 a = s[0] for j in range(l-1): if i >> j == 0: a += '+' + s[j+1] else: a += '-' + s[j+1] ans = eval(a) if ans == 7: print(a + '=7')
p04045
s961333926
Wrong Answer
from itertools import product N,K = list(map(int,input().split())) D = list(map(int,input().split())) D_ = [_ for _ in range(10) if _ not in D] D_.sort() break_flag=False for s_ in D_: if break_flag: break elif s_ == 0: continue for p in product(D_,repeat=len(str(N))-1): ans=int(s...
p03624
s733972206
Accepted
s=list(input()) for i in range(ord('a'),ord('z')+1): if s.count(chr(i))==0: print(chr(i)) exit() print('None')
p02860
s007545311
Accepted
n=int(input()) s=input() import sys a=0 if n==1: print('No') sys.exit() if n%2!=0: print('No') sys.exit() else: for i in range(n//2): if s[i]==s[i+(n//2)]: pass else: a=1 break if a==0: print('Yes') else: print('No')
p03698
s051541057
Accepted
S = list(input()) flag = [0]*26 for c in S: if(flag[ord(c)-ord('a')] == 0): flag[ord(c)-ord('a')] = 1 else: print("no") exit() print("yes")
p02602
s996849698
Wrong Answer
import numpy as np tmp=[int(i) for i in input().split(' ')] tmp_s=[int(i) for i in input().split(' ')] score=[] leng=tmp[0]-tmp[1]+1 for i in range(leng): t=np.prod(np.array(tmp_s)[i:i+tmp[1]]) score.append(t) if i>0: if score[i-1]<score[i]: print('Yes') else: print('No')
p02983
s521517162
Accepted
L,R=map(int,input().split()) ans=2019 for i in range(L,R): for j in range(i+1, R+1): if j%2019==0: print(0) exit() ans=min(ans,(i*j)%2019) print(ans)
p02963
s430130629
Wrong Answer
#!/usr/bin/env python def main(): s = int(input()) if s <= 10 ** 9: x1 = s y2 = 1 y1 = 0 x2 = 0 else: u, d = divmod(s, 10**9) x1 = u + 1 y2 = 10 ** 9 y1 = 10 ** 9 - d x2 = 1 print(0, 0, x1, y1, x2, y2) if __name__ == '__main__': ...
p02582
s292039082
Accepted
S = input() for i in range(4)[::-1]: if 'R' * i in S: print(i) exit()
p02584
s398721384
Accepted
X,K,D=map(int, input().split()) if abs(X) // abs(D) > K: print(abs(X)-(K*D)) exit() K2= K - (abs(X) // D) X= abs(X) - abs(((K-K2)*D)) if K2 % 2 == 1: X= abs(X) - D print(abs(X))
p04031
s400305531
Accepted
ans = 10 ** 9 n = int(input()) A = list(map(int,input().split())) for i in range(-100,101): X = 0 for j in A: X += (j - i) ** 2 ans = min(ans,X) print(ans)
p02719
s132104682
Accepted
N, K = map(int, input().split(' ')) print(min(N % K, abs(N % K - K)))
p02690
s880744006
Accepted
import sys input = sys.stdin.readline x = int(input()) a = 1 while True: for b in range(0, a): if a**5 - b**5 == x: print(a, b) sys.exit() if a**5 + b**5 == x: print(a, -b) sys.exit() a += 1
p02959
s586591922
Wrong Answer
n = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 for i in range(n): if B[i] - A[i] >= 0: ans += A[i] B[i] = B[i] - A[i] if B[i] - A[i+1] >= 0: ans += A[i+1] else: ans += B[i] A[i+1] = A[i+1] - B[i] ...
p03495
s266420863
Accepted
import collections n,k=map(int,input().split()) a=list(map(int,input().split())) c=collections.Counter(a) li=c.most_common() if len(li)<=k: print(0) exit() li=li[k:] ans=0 for i in li: ans+=i[1] print(ans)
p03061
s108818267
Accepted
from math import * N=int(input()) A=list(map(int,input().split())) left=[0]*(N+1) for i in range(N): left[i+1]=gcd(left[i],A[i]) right=[0]*(N+1) for i in range(N-1,-1,-1): right[i]=gcd(right[i+1],A[i]) ans=0 for i in range(N): ans=max(ans,gcd(left[i],right[i+1])) print(ans)
p02796
s749157212
Wrong Answer
n = int(input()) xl = [tuple(map(int, input().split())) for _ in range(n)] xl = sorted(xl) def run(xl): res = 1 x, l = xl[0] cur = x + l for (x, l) in xl: if x - l >= cur: cur = x + l res += 1 return res res = max(run(xl), run(list(reversed([(-x, l) for x, l in x...
p03126
s134059675
Accepted
N, M = map(int, input().split()) a = set([i + 1 for i in range(M)]) for n in range(N): A = list(map(int, input().split())) K = A.pop(0) a &= set(A) print(len(a))
p02553
s256935079
Accepted
a, b, c, d = map(int, input().split()) ans = max(a*c, a*d, b*c, b*d) print(ans)
p03407
s195963264
Wrong Answer
a,b,c = map(int,input().split()) x = 2*(a+b) if x>=c: print("Yes") else: print("No")
p02726
s714467838
Accepted
N,X,Y = map(int,input().split()) X -= 1 Y -= 1 ans = [0]*(N) d = [[N]*N for i in range(N)] for i in range(N): for j in range(i,N): if i<=X and Y<=j: d[i][j] = X-i+j-Y+1 else: d[i][j] = min(abs(i-X)+abs(Y-j)+1,j-i) for i in range(N): for j in range(i+1,N): an...
p02572
s761990009
Accepted
N = int(input()) l = list(map(int,input().split())) Sum = sum(l) ans = 0 for i in range(N-1): Sum -= l[i] ans += Sum*(l[i]) ans %= (10**9 + 7) print(ans)
p02755
s858729345
Wrong Answer
a,b=list(map(int,input().split())) for i in range(1000): if int(i*0.08)==a and int(i*0.1)==b: print(i) break elif i==100: print(-1)
p03556
s998388107
Wrong Answer
A=int(input()) N=1 for i in range(A): if i**2 <= A: N = i**2 else: break print(N)
p04034
s529017576
Accepted
from collections import defaultdict n,m=map(int, input().split()) v = [0]*n v[0]=1 ans = [1]*n fi = 1 for i in range(m): a,b=map(int, input().split()) ans[a-1]-=1 ans[b-1]+=1 if v[a-1]: v[b-1]=1 fi+=1 if ans[a-1]==0: v[a-1]=0 fi-=1 print(sum(v))
p03852
s249189988
Accepted
c=input() bo=["a","i","u","o","e"] if c in bo: print("vowel") else: print("consonant")
p02771
s836604441
Accepted
a,b,c=map(int,input().split()) if a==b and b!=c: print("Yes") elif b==c and c!=a: print("Yes") elif c==a and a!=b: print("Yes") else: print("No")
p03862
s314825988
Accepted
n,x = map(int,input().split()) a = list(map(int,input().split())) c = 0 if a[0] > x: c += a[0] - x a[0] = x for i in range(n-1): if a[i]+a[i+1] > x: c += a[i]+a[i+1] - x a[i+1] = x-a[i] print(c)
p03126
s361342394
Accepted
n,m = map(int,input().split()) Al =[0]*(m+1) for i in range(n): A = list(map(int,input().split())) for j in range(1,A[0]+1): Al[A[j]] += 1 print(Al.count(n))
p02555
s215324082
Wrong Answer
n=int(input()) ans=[0]*(2001) ans[3]=1 for i in range(4,2001): a=1 for j in range(3,i): if (i-j>=3 ): a+=(ans[j]*ans[i-j]) a%=(10**9+7) ans[i]=a; print(ans[n]%(10**9+7))
p03862
s149470916
Wrong Answer
N, x = map(int, input().split()) a = list(map(int, input().split())) ans = 0 y = a[0] for i in range(1, N): z = a[i] w = max(y+z-x, 0) y = z-w ans += w print(ans)
p03075
s335013181
Accepted
a=int(input()) b=int(input()) c=int(input()) d=int(input()) e=int(input()) k=int(input()) array=[a,b,c,d,e] if(max(array)-min(array) <= k): print("Yay!") else: print(":(")
p02547
s714880457
Accepted
N = int(input()) D1 = [0]*N D2 = [0]*N for i in range(N): D1[i], D2[i] = map(int, input().split()) a = 0 for i in range(N-2): if D1[i] == D2[i] and D1[i+1] == D2[i+1] and D1[i+2] == D2[i+2]: a = 1 if a == 1: print("Yes") else: print("No")
p02705
s976882791
Wrong Answer
import math R = int(input()) print(2*math.pi)
p02714
s806408038
Wrong Answer
N = int(input()) S = list(input()) cnt = sum([1 for i in range(N-2) for j in range(i+1, N-1) for k in range(j+1, N) if S[i] != S[j] != S[k] and j-i != k-j ]) print(cnt)
p02909
s911946040
Wrong Answer
print('CRSlauoinunndyyy'[id(id)%3::3])
p03434
s351340638
Wrong Answer
n = int(input()) a = list(map(int, input().split())) a.sort() Alice = 0 Bob = 0 for i in range(n): if i % 2 == 0: Alice += a[i] else: Bob += a[i] print(Alice - Bob)
p03796
s832764053
Accepted
N=int(input()) ans=1 for i in range(1,N+1): ans=(ans*i)%1000000007 print(ans%(10**9+7))
p03723
s692335448
Wrong Answer
# おっぱっぴー A, B, C = map(int, input().split()) if A == B == C: print(-1) for i in range(100): A, B, C = B/2+C/2, A/2+C/2, A/2+B/2 if A % 2 != 0 or B % 2 != 0 or C % 2 != 0: print(i+1) break
p02640
s175553304
Wrong Answer
X, Y = map(int, input().split()) ans = 0 for i in range(X): ans += 4 if ans >= Y: print('Yes') else: print('No')
p02881
s315463341
Accepted
import sys n, *lst = map(int, sys.stdin.read().split()) sqr = int(n ** 0.5) + 1 for i in range(sqr, 0, -1): if not n % i: print(i + n // i - 2) quit()
p03555
s233940669
Accepted
a=list(input()) b=list(input()) if a[0]==b[2] and a[1]==b[1] and a[2]==b[0]: print("YES") else: print("NO")
p03698
s642382447
Wrong Answer
s = input() check = True for c in s: if s.count(c) > 1: check = False break print('Yes' if check else 'No')
p02842
s127095051
Wrong Answer
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) n = int(input()) def binary_search(ok, ng, cond): while abs(ok - ng) > 1: mid = (ok + ng) / 2 if cond(mid): ok = mid else: ng = mid return ok candidate = int(binary_search(n, 0, lambda x: x * ...
p03076
s785700361
Accepted
a = [0]*5 a[0] = int(input()) a[1] = int(input()) a[2] = int(input()) a[3] = int(input()) a[4] = int(input()) b = 10**10 t = 0 for i in range(5): c = a[i]%10 t += -1*(-1*a[i]//10)*10 if c == 0: pass else: b = min(b,c) if b == 10**10: print(t) else: print(t+b-10)