problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02729
s640964985
Accepted
import math s = input().split() n=int(s[0]) k=int(s[1]) result=0 if n>1: result+=math.factorial(n)/math.factorial(2)/math.factorial(n-2) if k>1: result+=math.factorial(k)/math.factorial(2)/math.factorial(k-2) print(int(result))
p02612
s435765496
Accepted
n = int(input()) print((-n)%1000)
p03779
s840867829
Accepted
def main(): import sys x=int(input()) cnt=0 if x==1: print(1) sys.exit() if x==2: print(2) sys.exit() for i in range(1,x): if cnt<x: cnt+=i else: t=i-1 break print(t) if __name__=='__main__': main()
p03331
s960256025
Accepted
n=int(input()) if n in [10,100,1000,10000,100000]: print(10) else: sum=0 for i in range(len(str(n))): sum+=n%10 n=n//10 print(sum)
p02832
s305105868
Wrong Answer
n = int(input()) a = list(map(int, input().split())) if a.count(1) == 0: print(-1) exit() cnt = 1 for i in range(a.index(1), n): if a[i] == cnt + 1: cnt += 1 print(i) print(len(a) - cnt)
p02835
s336419088
Accepted
a,b,c=map(int,input().split()) if a+b+c>=22: print("bust") if a+b+c<=21: print("win")
p02790
s026447624
Wrong Answer
a, b = map(int, input().split()) print(str(min(a,b))*min(a,b))
p03719
s735719749
Accepted
a,b,c=map(int,input().split()) print("Yes"if c>=a and c<=b else"No")
p02755
s965911869
Accepted
import math a,b=map(int,input().split()) ans=-1 for i in range(1,5000): #print(int(i*0.08)) if math.floor(i*0.08)==a and math.floor(i*0.1)==b: #print(int(i*0.08)) ans=i break print(ans)
p03475
s425097614
Accepted
import math N = int(input()) data = [] for _ in range(N-1): data.append(list(map(int,input().split()))) def time(t, i): if t <= data[i][1]: return data[i][0] + data[i][1] else: k = math.ceil((t - data[i][1]) / data[i][2]) return data[i][0] + data[i][1] + k * data[i][2] for i in ra...
p03131
s164720294
Accepted
K,A,B=map(int,input().split()) q,r=divmod(K-A+1,2) print(max(A+q*(B-A)+r,K+1))
p03001
s698238986
Wrong Answer
w,h,x,y=map(int,input().split()) if x==w/2 and y==h//2: print("{} {}".format(w*h/2,1)) else: print("{} {}".format(w*h/2,0))
p03760
s315068911
Accepted
o = str(input()) e = str(input()) password = "" for i in range(min(len(o), len(e))): password += o[i] + e[i] if len(o) != len(e): password += o[-1] print(password)
p02687
s939310120
Accepted
c = input() if c == "ARC": print("ABC") elif c == "ABC": print("ARC")
p02783
s630114549
Wrong Answer
h, a = map(int,input().split()) print(int(h/a)+1)
p03264
s410435466
Accepted
N = int(input()) if (N % 2 == 0): print(int((N/2)*(N/2))) else: par=int(N/2) impar=N-par print(int(par*impar))
p02576
s915938719
Accepted
import math n, x, t = map(int, input().split(" ")) out = int(math.ceil(n/x)) * t if x != 0 else 0 print(out)
p02971
s062185281
Accepted
n = int(input()) a = [int(input()) for _ in range(n)] s = sorted(a) one, two = s[-1], s[-2] for i in a: print(one if i != one else two)
p02681
s472390738
Accepted
#!/usr/bin/env python3 def main(): S = input() T = input() if S == T[:-1:]: print('Yes') else: print('No') if __name__ == "__main__": main()
p03037
s572815732
Accepted
n,m = map(int,input().split()) count = 0 lmax = 0 rmin = 100000 for i in range(m): l,r = map(int,input().split()) lmax = max(l,lmax) rmin = min(r,rmin) print(max(rmin-lmax+1,0))
p02879
s607993899
Accepted
if __name__ == "__main__": A, B = input().split() if len(A) == 1 and len(B) == 1: print(int(A) * int(B)) else: print("-1")
p03478
s810764463
Wrong Answer
N,A,B = map(int,input().split()) count = 0 for i in range (1,N+1): a=i//1000 b=(i%1000)//100 c=(i-a*1000-b*100)//10 d=i%10 #print(a,b,c,d) e = a+b+c+d if e>=A and e<=B: count += i print(count)
p03679
s593441146
Wrong Answer
x, a, b = map(lambda x: int(x), input().split()) if b < a: print('delicious') elif x <= b - a: print('safe') else: print('dangerous')
p02933
s386140302
Wrong Answer
a = int(input()) s = input() if a >= 3200: print('s') if a < 3200: print('red')
p03062
s168630101
Wrong Answer
N=int(input()) A=list(map(int,input().split())) for i in range(N-1): abs_a = list(map(abs, A)) min_a = min(abs_a) for i in range(N-1): if A[i] < 0: A[i] = -A[i] A[i+1] = -A[i+1] if A[N-1] < 0: print(sum(abs_a) - min_a * 2) else: print(sum(abs_a))
p03698
s661162469
Wrong Answer
S = input() len_orig = len(S) s = set() for i in range(len(S)): s.add(S[i]) if len(s)==len_orig: print("Yes") else: print("No")
p03339
s749216052
Wrong Answer
N=int(input()) S=input() ap=[0]*(N+1) bp=[0]*(N+1) a=0 b=0 for i in range(N): if S[i]=='W': a+=1 else: b+=1 ap[i+1]=a bp[i+1]=b ans=10**9 for j in range(N): ans=min(ap[j-1]+bp[N]-bp[j],ans) print(ans)
p02882
s924042121
Accepted
a, b, x = map(int, input().split()) a_ = 2 * x / a / b import math #print(a_, a, b, x) if a_ < a: ang = math.degrees(math.atan(b / a_)) print(ang) else: b_ = 2 * ((a**2) * b - x) / (a**2) ang = math.degrees(math.atan(b_ / a)) print(ang)
p02909
s954494163
Wrong Answer
a = input() if a == "Sunny": print("Cloudy") elif a == "cloudy": print("Rainy") else: print("Sunny")
p03767
s137259266
Accepted
N = int(input()) a = list(map(int, input().split())) a.sort(reverse=True) ans = 0 for i in range(1, len(a)-N): if i % 2 == 1: # print(a[i]) ans += a[i] print(ans)
p02760
s514851651
Wrong Answer
a = [input().split() for i in range(3)] n = int(input()) b = [int(input()) for i in range(n)] total = [] s = 0 for i in range(n): for k in range(3): for j in range(3): if b[i] == int(a[k][j]): total.append(s + j) s = s + 3 if ((0 and 1 and 2) in total) or ((3 and 4 and 5) in total) or ((6 and ...
p02833
s764236570
Accepted
N = int(input()) ans = 0 i = 1 while 5**i <= N: ans += ((N // (2 * 5**i))) i+=1 if N % 2: print(0) else: print(ans)
p03243
s661933425
Accepted
n = int(input()) for i in range(1,10): x = i*111 if n <=x: print(x) exit()
p03433
s166753217
Accepted
print('YNeos'[int(input())%500>int(input())::2])
p02953
s653974777
Accepted
n = int(input()) nums = list(map(int,input().split())) tall = 0 for i in nums: if tall - i >=2: print('No') exit() tall = max(tall,i) print('Yes')
p02600
s419295623
Wrong Answer
x = int(input()) for i in range(3, 10): if i * 200 > x: print(11 - i) exit()
p02577
s927306210
Wrong Answer
N = int(input()) s = [] for i in range(len(str(N))): s.append(N % 10) N // 10 if sum(s) % 9 == 0 and sum(s) != 0: print('Yes') else: print('No')
p02708
s396073825
Wrong Answer
N,K = map(int,input().split()) s = int(((N+1)*((N+1)**2 + 5))/6 -((K-1)*((K-1)**2 + 5))/6) print(s%(10**9 + 7))
p02691
s279782952
Accepted
N = int(input()) A = list(map(int, input().split())) L = {} R = {} for i in range(N): t = A[i]+i if t in L: L[t] += 1 else: L[t] = 1 s = i - A[i] if s in R: R[s] += 1 else: R[s] = 1 #print(L,R) ans = 0 for i in range(N): t = A[i]+i #ans += R[t] if t in R.keys(): ans += R[t]...
p03659
s495769033
Accepted
import numpy as np n = int(input()) a = np.array(list(map(int, input().split()))) cumsum_a = a.cumsum() sum_a = cumsum_a[-1] ans = 2 * 10**9 for i in range(n-1): ans = min(ans, abs(sum_a - 2*cumsum_a[i])) print(ans)
p02597
s247375116
Accepted
n = int(input()) c = input() left, right = 0, n - 1 cnt = 0 while left <= right: while left < n and c[left] == 'R': left += 1 while right > -1 and c[right] == 'W': right -= 1 if left == n or right == -1 or left >= right: break left += 1 right -= 1 cnt += 1 print(cnt)
p03696
s076820610
Wrong Answer
n = int(input()) s = list(input()) c0 = 0 c1 = 0 z0 = 0 z1 = 0 for i in range(n): if s[i] == "(": c0 += 1 else: c1 += 1 if c0 < c1 and s[i] != "(": z0 += 1 if c0 > c1 - z0 and s[i] != ")": z1 += 1 ans = ["("]*z0 + s + [")"]*max(z1-1,0) print("".join(ans))
p03252
s661789648
Accepted
def main(): import copy s, t = input(), input() a = [[] for _ in range(26)] b = copy.deepcopy(a) for i, j in zip(s, t): x, y = map(lambda x: ord(x) - 97, [i, j]) a[x].append(y) b[y].append(x) f = all(len(set(i)) <= 1 for i in a) g = all(len(set(i)) <= 1 for i in b) ...
p02646
s273054536
Wrong Answer
a, v = map(int, input().split()) b, w = map(int, input().split()) t = int(input()) if a < b: if w < v and (b-a)%(v-w)==0 and int((b-a)/(v-w)) <= t: print("YES") else: print("NO") else: print("NO")
p02760
s870550570
Accepted
a = [[int(x) for x in input().split()] for _ in range(3)] n = int(input()) for _ in range(n): b = int(input()) for i in range(3): for j in range(3): if b == a[i][j]: a[i][j] = 0 ans = "No" for i in range(3): if sum(a[i]) == 0: ans = "Yes" for j in range(3): if a[0][j] + a[1][j] +...
p02957
s750808422
Wrong Answer
a, b = map(int, input().split()) if (a+b)%2 != 0: print('IMPOSSIBLE') else: print((a+b)/2)
p02603
s449305683
Wrong Answer
import math from itertools import groupby N = int(input()) A = list(map(int, (input().split()))) cash = 1000 stock = 0 A = [i[0] for i in groupby(A)] if (A[0] == max(A)): print(cash) else: for i in range(len(A)-1): if (A[i] > A[i+1]): cash = cash + stock*A[i] stock = 0 el...
p03067
s161529155
Accepted
a,b,c = (int(x) for x in input().split()) if a<c<b or b<c<a: print("Yes") else: print("No")
p03220
s841805629
Accepted
import sys input = sys.stdin.readline N = int(input()) T,A = [int(i) for i in input().split()] H = [int(i) for i in input().split()] d = 1000000000000 index = 0 for i in range(N) : dT = T - H[i] * 0.006 dd = abs(A - dT) if dd < d : d = dd index = i print(index+1)
p03862
s556849298
Accepted
import sys import numpy as np def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def mi(): return map(int, input().split()) def li(): return list(mi()) def main(): n, x = mi() a = li() cnt = 0 for i in range(1,n): if a[i-1]+a[i]>x: cnt += a[i-1]+a[i]-x ...
p03323
s333731705
Wrong Answer
n_str = input() a_str, b_str = n_str.split() a = int(a_str) b = int(b_str) if a <= 8: if b <= 8: print('Yay!') else: print(':(') elif a > 8: if b <= 8: print('Yay!') else: print(':(')
p03761
s591920658
Accepted
n = int(input()) import collections a = list(input()) ans = collections.Counter(a) for i in range(n-1): l = collections.Counter(list(input())) for i in ans.keys(): if i in l: ans[i] = min(ans[i],l[i]) else: ans[i] = 0 l = [] for i in ans.keys(): for j in range(ans[i]...
p04045
s614361955
Accepted
N,K=map(int,input().split()) Dlist=list(map(int,input().split())) flag=True i=0 while flag: ans=str(i) num=0 if i>=N: for j in range(len(ans)): if int(ans[j]) not in Dlist: num+=1 if num==len(ans): print(i) flag=False ...
p03324
s022297104
Accepted
D, N = map(int, input().split()) if N != 100: if D == 0: print(N) elif D == 1: x = [100 * i for i in range(1, 101)] print(x[N-1]) elif D == 2: x = [10000 * i for i in range(1, 101)] print(x[N-1]) else: if D == 0: print(101) elif D == 1: x = [100 * i for i in range(1, 101)] prin...
p02795
s551948228
Wrong Answer
h = int(input()) w = int(input()) n = int(input()) a = max(h, w) ans = 1 while a < n: a = max(h, w) a *= ans ans += 1 print(ans-1)
p02693
s743400680
Accepted
def main(): K = int(input()) A, B = list(map(int, input().split(' '))) for n in range(A, B + 1): if n % K == 0: print('OK') exit(0) print('NG') if __name__ == '__main__': main()
p03455
s353741498
Wrong Answer
a = 10 print(10)
p02970
s587644755
Wrong Answer
n,d=map(int,input().split()) a=n//(2*(d+1))+1 print(a)
p03087
s708758022
Accepted
n, q = map(int, input().split()) s = input() ls = [0] * n for i in range(n-1): if s[i] == 'A' and s[i+1] == 'C': ls[i+1] = ls[i]+1 else: ls[i+1] = ls[i] ans = [] for i in range(q): l, r = map(int, input().split()) ans.append(ls[r-1] - ls[l-1]) for x in ans: print(x)
p03555
s322231755
Accepted
c1 = input() c2 = input() c3 = c1[::-1] c4 = c2[::-1] if c1 == c4 and c2 == c3: print('YES') else: print('NO')
p02660
s894337366
Wrong Answer
n=int(input()) ans=0 r=int(n**0.5)+1 for i in range(2,r): if n%i==0: ans+=1 n/=i if ans==0 and not n==0: ans=1 print(ans)
p03293
s211571100
Accepted
s = str(input()) t = str(input()) isOK = False for i in range(1,len(s)+1): if s==t[-i:]+t[:-i]: isOK = True break if isOK: print('Yes') else: print('No')
p03994
s141470421
Accepted
import string s=list(input()) k=int(input()) str=string.ascii_lowercase abc=str+str s_len=len(s) for i in range(s_len): si_inx=abc.index(s[i]) if i==s_len-1: k%=26 s[i]=abc[si_inx+k] break if s[i]=='a': continue if k>=26-si_inx: k-=26-si_inx s[i]='a' else: continue if k<=0...
p02682
s769288554
Accepted
a,b,c,k = map(int,input().split()) ans = 0 if k >= a: k -= a ans += a if k >= b: k -= b if k > 0: ans -= k print(ans) else: ans = k print(ans)
p03485
s732495044
Wrong Answer
a,b=map(int,input().split()) print(round((a+b)/2))
p02663
s426985214
Accepted
H1,M1,H2,M2,K = map(int,input().split()) print((H2-H1)*60+(M2-M1)-K)
p04033
s671467298
Accepted
# -*- coding: utf-8 -*- import sys sys.setrecursionlimit(10**9) INF=10**18 MOD=10**9+7 input=lambda: sys.stdin.readline().rstrip() YesNo=lambda b: bool([print('Yes')] if b else print('No')) YESNO=lambda b: bool([print('YES')] if b else print('NO')) int1=lambda x:int(x)-1 a,b=map(int,input().split()) if a*b<0: prin...
p03799
s515204074
Accepted
n, m = map(int, input().split()) if n >= m // 2: print(m // 2) else: print((n + m // 2) // 2)
p02946
s411756327
Accepted
import sys K,X = map(int,input().split()) if not ( 1 <= K <= 100 and 0 <= X <= 100 ): sys.exit() for I in range(X-K+1,X+K): print(I)
p02700
s155104594
Wrong Answer
A, B, C, D = map(int, input().split()) if A == C: if B>D: print("Yes") else: print("No") elif(A>C): print("Yes") elif(C>A): print("No")
p03136
s660483911
Accepted
N=int(input()) li=list(map(int,input().split())) if 2*max(li)<sum(li): print("Yes") else: print("No")
p04012
s495932868
Accepted
from collections import Counter w=input() c=Counter(w) a=0 c=list(c.values()) for i in range(len(c)): if c[i]%2!=0: print("No") exit() print("Yes")
p03767
s319392546
Accepted
N = int(input()) A = list(map(int, input().split())) A.sort(reverse=True) answer = 0 for i in range(N): answer += A[1+2*i] print(answer)
p02615
s756130417
Accepted
N = int(input()) A = list(map(int, input().split())) B = [] for a in A: B.append(a) B.append(a) B.sort() B.pop() ans = 0 for i in range(N - 1): ans += B.pop() print(ans)
p03221
s761136088
Accepted
N, M = map(int, input().split()) X = [list(map(int, input().split())) for _ in range(M)] res = [""] * M ctr = [0] * (N + 1) for i, (p, y) in sorted(enumerate(X), key=lambda x: (x[1][0], x[1][1])): ctr[p] += 1 res[i] = "{:0>6}{:0>6}".format(p, ctr[p]) print(*res, sep="\n")
p03472
s873915546
Accepted
def LI(): return list(map(int, input().split())) N, H = LI() amax = 0 blist = [] for _ in range(N): a, b = LI() amax = max(amax, a) blist.append(b) blist.sort() ans = 0 for i in range(N-1, -1, -1): if blist[i] <= amax: break ans += 1 H -= blist[i] if H <= 0: break if ...
p04044
s862958933
Accepted
N, S = input().split() str_list = [input() for _ in range(int(N))] print("".join(sorted(str_list)))
p02755
s510633689
Accepted
A,B=map(int,input().split()) cnt=0 for i in range(1010): if int(i*0.08)==A and int(i*0.1)==B: print(i) break else: cnt+=1 if cnt==1010: print(-1)
p04019
s734263121
Wrong Answer
a = str(input()) n = 0 e = 0 s = 0 w = 0 for i in a: if i=="N": n+=1 if i=="E": e+=1 if i=="S": s+=1 if i=="W": w+=1 if n==s and e==w: print("Yes") elif n>s: print("Yes") else: print("No")
p02982
s131436547
Accepted
n, d = map(int, input().split()) a = [list(map(int, input().split())) for _ in range(n)] b = 0 for i in range(n): for j in range(i + 1, n): s = 0 for c, e in zip(a[i], a[j]): s += (c - e) ** 2 if s ** 0.5 == int(s ** 0.5): b += 1 print(b)
p03035
s208379697
Accepted
a,b=map(int,input().split()) c=0 if a>=13: print(b) elif 6<=a<=12: print(b//2) else: print(c)
p04020
s780319729
Accepted
n = int(input()) ans = 0 rem = 0 for _ in range(n): a = int(input()) ans += (a+rem)//2 if (a+rem)%2 == 1 and a > 0: rem = 1 else: rem = 0 print(ans)
p02555
s652850899
Wrong Answer
S = int(input()) L = S//3 res = 0 from scipy.special import comb for l in range(1,L+1): s = S - l*3 #a = cmb_(s, l) a = comb(s+l-1, l-1, exact=True) res += a print(res)
p03821
s451612661
Accepted
n=int(input()) a=[0]*n b=[0]*n for i in range(n): a[i],b[i]=map(int,input().split()) ans=0 for i in range(n)[::-1]: a[i]+=ans if not a[i]%b[i]==0: ans+=b[i]-a[i]%b[i] print(ans)
p03109
s417538982
Wrong Answer
def still_tdb(s): return "Heisei" if s < "2019/04/30" else "TBD" def main(): s = str(input()) print(still_tdb(s)) if __name__ == '__main__': main()
p02767
s559170473
Wrong Answer
N = int(input()) X = list(map(int,input().split())) X.sort() min = 100*100 for t in range(1, 101): sum = 0 for x in X: sum += (x - t)**2 if sum < min: min = sum print(min)
p03037
s424192312
Wrong Answer
n , m = map(int , input().split()) l = -10 r = 100000 for i in range(m): j = list(map(int , input().split())) l = max(l , j[0]) r = min(r , j[1]) print(min(r - l + 1 , n))
p03730
s870666852
Accepted
a,b,c=map(int,input().split()) amari = [] flag = True i = 0 FLAG = False while flag: check = b*i+c if check % a ==0: FLAG = True flag = False else: if 0 == amari.count(check % a): amari.append(check%a) else: flag = False i = i + 1 if FLAG: print("YES") else: print("NO")
p02678
s850684086
Accepted
from collections import deque n, m = map(int, input().split()) to = [[] for _ in range(n)] for i in range(m): a, b = [int(i) - 1 for i in input().split()] to[a].append(b) to[b].append(a) dist = [0] + [-1] * (n - 1) pre = [-1] * n search = deque([0]) while search: v = search.popleft() for u in to[v]...
p03854
s020838985
Accepted
s=input() import re #re.match は複数を対象にすればマッチする該当のものが返される。一つの時ifの後に持ってくると条件式として利用可能。 if re.match("^(dream|dreamer|erase|eraser)+$",s) : print("YES") else: print("NO")
p04043
s981623239
Accepted
l = list(map(int, input().split())) count_5 = 0 count_7 = 0 for r in l: if r == 5: count_5 += 1 if r == 7: count_7 += 1 if count_5 == 2 and count_7 == 1: print('YES') else: print('NO')
p02948
s234782973
Wrong Answer
n,m=map(int,input().split()) X=[] for i in range(n): a,b=map(int,input().split()) X.append([a,b]) Y=sorted(X,key=lambda x:(x[1],x[0]), reverse=True) ans=0 d=0 for i in range(n): if d+Y[i][0]<=m: ans+=Y[i][1] d+=1 print(ans)
p03544
s970983394
Accepted
N=int(input()) Lucas=[2,1] for i in range(2,N+1): lucas_num = Lucas[i-1] + Lucas[i-2] Lucas.append(lucas_num) print(Lucas[N])
p03385
s149185292
Accepted
s=list(input()) cnt_a=s.count('a') cnt_b=s.count('b') cnt_c=s.count('c') if cnt_a==cnt_b==cnt_c: print('Yes') else: print('No')
p03617
s682810144
Accepted
def main(): Q, H, S, D = map(int, input().split()) N = int(input()) Q4 = 4*Q H2 = 2*H D12 = D/2 M = min(Q4, H2, S) if D12 < M: ans = (N//2)*D + (N%2)*M else: ans = N*M print(ans) if __name__ == "__main__": main()
p02747
s591678522
Accepted
S = input() def is_hitachi(S): hitachi = [ 'hi', 'hihi', 'hihihi', 'hihihihi', 'hihihihihi', ] if S in hitachi: return 'Yes' else: return 'No' print(is_hitachi(S))
p02742
s626254269
Accepted
H, W = map(int, input().split()) if (H==1) or (W == 1): print(1) elif (H%2==0) or (W%2==0): print(int(H*W/2)) else: print(int((H*W+1)/2))
p03997
s304417057
Accepted
a,b,h=[int(input()) for i in range(3)] print(int((a+b)*h/2))
p02633
s378693534
Accepted
x = int(input()) k = 1 while(True): if k * x % 360 == 0: print(k) break else: k += 1
p03385
s219810406
Accepted
S = input() list = ['a','b','c'] if S[0] in list: list.remove(S[0]) if S[1] in list: list.remove(S[1]) if S[2] in list: print('Yes') else: print('No') else: print('No') else: print('No')