problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03478
s251132359
Accepted
N, A, B = map(int, input().split()) ans = 0 for i in range(1, N+1): cnt = 0 i = str(i) for j in i: cnt += int(j) if cnt >= A and cnt <= B: ans += int(i) print(ans)
p02987
s145427217
Wrong Answer
a=input() b=sorted(a) if b[0]==b[1] and b[2]==b[3]: print('Yes') else: print('No')
p02548
s679609940
Accepted
n = int(input()) ans = 0 for i in range(1, n): ans += (n-1)//i print(ans)
p03150
s893061720
Accepted
s = input() k = 'keyence' k_size = len(k) d_size = len(s) - k_size result = "NO" for i in range(k_size): t = s[:i] + s[i+d_size:] if t == k: result = "YES" break print(result)
p02694
s393684155
Accepted
k = int(input()) r = 0.01 s = 100 n = 5 i = 0 while True: if k <= s: break else: s = int(s * (1 + r)) i = i + 1 print(i)
p03377
s705400932
Wrong Answer
a,b,x=map(int,input().split()) if a+b < x and a < x: print('YES') else: print('NO')
p03109
s621585574
Wrong Answer
S = list(input()) if S[5] == '1': print('TBD') elif S[6] == '1' or '2' or '3' or '4': print('Heisei') else: print('TBD')
p03681
s710075395
Accepted
n, m = map(int, input().split()) if abs(n - m) > 1: print(0) else: ret1 = 1 for i in range(1, n + 1): ret1 = (ret1 * i) % 1000000007 ret2 = 1 for i in range(1, m + 1): ret2 = (ret2 * i) % 1000000007 print((ret1 * ret2 * (2 if n == m else 1)) % 1000000007)
p03479
s622826166
Wrong Answer
import sys x,y = map(int,input().split()) cnt = 1 for i in range(1,60): if x*2 <= y: cnt += 1 x *= 2 else: print(cnt) sys.exit()
p02761
s811131002
Wrong Answer
n,m = map(int,input().split()) ans = list() sc_list = [list(map(str,input().split())) for _ in range(m)] if n == 0: j = 0 else: j = 10 ** n for k in range(j,10 ** n): st = str(i) for s,c in sc_list: if st[s] != c: break else: print(st) exit() else: print('-1')
p03797
s613081106
Accepted
N, M = map(int, input().split()) v = M - N * 2 # print('v', v) if v <= 0: print(M // 2) exit() ans = N + v // 4 print(ans)
p02957
s378483914
Wrong Answer
# -*- coding: utf-8 -*- a, b = map(int, input().split()) print((a+b)/2 if (a+b)%2==0 else 'IMPOSSIBLE')
p02814
s849669963
Wrong Answer
def get_gcd(a, b): while b != 0: a, b = b, a % b return a def get_lcm(a, b): return a * b // get_gcd(a, b) N, M = map(int, input().split()) A = list(map(int, input().split())) A = list(set(A)) B = A[0] if sum([a % 2 != 0 for a in A]) > 0: print(0) else: for b in A[1:]: ...
p03095
s479489207
Accepted
from collections import Counter _=input() s=input() s=Counter(s) ans=1 for i in s.values(): ans=(ans*(i+1))%(10**9+7) print(ans-1)
p02731
s964195757
Accepted
l = int(input()) print((l/3)**3)
p02973
s571446939
Wrong Answer
import sys from bisect import bisect_right read = sys.stdin.read readline = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 8) INF = float('inf') MOD = 10 ** 9 + 7 def main(): N = int(readline()) A = list(int(readline()) for _ in range(N)) LIS = [INF]*N A.reverse() for a in A: i = b...
p03377
s223261176
Wrong Answer
import sys import itertools sys.setrecursionlimit(1000000000) from heapq import heapify,heappop,heappush,heappushpop import collections a,b,x = map(int,input().split()) ab = a+b if x>=a and x<ab: print("Yes") else: print("No")
p03219
s178249300
Accepted
x,y = map(int,input().split()) print(x + int(y/2))
p02765
s392064972
Accepted
N,R=map(int,input().split()) if(N>=10):print(R) else:print(R+100*(10-N))
p02784
s191805844
Accepted
N,K = [int(x) for x in input().split()] A = [int(x) for x in input().split()] if sum(A)>=N: print("Yes") else: print("No")
p03767
s449497317
Accepted
N = int(input()) A = [int(i) for i in input().split()] sorted_A = sorted(A, reverse=True) print(sum(sorted_A[1:2*N:2]))
p02705
s899166618
Wrong Answer
import math as m r=int(input()) print(m.pi*r*r)
p02951
s544693951
Wrong Answer
a, b, c = map(int, input().split()) while b <= a: c -= 1 b += 1 print(c)
p03627
s186489131
Accepted
#!/usr/bin/env python3 import collections import itertools as it import math #import numpy as np # = input() n = int(input()) # = map(int, input().split()) l = list(map(int, input().split())) # = [int(input()) for i in range(N)] # c = collections.Counter(l) cmc = c.most_common() if cmc[0][1] == 1 or len(cmc) =...
p03038
s878747399
Accepted
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) N, M = lr() A = lr() BC = [lr() for _ in range(M)] BC.sort(key=lambda x: x[1], reverse=True) D = [] count = 0 for b, c in BC: x = [c] * b D.extend(x) count += b if cou...
p03785
s232917354
Accepted
n,c,k=map(int,input().split()) t=[int(input()) for i in range(n)] t=sorted(t) time=t[0] cnt=0 ans=0 for i in range(n): #制限時間以内かつC人以内 if time+k>=t[i] and cnt<=c-1: cnt+=1 else: ans+=1 time=t[i] cnt=1 print(ans+1)
p02659
s134932315
Wrong Answer
import math A,B = list(map(float, input().split())) print(int(A*int(B*100)/100))
p03274
s651750610
Accepted
n, k = map(int, input().split()) X = list(map(int, input().split())) ans = 10 ** 9 for i in range(n - k + 1): if X[i] * X[i + k - 1] < 0: dup = min(abs(X[i]), abs(X[i + k - 1])) * 2 sgl = max(abs(X[i]), abs(X[i + k - 1])) dist = dup + sgl else: dist = max(abs(X[i]), abs(X[i + k - 1])) ans = min(an...
p02747
s737003586
Accepted
s = input() n = len(s) if n % 2: print('No') exit() for i in range(0,n-1,2): if s[i:i+2] != 'hi': print('No') exit() print('Yes')
p02629
s311753465
Accepted
n = int(input()) s = [] while n!=0: if n<=26: s.append(n) n = 0 else: x = n % 26 #余りが0の場合には26にする if not x: x = 26 s.append(x) n = (n - 1) // 26 t = [] #求めた順番とは逆に並べる for i in range(len(s)-1,-1,-1): t.append(chr(s[i]+96)) print(''.join(t))
p03665
s921406277
Accepted
n,p = map(int,input().split()) a = [int(i) for i in input().split()] if all([i%2 == 0 for i in a]): if p == 1: print(0) else: print(pow(2,n)) else: print(pow(2,n-1))
p03107
s462471989
Accepted
S = input() zero = S.count("0") one = S.count("1") print(min(zero,one)*2)
p02596
s774673765
Accepted
K = int(input()) x = 7%K for i in range(K): if x == 0: print(i+1) exit() x = (x*10+7)%K print(-1)
p02583
s150944985
Accepted
n = int(input()) li = list(map(int, input().split())) ans = 0 for i in range(len(li)-2): for j in range(i+1,len(li)-1): for k in range(j+1,len(li)): a = li[i] b = li[j] c = li[k] if a==b or b==c or c==a: continue if a+b>c and b+c>a and c+a>b: ans += 1 print(ans)
p03289
s382534422
Wrong Answer
""" 1. The initial character of S is an uppercase A. 2. There is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive). 3. All letters except the A and C mentioned above are lowercase. """ import collections def a(r): return r[0] == 'A' def b(r): return ...
p02860
s347955035
Accepted
N = int(input()) S = input() if N%2==0: if S[:int(N/2)] == S[int(N/2):]: print('Yes') else: print('No') else: print('No')
p02873
s595489066
Accepted
S=input() right=[0]*(len(S)+1) for i in range(len(S)): if S[i]=="<": right[i+1]=right[i]+1 left=[0]*(len(S)+1) for i in range(len(S)-1,-1,-1): if S[i]==">": left[i]=left[i+1]+1 total=0 for i in range(len(S)+1): total+=max(right[i],left[i]) print(total)
p02689
s348137333
Wrong Answer
[n,m] = [int(i) for i in input().split()] h = [int(i) for i in input().split()] #table = [[0]*n for i in range(n)] ls = [1] * n for i in range(m): [a,b] = [int(j)-1 for j in input().split()] if h[a] < h[b]: ls[a] = 0 else: ls[b] = 0 print(sum(ls)) #print(ls)
p02661
s455181629
Accepted
from statistics import median N = int(input()) A = [0] * N B = [0] * N max=0 min =0 for c in range(N): A[c], B[c] = map(int, input().split()) med_A = median(A) med_B = median(B) if N%2==0: print(int((med_B-med_A)*2+1)) else: print(med_B-med_A+1)
p03317
s980536344
Accepted
def main(): n, k = map(int, input().split()) a_lst = list(map(int, input().split())) tmp = k count = 1 while tmp < n: tmp += k - 1 count += 1 print(count) if __name__ == '__main__': main()
p02554
s998137641
Accepted
N = int(input()) x = 10**N - 2*(9**N) + 8**N print(x % (10**9+7))
p03943
s488983346
Accepted
a,b,c=sorted(map(int,input().split())) print("Yes" if a+b==c else "No")
p02660
s381633021
Wrong Answer
n = int(input()) c = 0 for i in range(2,10000000): if n % i == 0: n = n//i c+=1 # print(i,n) if c == 0 and n > 1: print(1) else: print(c)
p03698
s587537255
Accepted
from collections import defaultdict import sys s = input() n = len(s) dic = defaultdict(int) for i in range(n): dic[s[i]] += 1 if dic[s[i]]==2: print("no") sys.exit() print('yes')
p02663
s795292353
Wrong Answer
h = list(map(int, input().split())) tmp = 0 if h[0] > h[2]: tmp = (24 - abs(h[0] - h[2])) * 60 else: tmp = (h[2] - h[0]) * 60 if h[1] > h[3]: tmp += (60 - abs(h[1] - h[3]) - 30) else: tmp += h[3] - h[1] ans = 0 while tmp > 0: tmp -= h[4] if tmp > 0: ans += h[4] print(ans)
p03289
s067364513
Accepted
s = input() if s[0] == 'A' and s[2:-1].count('C') == 1: for i in range(1,len(s)): if s[i].islower() == True: continue else: if s[i] == 'C': continue else: print('WA') exit() else: print('WA') exit() print('AC...
p03592
s001231059
Accepted
n,m,k = map(int, input().split()) # 行と列の組み合わせを全探索で試し、1回でも成立する場合は終了する for i in range(n+1): for j in range(m+1): if i*(m-j) + j*(n-i) == k: print("Yes") exit() print("No")
p02755
s340968958
Wrong Answer
A, B = map(int, input().split()) for i in range(1, 10000): if int(0.08 * i) == A and int(0.01 * i) == B: print(i) quit() print('-1')
p02924
s161163594
Accepted
N = int(input()) print(int((N*(N-1))//2))
p02552
s114324769
Accepted
value = int(input()) if value == 0: print("1") else: print("0")
p02598
s118127276
Accepted
(N, K) = [int(n) for n in input().split()] A = [int(n) for n in input().split()] L = 0 H = max(A) def feasible(M): # M: maximum length S = sum([(a - 1) // M for a in A]) #print("S = {}, K = {}".format(S, K)) return S <= K # assert(not feasible(L)) assert(feasible(H)) while H - L > 1: #print(H, L...
p03379
s518434486
Accepted
#!/usr/bin/env python3 n = int(input()) x = list(map(int,input().split())) a = sorted(x) for j in x: if j <= a[n//2-1]: print(a[n//2]) else: print(a[n//2-1])
p02730
s867102569
Accepted
S = input() N = len(S) if S[:] == S[N-1::-1] and S[0:N//2] == S[N//2-1::-1] and S[(N+3)//2-1:] == S[N-1:(N+3)//2-2:-1]: print("Yes") else: print("No")
p02780
s586641897
Accepted
N, K = map(int, input().split()) P = [(int(i)+1)/2 for i in input().split()] wa_temp = sum(P[0:K]) max_wa = wa_temp for i in range(N-K): wa_temp = wa_temp - P[i] + P[i+K] if wa_temp > max_wa: max_wa = wa_temp print(max_wa)
p03721
s170860686
Accepted
L=lambda:list(map(int,input().split())) n,k=L() ab=sorted([L()for _ in range(n)]) for a,b in ab: k-=b if k<=0: print(a) exit()
p03407
s743079712
Wrong Answer
a,b,c=map(int,input().split()) print('YNeos'[a+2*b<c::2])
p03012
s857738505
Accepted
n=int(input()) w=list(map(int,input().split())) ans=10000 for i in range(n): s1=0 s2=0 for j in range(i): s1=s1+w[j] for k in range(i, n): s2=s2+w[k] ans=min(ans, max(s1, s2)- min(s1, s2)) print(ans)
p03012
s661974624
Accepted
n,*w=map(int,open(0).read().split()) s=10**9 sum_w=sum(w) for i in range(1,n): s=min(s,abs(sum_w-2*sum(w[:i]))) print(s)
p02909
s724301848
Wrong Answer
print('CRSlauoinunndyyy'[id(id)%3::3])
p02606
s975874263
Accepted
L, R, d = map(int,input().split()) ans = 0 for i in range(L, R+1): if i % d == 0: ans += 1 print(ans)
p02682
s501929225
Accepted
A,B,C,K = map(int,input().split()) if K<=A: print(K) elif K<=A+B: print(A) elif K<=A+B+C: print(A-(K-B-A)) else: print(A-C)
p02613
s766920231
Wrong Answer
n = int(input()) S = [] for i in range(n): S.append(input()) cnt_ac = 0 cnt_tle = 0 cnt_wa = 0 cnt_re = 0 for i in range(n): if S[i] == "AC": cnt_ac += 1 elif S[i] == "TLE": cnt_tle += 1 elif S[i] == "WA": cnt_wa += 1 elif S[i] == "RE": cnt_re += 1 print("AC x " + ...
p04030
s659300448
Wrong Answer
a = input() a=a.replace("0B","") a=a.replace("1B","") if a.find("B"): a=a.replace("0B","") a=a.replace("1B","") if a.find("B"): a=a.replace("B","") print(a) else: print(a)
p03042
s233626836
Accepted
s = input() a = int(s[:2]) b = int(s[2:]) if 0<a<13: if 0<b<13: print("AMBIGUOUS") else: print("MMYY") else: if 0<b<13: print("YYMM") else: print("NA")
p02645
s006882200
Wrong Answer
import random S = input() for i in range(100): x = random.randrange(len(S)-2) print(S[x] + S[x + 1] + S[x + 2])
p02661
s648728947
Accepted
N = int(input()) AB = [list(map(int,input().split())) for _ in [0]*N] c = [0]*N d = [0]*N for i,ab in enumerate(AB): a,b = ab c[i] = a d[i] = b c.sort() d.sort(reverse=True) if N%2: L = c[N//2] R = d[N//2] print(R-L+1) else: L1 = c[N//2-1] R1 = d[N//2] L2 = c[N//2] R2 = d[N//2...
p03035
s901611958
Accepted
a,b = map(int,input().split()) if a>12: print(b) elif a>5: print(b//2) else: print(0)
p02836
s069568374
Accepted
S = list(input()) a = 0 SS = S[::-1] for i in range(len(S)): if S[i] != SS[i]: a = a+1 print(a // 2)
p02600
s761783412
Accepted
x = int(input()) if x >= 400 and x <= 599: print(8) elif x >= 600 and x <= 799: print(7) elif x >= 800 and x <= 999: print(6) elif x >= 1000 and x <= 1199: print(5) elif x >= 1200 and x <= 1399: print(4) elif x >= 1400 and x <= 1599: print(3) elif x >= 1600 and x <= 1799: print(2) elif x >=...
p03211
s416461311
Wrong Answer
s=input() l=len(s) a=float('inf') for i in range(l-2): x=int(s[i:i+3]) if abs(x-753)<a: ans=x a=abs(x-753) print(ans)
p03285
s316911870
Accepted
import sys input = sys.stdin.readline def main(): N = int(input()) ans = "No" while N >= 0: if N % 4 == 0: ans = "Yes" break N -= 7 print(ans) if __name__ == "__main__": main()
p02789
s215929957
Accepted
def main(): N, M = map(int, input().split(" ")) if N == M: print("Yes") else: print("No") if __name__ == '__main__': main()
p02612
s473166048
Accepted
# -*- coding: utf-8 -*- n = int(input()) print((1000-n%1000)%1000)
p02633
s331744121
Accepted
x = int(input()) for i in range(1,361): if (x * i) % 360 == 0: k = i break print(k)
p03377
s227697424
Accepted
A,B,X = map(int,input().split(" ")) if A+B<X: print("NO") else: if A>X: print("NO") else: if (X-A)>B: print("NO") else: print("YES")
p03087
s314728693
Wrong Answer
n,q = map(int,input().split()) s = input() t = [0]*(n+1) for i in range(n): t[i+1] = t[i] + (1 if s[i:i+2]=="AC" else 0) print(t) for i in range(q): l,r = map(int,input().split()) print(t[r-1]-t[l-1])
p02881
s955490704
Accepted
n = int(input()) a = int(n**(1/2)) ans = 0 for i in reversed(range(a + 1)): if n%i == 0: ans = i break else: pass ans2 = int(n/ans) print(ans + ans2 - 2)
p02725
s763240737
Accepted
K,N=map(int,input().split()) A=list(map(int,input().split())) A.append(K+A[0]) d=0 for i in range(N): d=max(d,A[i+1]-A[i]) print(K-d)
p04012
s597449398
Wrong Answer
s = sorted(list(input())) for i in range(97, 97 + 26): print(s.count(chr(i))) if s.count(chr(i)) %2 != 0: print('NO') exit() print('YES')
p02570
s107037121
Accepted
x, y, z = list(map(int, input().split())) if(x<=y*z): print("Yes") else: print("No")
p03838
s290331101
Accepted
x, y = map(int, input().split()) cand = [(-x, y, 1), (x, y, 0), (-x, -y, 2), (x, -y, 1)] ans = 10e9 for a, b, c in cand: if a <= b: if ans > b - a + c: ans = b - a + c print(ans)
p03041
s870200740
Accepted
N, K = map(int,input().split()) S = input() print(S[:K-1]+S[K-1:K].lower()+S[K:])
p03998
s920202850
Accepted
S={c:list(input()) for c in "abc"} s="a" while S[s]:s=S[s].pop(0) print(s.upper())
p02957
s773940604
Wrong Answer
A,B=map(int,input().split()) if (A+B)%2==0: print((A+B)/2) else: print("IMPOSSIBLE")
p03360
s055922969
Accepted
a, b, c = sorted(list(map(int, input().split()))) k = int(input()) print(a+b+c*(2**k))
p02699
s338597199
Accepted
s, w = map(int, input().split()) print("unsafe" if w >= s else "safe")
p02935
s779444237
Accepted
n = int(input()) v = list(map(int,input().split())) v.sort() ans = v[0] for i in v: ans = (ans + i)/2 print(ans)
p03479
s807116408
Accepted
X, Y = map(int, input().split()) n = 0 A = X while A <= Y: n += 1 A *= 2 print(n)
p02814
s448354486
Accepted
n,m=map(int,input().split()) a=list(map(int,input().split())) import math def lcm(x, y): return (x * y) // math.gcd(x, y) x=1 for i in range(n): x=lcm(x,a[i]//2) power=[0]*n for i in range(n): while a[i]%2==0: a[i]//=2 power[i]+=1 if power.count(power[0])==n: print((m+x)//(2*x)) else: print...
p03944
s907555244
Accepted
w,h,n = map(int,input().split()) xs = 0 ys = 0 xe = w ye = h for i in range(n): x,y,a = map(int,input().split()) if a == 2: xe = min(xe,x) elif a == 1: xs = max(xs,x) elif a == 4: ye = min(ye,y) else: ys = max(ys,y) if xs < xe and ys < ye: print(abs(xs-xe)*abs(ys-...
p02730
s565769828
Accepted
S = list(input()) N = len(S) ans = "Yes" for i in range((N-1)//2): if ans == "Yes": if S[i] != S[N -1 - i]: ans = "No" for i in range((N-1)//2 -1): if ans == "Yes": if S[i] != S[(N - 1)//2 -1 - i]: ans = "No" for i in range((N-1)//2 - 1): if ans == "Yes": i...
p03030
s545950797
Wrong Answer
n = int(input()) rc = [list(map(str,input().split())) for i in range(n)] rc = (list(enumerate(rc))) rc.sort(key=lambda x:x[1][0], reverse=False) rc.sort(key=lambda x:x[1][1], reverse=True) for i in rc: print(i[0]+1)
p02729
s782905875
Accepted
def keisan(x): ret_val=0 for i in range(1,x): ret_val+=i return ret_val N,M=map(int,input().split()) print(keisan(N)+keisan(M))
p02948
s223881736
Wrong Answer
# ABC-137-D import heapq N, M = map(int, input().split()) BA = [] for _ in range(N): A, B = map(int, input().split()) BA.append((-1*B, A)) heapq.heapify(BA) ans = 0 check_M = 1 while check_M <= M: try: max_B = heapq.heappop(BA) except: break if max_B[1] <= check_M: ans += (-...
p03221
s384288358
Accepted
N, M = map(int, input().split()) x = [[] for _ in range(N)] a = [None] * M for i in range(M): P, Y = map(int, input().split()) x[P-1].append(Y) a[i] = (P, Y) y = {} for i in range(N): x[i].sort() for j, Y in enumerate(x[i]): y[(i+1, Y)] = j + 1 for i in range(M): print('{}{}'.format(st...
p02780
s032652371
Accepted
n, k = map(int, input().split()) P = list(map(int, input().split())) ans = 0 E = [] for p in P: E.append(p*(p+1)/(2*p)) cumsumE = [0] for e in E: cumsumE.append(cumsumE[-1] + e) for i in range(0, n+1-k): ans = max(ans, cumsumE[i+k]-cumsumE[i]) print(ans)
p03479
s258772329
Accepted
import sys input = sys.stdin.readline def main(): X, Y = [int(x) for x in input().split()] ans = 0 x = X while x <= Y: x = x * 2 ans += 1 print(ans) if __name__ == '__main__': main()
p03803
s051832947
Wrong Answer
x = input() # x = x.replace(1,14) # replaceは,文字列しか使えない. ls_x = x.split() # xに入力した文字列たちを整数化 for i in range(len(ls_x)): ls_x[i] = int(ls_x[i]) if ls_x[0] == ls_x[1]: print("Draw") if ls_x[0] == 1: print("Alice") elif ls_x[1] == 1: print("Bob") elif ls_x[0] > ls_x[1]: print("Alice") elif ls_x[0]...
p02996
s864593191
Accepted
from collections import deque N = int(input()) A = deque() for _ in range(N): a,b = list(map(int,input().split())) A.append([b,a]) A = list(A) A.sort() time = 0 for i in A: time += i[1] if time > i[0]: print('No') exit() print('Yes')
p02630
s474697469
Wrong Answer
n=int(input()) a=list(map(int,input().split())) q=int(input()) bc=[list(map(int,input().split())) for i in range(q)] asum=sum(a) #当初の数列Aの要素の和 d={} for i in a: if i in d: d[i]+=1 else: d[i]=1 for b,c in bc: print(b) print(c) if b in d: asum+=d[b]*(c-b) if c in d: d[c]+=d[b] else: ...