problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02647
s842560560
Accepted
n, k = map(int, input().split()) a = list(map(int, input().split())) #n = 2 * 10 ** 5 #a = [0] * n cnt = 0 while cnt < k: imos = [0] * (n + 1) for i in range(n): imos[max(i - a[i], 0)] += 1 imos[min(i + a[i] + 1, n)] -= 1 for i in range(n): imos[i + 1] += imos[i] a = imos[0:n...
p02661
s546213309
Wrong Answer
n=int(input()) m=[] M=[] for _ in range(n): x,y=map(int,input().split()) m.append(x) M.append(y) m=sorted(m) M=sorted(M) z=n//2 if n%2==1: a=m[z] b=M[z] print(b-a+1) else: a=(m[z]+m[z-1])//2 b=(M[z]+M[z-1])//2 print(2*(b-a)+1)
p02792
s904024182
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import defaultdict N = int(read()) counter = defaultdict(int) for x in map(str,range(1,N+1)): head = x[0] tail = x[-1] counter[(head, tail)] += 1 ans = 0 items = list(counte...
p03250
s411725924
Accepted
l = sorted(list(map(int,input().split()))) print(10*l[2]+l[1]+l[0])
p02836
s448554262
Wrong Answer
S=input() count=0 for i in range(len(S)): if S[i]!=S[-i-1]: count+=1 print(count)
p03962
s303889337
Wrong Answer
if __name__ == "__main__": a, b, c = map(int,input().split()) ans = 3 if a == b: ans -= 1 if b == c: ans -= 1 if c == a: ans -= 1 print(ans)
p03161
s830596293
Accepted
import numpy as np n,k = list(map(int,input().split())) h=np.array([int(i) for i in input().split()]) dp = np.array([0]*n) for i in range(1,n): j=max(0,i-k) dp[i] = np.min(dp[j:i]+abs(h[i]-h[j:i])) print(dp[-1])
p02778
s713291676
Wrong Answer
s = input() print('×' * len(s))
p02759
s184142929
Accepted
# -*- coding: utf-8 -*- N = int(input()) print((N + 1) // 2)
p02833
s085994224
Accepted
import math N = int(input()) if N % 2 == 0: ans = 0 for i in range(0, 26): ans += N // (5 ** i * 10) print(ans) else: print(0)
p02973
s698988524
Accepted
#import sys #import numpy as np import math #from fractions import Fraction import itertools from collections import deque from collections import Counter import heapq #from fractions import gcd #input=sys.stdin.readline import bisect n=int(input()) d=[] a=(int(input()))*-1 d.append(a) ans=1 for i in range(n-1): a...
p03711
s907136128
Wrong Answer
a = [1,3,5,7,8,10,12] b = [4,6,9,11] x,y = map(int, input().split()) if (x in a and b in a) or (x in b and y in b): print("Yes") else: print("No")
p02753
s433087991
Wrong Answer
x = list(input()) if x[0] == x[1] and x[1]==x[2]: print("Yes") else: print("No")
p03419
s032406458
Wrong Answer
N, M = map(int,input().split()) total = N * M sumi = 4 if N >= 2 and M >= 2: hen = (N-2) * 2 + (M-2) * 2 ans = total - sumi - hen elif N == 1 and M > 1: hen = M-2 ans = hen elif N > 1 and M == 1: hen = N - 2 ans = hen else: ans = 0 print(ans)
p02813
s474582154
Wrong Answer
n=int(input()) s=list(map(int,input().split())) q=list(map(int,input().split())) li=[] for i in range(1,n+1): for j in range(1,n+1): for k in range(1,n+1): if i==k or i==j or j==k: continue else: li.append([i,j,k]) result1=0 result2=0 for i in range(len(li)): if li[i]==s: resul...
p03827
s592792121
Wrong Answer
import sys input = sys.stdin.readline N = int(input()) S = list(input().rstrip()) maxx = -(10 ** 9) x = 0 for i in S: if i == "I": x += 1 else: x -= 1 if x > maxx: maxx = x print(x)
p02802
s416746461
Wrong Answer
n,m = map(int,input().split()) count_ac = 0 count_wa = 0 l = [('','')]*m memo_n = [] idx = 0 for i in range(m): t = tuple(input().split()) l[i] = t if t[1] == 'AC' and t[0] not in memo_n: memo_n.append(t[0]) count_ac += 1 count_wa += l[idx:i+1].count((t[0],'WA')) idx = i pri...
p03605
s603687092
Accepted
S = input() if ("9" in S) == True: result = "Yes" else: result = "No" print(result)
p03644
s937808103
Wrong Answer
n = int(input()) a = 0 b = 0 c = 0 for i in range(1, n+1): j = i while j%2 == 0: a += 1 j = j/2 if a > b: b = a c = i a = 0 print(c)
p03087
s528231643
Accepted
n,q=(map(int,input().split())) s=input() count=0 c=[0]*n for i in range(1,n): if s[i-1]=='A': if s[i]=='C': count+=1 c[i]=count for _ in range(q): l,r=(map(int,input().split())) print(c[r-1]-c[l-1])
p02622
s213595956
Accepted
S = str(input()) T = str(input()) count = 0 for i in range(len(S)): if S[i] != T[i]: count = count + 1 print(count)
p03986
s473297196
Wrong Answer
X = list(input()) N = len(X) NHALF = N // 2 def solve2(): leadt = 0 nt, ns = 0, 0 for i in range(N): if nt == NHALF: break if X[i] == 'T': nt += 1 if ns == 0: leadt += 1 else: ns += 1 return N - 2 * min(ns, NHALF - ...
p02910
s510813271
Accepted
s = list(input()) ans = 'Yes' for i in range(len(s)): if i%2!=0 and not(s[i]=='L' or s[i]=='U'or s[i]=='D'): ans = 'No' elif i%2==0 and not(s[i]=='R' or s[i]=='U'or s[i]=='D'): ans = 'No' print(ans)
p02646
s159074151
Accepted
a,v = map(int,input().split()) b,w = map(int,input().split()) t = int(input()) k = v-w m = abs(a-b) if k*t >= m: print("YES") else: print("NO")
p03136
s748027828
Accepted
n=int(input()) l=list(map(int,input().split())) allsum=sum(l) mx = max(l) if mx < allsum-mx: print('Yes') else: print('No')
p03785
s376162955
Accepted
N,C,K = list(map(int,input().split())) T = [0]*N for i in range(N): T[i] = int(input()) T.sort() i = 0 ret = 0 while i < N: j = i ret += 1 while j < N and j < i+C and T[j] <= T[i]+K: j += 1 i = j print(ret)
p02993
s784663073
Accepted
S = input() Sl = list(S) if Sl[0] == Sl[1]: print('Bad') elif Sl[1] == Sl[2]: print('Bad') elif Sl[2] == Sl[3]: print('Bad') else: print('Good')
p03250
s620491385
Accepted
A,B,C = map(int,input().split()) print(max(10*A+B+C,10*B+C+A,10*C+A+B))
p03469
s782947332
Wrong Answer
x = input() print("2018" + x[6:])
p02697
s656465627
Accepted
n,m=map(int,input().split()) b=m//2 a=m-b for i in range(a): print(1+i,2*a-i) for i in range(b): print(2*a+1+i,2*a+2*b+1-i)
p03555
s614234900
Accepted
c1=list(input()) c2=list(input()) if c1[0]==c2[2] and c1[1]==c2[1] and c1[2]==c2[0]: print('YES') else: print('NO')
p02939
s688747862
Accepted
import sys li = list(input()) new_li = [] if len(li) == 1: print(1) sys.exit() tmp = '' for i,l in enumerate(li): if i == 0: new_li.append(li[0]) continue if len(tmp)>0: new_li.append(tmp+l) tmp = '' elif new_li[-1] != l: new_li.append(l) else: tmp...
p02743
s090825218
Wrong Answer
a, b, c = map(int, input().split()) ans = 'Yes' if (a + b - c + 2*(a*b)**0.5) < 0 else 'No' print(ans)
p03087
s675017655
Accepted
N, Q = map(int, input().split()) S = input() s = S[:2] ans = 'AC' lst = [0] count = 0 for i in range(N-1): s = S[i] + S[i + 1] count += (s == ans) lst.append(count) for _ in range(Q): a, b = map(int, input().split()) print(lst[b - 1] - lst[a - 1])
p02657
s269213955
Accepted
a, b = map(int, input().split()) print(a * b)
p03261
s302673001
Wrong Answer
N = int(input()) a = [] flag = 0 for i in range(N): t = input() if t not in a: a.append(t) else: flag = 1 if flag == 0: print('Yes') else: print('No')
p03455
s649636708
Wrong Answer
a, b = map(int, input().split()) if a%2 == 0 and b%2 == 0: print('Even') else: print('Odd')
p03251
s342054916
Accepted
n,m,X,Y = map(int,input().split()) x = max(list(map(int,input().split()))) y = min(list(map(int,input().split()))) if y-x > 0 and x < Y and y > X: print('No War') else: print('War')
p02630
s772567327
Accepted
N = int(input()) A = list(map(int, input().split())) Q = int(input()) from collections import defaultdict d = defaultdict(int) S = 0 for a in A: d[a] += 1 S += a for _ in range(Q): b, c = map(int, input().split()) S += d[b] * (c - b) print(S) d[c] += d[b] d[b] = 0
p02597
s837183485
Wrong Answer
n = int(input()) wr = input() j = n ans = 0 for i in range(0,n): if wr[i] == 'W': while j>=1: j-=1 if wr[j] == 'R': ans+=1 break print(ans)
p03289
s995614493
Accepted
S = input() if S[0] == "A" and "C" in S[2:-1] and S.count("C") == 1 and len([s for s in S if s.isupper()]) == 2: print("AC") else: print("WA")
p03632
s629062701
Accepted
a,b,c,d = map(int,input().split()) count = 0 for i in range(101): if a<=i<b and c<=i<d:count+=1 print(count)
p03730
s311380474
Accepted
#9 B - Choose Integers AC(hint) A,B,C = map(int,input().split()) result = 'NO' num = 0 #(k+B)A%B = (kA + AB)%B = kB for i in range(1,B+1): num = (A*i)%B if num == C: result = 'YES' break print(result)
p02802
s977125373
Accepted
N,M = map(int,input().split()) correct = [0]*N penalty = [0]*N ans_c,ans_p = 0,0 for i in range(M): p,s = input().split() p = int(p) if s=="AC": if correct[p-1]==0: correct[p-1]+=1 if s=="WA": if correct[p-1]==0: penalty[p-1]+=1 ans_penalty = 0 for i in range(N):...
p02554
s590862020
Wrong Answer
N = int(input()) print(10**N-2*9**N+8**N)
p02640
s982360534
Accepted
x, y = map(int, input().split()) aa = y - 2 * x a = aa / 2 print('Yes' if 0 <= a <= x and aa % 2 ==0 else 'No')
p03105
s607951612
Wrong Answer
A,B,C=map(int,input().split()) if B<C: print(0) elif A*C>B: print(A) else: print(C)
p02963
s855232308
Accepted
s=int(input()) x1,y1=0,0 x2,y2=10**9,1 x3,y3=0,0 mod=10**9 r=(mod-s%mod)%mod q=(s+r)/mod x3=int(r) y3=int(q) print(x1,y1,x2,y2,x3,y3)
p03545
s446163129
Accepted
from itertools import product A,B,C,D = list(input().strip()) for x in product(("+","-"),repeat=3): if eval(A+x[0]+B+x[1]+C+x[2]+D)==7: print(A+x[0]+B+x[1]+C+x[2]+D+"=7") break
p02948
s526610638
Accepted
import heapq N,M=map(int,input().split()) W=[list(map(int,input().split())) for _ in range(N)] a=[[i,0] for i in range(1,M+2)] W.extend(a) W.sort() q=[] ans=0 for i,j in W: if i>M+1: break if j!=0: heapq.heappush(q,-j) else: heapq.heappush(q,-j) ans-=heapq.heappop(q) print(an...
p02970
s214028508
Wrong Answer
n,d = [int(i) for i in input().split()] a = 2*d+1 print((n+d-1)//d)
p03986
s349374548
Wrong Answer
def cal(): x = input() i = 0 while i <= 2*10**5: i += 1 x1 = x.replace('ST', '', 10**5) print(len(x)) cal()
p02628
s774504737
Accepted
#!/usr/bin/env python3 N, K = list(map(int, input().split())) p_list = list(map(int, input().split())) ans = sum(sorted(p_list)[:K]) print(ans)
p02790
s512558728
Accepted
a, b = input().split() aa, bb= "", "" for i in range(int(b)): aa += a for i in range(int(a)): bb += b if int(aa) >= int(bb): print(aa) else: print(bb)
p02939
s798018499
Wrong Answer
s = list(input()) i = len(s) p = 0 while i >= 3: if s[i-1] == s[i-2]: i -= 3 p += 2 else: i -= 1 p += 1 print(p + 1)
p03407
s493596840
Accepted
a,b,c = map(int,input().split()) print("Yes" if a+b >= c else "No")
p03013
s600209215
Accepted
N, M = map(int, input().split()) a = [0] * (N+1) for _ in range(M): i = int(input()) a[i] = 1 dp = [0] * (N+2) dp[N] = 1 mod = 1000000007 for i in range(N-1, -1, -1): if a[i]: dp[i] = 0 continue dp[i] = (dp[i+1] + dp[i+2]) % mod print(dp[0])
p03264
s753790304
Wrong Answer
k=int(input()) if k%2==0: print((k/2)**2) else: print((k//2)*(k//2+1))
p02789
s838706545
Accepted
a = input() l = a.split() n = int(l[0]) m = int(l[1]) if n == m: print("Yes") else: print("No")
p03862
s925846065
Wrong Answer
def LI(): return list(map(int,input().split())) N,x = LI() a = LI() ans = 0 sum_a = [] for i in range(N-1): sum_a.append(a[i]+a[i+1]) sum_a = [0]+sum_a+[0] for j in range(N): if sum_a[j]>x: ans += sum_a[j]-x sum_a[j+1] -= sum_a[j]-x print(ans)
p03309
s113379143
Accepted
import sys import math def input(): return sys.stdin.readline()[:-1] def mi(): return map(int, input().split()) def ii(): return int(input()) def main(): N = ii() A = list(mi()) for i in range(N): A[i] -= i+1 median = sorted(A)[N//2] print(sum(abs(A[i]-median) for i in range(...
p03239
s757142667
Wrong Answer
N, T = map(int, input().split()) min_c = 1001 for _ in range(N): c, t = map(int, input().split()) if t <= T and c < min_c: min_c = c print('TLE' if min_c == 1000 else min_c)
p02833
s635546703
Accepted
L = [10, 50, 250, 1250, 6250, 31250, 156250, 781250, 3906250, 19531250, 97656250, \ 488281250, 2441406250, 12207031250, 61035156250, 305175781250, 1525878906250, \ 7629394531250, 38146972656250, 190734863281250, 953674316406250, \ 4768371582031250, 23841857910156250, 119209289550781250, 59604644775390625...
p02623
s188678966
Accepted
n,m,k=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) a,b=[0],[0] for i in range(n): a.append(a[i]+A[i]) for i in range(m): b.append(b[i]+B[i]) ans,j=0,m for i in range(n+1): if a[i]>k: break while b[j]>k-a[i]: j-=1 ans=max(ans,i+j) print(a...
p02584
s438251216
Accepted
it = lambda: list(map(int, input().strip().split())) def solve(): X, K, D = it() X = abs(X) if X - K * D >= 0: return X - K * D K = K - X // D X = X - X // D * D assert K >= 0 assert X >= 0 return abs(X) if K % 2 == 0 else abs(X - D) if __name__ == '__main__': ans = solve(...
p02760
s696270017
Wrong Answer
x, y, z = input().split() a, b, c = input().split() d, e, f = input().split() N = int(input()) for i in range(1, N+1): i = input() if i == x or i == y or i == z or i == a or i == b or i ==c or i == d or i == e or i == f: print('Yes') else: print('No')
p03493
s583513732
Accepted
S = list(input()) cnt = S.count('1') print(cnt)
p03860
s476893562
Accepted
a, b, c = map(str, input().split()) A = [i for i in a] B = [i for i in b] C = [i for i in c] print(A[0]+B[0]+C[0])
p02707
s798523568
Accepted
N=int(input()) A=list(map(int,input().split())) B=[0]*N for i in range(N-1): B[A[i]-1]+=1 for i in range(N): print(B[i])
p03699
s764999925
Wrong Answer
N = int(input()) S = [int(input()) for _ in range(N)] S.sort() res = sum(S) i = 0 while res > 0 and res % 10 == 0: res -= S[i] i -= 1 print(res)
p02727
s613588146
Wrong Answer
from heapq import heappop,heappush x,y,a,b,c=map(int,input().split()) p=list(map(int,input().split())) p.sort(reverse=1) q=list(map(int,input().split())) q.sort(reverse=1) r=list(map(int,input().split()))+[0] r.sort(reverse=1) h=[] m=p[0] for i in range(x): heappush(h,p[i]) m=min(m,p[i]) for i in range(y): heappu...
p02900
s478680727
Accepted
import fractions a,b=map(int,input().split()) g=fractions.gcd(a,b) ans=1 i=2 while i*i<=g: if g%i==0: ans+=1 while g%i==0: g//=i i+=1 if g>1: ans+=1 print(ans)
p03037
s141298679
Accepted
n, m = map(int, input().split()) LR = [list(map(int, input().split())) for _ in range(m)] L_max = 0 R_min = 10 ** 5 + 1 for L, R in LR: L_max = max(L_max, L) R_min = min(R_min, R) ans = R_min - L_max + 1 if ans < 0: print(0) else: print(ans)
p03555
s854200589
Accepted
s = [ list(input()) for i in range(2)] t = [ [0 for j in range(3)] for i in range(2) ] for i in range(2): for j in range(3): t[1-i][2-j] = s[i][j] print("YES" if s == t else "NO")
p03705
s359742900
Accepted
n , a, b = map(int, input().split()) if b < a: print(0) exit() if n == 1: if a != b: print(0) exit() else: print(1) exit() print((n-2) * (b-a) + 1)
p03457
s085923004
Wrong Answer
N = int(input()) t = [0]*100001 x = [0]*100001 y = [0]*100001 for n in range(N): t[n+1], x[n+1], y[n+1] = map(int, input().split()) ans = True for n in range(N): dt = t[n+1] - t[n] dist = (x[n+1] - x[n]) + (y[n+1] - y[n]) if dt < dist: ans = False if dt % 2 != dist % 2: ans = False...
p02879
s780937305
Accepted
a,b = map(int,input().split()) print(a*b if max(a,b) < 10 else -1)
p02608
s739840509
Wrong Answer
import itertools import math import collections def func(x,y,z): return x**2+y**2+z**2+x*y+y*z+z*x n = int(input()) s = int(math.sqrt(n)) nums = list(range(1,s)) arr = [] com = list(itertools.product(nums, repeat=3)) for i in range(len(com)): # print(com) ans = func(com[i][0],com[i][1],com[i][2]) arr...
p03043
s292485624
Accepted
A=list(map(int,input().split())) N=A[0] K=A[1] p=0 for i in range(1,N+1): count=0 while i<=K-1: i=i*2 count=count+1 p=p+(1/2)**(count) print(p/N)
p03760
s238194025
Wrong Answer
o = input() e = input() lis = [] for i in range(max(len(o),len(e))-1): lis.append(o[i]) lis.append(e[i]) if len(o)>len(e): lis.append(o[-1]) elif len(o)==len(e): lis.append(o) lis.append(e) print(''.join(lis))
p02814
s245756824
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) half = [i//2 for i in A] def f(v): r = 0 while v % 2 == 0: v /= 2 r += 1 return r from fractions import gcd def f2(x, y): return (x * y) // gcd(x, y) d = f(A[0]) for ai in A: if d != f(ai): print(0) ...
p03252
s879170067
Accepted
from collections import Counter S=input() T=input() SS=Counter(S) TT=Counter(T) if sorted(SS.values())==sorted(TT.values()): print('Yes') else: print('No')
p02697
s746509821
Accepted
n, m = map(int, input().split()) if m%2 == 0: gu_max, ki_max = m, m-1 else: gu_max, ki_max = m-1, m gu_start = 1 ki_start = 1 + gu_max + 1 for sa in range(m)[::-1]: sa += 1 if sa%2 == 0: print(gu_start, gu_start+sa) gu_start += 1 else: print(ki_start, ki_start+sa) k...
p03773
s832478883
Accepted
a,b = map(int, input().split()) if a + b >= 24: print(a + b - 24) else: print(a + b)
p02570
s442193613
Accepted
d, t, s = map(int, input().split()) if d/s <= t: print("Yes") else: print("No")
p02787
s540387199
Accepted
H, N = map(int, input().split()) dp = [[0] + [1e20] * (H) for _ in range(N)] for i in range(N): A, B = map(int, (input().split())) for j in range(1, H + 1): dp[i][j] = min(dp[i - 1][j], dp[i][max(j - A, 0)] + B) print(dp[-1][-1])
p02628
s383691204
Accepted
N,K = map(int,input().split()) p = list(map(int,input().split())) ans = 0 for i in range(K): ans += min(p) p.remove(min(p)) print(ans)
p03289
s689278084
Accepted
S = input() if S[0] != "A": print("WA") exit() elif S[2:-1].count("C") != 1 or S[:2].count("C") != 0 or S[-1:].count("C") != 0: print("WA") exit() else: S = S[1:].replace("C", "") if S.islower(): print("AC") else: print("WA")
p02848
s954791636
Wrong Answer
n=int(input()) ans = "" for c in input(): ans+= chr((ord(c)+n)) print(ans)
p03592
s763239140
Accepted
import sys n, m, k = map(int, input().split()) for i in range(n+1): for j in range(m+1): if i*(m-j)+(n-i)*j == k: print('Yes') sys.exit() print('No')
p02777
s449879339
Wrong Answer
list1 = input() list1 = list1.split(' ') list2 = input() list2 = list2.split(' ') list3 = input() S = list1[0] T = list1[1] lenS = int(list2[0]) lenT = int(list2[1]) select = list3[0] if select == S: lenS -= 1 else: lenT -= 1 print(lenS,lenT)
p03017
s838078020
Wrong Answer
n, a, b, c, d = map(int, input().split()) s = input() ss = s[min(a-1, b-1): max(c, d)] if ss.count("##") or ((d < c or b < a) and ss.count("...") == 0): print("No") else: print("Yes")
p03030
s299473705
Accepted
n=int(input()) d=[] for i in range(n): s,p=input().split() d.append((s,100-int(p),i+1)) d.sort() for i in range(n): print(d[i][2])
p02835
s728609072
Accepted
a,b,c=map(int,input().split()) if a+b+c>=22: print('bust') else: print('win')
p02983
s783077228
Accepted
# -*- coding: utf-8 -*- """ Created on Tue May 12 13:43:11 2020 @author: shinba """ import sys import itertools l,r = map(int,input().split()) if l % 2019 == 0: print(0) sys.exit() else: if l//2019 +1 <= r/2019: print(0) sys.exit() l %= 2019 r %= 2019 ans = float("inf") for i in iterto...
p03077
s615239279
Accepted
N = int(input()) move = [] for _ in range(5): move.append(int(input())) min_value = min(move) group_count = -(-N // min_value) # 最後のグループが出発するまでの値はgroup_count - 1 print(group_count - 1 + 5)
p04011
s981012860
Accepted
n,k,x,y = [int(input()) for i in range(4)] print(n*x-(x-y)*max(n-k,0))
p03475
s855828741
Accepted
N = int(input()) C = [0]*(N-1) S = [0]*(N-1) F = [0]*(N-1) for i in range(N-1): C[i], S[i], F[i] = map(int, input().split()) for i in range(N): t = 0 for j in range(i, N-1): if t < S[j]: t = S[j] elif t % F[j] == 0: pass else: t = t + F[j] - (t % ...
p02608
s622413383
Accepted
# -*- coding: utf-8 -*- def score(x,y,z): return pow(x,2)+pow(y,2)+pow(z,2)+(x*y)+(y*z)+(z*x) N = int(input()) num = [0 for i in range(N)] # x,y,zは高々10^2 for x in range(1,100): for y in range(1,100): for z in range(1,100): value = score(x,y,z) if value <= N: n...
p02909
s700220352
Wrong Answer
s=input() if s=="Sunny": print("Cloudy") if s=="Cloudy": print("Rainy") else: print("Sunny")