problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02873
s678086825
Accepted
#!/usr/bin python3 # -*- coding: utf-8 -*- def main(): S = input() n = len(S)+1 left=[0]*n right=[0]*n for i,s in enumerate(S): if s=='<': left[i+1]=left[i]+1 for i,s in enumerate(S[::-1]): if s=='>': right[n-i-2]=right[n-i-1]+1 ret =0 for i in range(n): ret+= max(left[i],right[i]) print(ret) if __name__ == '__main__': main()
p02718
s223968331
Accepted
import sys input = sys.stdin.readline n,m = map(int,input().split()) A = list(map(int,input().split())) a = 0 s = sum(A) for i in range(n): if A[i] *4*m>= s: a += 1 if a >= m: print("Yes") else: print("No")
p02842
s148827699
Accepted
N = int(input()) for i in range(1, 50001): if int(1.08 * i) == N: print(i) break else: print(":(")
p03803
s427410722
Accepted
a, b = map(int, input().split()) if a == b: print('Draw') elif a == 1: print("Alice") elif b == 1: print('Bob') elif a > b: print('Alice') elif b > a: print('Bob')
p03943
s723120989
Accepted
a,b,c = map(int,input().split()) if a+b ==c or b+c ==a or c+a == b: print("Yes") else: print("No")
p03435
s656291182
Accepted
C=[] for _ in range(3): a=list(map(int,input().split())) b=min(a) for i in range(3): a[i]-=b C.append(a) if C[0]==C[1] and C[1]==C[2] and C[0]==C[2]: print("Yes") else: print("No")
p03434
s484821908
Accepted
N = int(input()) a = sorted(list(map(int,input().split())),reverse=True) alice = 0 bob = 0 for i in range(N): if i % 2 == 0: alice += a[i] else: bob += a[i] print(alice - bob)
p02963
s428362047
Accepted
S = int(input()) from math import sqrt, ceil rtS = sqrt(S) u = 10 ** 9 ans = [0 for _ in range(6)] ans[2] = u ans[3] = 1 ans[5] = ceil(S/u) ans[4] = ans[5] * u - S print(*ans)
p03485
s985971097
Wrong Answer
a,b=map(int,input().split()) print((a+b)//2)
p02743
s396407408
Accepted
from decimal import Decimal a, b, c = map(Decimal, input().split()) print('Yes' if a.sqrt() + b.sqrt() < c.sqrt() else 'No')
p02882
s031309970
Accepted
import math a, b, x = map(int, input().split()) sq = a*a*b/2 if sq >= x: A1 = 2*x/(a*b) num = math.atan(b/A1) else: B1 = 2*x/a**2 - b num = math.atan((b-B1)/a) print(math.degrees(num))
p03672
s721312726
Accepted
s = input() ans = '' while True: i = len(s)//2 if s[0:i]==s[i:-1]: ans = s[0:i]+s[i:-1] break s = s[0:-1] print(len(ans))
p03723
s284121794
Wrong Answer
#!/usr/bin/env python3 a, b, c = map(int, input().split()) if (a + b + c) % 2 != 1: print(-1) else: cnt = 0 while True: if a % 2 or b % 2 or c % 2: break cnt += 1 a, b, c = (b + c) // 2, (a + c) // 2, (a + b) // 2 print(cnt)
p03481
s944448938
Accepted
x,y = map(int,input().split()) cnt = 1 for i in range(x,y+1): x = x*2 if x > y: break cnt += 1 print(cnt)
p03407
s896908780
Accepted
a,b,c = map(int, input().split()) if a+b >= c: print("Yes") else: print("No")
p03106
s501406248
Wrong Answer
a, b, k = map(int, input().split()) num_list = [] for i in range(1,100): if a % i == 0 & b % i == 0: num_list.append(i) print(num_list[k-1])
p02916
s189518785
Accepted
n = int(input()) a=list(map(int,input().split())) b=list(map(int,input().split())) c=list(map(int,input().split())) ma=sum(b) for i in range(0,n-1): if a[i+1]-a[i]==1: ma+=c[a[i]-1] print(ma)
p02791
s808273466
Accepted
N = int(input()) P = list( map( int, input().split() ) ) c = 1 m = P[0] for i in range(1,N): if P[i] <= m: c += 1 m = P[i] print(c)
p02994
s469683955
Accepted
a,b=map(int,input().split()) n=list(range(b,b+a)) o=[] for i in n: o.append(abs(i)) del n[o.index(min(o))] print(sum(n))
p03698
s209541069
Wrong Answer
s=list(input()) li=[] non=False for c in s: if c in li: non=True break if non: print("yes") else: print("no")
p02888
s920900635
Accepted
N = int(input()) L = list(map(int, input().split())) L.sort() from bisect import bisect_left ans = 0 for a in range(0, N-2): for b in range(a+1, N-1): t = L[a] + L[b] idx = bisect_left(L,t) ans += max(0, idx-b-1) print(ans)
p03220
s836280487
Accepted
N = int(input()) T,A = map(int, input().split()) H = [int(i) for i in input().split()] ans = [float("inf"), 0] for i,h in enumerate(H): tmp = abs(A - (T - h * 0.006)) if ans[0] > tmp: ans = [tmp, i + 1] print(ans[-1])
p03086
s153046753
Accepted
s = str(input()) list = ['A','C','G','T'] score = 0 tmp = 0 for i in s: if(i in list): tmp += 1 else: score = max(score,tmp) tmp = 0 score = max(score,tmp) print(score)
p02639
s780036231
Accepted
# coding:utf-8 import sys import math import time #import numpy as np import collections from collections import deque from collections import Counter import queue import copy import bisect import heapq import itertools #sys.setrecursionlimit(10**7) #N, Q = map(int, input().split()) #G = [list(input()) for i in range(H)] #INF = V * 10001 #A = [int(i) for i in input().split()] #AB = [list(map(int, input().split())) for _ in range(K)] x = list(map(int,input().split())) ans = 0 print(x.index(0)+1)
p03352
s416479732
Wrong Answer
import math def main(): x = int(input()) print(int(math.sqrt(x))*int(math.sqrt(x))) main()
p02608
s283411064
Accepted
n=int(input()) ans=[0]*(n+1) for x in range(1,int(n**0.5)+2): for y in range(1,int(n**0.5)+2): for z in range(1,int(n**0.5)+2): if x**2+y**2+z**2+x*y+y*z+z*x<=n: ans[x**2+y**2+z**2+x*y+y*z+z*x]+=1 for item in ans[1:]: print(item)
p02717
s888346979
Accepted
x,y,z=input().split() print(z,x,y)
p02629
s396834265
Accepted
n=int(input()) s = '' for i in range(11): if n != 0: n -= 1 s += chr(ord('a') + n % 26) n //= 26 print(s[::-1])
p03672
s655970388
Accepted
s = input() n = len(s) for i in range(2,n-1,2): if s[:(n-i)//2] == s[(n-i)//2:n-i]: print(n-i) exit()
p03557
s912526180
Accepted
import bisect N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) A.sort() B.sort() C.sort() ans = 0 for i in B: a = bisect.bisect_left(A, i) b = bisect.bisect_right(C, i) ans += a * (N - b) print(ans)
p02829
s404810020
Accepted
a = int(input()) b = int(input()) print(6 - a - b)
p02717
s708592423
Accepted
x, y, z = input().split() print(z, x, y)
p03455
s567785989
Wrong Answer
a, b = map(int, input().split()) if (a * b) % 2 == 1: print ('odd') else: print ('even')
p02629
s381553726
Wrong Answer
alp = [chr(i) for i in range(97, 97+26)] N = int(input()) q = N s = "" while True: q,m = divmod(q,26) s = alp[m - 1] + s if q == 0: break print(s)
p02624
s892328661
Wrong Answer
def yakusuu(x): kosuu = 0 for i in range(1,x + 1,1): if x % i == 0: kosuu += 1 return kosuu x = input() intNum = int(x) ans = 0 for i in range(1,intNum + 1,1): print(i) ans += i * yakusuu(i) print(ans)
p02847
s196384847
Wrong Answer
w = {'SAT': 1, 'MON': 2, 'TUE': 3, 'WED': 4, 'THU': 5, 'FRI': 6, 'SUN': 7} s = input() print(w[s])
p03043
s166341028
Wrong Answer
N,K=map(int,input().split()) sum_value = 0 for i in range(1,N+1): if(i>=K): sum_value = sum_value+1/N else: for j in range(1,17): if(i*(2**j)>=K): sum_value=sum_value+((1/N)*(1/(2**j))) break print(sum_value)
p03611
s585209306
Accepted
N = int(input()) A = [int(i) for i in input().split()] from collections import defaultdict cnt = defaultdict(int) for a in A: cnt[a] += 1 cnt[a-1] += 1 cnt[a+1] += 1 print(max(cnt.values()))
p03657
s010914009
Accepted
A = list(map(int, input().split())) A.append(sum(A)) ans = False for i in A: if i%3 == 0: ans = True if ans: print("Possible") else: print("Impossible")
p02570
s438351248
Wrong Answer
d,t,s = map(int,input().split()) if d / s >= t: print("No") else: print("Yes")
p03208
s343233009
Accepted
n,k = map(int,input().split()) h = [int(input()) for _ in range(n)] #n,k = 7,3 #h = [10,11,12,14,15,20,0] h.sort() ans = 10**10 for i in range(n-k+1): ans = min(h[i+k-1] - h[i] , ans) print(ans)
p03061
s524189432
Accepted
from fractions import gcd n = int(input()) a = [int(i) for i in input().split()] # 累積 gcd(左と右両方) left, right = [0] * (n + 1), [0] * (n + 1) for i in range(n): left[i + 1] = gcd(left[i], a[i]) for i in reversed(range(0, n)): right[i] = gcd(right[i + 1], a[i]) # 累積 ans = 0 for i in range(n): l = left[i] r = right[i + 1] ans = max(ans, gcd(l, r)) print(ans)
p02859
s172430405
Accepted
r = int(input()) print(r**2)
p02570
s645435085
Accepted
d, t, s = map(int, input().split()) dist = t * s if dist >= d: print("Yes") else: print("No")
p03145
s615849906
Accepted
a,b,c=map(int,input().split()) if (a**2)+(b**2)==(c**2): s=a*b/2 elif (a**2)+(c**2)==(b**2): s=a*c/2 elif (b**2)+(c**2)==(a**2): s=b*c/2 print(int(s))
p03854
s899430048
Accepted
s = input() s = s.replace("eraser", "").replace("erase", "").replace("dreamer", "").replace("dream", "") if len(s) > 0: print("NO") else: print("YES")
p03449
s845376917
Accepted
N = int(input()) a1 = list(map(int,input().split())) a2 = list(map(int,input().split())) maxim = 0 for i in range(N): count = 0 count += sum(a1[:i+1]) + sum(a2[i:]) if count > maxim: maxim = count print(maxim)
p02923
s552217183
Accepted
n = int(input()) h = list(map(int, input().split())) c, d = 0, 0 for i in range(n-1): if h[i] >= h[i+1]: c += 1 else: d = max(c, d) c = 0 print(max(c, d))
p03407
s370412133
Accepted
a, b, c = map(int, input().split()) if a+b >= c: print('Yes') else: print('No')
p02760
s094426834
Wrong Answer
a = [int(j) for i in range(3) for j in input().split(' ')] n = int(input()) nn = [int(input()) for i in range(n)] cnt = 0 for ni in nn: if ni in a: cnt += 1 a[a.index(ni)] = 0 judge = "No" for i in range(3): if sum(a[i::3])==0 or sum(a[i*3:i*3+3])==0: judge = "Yes" if sum(a[::4])==0 or sum(a[2:-1:4])==0: judge = "Yes" print(judge)
p02693
s503548618
Wrong Answer
k = int(input()) l, m = map(int, input().split()) if (l-l%k == m): print("OK") elif ((l/k+k)*k <= m): print("OK") else: print("NG")
p03067
s145795519
Wrong Answer
A,B,C = map(int,input().split()) maxi=max(A,B,C) mini=min(A,B,C) if B!=maxi and B!=mini: print("Yes") else: print("No")
p03274
s614089934
Wrong Answer
N, K = map(int, input().split()) x = list(map(int, input().split())) ans = float('inf') for l in range(K): r = l + K - 1 if r>=N: continue ans = min(ans, min(abs(x[l]), abs(x[r])) + x[r] - x[l]) print(ans)
p03386
s567851032
Accepted
A, B, K = map(int, input().split()) for i in range(A, min(B+1, A+K)): print(i) for i in range(max(A+K, B-K+1), B+1): print(i)
p02993
s542323359
Accepted
S = input() if S[0] == S[1] or S[1] == S[2] or S[2] == S[3]: print('Bad') else: print('Good')
p03323
s999044782
Accepted
a, b = map(int, input().split()) if a <= 8 and b <= 8: print('Yay!') else: print(':(')
p02912
s641754767
Accepted
import heapq N,M=map(int,input().split()) A=list(map(lambda x:int(x)*(-1),input().split())) heapq.heapify(A) def func(): n=-heapq.heappop(A) n//=2 heapq.heappush(A,-n) for i in range(M): func() print(-sum(A))
p02842
s476893011
Wrong Answer
import math N=int(input()) X=math.ceil(N/1.08) if math.floor(X*1.08)==N: print(X) else: print(':(')
p03986
s620713452
Wrong Answer
x = input() s_count = x.count('S') t_count = x.count('T') count = 0 for i in range(len(x)): if s_count == 0 or t_count == 0: break if x[i]=='S': s_count -= 1 if t_count > 0: count += 1 else: t_count -= 1 print(len(x)-count*2)
p02881
s053453107
Wrong Answer
import math n = int(input()) n_list = [] for i in range(1, int(math.sqrt(n))): if n % i == 0: n_list.append((i, n//i)) sa = 10**13 for x, y in n_list: if sa >= abs(x-1)+abs(y-1): sa = abs(x-1) + abs(y-1) print(sa)
p02697
s261907063
Accepted
n,m = map(int, input().split()) if n%2: a=1 b=n for i in range(m): print(a,b) a+=1 b-=1 else: a=1 b=n m2=(m+1)//2 for i in range(m2): print(a,b) a+=1 b-=1 m3=m-m2 a=1+m2 b=n-m2-1 for i in range(m3): print(a,b) a+=1 b-=1
p03474
s906924102
Accepted
def main(): a, b = map(int, input().split()) s = input() for i in range(a + b + 1): if i == a: if s[i] != "-": print("No") exit() else: if not "0" <= s[i] <= "9": print("No") exit() else: print("Yes") if __name__ == "__main__": main()
p02677
s039514293
Wrong Answer
import sys import math input = sys.stdin.readline sys.setrecursionlimit(4100000) def main(): A, B, H, M = map(int, input().rstrip().split()) theta_m = 2 * math.pi * M / 60 theta_h = 2 * math.pi * (H * 60 + M) / (12 * 60) theta = (theta_h - theta_m) % math.pi ans = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(theta)) print(theta_m) print(theta_h) print(theta) print(ans) if __name__ == '__main__': main()
p02682
s886582135
Accepted
a, b, c, k = list(map(int, input().split())) c = k- a- b if c < 0 : c = 0 if a > k: a = k print(a -c)
p02880
s673260108
Wrong Answer
n = int(input()) for i in range(1,10): r = n%i ans = n//i if r == 0: if ans <= 9: print("Yes") else: print("No") else: print("No")
p02917
s307654360
Accepted
n = int(input()) b = list(map(int, input().split())) print(b[0] + b[-1] + sum([min(b[i], b[i + 1]) for i in range(n - 2)]))
p03126
s486172850
Wrong Answer
n,m=map(int,input().split()) kouho=[i for i in range(1,m+1)] for i in range(n): x=list(map(int, input().split())) a=x[1:] for i in kouho: if not i in a:kouho.remove(i) print(len(kouho))
p02584
s187855174
Wrong Answer
x,k,d= map(int, input().split()) if abs(x) >= k*d: print(abs(x)-k*d) elif abs(x)%d==0: if (int(abs(x)/d)+1000000000000000-k)%2==0: print(0) else: print(d) else: print((abs(x)+(1000000000000000-k)*d)%d)
p02552
s273791213
Wrong Answer
from random import randint print(randint(0,1))
p02996
s220263260
Accepted
N = int(input()) AB = [list(map(int, input().split())) for _ in range(N)] AB.sort(key=lambda ab: ab[1]) cnt = 0 for a, b in AB: if cnt + a <= b: cnt += a else: print("No") exit() print("Yes")
p02958
s241200693
Wrong Answer
import sys n=int(input()) p=list(map(int,input().split())) q=sorted(p) for i in range(n-1): for j in range(i,n): s=p[i] p[i]=p[j] p[j]=s if p==q: print("YES") sys.exit() s=p[i] p[i]=p[j] p[j]=s print("N0")
p03625
s179366682
Accepted
N=int(input()) A=list(map(int,input().split())) A.sort(reverse=True) A.append(0) i=0 ans=1 d=0 while i<N: b=A[i] c=0 while i<N and b==A[i]: i+=1 c+=1 if 2<=c<=3: d+=1 ans*=b if d==2: break elif 4<=c: if d==0: ans*=b*b d=2 break else: ans*=b d+=1 break if d!=2: print(0) else: print(ans)
p03427
s283438621
Accepted
s=list(input()) memo = [] for i in s: memo.append(int(i)) ans = max(sum(memo),(memo[0]-1)+(len(memo)-1)*9) print(ans)
p04043
s814199176
Accepted
def main(): A, B, C = map(int, input().split()) if (A == 5 and B == 7 and C == 5) or (A == 7 and B == 5 and C == 5) or (A == 5 and B == 5 and C ==7): print('YES') else: print('NO') main()
p02773
s888482022
Accepted
n=int(input()) a={} for i in range(n): key=input() if key in a: a[key]+=1 else: a[key]=1 b=max(list(a.values())) c=[] for k,v in a.items(): if v==b: c.append(k) c=sorted(c) for i in range(len(c)): print(c[i])
p03605
s787819083
Accepted
N = str(input()) if "9" in N: print("Yes") else: print("No")
p03854
s921994138
Wrong Answer
words=["eraser","erase","dreamer","dream"] S=input() for i in range(0,4): S=S.replace(words[i],"",) if S=="": print("Yes") else: print("No")
p03745
s694681956
Accepted
N = int(input()) a = list(map(int, input().split())) f = None count = 1 for i in range(N - 1): if f is None: if a[i] < a[i + 1]: f = 1 elif a[i] > a[i + 1]: f = -1 continue if (f == 1 and a[i] > a[i + 1]) or (f == -1 and a[i] < a[i + 1]): count += 1 f = None print(count)
p03289
s909423306
Wrong Answer
import sys input = sys.stdin.readline S = input().rstrip() trimed_S = S[3:-2].replace('C', '', 1) ans = 'AC' if S[0] != 'A': ans = 'WA' elif not trimed_S.islower() or len(S) - len(trimed_S) != 1: ans = 'WA' print(ans)
p02742
s696876213
Accepted
h,w = map(int,input().split()) s = (h * w) // 2 if (h==1) or (w==1): t = 1 elif (h*w) % 2 == 0: t = s elif (h*w) % 2 == 1: t = s+1 print (t)
p02555
s123855637
Accepted
S = int(input()) mod = 10**9+7 dp = [0 for _ in range(S+1)] dp[0] = 1 for i in range(3, S+1): dp[i] = dp[i-1]+dp[i-3] dp[i] = dp[i]%mod print(dp[-1])
p02784
s553386895
Accepted
h,n = map(int, input().split()) a = map(int, input().split()) result="No" s = 0 for i in a: s += i if s >= h: result = "Yes" break print(result)
p03136
s773605000
Accepted
N = int(input()) L = [int(i) for i in input().split()] L.sort() M = L.pop() if M < sum(L): print('Yes') else: print('No')
p03469
s264082933
Accepted
s = input() print("2018" + s[4:])
p02823
s884847875
Accepted
N, A, B = map(int,input().split(" ")) ans = 0 diff = abs(A-B) if diff % 2 == 0: ans = diff // 2 else: edge = min(A-1, N-B) + 1 edge += (B-A-1)//2 ans = edge print(ans)
p02600
s200190936
Accepted
X = int(input()) K =[400,600,800,1000,1200,1400,1600,1800,9999] for k in range(8): if K[k]<=X and K[k+1]>X: print(8-k) break
p04005
s416090064
Accepted
#!/usr/bin/env python a, b, c = map(int, input().split()) if a*b*c%2 == 0: print(0) exit() print(min(a*b, b*c, a*c))
p02695
s994502515
Accepted
import itertools n,m,q = map(int,input().split()) target = [list(map(int,input().split())) for _ in range(q)] ans = 0 for A in itertools.combinations_with_replacement(range(1,m+1),n): count = sum([abcd[3] for abcd in target if A[abcd[1]-1] - A[abcd[0]-1] == abcd[2]]) ans = max(ans,count) print(ans)
p02939
s974359070
Accepted
# coding: utf-8 def main(): S = input() ans = 0 a, b = '', '' for s in S: a += s if a != b: ans += 1 b = a a = '' print(ans) if __name__ == "__main__": main()
p02714
s526302197
Accepted
n=int(input()) s,rem=input(),0 ans = s.count('R') * s.count('B') * s.count('G') for i in range(1, (n-1) // 2 + 1): for j in range(i*2, n): if s[j]+s[j-i]+s[j-2*i] in ("RGB","RBG","GRB","GBR","BGR","BRG"): rem += 1 print(ans - rem)
p03219
s356834576
Accepted
X, Y = map(int, input().split()) print(int(X+(Y/2)))
p03220
s467140964
Wrong Answer
n = int(input()) t, a = map(int, input().split()) h = list(map(int, input().split())) ret, tmp_temp = 1, h[0] for i, height in enumerate(h): x = t - height*0.006 if abs(a-x) <= a-tmp_temp: tmp_temp = x ret = i+1 print(ret)
p03485
s262405047
Accepted
import math a, b = map(int, input().split()) print(math.ceil((a+b) / 2))
p02603
s095026887
Accepted
N=int(input()) A=list(map(int, input().split())) mon=1000 for i in range(1,N): if A[i]>A[i-1]: mon=mon//A[i-1]*A[i]+mon%A[i-1] print(mon)
p03479
s883642274
Accepted
ans=0 a,b=map(int,input().split()) while True: if a*2<=b: ans+=1 a=a*2 else: break print(ans+1)
p02970
s594931178
Accepted
n,d=map(int,input().split()) import math ans=math.ceil(n/(2*d+1)) print(ans)
p04043
s610173268
Wrong Answer
A, B, C = map(str, input().split()) D = 0 E = 0 if A == 5: D += 1 if A == 7: E += 1 if B == 5: D += 1 if B == 7: E += 1 if C == 5: D += 1 if C == 7: E += 1 if D == 2 and E==1: print("YES") else: print("NO")
p03673
s909696125
Accepted
N = int(input()) A = list(map(int, input().split())) if N % 2 == 0: latter = A[0:N:2] former = A[1:N:2][::-1] print(*(former + latter)) else: former = A[0:N:2][::-1] latter = A[1:N:2] print(*(former + latter))
p02789
s806111023
Accepted
a = [] a = input().split() N = int(a[0]) M = int(a[1]) if N == M: print('Yes') else: print('No') #print('N=', N, 'M=', M)
p03761
s777420220
Accepted
n = int(input()) s = [input() for _ in range(n)] al = [] lst = [] for i in s: for j in i: if not j in al: al.append(j) al = sorted(al) for i in al: num = float('inf') for j in s: num = min(num, j.count(i)) lst.append(num) result = [al[i] * lst[i] for i in range(len(al))] print(''.join(result))