problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p03481
s838716490
Wrong Answer
import math x,y = map(int,input().split()) num = y//x ans = int(math.log2(num)) + 1 print(ans)
p02555
s242105319
Accepted
s = int(input()) mod = 10**9 + 7 f = [0]*2001 g = [0]*2001 f[3]=1 f[4]=1 g[3]=1 g[4]=2 for i in range(4,s+1): f[i]=1 + g[i-3] f[i]%=mod g[i]=f[i] + g[i-1] g[i]%=mod print(f[s])
p03001
s434146554
Accepted
W, H ,x, y = map(int, input().split()) if W == H: if x == W/2 and y == H/2: can = 1 else: can = 0 else: if x == W/2 or y == H/2: if x == W/2 and y == H/2: can = 1 else: can = 0 else: if y == (H/W)*x or y == (-H/W)*x: can = 0 else: can = 1 print('{:.9f}'.format(W...
p02646
s198379109
Wrong Answer
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) if V <= W: print("NO") exit() d = abs(A - B) s = V - W if d < s * T: print("YES") else: print("NO")
p02918
s091620275
Accepted
n,k=map(int,input().split()) s=input() t=s[0] ans=0 u=0 f=True for i in range(1,n): if t==s[i]: ans+=1 else: t=s[i] if f: f=False else: f=True u+=1 if k<=u: ans+=2*k if k>u: ans=n-1 print(ans)
p03219
s414946479
Wrong Answer
X, Y = map(int, input().split()) print(X + (Y / 2))
p03455
s401326106
Wrong Answer
a, b = map(int, input().split()) c= a*b if c%2 == 0: print('even') else: print('odd')
p02572
s655014586
Accepted
n=int(input()) l=list(map(int,input().split())) mod=10**9+7 ans=pow(sum(l)%mod,2,mod) for i in range(n): ans-=l[i]**2 ans%=mod ans*=pow(2,mod-2,mod) print(ans%mod)
p03162
s873084186
Wrong Answer
N=int(input()) dp=[[0]*3 for i in range(N+1)] for i in range(1,N): a=list(map(int,input().split())) for j in range(3): for k in range(3): if j==k: continue dp[i][k]=max(dp[i][k],dp[i-1][j]+a[k]) print(max(dp[-1]))
p02697
s325788867
Accepted
from collections import Counter,defaultdict,deque from heapq import heappop,heappush,heapify from bisect import bisect_left,bisect_right import sys,math,itertools,fractions,pprint sys.setrecursionlimit(10**8) mod = 10**9+7 INF = float('inf') def inp(): return int(sys.stdin.readline()) def inpl(): return list(map(int, ...
p02829
s790823605
Wrong Answer
ans = 6 for _ in range(2): a = int(input()) ans += a print(6 - ans)
p02706
s421864832
Accepted
N, M = map(int, input().split()) A = list(map(int, input().split())) for i in range(M): N -= A[i] if N>=0: print(N) elif N < 0: print(-1)
p03943
s116212909
Wrong Answer
a=list(map(int,input().split()));print("NYoe s"[sum(a)//2in a::2])
p03252
s007022655
Wrong Answer
import sys sys.setrecursionlimit(10 ** 7) f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): S = input() T = input() check = {} for s, t in zip(S, T): if check.get(t, 0) != 0: if check.get(t) != s: print("No") break else: che...
p02753
s032993062
Accepted
S = str(input()) if S == "AAA": ans = 'No' elif S == "BBB": ans = 'No' else: ans = 'Yes' print(ans)
p03485
s452860424
Wrong Answer
a,b = map(int, input().split()) print(((a+b)//2)+1)
p02598
s340059245
Accepted
from heapq import heappush, heappop from math import ceil, floor N, K = map(int, input().split()) A = [int(i) for i in input().split()] ng, ok = 0, 10 ** 9 for _ in range(50) : mid = (ng + ok) / 2 ret = 0 for a in A : ret += floor(a / mid) if ret <= K : ok = mid else : ng = mid print(ceil(ng...
p03210
s553185277
Accepted
x=int(input()) if x==3 or x==5 or x==7: print('YES') else: print('NO')
p03317
s483151711
Accepted
from math import ceil N, K = map(int, input().split()) A = list(map(int, input().split())) ans = ceil((N-1)/(K-1)) print(ans)
p03145
s478766695
Accepted
# coding: utf-8 import sys sr = lambda: sys.stdin.readline().rstrip() ir = lambda: int(sr()) lr = lambda: list(map(int, sr().split())) a, b, c = lr() answer = a * b // 2 print(answer)
p02947
s170188750
Accepted
import math import collections N = int(input()) String = [] for i in range (0, N): S = str(input()) S = sorted(S) V = str(S[0]) for j in range (1, 10): V = V+str(S[j]) String.append(V) cnt = collections.Counter() for word in String: cnt[word] += 1 V = cnt.most_common() count = 0 for i in range (0, len...
p03210
s615083039
Accepted
x = int(input()) ans = "YES" if (x == 3 or x == 5 or x == 7) else "NO" print(ans)
p02848
s227958011
Accepted
nim = int(input()) data = input() result = "" for i in data: result+=chr(65+(ord(i)-65+nim)%26) print(result)
p03827
s258608263
Accepted
n=int(input()) s=list(input()) k=[0] for i in range(0,n): if s[i]=='I':k.append(int(k[i]+1)) else:k.append(int(k[i]-1)) print(max(k))
p02627
s119925123
Accepted
alpha = input() ans = 'A' if alpha.isupper() else 'a' print(ans)
p02953
s475549332
Accepted
# C - Build Stairs N = int(input()) H = [int(h) for h in input().split()] ans = 'Yes' for i in range(1, N): if H[i - 1] <= H[i] - 1: H[i] -=1 if H[i] < H[i - 1]: print('No') break else: print('Yes')
p02859
s767214302
Accepted
#!/usr/bin/env python3 def main(): r=int(input()) ans=r**2 print(ans) if __name__ == "__main__": main()
p03944
s088470536
Wrong Answer
import sys input = sys.stdin.readline W,H,N = list(map(int,input().split())) x0 = 0 y0 = 0 x1 = W y1 = H for i in range(N): x,y,a = list(map(int,input().split())) if a == 1: x0 = max(x,x0) elif a == 2: x1 = min(x,x1) elif a == 3: y0 = max(y,y0) elif a == 4: y1 = mi...
p03493
s747943251
Wrong Answer
a = input() b = int(a) count = 0 for i in range(len(a)-1): ichi = b/10 if ichi == 1: count+=1 b %= 10 print(count)
p02706
s262541304
Accepted
INT = lambda: int(input()) INTM = lambda: map(int,input().split()) STRM = lambda: map(str,input().split()) STR = lambda: str(input()) LIST = lambda: list(map(int,input().split())) LISTS = lambda: list(map(str,input().split())) def do(): n,m=INTM() a=LIST() print(max(n-sum(a),-1)) if __name__ == '__main__': ...
p03637
s706916923
Accepted
a = int(input()) list = list(map(int, input().split())) m=[0]*3 for i in list: if i%4==0: m[0]+=1 elif i%2==0: m[1]+=1 else: m[2]+=1 if(m[0]+1>=m[2]+m[1]%2): print("Yes") else: print("No")
p03351
s576147646
Accepted
a,b,c,d=map(int,input().split()) if abs(c-a)<=d: print('Yes') elif abs(b-a)<=d and abs(c-b)<=d: print('Yes') else: print('No')
p02765
s318245646
Wrong Answer
N = 2 X = [1,4] ans = [] count = 0 for i in range(1,N+1): number = 0 count = 0 for j in X: number = number + ((j-i)**2) count = count + 1 if N == count: ans.append(number) print(min(ans))
p02952
s185359009
Accepted
N = int(input()) count, n1, n2 = 0, 1, 9 while n1 <= N: if n2 <= N: count += n1 * 9 else: count += (N - n1 + 1) n1, n2 = n1 * 100, n1 * 1000 - 1 print(count)
p03427
s988334668
Accepted
N = int(input()) N = N + 1 N_str = str(N) first_N = int(N_str[0]) - 1 num = len(N_str)-1 print(num*9+first_N)
p02912
s152517604
Accepted
#n=int(input()) n,m=map(int,input().split()) al=list(map(int,input().split())) #l=[list(map(int,input().split())) for i in range(n)] import math import heapq hq=[(-1)*val for val in al] heapq.heapify(hq) for i in range(m): mx=(-1)*(heapq.heappop(hq)) newval=math.floor(mx/2) heapq.heappush(hq,(-1)*newval...
p03469
s436467194
Wrong Answer
print("2018"+input())
p03150
s035184379
Accepted
S = str(input()) str_keyence = "keyence" if S.find("keyence")==0 or S.rfind("keyence")==len(S)-7: print("YES") else: for i in range(1,7): #print(str_keyence[0:i],str_keyence[i:]) #print(S.find(str_keyence[0:i])) #print(S.find(str_keyence[i:])) if S.find(str_keyence[0:i])==0 and S.rfind(str...
p02832
s695633113
Wrong Answer
N=int(input()) a=list(map(int,input().split())) ans=0 l=1 for i in a: if i!=l: ans+=1 else: l+=1 print(ans)
p02618
s949411600
Accepted
D=int(input()) c=list(map(int,input().split())) s=[list(map(int,input().split())) for i in [0]*D] k=[] for i in range(D): l=-1 p=0 for j in range(26): q=s[i][j]-sum([c[a]for a in k]) p=max([p,q]) if p==q: l=j if l==-1: l=k[-1] k+=[l] print(l+1)
p03041
s335258589
Wrong Answer
N, K = map(int, input().split()) S = list(input()) S[K-1].lower() C = ''.join(S) print(C)
p03038
s936212858
Wrong Answer
N,M=map(int,input().split()) A=list(map(int,input().split())) B=[0]*M C=[0]*M D=[] for i in range(M): B[i],C[i]=map(int,input().split()) D+=[C[i]]*B[i] D.reverse() A.sort() for i in range(sum(B)): if A[i] < D[i]: A[i]=D[i] else: break if i==N-1: break print(sum(A))
p02989
s399112686
Wrong Answer
# For taking integer inputs. def inp(): return(int(input())) # For taking List inputs. def inlist(): return(list(map(int, input().split()))) # For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable. ...
p03797
s258940340
Accepted
N, M = map(int, input().split()) if N <= M/2: ans = N + (M - 2*N)//4 else: ans = M//2 print(ans)
p02547
s151454076
Accepted
N = int(input()) cnt = 0 ans = 'No' for i in range(N): x,y = [int(x) for x in input().split()] if x == y: cnt += 1 if cnt == 3: ans = 'Yes' else: cnt = 0 print(ans)
p02606
s079481893
Accepted
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines read = sys.stdin.buffer.read sys.setrecursionlimit(10 ** 7) INF = float('inf') L, R, d = map(int, input().split()) ans = 0 for i in range(L, R+1): if i % d == 0: ans += 1 print(ans)
p02623
s683159295
Accepted
n,m,k=map(int,input().split()) A=[0]+list(map(int,input().split())) B=[0]+list(map(int,input().split())) ans=0 for i in range(1,n+1): A[i]+=A[i-1] for j in range(1,m+1): B[j]+=B[j-1] b_cnt=m for a_cnt in range(n+1): if A[a_cnt]>k: continue while A[a_cnt]+B[b_cnt]>k: b_cnt-=1 ans=max(ans,a_cnt+b...
p03623
s791552756
Wrong Answer
S = list(input()) S.sort() S = set(S) alphabet = list("abcdefghijklmnopqrstuvwxyz") for i in alphabet: if i in S: if i == "z": print("None") else: pass elif i not in S: print(i) break
p02796
s770612719
Wrong Answer
# お尻から見ていってはやく始まる方を数え上げれば良い N = int(input()) data = [] for _ in range(N): X, L = map(int, input().split()) data.append((X-L+1, X+L-1)) data.sort() count = 1 j = N-1 for i in range(N-2, -1, -1): if data[i][1] <= data[j][0]: j = i count += 1 print(count)
p03971
s833863440
Accepted
N, A, B = map(int, input().split()) S = input() student_pass = A + B abroad_student_pass = B passed_students = 0 passed_students_abroad = 0 for status in S: if status == 'c': print('No') elif status == 'a': if passed_students < student_pass: print('Yes') passed_students += 1 else: pr...
p02693
s585336125
Accepted
k=int(input()) a,b=map(int,input().split()) f=0 for i in range(a,b+1): if i%k==0: f=1 print('OK' if f==1 else 'NG')
p02663
s197329945
Wrong Answer
h1,m1,h2,m2,k=map(int,input().split()) print(h1*60+m1-k-m2-60*h2)
p03352
s601677218
Accepted
x=int(input()) ans=0 for b in range(1,int(x**(1/2)+1)): for p in range(1,11): if b**p<=x and b**p>ans: ans=b**p print(ans)
p02963
s794553278
Accepted
S=int(input()) M=10**9 Q,R=divmod(S,M) if R: print(0,0,M,1,M-R,Q+1) else: print(0,0,M,1,0,Q)
p02612
s362719105
Wrong Answer
N=int(input()) if (N%1000)>=500: print(1000-(N%1000)) else: print((N%1000))
p03352
s861031970
Wrong Answer
x = int(input()) i = 1 while (i+1)**2 <= x: i += 1 print(i**2)
p03000
s605107071
Wrong Answer
n, x = map(int, input().split()) l = list(map(int, input().split())) d = 0 cnt = 0 for i in l: if d <= x: d += i cnt+= 1 else: cnt -= 1 print(cnt) print(cnt)
p03360
s332215298
Wrong Answer
a, b, c = map(int, input().split()) k = int(input()) list = [a, b, c] max = max(list) if a == max: print(b+c+a*2*k) elif b == max: print(a+c+b*2+k) else: print(a+b+c*2*k)
p03254
s504205559
Accepted
N, x = map(int, input().split()) a_list = sorted(list(map(int, input().split()))) for i in range(N): x = x - a_list[i] if x < 0: break if i == N-1 and x == 0: i += 1 print(i)
p03611
s872896407
Accepted
n = int(input()) A = list(map(int, input().split())) A = sorted(A) from bisect import bisect_left ans = 0 for i in range(0, A[-1]+1): cnt = bisect_left(A, i+2) - bisect_left(A, i-1) ans = max(ans, cnt) #print(i, cnt) print(ans)
p02696
s608207525
Accepted
A, B, N = map(int, input().split()) r = min(B-1, N) print(A*r//B)
p03127
s467922375
Accepted
N=int(input()) A=map(int,input().split()) import math from functools import reduce print(reduce(math.gcd, A))
p02917
s302226501
Accepted
n = int(input()) b = list(map(int,input().split())) a = [] a.append(b[0]) for i in range(1,n-1): a.append(min(b[i],b[i-1])) a.append(b[n-2]) print(sum(a))
p03035
s005998081
Accepted
a,b=map(int,input().split()) if a>=13: print(b) elif 6 <= a < 13: print(b//2) else: print(0)
p02847
s462384393
Accepted
s = input() if s == "SUN": print(7) elif s == "MON": print(6) elif s == "TUE": print(5) elif s == "WED": print(4) elif s == "THU": print(3) elif s == "FRI": print(2) else: print(1)
p03251
s258711218
Accepted
N, M, X, Y = map(int, input().split()) x = list(map(int, input().split())) y = list(map(int, input().split())) x.sort() y.sort() f = True for i in range(X + 1, Y + 1): if x[-1] < i <= y[0]: f = False break if f: print("War") else: print("No War")
p03107
s985679468
Wrong Answer
s=input() l=[] for ss in s: l.append(ss) n=len(s) cnt=0 i=0 while cnt<=n and i<=len(l)-2: if l[i]=='0' and l[i+1]=='1': if i<0: i=0 cnt+=2 del l[i:i+2] i=i-1 elif l[i]=='1' and l[i+1]=='0': if i<0: i=0 cnt+=2 del l[i:i+2] i=i-1 else: i+=1 print(cnt)
p04005
s833871199
Accepted
A, B, C = map(int, input().split()) if A % 2 == 0 or B % 2 == 0 or C % 2 == 0: print(0) else: l = sorted([A, B, C]) print(l[0]*l[1])
p02726
s402180197
Wrong Answer
N,X,Y = map(int,input().split()) matrix = [[0 for n in range(0,N)] for nn in range(0,N)] for n in range(N): for i in range(n+1,N): s = i+1 d = n+1 p1 = abs(s-d) p2 = abs(s-X)+abs(d-Y) p3 = abs(s-Y)+abs(d-X) matrix[n][i] = min(p1,p2,p3) matrix = sum(matrix,[]) for n in...
p03106
s569673088
Accepted
a, b, k = map(int, input().split()) s = [] for i in range(1, min(a, b) + 1): if a % i == 0 and b % i == 0: s.append(i) print(s[len(s)-k])
p03146
s972917324
Accepted
s = int(input()) l = [] l.append(s) for i in range(10000000): if s%2 == 0: s //= 2 else: s = s*3+1 if s in l: print(i+2) break l.append(s)
p03136
s306125556
Accepted
n = int(input()) lst = list(map(int, input().split())) print('Yes' if 2 * max(lst) < sum(lst) else 'No')
p02995
s290435346
Accepted
import math as m A,B,C,D=map(int,input().split()) A-=1 g=C*D//m.gcd(C,D) x=B//C-A//C y=B//D-A//D z=B//g-A//g print(B-A-x-y+z)
p02603
s903719802
Accepted
N = int(input()) A = list(map(int,input().split())) M = 1000 S = 0 for i in range(N-1): M+=S*A[i] S = 0 if A[i+1]>=A[i]: tmp=M//A[i] M -= tmp*A[i] S+=tmp M+=S*A[-1] S = 0 print(M)
p02719
s826802081
Accepted
N, K = map(int, input().split()) mod = N%K gyaku = K-mod print(min(mod, gyaku))
p03565
s499422482
Accepted
s = str(input()) t = str(input()) L = [] for i in range(len(s)-len(t)+1): for j in range(len(t)): if s[i+j] == '?' or s[i+j] == t[j]: continue else: break else: ns = s[:i] + t + s[i+len(t):] ns = ns.replace('?', 'a') L.append(ns) L.sort() if L: ...
p03672
s396971139
Accepted
S = input() while 2 <= len(S): S = S[:len(S)-2] center = int(len(S)/2) if S[:center] == S[center:]: print(int(len(S))) break
p03274
s332068259
Wrong Answer
n,k=map(int,input().split()) x=list(map(int,input().split())) xmin=(x[n-1]-x[0])*2 for i in range(n-k): x1=abs(x[i])+abs(x[i+k-1]-x[i]) x2=abs(x[i+k-1])+abs(x[i+k-1]-x[i]) xmin=min(xmin,x1,x2) print(xmin)
p03544
s594265718
Accepted
N = int(input()) L = [0]*(N+1) L[0] = 2 L[1] = 1 for i in range(2,N+1): L[i] = L[i-1] + L[i-2] print(L[N])
p02777
s903869774
Wrong Answer
S,T=list(input().split()) A,B=list(map(int,input().split())) U=input() D=dict() D[S]=A D[T]=B D[U]-=1 print(*list(D.values()))
p02982
s675523587
Accepted
import math import numpy as np N,D = map(int,input().split()) X = np.array([list(map(int,input().split())) for n in range(N)]) ans = 0 for n in range(N): for m in range(N): d = 0 for x,y in zip(X[n],X[m]): d += (x-y)**2 if math.sqrt(d).is_integer() and d != 0: ans+=1 print(ans//2)
p02693
s864726647
Accepted
k=int(int(input())) a,b=map(int,input().split()) f=0 for i in range(a,b+1): if i%k==0: print("OK") f=1 break if f==0: print("NG")
p03293
s990702752
Accepted
s = input() t = input() k = 0 for i in range(len(s)): x = s[i:] + s[:i] if x == t: k=1 break if k==1: print("Yes") else: print("No")
p03723
s710862542
Wrong Answer
A, B, C = map(int, input().split()) if A == B and B == C: print(-1) elif A % 2 == 1 or B % 2 == 1 or C % 2 == 1: print(0) else: step = 0 while True: step += 1 nA = B // 2 + C // 2 nB = A // 2 + C // 2 nC = A // 2 + B // 2 A, B, C = nA, nB, nC if A % 2 != ...
p03698
s033650084
Wrong Answer
S=input() L=set(S) print('Yes' if len(S)==len(L) else "No")
p03543
s140088687
Accepted
n = input() if n[0] == n[1] and n[1] == n[2]: print("Yes") elif n[1] == n[2] and n[2] == n[3]: print("Yes") else: print("No")
p04045
s246890887
Wrong Answer
N, K = map(int, input().split()) D = list(map(int, input().split())) available = [i for i in range(10) if i not in D] values = available.copy() idx = int(values[0] == 0) while True: base = values[idx] * 10 for a in available: n = base + a if n >= N: print(n) quit() values.append(n) idx +...
p03487
s667691491
Wrong Answer
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines n = int(readline()) a = list(map(int, read().split())) dic = {} ans = 0 for i in range(n): ans += 1 try: dic[a[i]] += 1 if dic[a[i]] == a[i]: ans -= a[i] except KeyError: dic[a[...
p03544
s001228866
Accepted
n=int(input()) l=[2,1] for i in range(2,100): t=l[i-1]+l[i-2] l.append(t) print(l[n])
p03625
s492511242
Accepted
from collections import Counter import sys n = int(input()) a = Counter(list(map(int,input().split()))) lis = sorted(a.items(), key = lambda z: z[0], reverse = True) ans = [] for i in lis: if len(ans) == 0 and i[1] >= 4: print(i[0]**2) sys.exit() elif i[1] >= 2 and len(ans) <= 1: ans.ap...
p02756
s040364921
Wrong Answer
from collections import deque s = input() q = int(input()) s = deque(s) t = 0 for _ in range(q): query = list(map(str, input().split())) if query[0] == "1": t = 1 - t else: if t == 0: if query[1] == "1": s.appendleft(query[2]) elif query[1] == "2": s.append(query[2]) elif t == 1: if que...
p03557
s251254751
Accepted
import bisect N = int(input()) A = sorted(list(map(int, input().split()))) B = sorted(list(map(int, input().split()))) C = sorted(list(map(int, input().split()))) cnt = [0]*N for i in range(N): cnt[i] = cnt[i-1] + bisect.bisect_left(A,B[i]) ans = 0 for i in range(N): target = bisect.bisect_left(B,C[i]) if t...
p03617
s129630402
Wrong Answer
q,h,s,d=map(int,input().split()) n=int(input()) l=min(q*n*8,h*n*4,s*n*2,d*n) if l != d*n: print(l/2) else: m=min(q*4,h*2,s) print((d*(n-1)/2)+m if n%2==1 else l/2)
p03041
s893052385
Accepted
N, K = map(int, input().split()) S = list(input()) S[K-1] = S[K-1].lower() print("".join(S))
p02970
s253546586
Accepted
import math n, d = map(int, input().split()) print(math.ceil(n / (d * 2 + 1)))
p03282
s276178965
Wrong Answer
def main(): S=input() K=int(input()) for i in S: if i!='1': print(i) exit() main()
p03407
s544456861
Accepted
a,b,c = map(int,input().split()) if a+b >= c: print("Yes") else: print("No")
p02909
s086139552
Accepted
S = input() if S == "Sunny": print("Cloudy") elif S == "Cloudy": print("Rainy") elif S == "Rainy": print("Sunny")
p03261
s382240486
Accepted
n = int(input()) w = list(input() for _ in range(n)) ans = True w2 = set(w) if len(w) != len(w2): ans = False for i in range(n-1): if w[i][-1] != w[i+1][0]: ans = False if ans: print("Yes") else: print("No")
p03338
s303560879
Accepted
n = int(input()) s = [i for i in input()] import collections ans = 0 for i in range(1, n): #print(s[:i], s[i:]) c1 = collections.Counter(s[:i]) c2 = collections.Counter(s[i:]) p = c1.keys() & c2.keys() #print(p) if len(p) > ans: ans = len(p) print(ans)