problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03150
s076179704
Accepted
s=input() word='keyence' flag=0 if s[:6]==word: flag=1 if s[-7:]==word: flag=1 for i in range(7): if s[:i]+s[-(7-i):]==word: flag=1 print('YES' if flag else 'NO')
p03282
s376058358
Wrong Answer
import sys s = input() k = int(input()) for i in range(0, len(s)): if s[i] != '1': print(s[i]) sys.exit(0) print('1')
p02835
s765828102
Accepted
X = list(map(int,input().split())) if sum(X) <= 21: print("win") else: print("bust")
p03773
s262386337
Accepted
A,B=map(int,input().split()) ans=A+B if ans>=24: print(ans-24) else: print(ans)
p02983
s469484691
Wrong Answer
l,r = map(int,input().split()) ans = 2019 for i in range(l,r+1): if ans == 0: break ans = min(ans,i%2019) print(ans*(ans+1))
p02640
s173305707
Wrong Answer
X,Y=map(int,input().split()) if 2*X<=Y and Y<=4*X: print('Yes') else: print('No')
p02760
s571054220
Accepted
a = [0] * 3 for i in range(3): a[i] = list(map(int, input().split())) n = int(input()) b = set() for _ in range(n): b.add(int(input())) if ( set(a[0]) <= b or set(a[1]) <= b or set(a[2]) <= b or set(x[0] for x in a) <= b or set(x[1] for x in a) <= b or set(x[2] for x in a) <= b or {a[0][0], a[1][1], a[2][2]} <= b or {a[0][2], a[1][1], a[2][0]} <= b ): print("Yes") else: print("No")
p02627
s124170385
Wrong Answer
a = input() if ord(a) <= ord('Z'): print('A') else: print(a)
p03449
s818263929
Wrong Answer
n = int(input()) a = list(map(int, input().split())) b = list(map(int, input().split())) rua = [0] * (n + 1) rub = [0] * (n + 1) for i in range(n): rua[i + 1] = rua[i] + a[i] rub[i + 1] = rub[i] + b[i] ans = 0 for i in range(n): ans = max(ans, rua[i + 1] + rub[n - i]) print(ans)
p03377
s517025478
Wrong Answer
A, B, X = map(int, input().split()) if 0 < X - A <= B: print("Yes") else: print("No")
p02708
s285346531
Accepted
N, K = map(int, input().split()) MOD = 10 ** 9 + 7 ans = 0 for k in range(K, N+2): ans = (ans + k*N - k*(k-1) + 1) % MOD # print(k*(k-1)//2, k*N - k*(k-1)//2) print(ans)
p03319
s693028055
Accepted
#!/usr/bin/env python3 import collections import itertools as it import math #import numpy as np # = input() # = int(input()) n, k = map(int, input().split()) # = list(map(int, input().split())) # = [int(input()) for i in range(N)] # # c = collections.Counter() n -= k k -= 1 print(n // k + (int(bool(n % k))) + 1)
p02916
s157339684
Accepted
n = int(input()) a = [int(i) for i in input().split()] b = [int(i) for i in input().split()] c = [int(i) for i in input().split()] total = 0 for i in range(n-1): if a[i]+1==a[i+1]: total += c[a[i]-1] total += sum(b) print(total)
p03719
s944835852
Wrong Answer
a,b,c=map(int,input().split()) if a<=c<=b: print("YES") else: print("NO")
p02702
s360066597
Accepted
S = input() N = len(S) map_ = [-1] * 2019 map_[0] = 0 ans = 0 now = 0 for i in range(0, N): now = (now + int(S[N - i - 1]) * pow(10, i, 2019)) % 2019 map_[now] += 1 ans += map_[now] print(ans)
p03327
s976000403
Accepted
n = int(input()) if n < 1000: print("ABC") else: print("ABD")
p03997
s680895877
Accepted
a = int(input()) b = int(input()) h = int(input()) print((a+b) * h // 2)
p03760
s875593721
Accepted
o = input() e = input() olen = len(o) elen = len(e) res = "" if olen == elen: for i in range(olen): res += o[i] res += e[i] print(res) else: for i in range(elen): res += o[i] res += e[i] res += o[elen] print(res)
p02705
s800568454
Accepted
n = int(input()) print(n*2*3.14159)
p02711
s742881492
Wrong Answer
n = input() if n[0] != 7 and n[1] != 7 and n[2] == 7: print("No") else: print("Yes")
p02823
s143778518
Accepted
N,A,B = map(int,input().split()) if (B-A)%2 == 0: print((B-A)//2) else: print( (B-A)//2 + 1 +min(A-1,N-B) )
p03030
s596905106
Accepted
n=int(input()) l=[] for i in range(n): a,b=input().split() b=-1*int(b) l.append([a,b,i+1]) l=sorted(l) for i in range(n): print(l[i][2])
p03109
s913653577
Accepted
s = input() year = s[0:4] month = s[5:7] day = s[8:10] i = int(year + month + day) if i <= 20190430: print('Heisei') else: print('TBD')
p02897
s375359015
Wrong Answer
N = int(input()) if N == 1: print(0) elif N % 2 == 0: print(0.5) else: print((N//2) / N)
p02820
s588652815
Wrong Answer
N,K = map(int,input().split()) R,S,P = map(int,input().split()) T = str(input()) lst = [] for i in range(len(T)): if T[i] == 'r': lst.append(P) elif T[i] == 's': lst.append(R) else: # T[i] == 'p' lst.append(S) #print(lst) for j in range(N,K,-1): if lst[j-1] == lst[j-K-1]: lst[j-K-1] = 0 print(sum(lst))
p02785
s851085159
Accepted
n,k = map(int, input().split()) H = list(map(int, input().split())) H.sort(reverse=True) for i in range(min(k,n)): H[i] = 0 print(sum(H))
p02646
s582646519
Wrong Answer
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if a > b: a = a - v * t b = b - w * t print('YES' if a < b else 'NO') elif a < b: a = a + v * t b = b + w * t print('YES' if a > b else 'NO')
p02720
s416865750
Accepted
k=int(input()) from collections import deque q = deque(range(1,10)) for i in range(k-1): d = q.popleft() #10 if d % 10 != 0: q.append(10 * d + d % 10 - 1) #11 q.append(10 * d + d % 10) #12 if d % 10 != 9: q.append(10 * d + d % 10 + 1) print(q.popleft())
p03673
s411550610
Wrong Answer
n = int(input()) a = list(map(int,input().split())) b = "" if n%2 == 0: for i in range(0,n,2): b = b + str(a[i]) b = str(a[i+1]) + b else: for i in range(0,n-1,2): b = str(a[i]) + b b = b + str(a[i+1]) b = str(a[n-1]) + b print(" ".join(b))
p02661
s086904159
Accepted
N=int(input()) A=[0 for _ in range(N)] B=[0 for _ in range(N)] for i in range(N): a,b=[int(s) for s in input().split()] A[i]=a B[i]=b A.sort() B.sort() def doublemed(ls,num): if num%2==0: return(ls[num//2-1]+ls[num//2]) else: return(ls[num//2]) meda=doublemed(A,N) medb=doublemed(B,N) print(medb-meda+1)
p04033
s186534125
Accepted
a, b = list(map(int, input().split())) if 0 < a: ans = 'Positive' elif b < 0: if (b - a + 1) % 2 == 0: ans = 'Positive' else: ans = 'Negative' else: ans = 'Zero' print(ans)
p03030
s886480796
Wrong Answer
N = int(input()) A = [] for i in range(N): a,b=input().split() b=100-int(b) A.append(a+str(b)) B=sorted(A) for b in B: print(A.index(b)+1)
p03239
s037730764
Accepted
n,t=map(int,input().split()) ans=10**10 for _ in range(n): c,tt=map(int,input().split()) if tt<=t:ans=min(ans,c) if ans==10**10:print("TLE") else:print(ans)
p02790
s030557691
Wrong Answer
a,b=map(int,input().split()) c=0 for i in range(a): c+=b*(10**i) d=0 for j in range(b): d+=a*(10**j) e=min(c,d) print(e)
p03448
s547180651
Wrong Answer
a=int(input()) b=int(input()) c=int(input()) x=int(input()) aa=x//500 bb=x//100 cc=x//50 ans=0 for ai in range(aa): for bi in range(bb): for ci in range(cc): y=500*ai+100*bi+50*ci if x == y: ans+=1 if y>x: break print(ans)
p03767
s640431924
Wrong Answer
#!/usr/bin python3 # -*- coding: utf-8 -*- import sys input = sys.stdin.readline def main(): N = int(input()) A = list(map(int, input().split())) A.sort() print(sum(A[N:2*N])) if __name__ == '__main__': main()
p03433
s513108740
Accepted
N = int(input()) A = int(input()) if N % 500 == 0 : answer = "Yes" elif N % 500 <= A: answer = "Yes" else: answer = "No" print(answer)
p03161
s272061268
Accepted
n, k = map(int, input().split()) scaffolds = list(map(int, input().split())) dp = [10 ** 5 * 10 ** 4] * n dp[0] = 0 for i in range(n): for j in range(1, k + 1): if i + j >= n: break dp[i + j] = min(dp[i + j], abs(scaffolds[i] - scaffolds[i + j]) + dp[i]) print(dp[-1])
p03324
s956518335
Wrong Answer
D,N=map(int,input().split()) print(N*100**D)
p03073
s837893840
Accepted
S = list(map(int, input())) zero = [] one = [] zerocount = 0 onecount = 0 for i in range(len(S)): if i%2 == 0: zero.append(0) one.append(1) else: zero.append(1) one.append(0) for i in range(len(S)): if zero[i] != S[i]: zerocount += 1 if one[i] != S[i]: onecount += 1 if zerocount<onecount: print(zerocount) else: print(onecount)
p03145
s388461302
Wrong Answer
import sys from bisect import * from heapq import * from collections import * from itertools import * from functools import * from math import * from fractions import * sys.setrecursionlimit(100000000) input = lambda: sys.stdin.readline().rstrip() def main(): x, y, z = map(int, input().split()) print(x * y / 2) main()
p02708
s855645479
Wrong Answer
N, K = map(int, input().split()) MOD = 10**9 + 7 nac = [0] * (N + 2) ninv = [0] * (N + 2) inv = [0] * (N + 2) nac[0],nac[1] = 1,1 inv[0] = 1 ninv[0],ninv[1] = 1,1 for i in range(2, N + 2): nac[i] = (nac[i-1] * i % MOD) inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD ninv[i] = int(ninv[i - 1] * inv[i] % MOD) ret = 0 for i in range(K,N+2): ret += (nac[N + 1] / nac[i]/ nac[N+1 - i]) print(int(ret))
p03705
s623144172
Wrong Answer
N,A,B = map(int,input().split()) print((N-1)*B+A-(N-1)*A-B+1)
p02953
s137679100
Accepted
n=int(input()) h=list(map(int,input().split())) t=0 f=0 for i in range(n-1): if h[i]<=h[i+1]+1 and t<h[i]: h[i]-=1 t=h[i] elif h[i]<=h[i+1] and t==h[i]: t=h[i] else: f=1 break if f==0: print('Yes') else: print('No')
p03013
s940085903
Wrong Answer
# C - Typical Stairs N,M = map(int,input().split()) A = [int(input()) for _ in range(M)] # dp[i]: i 段目まで来た時の移動方法の総数 dp = [0]*(N+1) dp[0] = 1 for v in range(1,N+1): if v in A: continue dp[v] = (dp[v] + dp[v-1])%(1000000007) if v > 1: dp[v] = (dp[v] + dp[v-2])%(1000000007) print(dp) print(dp[N])
p02548
s559403731
Wrong Answer
N=int(input()) count=0 for k in range(1,N): for a in range (1,k): if k%a==0: count=count+1 else: continue print(count)
p02947
s878615478
Accepted
n = int(input()) import collections d = collections.defaultdict(int) ans = 0 for i in range(n): sl = sorted([j for j in input()]) ss = ''.join(sl) ans += d[ss] d[ss] += 1 print(ans)
p02880
s371952758
Wrong Answer
n = int(input()) kuku = set() for i in range(1,9): for j in range(1,9): kuku.add(i*j) if n in kuku: print('Yes') else: print('No')
p02702
s956479771
Accepted
def resolve(): S = input() table=[0]*2019 table[0]=1 x = 0 x_10 =1 for i in S[::-1]: x = (x+ int(i)*x_10)%2019 table[x]+=1 x_10*=10 x_10 %= 2019 ans =0 for i in table: ans += i*(i-1)//2 print(ans) if __name__ == "__main__": resolve()
p02983
s944235444
Wrong Answer
l,r = map(int,input().split()) if l - r >= 2019: print(0) else: s = l % 2019 if s + l - r >= 2019: print(0) else: print(s*(s+1))
p02723
s150093533
Accepted
import sys input = sys.stdin.readline S = input().strip() if S[2] == S[3] and S[4] == S[5]: print('Yes') else: print('No')
p03211
s208059240
Accepted
S = str(input()) a = [] for i in range(0,len(S)-2): a.append(abs(int(S[i:i+3])-753)) print(min(a))
p02660
s104672346
Wrong Answer
def solve(n): if n == 1: return 0 res = 0 for i in range(2, int(n ** 0.5) + 1): cnt = 1 while n % (i ** cnt) == 0: n //= i ** cnt res += 1 cnt += 1 return max(res, 1) n = int(input()) ans = solve(n) print(ans)
p02783
s139045146
Accepted
H,A=map(int,input().split()) print((H+A-1)//A)
p03281
s531340435
Wrong Answer
N = int(input()) if N < 105: print(0) elif N < 135: print(1) elif N < 165: print(2) elif N < 189: print(3) elif N >= 195: print(4)
p03239
s380530280
Wrong Answer
N,T = input().split(" ") N,T = int(N),int(T) time = dict() for i in range(N): c,t = input().split(" ") time[int(c)] = int(t) for key, value in sorted(time.items(), key=lambda item: item[1]): if value <= T: print(value) break else: print("TLE") break
p02699
s595693517
Accepted
#!/usr/bin/env python # -*- coding: utf-8 -*- def main(): S, W = map(int, input().split()) print("unsafe"if S <= W else "safe") if __name__ == "__main__": main()
p02765
s001494055
Accepted
N, R = map(int, input().split()) print(R) if N >= 10 else print(R+(100*(10-N)))
p04011
s997214165
Accepted
n,k,x,y=(int(input()) for i in range(4)) if n<=k: ans=n*x else: ans=k*x+(n-k)*y print(ans)
p03838
s625394456
Accepted
x,y = list(map(int, input().split())) ans=0 if abs(x) < abs(y): if x<0: ans+=1 ans+=abs(y)-abs(x) if y<0: ans+=1 elif abs(x) > abs(y): if x>0: ans+=1 ans+=abs(x)-abs(y) if y>0: ans+=1 else: if x!=y: ans+=1 print(ans)
p02987
s915152104
Wrong Answer
import sys a1=sys.stdin.readline() a2=list(a1) b=[ord(x) for x in a2] b.sort() if b[0]==b[1] and b[2]==b[3] and b[0]!=b[3] and b[1]!=b[2] and len(a2)==4: print("Yes") elif len(a2)==4: print("No") else: print("Error")
p02682
s422178908
Accepted
A , B , C , K = map ( int ,input().strip().split(" ") ) l = [ 1 , 0 , -1 ] ; t = 0 for ( c,r ) in zip ( l , ( A, B , C ) ) : if r >= K : t += K * c ; break ; else : K -= r ; t += r * c ; print ( t ) ;
p03317
s030417009
Accepted
N,K = map(int, input().split()) A = [int(i) for i in input().split()] if N == K: print(1) else: cnt = 1 N -= K while N > 0: cnt += 1 N -= K N += 1 print(cnt)
p02570
s522937029
Accepted
D, T, S = map(int, input().split()) if T*S >= D: print("Yes") else: print("No")
p04005
s330998262
Accepted
a, b, c = map(int, input().split()) ans = float('inf') ans = min(ans, a * b * ((c + 1) // 2) - a * b * (c // 2)) ans = min(ans, b * c * ((a + 1) // 2) - b * c * (a // 2)) ans = min(ans, c * a * ((b + 1) // 2) - c * a * (b // 2)) print(ans)
p03481
s782187585
Accepted
X, Y = map(int, input().split()) ans = 0 while X <= Y: X *= 2 ans += 1 print(ans)
p02687
s978891697
Accepted
# 文字列の入力 s = input() # 出力 if s == 'ABC': print('ARC') elif s == 'ARC': print('ABC')
p03803
s426813935
Wrong Answer
A,B = map(int,input().split()) if A>B: print("Alicd") elif A<B: print("Bob") else: print("Draw")
p03137
s282996830
Accepted
import sys input = lambda: sys.stdin.readline().rstrip() N, M = map(int, input().split()) X = list(map(int, input().split())) X.sort() if N >= M: print(0) sys.exit() dist = [] for i in range(len(X)-1): dist.append(X[i+1] - X[i]) dist.sort(reverse=True) ans = X[-1] - X[0] for i in range(N-1): ans -= dist[i] print(ans)
p02578
s142011817
Accepted
N = int(input()) A = list(map(int,input().split())) step = 0 height = 0 for i in range(N): if A[i] <= height: step += height - A[i] else: height = A[i] print(step)
p02697
s918459461
Wrong Answer
i = list(map(int, input().split())) k=int(i[0]/2) if i[0]%2==1: for j in range(i[1]): print(k-j, k+1+j) else: for j in range(i[1]): if (k-j)*2!=(k+1+j): print(k-j, k+1+j)
p03474
s530994703
Wrong Answer
import re a,b = list(map(int,input().split())) s = input() if re.match(r"[1-9][1-9]*",s[:a]): if s[a]=="-": if re.match(r"[1-9][1-9]*",s[(a+1):]): print("Yes") exit() print("No")
p03160
s046516301
Accepted
N = int(input()) h = list(map(int, input().split())) list = [0 for _ in range(N)] list[0] = 0 list[1] = abs(h[1]-h[0]) for i in range(2, N): list[i] = min(abs(h[i] - h[i-1]) + list[i-1], abs(h[i] - h[i-2]) + list[i-2]) print(list[N-1])
p02697
s108398293
Accepted
n,m=map(int,input().split()) if n%2==1: x=[f"{i+1} {n-i}" for i in range(m)] print(" ".join(x)) else: x=[f"{i+1} {n-i}" if i<m/2 else f"{i+1} {n-i-1}" for i in range(m)] print(" ".join(x))
p04045
s074533691
Accepted
N, K = map(int, input().split()) D = list(input().split()) while True: n = str(N) for i in range(K): f = 0 if D[i] in n: N += 1 f = 1 break if f == 0: break print(N)
p04045
s500363690
Wrong Answer
n, k = map(int, input().split()) d = list(input().split()) n = 1000 flag = True while flag: flag2 = True for si in str(n): if si in d: n += 1 flag2 = False break if flag2: break else: flag = True print(n)
p02615
s445751404
Accepted
N = int(input()) A = [int(i) for i in input().split()] A.sort(reverse=True) ret = A[0] c = N - 2 i = 1 while c : if c >= 2 : ret += A[i] * 2 c -= 2 else : ret += A[i] c -= 1 i += 1 print(ret)
p03328
s885179178
Accepted
a, b = map(int, input().split()) diff = b - a sum = 0 for i in range(1, diff, 1): sum += i ans = sum - a print(ans)
p03160
s163386626
Wrong Answer
def frog(arr): n=len(arr) if n<=1: return 0 dp=[0]*(n+1) # dp[2]=abs(arr[0]-arr[1]) # if n==2: # return dp[2] for i in range(2,n+1): dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i-2]),dp[i-2]+abs(arr[i-1]-arr[i-3])) return dp[n] n=int(input()) arr=[int(i) for i in input().split()] frog(arr)
p02784
s152805236
Accepted
h,n=map(int,input().split()) a=[int(x) for x in input().split()] if sum(a) >= h: print("Yes") else: print("No")
p03611
s378293527
Accepted
N=int(input()) a=list(map(int,input().split())) count=[0 for _ in range(100001)] for x in a: count[x]+=1 count[x+1]+=1 if x>0: count[x-1]+=1 print(max(count))
p02663
s728813626
Wrong Answer
h1,m1,h2,m2,k=map(int,input().split()) s=abs(h2-h1)*60+abs(m2-m1) n=s-k print(n)
p03861
s614402534
Accepted
a,b,x = map(int, input().split()) if a%x == 0: buf1 = a//x - 1 else: buf1 = a//x buf2 = b//x print(buf2 - buf1)
p02743
s735341893
Accepted
a, b, c = map(int, input().split()) ans = None if a + b >= c: ans = "No" elif 4 * a * b < c ** 2 + (a + b) ** 2 - 2 * c * (a + b): ans = "Yes" else: ans = "No" print(ans)
p03644
s083673983
Accepted
N=int(input()) ans=1 cnt=0 for i in range(1,N+1): tmp=0 n=i while True: if n%2==0: tmp+=1 else: break n//=2 if tmp>cnt: ans=i cnt=tmp print(ans)
p02691
s041625821
Accepted
import sys from collections import Counter n, *a = map(int, sys.stdin.read().split()) def main(): b = [a[i] + i for i in range(n)] c = [i - a[i] for i in range(n)] cb = Counter(b) cc = Counter(c) tot = 0 for v, c in cb.items(): tot += c * cc[v] print(tot) if __name__ == '__main__': main()
p03289
s570975338
Accepted
s = input() if s[0] == "A" and s[2:-1].count("C") == 1: tmp = s.replace("A","").replace("C","") if tmp.islower(): print("AC") else: print("WA") else: print("WA")
p03761
s160912456
Accepted
ans="" n=int(input()) s=[input() for _ in range(n)] from collections import Counter d=Counter(s[0]) for i in s[1:]: d&=Counter(i) for i ,k in sorted(d.items()): ans+=i*k print(ans)
p03544
s060918460
Accepted
a,b=2,1 for _ in range(int(input())-1): a,b=b,a+b print(b)
p02711
s259734755
Accepted
n=input() if "7" in n: print("Yes") else: print("No")
p03030
s610970669
Wrong Answer
n = int(input()) sp = [input().split() for _ in range(n)] for i in range(n): sp[i][1] = int(sp[i][1]) sp[i] = sp[i]+[i+1] sp_s0 = sorted(sp, key=lambda x:(x[0], -x[1]), reverse=False) print(sp_s0) for i in range(n): print(sp_s0[i][2])
p02860
s022291938
Accepted
N = int(input()) S = str(input()) flag = False half = (N+1) // 2 if S[:half] == S[half:N]: flag = True if flag: print("Yes") else: print("No")
p03435
s150180460
Wrong Answer
#088_C c = [sum(list(map(int, input().split()))) for _ in range(3)] print('Yes' if sum(c)%3==0 else 'No')
p02718
s886863796
Wrong Answer
N,M = map(int, input().split()) A = [int(N) for N in input().split()] X=0 F=int(sum(A)/(4*M)) for i in range(N): if A[i] >= F: X+=1 if X>=M: print('Yes') else: print('No')
p03827
s593303540
Accepted
n=int(input()) s=input() maxi=0 cnt=0 for i in range(len(s)): if s[i]=='I': cnt+=1 if maxi < cnt: maxi = cnt elif s[i]=='D': cnt-=1 print(maxi)
p03852
s816310930
Accepted
c=str(input()) if c=='a' or c=='i' or c=='u' or c=='e' or c=='o': print("vowel") else: print("consonant")
p02973
s052414409
Accepted
from collections import deque import bisect N = int(input()) table = deque() for n in range(N): a = int(input()) if n == 0: table.append(a) else: if a <= table[0]: table.appendleft(a) else: table[bisect.bisect_left(table, a)-1] = a print(len(table))
p03126
s491011139
Accepted
import sys n,m=map(int,input().split()) ans=[0]*(m+1) output=0 for i in range(n): k=list(map(int,input().split())) for j in range(1,len(k)): ans[k[j]]+=1 for i in ans: if i==n: output+=1 print(output)
p03433
s086630492
Accepted
N,A=[int(input()) for i in range(2)] print('Yes'if N%500<=A else 'No')
p02691
s259574881
Wrong Answer
N = int(input()) As = [int(n) for n in input().split()] # len(As) = N # Ai = 身長 c = 0 for i, ai in enumerate(As): # i + ai = 最低これだけ先が無いとダメ j0 = i + ai if j0 >= N-1: continue j = 1 while True: if j == As[j0+j]: c += 1 if j0+j >= N-j: break if N-j0-j == As[N-j]: c += 1 j+=1 print(c)