problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02860
s026664049
Accepted
n = int(input()) s = input() if n %2 != 0: print("No") else: if s[:(n//2)] == s[(n//2):]: print("Yes") else: print("No")
p03485
s276152120
Accepted
a,b = map(int,input().split()) print((a+b+1)//2)
p03457
s421194894
Accepted
n = int(input()) now = [0,0,0] for i in range(n): s = list(map(int,input().split())) time = s[0] - now[0] dis = abs(s[1] - now[1]) + abs(s[2] - now[2]) if time < dis or (time-dis)%2 == 1: print("No") exit() now = s print("Yes")
p03251
s296196374
Accepted
n,m,x,y=map(int,input().split()) x=sorted(list(map(int,input().split()))+[x]) y=sorted(list(map(int,input().split()))+[y]) if x[-1]<y[0]: print('No War') else: print('War')
p03160
s156497432
Accepted
import sys n=int(input()) k=2 l=list(map(int,input().split())) ans=[0,abs(l[1]-l[0])] for i in range(2,n): m=sys.maxsize c=1 while c<min(k+1,i+1): m=min(abs(l[i]-l[i-c])+ans[-c],m) c+=1 ans.append(m) # print(ans) print(ans[-1])
p03062
s885731143
Wrong Answer
n=int(input()) l=[*map(int,input().split())] c=0 for e,i in enumerate(l): if i<0: c+=1 l[e]=-i print(sum(l)-[0,min(l)*2][i%2*l.count(0)])
p03281
s879156301
Accepted
def make_divisors(n): divisors=[] for i in range(1,int(n**0.5)+1): if n%i==0: divisors.append(i) if i!=n//i: divisors.append(n//i) return divisors N = int(input()) count = 0 for i in range(1,N+1,2): if len(make_divisors(i)) == 8: count += 1 print(count)
p03105
s566946220
Accepted
A, B, C = map(int, input().split()) ans = B // A if ans > C: print(C) else : print(ans)
p03261
s028070938
Wrong Answer
n = int(input()) dic = {} w = list(input().split()) ok = True pre = w[0][0] for s in w: if(s in dic): ok = False else: dic[s] = 0 if(pre[-1] != s[0]): ok = False pre = s if ok : print("Yes") else: print("No")
p02645
s553104385
Wrong Answer
a = str(input()) print(a[2])
p03331
s051430307
Accepted
N = int(input()) def f(k): s = str(k) n = len(s) ans = 0 for i in range(n): ans += int(s[i]) return ans ans = float("INF") for i in range(1, N): j = N-i t = f(i) + f(j) ans = min(ans, t) print(ans)
p02717
s176810138
Accepted
#A x, y, z = [int(_) for _ in input().split()] x, y = y, x x, z = z, x print(x, y, z)
p03254
s995004126
Accepted
N,X=map(int,input().split()) L=list(map(int,input().split())) L=sorted(L) count=0 for i in range(N): if i==(N-1): if X!=L[i]: count=count else: count+=1 elif L[i]<=X: X-=L[i] count+=1 print(count)
p02786
s152031388
Wrong Answer
import math import numpy as np H=int(input()) if H==1: print(1) else: n = int(np.log2(H+1)) ans = 2**(n+1)-1 print(ans)
p02779
s564616112
Wrong Answer
from collections import Counter n = int(input()) a = list(map(int, input().split())) re = 0 c = Counter(a) for i in c.values(): if i > 1: re += 1 if re > 0: print("No") else: print("Yes")
p03317
s094705631
Wrong Answer
from math import ceil n,k=map(int,input().split()) if n <= k: print(1) quit() A=list(map(int,input().split())) ind = A.index(1) ans = ceil((ind+1)/k)+ceil((n-ind+1)/k) print(ans)
p03251
s703576693
Wrong Answer
n,m,x,y=map(int,input().split()) X= list(map(int,input().split())) Y= list(map(int,input().split())) maxx = max(X) miny = min(Y) for i in range(x+1,y+1): if maxx +1 <= miny: print("No War") break print("War")
p02795
s346750620
Wrong Answer
h = int(input()) w = int(input()) n = int(input()) lo = max(h,w) lp = min(h,w) cnt = 0 tmp = 0 for i in range(h*w): if tmp < n and tmp+lo <= n: tmp += lo cnt += 1 elif tmp < n and tmp+lo >= n: tmp += lp cnt += 1 else: break print(cnt)
p02601
s039361743
Wrong Answer
A, B, C = map(int, input().split()) K = int(input()) a=0 for i in range(K): i += 1 if B*(2**i) > A: if C*(2**(K-i)) > B*(2**i): print('Yes') a=1 if a==0: print('No')
p02712
s671493235
Wrong Answer
# coding: utf-8 # Your code here! def main(): number = int(input()) answear = sum([result for result in range(number) if result % 3 != 0 or result % 5 != 0]) print(answear) if __name__ == "__main__": main()
p02793
s900253647
Accepted
from fractions import gcd MOD = 1000000000 + 7 N = int(input()) A = list(map(int, input().split())) l = 1 ans = 0 for a in A: g = gcd(a, l) l = (l // g) * a ans = (ans * (a // g)) % MOD ans = (ans + (l // a)) % MOD print(int(ans))
p03317
s962658893
Accepted
N, K = map(int, input().split()) A = list(map(int, input().split())) # 1の場所を探す pos = A.index(1) count = 0 num_forward = pos # 前方の残り数 num_backward = N - pos - 1 # 後方の残り数 # 前方にX回試行したときに負の余りが生じる場合は後方に回す rest = num_forward % -(K - 1) num_backward += rest while num_forward > 0: # 先頭まで1にする num_forward -= K - 1 count += 1 while num_backward > 0: # 末尾まで1にする num_backward -= K - 1 count += 1 print(count)
p03821
s888495260
Accepted
n = int(input()) A = [] B = [] for i in range(n): a, b = map(int, input().split()) A.append(a) B.append(b) A = A[::-1] B = B[::-1] t = 0 for i, j in zip(A, B): if (i+t) % j == 0: continue else: t += j - (i+t) % j print(t)
p02726
s733426381
Accepted
n,x,y = map(int,input().split()) k = [0]*(n) for i in range(1,n): for j in range(i+1,n+1): ind = min(j-i,abs(x-i) + abs(j-y) + 1) k[ind] += 1 for i in range(1,n): print(k[i])
p02726
s731978210
Wrong Answer
import collections N,X,Y = list(map(int,input().split())) ans = 0 A = [] B = [] for j in range(X+1,Y): A.append(j-1) A.append(N-j) for f in range(len(A)): for h in range(1,A[f]+1): B.append(h) B = str(B) c = collections.Counter(B) for i in range(1,N-Y+X+2): F = N-Y+X-i+1 D = str(i) C = c[D] print(F+C)
p04011
s072789106
Wrong Answer
N = int(input()) K = int(input()) X = int(input()) Y = int(input()) if K < N: ans = N*X + (N-K)*Y else: ans = N*X print(ans)
p02760
s148865850
Accepted
p,r=input,range A=sum([list(map(int,p().split()))for _ in r(3)],[]) b=[int(p())for _ in r(int(p()))] print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if sum(1<<i for i in r(9)if A[i]in b)&v==v]else'No')
p02766
s552018003
Accepted
n,k=map(int, input().split()) result = 0 while n != 0: result+=1 n//=k print(result)
p03261
s129881073
Accepted
n = int(input()) words = [input()] for i in range(n-1): s = input() if s in words or words[-1][-1] != s[0]: print("No") exit() words.append(s) print("Yes")
p03836
s983536152
Accepted
A, B, C, D = map(int, input().split()) x = C-A y = D-B first = 'U'*y+'R'*x second = 'D'+"L"*(x-1)+'D'*(y-1)+'L' third = 'LU'+first+'RD' last = 'RD'+second+'LU' print(first+second+third+last)
p02951
s955495636
Accepted
a, b, c = map(int, input().split()) print(max(0, c - (a - b)))
p02624
s747393352
Wrong Answer
import math a=int(input()) b=list(i+1 for i in range(a)) www=0 for j in b: c=[x+1 for x in range(int(math.sqrt(j)//1))] for y in c: if j%y==0: if not j/y==y: www=+j*2 else: www+=j print(www)
p03317
s999441101
Wrong Answer
import math N,K = map(int,input().split()) A = list(map(int,input().split())) if N == K: print(1) elif K == 2: print(N-1) else: print(math.ceil(N/(K-1)))
p02725
s291138895
Accepted
k,n=map(int,input().split()) a=list(map(int,input().split())) l=[] for i in range(n-1): l.append(abs(a[i]-a[i+1])) l.append(k-a[-1]+a[0]) print(sum(l)-max(l))
p02836
s668982176
Wrong Answer
ess = input() sse = ess[::-1] hugs = 0 for i in range(0, len(ess)): if ess[i] != sse[i]: hugs += 1 print(hugs)
p03657
s996100766
Accepted
a,b = map(int,input().split()) if a%3==0 or b%3==0 or (a+b)%3==0: print("Possible") else: print("Impossible")
p02754
s902647891
Wrong Answer
N,A,B = map(int,input().split()) print((N//(A+B))*B)
p02818
s051986768
Accepted
a,b,k=map(int,input().split()) if a+b<k: print(0,0) elif a<k: print(0,b-(k-a)) elif a==k: print(0,b) elif a>k: print(a-k,b)
p02862
s552470890
Wrong Answer
X,Y=map(int,input().split()) mod=pow(10,9)+7 m=(2*X-Y)//3 n=(2*Y-X)//3 if (X+Y)%3!=0 or m<=0 or n<=0: print("0") else: bunsi=1 bunbo=1 for i in range(0,n): bunsi=(bunsi*(m+1+i))%mod bunbo=(bunbo*(1+i))%mod print((bunsi*pow(bunsi,mod-2,mod))%mod)
p03910
s613562164
Wrong Answer
import math import sys n = int(sys.stdin.readline().rstrip()) if n == 1: print(1) elif n == 2: print(2) elif n % 2 == 1: print(n // 2) print(n // 2 + 1) else: print(n // 2 - 1) print(n // 2 + 1)
p02833
s622879450
Wrong Answer
n = int(input()) cnt = 0 mod = 10 while n//mod !=0: cnt += n//mod mod*=5 print(cnt)
p03043
s970559543
Accepted
import math import sys n,k = map(int,input().split()) ans = 0 for i in range(1,n+1): if i >= k: ans += (1/n) else: ans += (1/n) * (1/2)**(math.ceil(math.log2(k/i))) print(ans)
p03061
s622086247
Accepted
import fractions N = int(input()) A = list(map(int, input().split())) L = [0] R = [0] for i in range(N): L.append(fractions.gcd(L[i],A[i])) R.append(fractions.gcd(R[i],A[N-i-1])) R.reverse() ans = 0 for i in range(N): ans = max(ans,fractions.gcd(L[i],R[i+1])) print(ans)
p03797
s067679969
Accepted
n,m=map(int, input().split()) if n>=m/2: m_fin = m//2 print(m_fin) else: m_aft = m -2*n m_fin = m_aft//4 print(n+m_fin)
p02880
s039197881
Accepted
N=int(input()) ans=False for i in range(1,10): if N%i==0 and N/i>0 and N/i<10: ans=True print('Yes' if ans else 'No')
p03679
s261858398
Accepted
X, A, B = list(map(int, input().split())) if A - B >= 0: print('delicious') elif B - A <= X: print('safe') else: print('dangerous')
p03329
s278718802
Wrong Answer
A=[1,6,36,216,1296,7776,46656,9,81,729,6561,59049] N=int(input()) ans=0 while N!=0: N-=max([a for a in A if a<=N]) ans+=1 print(ans)
p02606
s405227494
Accepted
def main(): L, R, d = map(int, input().split()) ans = 0 for i in range(L, R + 1): if i % d == 0: ans += 1 print(ans) if __name__ == "__main__": main()
p02963
s654588526
Accepted
n=int(input()) a=-(-n//10**9) b=10**9*a-n print(0,0,10**9,1,b,a)
p02912
s663343921
Accepted
N,M=map(int,input().split()) *A,=map(int,input().split()) from heapq import* B=[] for a in A: B.append(-a) heapify(B) for i in range(M): b=heappop(B) b=0--b//2 heappush(B,b) print(-sum(B))
p02618
s948849805
Wrong Answer
D=int(input()) c = list(map(int,input().split())) last_day = [0]*26 score = 0 def calc_sum(day,t,sum,s): sum += s[t-1] for j in range(len(c)): if(j!=day-1): sum -= c[j]*(day-last_day[j]) return sum for i in range(D): s = list(map(int,input().split())) t = 1 max = -10000000 score = 0 for j in range(26): if(max < calc_sum(i+1,j,score,s)): max = calc_sum(i+1,j,score,s) t = j last_day[t-1]=i print(t)
p03730
s692675858
Accepted
A,B,C=map(int,input().split()) #for分の繰り返し範囲 #A*B % B=0 #A*(B+1) % B=A #→繰り返し範囲はA*Bまでで十分 for i in range(A,A*B+1,A): if i%B==C: print("YES") exit() print("NO")
p03773
s980339211
Accepted
a,b = map(int, input().split()) if a+b>23: print(a+b-24) else: print(a+b)
p03360
s463405606
Accepted
a,b,c=map(int,input().split()) k=int(input()) ans=a+b+c-max(a,b,c)+max(a,b,c)*2**k print(ans)
p02818
s255610762
Accepted
A, B, K = list(map(int,input().split())) if A >= K: A -= K elif A+B >= K: B = B + A - K A = 0 else: A = 0 B = 0 print(str(A) + " " + str(B))
p02603
s392848887
Accepted
n = int(input()) A = [*map(int, input().split())] + [0] yen, stock = 1000, 0 now = A[0] for nxt in A[1:]: if now < nxt: stock += yen // now yen -= yen // now * now else: yen += stock * now stock = 0 now = nxt print(yen + stock * now)
p02613
s851731734
Wrong Answer
n = int(input()) s = [input() for i in range(n)] print('AC x' + str((s.count('AC')))) print('WA x' + str((s.count('WA')))) print('TLE x' + str((s.count('TLE')))) print('RE x' + str((s.count('RE'))))
p02621
s771858875
Accepted
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) a = int(input()) print(a + a ** 2 + a ** 3)
p02546
s336384580
Accepted
s = input() if s[-1]=="s": print(s+"es") else: print(s+"s")
p03219
s965795797
Wrong Answer
x, y = map(int,input().split()) print(x + y/2)
p03041
s466084124
Wrong Answer
n,k = map(int,input().split()) ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" abc = "abcdefghijklmnopqrstuvwxyz" s = input() ans = "" for ss in s: ans += abc[ABC.find(ss)] print(ans)
p03345
s742686164
Accepted
a,b,c,k = map(int, input().split()) over = 10**18 if abs(a-b)> over: print("unfair") elif k %2 == 0: print(a-b) else: print(b-a)
p02924
s081980845
Accepted
N = int(input()) print((N*(N-1))//2)
p03106
s108565713
Wrong Answer
a,b,k=map(int,input().split()) cnt=0 for i in range(1,min(a,b)+1): ans=0 if a%i==0 and b%i==0: ans+=i cnt+=1 if cnt==k: break print(ans)
p02768
s506192426
Accepted
def calc(n, x): up = 1 bottom = 1 for i in range(x): up *= (n - i) up = up % mod bottom *= (i + 1) bottom = bottom % mod return (up * pow(bottom, mod - 2, mod)) % mod mod = (10 ** 9) + 7 n, a, b = map(int, input().split()) ans = pow(2, n, mod) - 1 for i in [a, b]: ans -= calc(n, i) print(ans % mod)
p03282
s090010363
Accepted
s = list(input()) k = int(input()) for i in range(min(k,len(s))): if s[i] != '1': print(s[i]) exit(0) print(1)
p02766
s780179502
Accepted
# -*- coding: utf-8 -*- """ Created on Thu May 7 21:59:58 2020 @author: shinba """ N,K = map(int,input().split()) ans= 0 while N>0: N = N//K ans += 1 print(ans)
p02833
s715193834
Accepted
import sys input = sys.stdin.readline N = int(input()) def m5(N): count = 0 while True : k = N // 5 if k == 0 : break else : N = k count += k // 2 return count if N % 2 == 1 : print(0) else : s = str(N) o = int(s[-1]) N -= o print(m5(N))
p02646
s336947358
Accepted
A, V = map(int, input().split()) B, W = map(int, input().split()) T = int(input()) distance = abs(A - B) speed = V - W if (distance <= speed * T): print("YES") else: print("NO")
p02789
s636189625
Accepted
N, M = map(int,input().split()) if(M==N): print('Yes') else: print('No')
p02705
s871917787
Accepted
import sys # sys.stdin = open('input.txt') from math import pi r = int(input()) ans = 2 * r * pi print(ans)
p02633
s199227010
Accepted
X=int(input()) i=1 while True: if (X*i)%360==0: print(i) exit() i+=1
p02622
s194377087
Accepted
s = input() t = input() cnt = 0 for i in range(len(s)): if s[i] != t[i]: cnt += 1 print(cnt)
p02723
s067721035
Accepted
# import sys # input = sys.stdin.readline s = input() if s[2]==s[3] and s[4]==s[5]: print("Yes") else: print("No")
p03699
s930081371
Accepted
N = int(input()) S = [int(input()) for _ in range(N)] s = sum(S) S.sort() cnt = 0 while s % 10 == 0 and cnt < N: if S[cnt] % 10 != 0: s -= S[cnt] cnt += 1 if cnt == N: s = 0 print(s)
p03627
s583449383
Wrong Answer
import collections A=int(input()) l_after=[] l=list(map(int,input().split())) l=collections.Counter(l).most_common() for i in range(len(l)): if l[i][1] > 1: l_after.append(l[i][0]) l_after.sort(reverse=True) if len(l_after) < 2: print(0) exit() print(l_after[0]*l_after[1])
p02819
s126106571
Accepted
def is_prime(x): if x <= 1: return False else: for i in range(2,x): if x % i == 0: return False return True X = int(input()) while is_prime(X) == False: X += 1 print(X)
p03087
s982488805
Accepted
N ,Q = map(int,input().split()) S = input() lst = [] for i in range(Q): s,e = map(int,input().split()) lst.append([s-1,e-1]) #print(lst) cum = [0]*N for i in range(1,N): if S[i-1] == 'A' and S[i] == 'C': cum[i] = cum[i-1] + 1 else: cum[i] = cum[i - 1] for v in lst: print(cum[v[1]] - cum[v[0]])
p03860
s915962988
Wrong Answer
s = input() print("A{}C".format(s))
p03386
s435431731
Wrong Answer
a,b,k = map(int, input().split()) s = set() for i in range(a,min(a+k,b+1)): s.add(i) for i in range(max(a,b-k+1),b+1): s.add(i) for i in s: print(i)
p03210
s739263691
Accepted
print('YES' if input() in '753' else 'NO')
p02924
s303851285
Accepted
N=int(input()) print(((N-1)*N)//2)
p02688
s954275618
Accepted
N,K= list(map(int, input().split())) ans = [0]*(N+1) for i in range(K): d = int(input()) A = list(map(int, input().split())) for j in range(d): ans[A[j]] = 1 res = len(ans)-1-sum(ans) print(res)
p02582
s369419309
Accepted
S = list(input()) count = 0 ans = 0 for i in range(len(S)): if S[i] == 'R': count += 1 if ans < count: ans = count else: count = 0 print(ans)
p03695
s219689129
Accepted
n = int(input()) a = list(map(int, input().split())) rate = [0] * 9 for i in range(n): for j in range(8): if 400 * j <= a[i] < 400 * (j + 1): rate[j] += 1 break else: rate[8] += 1 counter = 0 for i in range(8): if rate[i] >= 1: counter += 1 print(max(1, counter), counter + rate[8])
p03695
s255703702
Wrong Answer
N = int(input()) a = list(map(int, input().split())) a = list(map(lambda x: x // 400, a)) #print(a) m = len(set(a)) M = len(set(a)) if 8 in a: m -= 1 M += a.count(8) M -= 1 M = min(M, 8) print(m, M)
p04031
s996438482
Wrong Answer
N = int( input() ) s = input() numbers = s.split() def getCost(target): cost = 0 for n in numbers: number = int(n) cost += (number - target)**2 return cost minCost = 0 for i in range(-100, 101): cost = getCost(i) if( cost < minCost ): minCost = cost print(minCost)
p02554
s084634647
Wrong Answer
mod = (int)(1e9+7) n = (int)(input()) print(pow(10, n, mod) - 2*pow(9, n, mod) + pow(8, n, mod))
p03673
s788260307
Accepted
n=int(input()) a=list(map(int,input().split())) ans=[] if n%2==1: i=n while i>=1: ans.append(str(a[i-1])) i-=2 i=2 while i<=n: ans.append(str(a[i-1])) i+=2 print(" ".join(ans)) else: i = n while i >= 1: ans.append(str(a[i - 1])) i -= 2 i = 1 while i <= n: ans.append(str(a[i - 1])) i += 2 print(" ".join(ans))
p04030
s948809741
Accepted
inputs = list(map(str, input())) output = '' for i in inputs: if i == 'B': output = output[:-1] elif i == '1': output += '1' else: output += '0' print(output)
p03433
s064197033
Accepted
n=int(input()) a=int(input()) print('Yes' if n%500<=a else 'No')
p03624
s373736463
Accepted
import collections S = list(input()) c = collections.Counter(S) ans = " " for i in range(97,123): s = chr(i) if s in c: continue else: ans = s break print("None" if ans ==" " else ans)
p02911
s303352816
Accepted
N,K,Q = map(int,input().split()) L = [0 for _ in range(N)] for _ in range(Q): k = int(input()) L[k-1] +=1 s = sum(L) for i in range(N): if K + L[i] -s <= 0: print("No") else: print("Yes")
p03131
s993035510
Accepted
#みんなのプロコン2019-C import sys readline = sys.stdin.buffer.readline def even(n): return 1 if n%2==0 else 0 k,a,b = map(int,readline().split()) if b-a <= 2: print(k+1) exit() res = max(0,(k-(a-1))//2) ans = a+res*(b-a) if not even(k-(a-1)): ans += 1 print(ans)
p03555
s806065190
Accepted
c_1 = list(input()) c_2 = list(input()) if (c_1[0] == c_2[2] and c_1[1] == c_2[1] and c_1[2] == c_2[0]): print('YES') else: print('NO')
p03059
s604827408
Accepted
A, B, T = map(int, input().split()) print(B * (T // A))
p02659
s616736793
Wrong Answer
A,B=input().split() A=int(A) B=int(100*float(B)+0.1) C=A*B print(int(C))
p02970
s878115295
Accepted
from math import ceil n,d = map(int,input().split()) print(ceil(n/(2*d+1)))
p03284
s022374602
Wrong Answer
a, b = map(int, input().split()) print(a%b)
p02760
s244177113
Accepted
A = [] for _ in range(3): a1, a2, a3 = map(int, input().split()) A += [(a1, a2, a3)] n = int(input()) B = [] for _ in range(n): B += [int(input())] for i in range(3): A += [(A[0][i], A[1][i], A[2][i])] A += [(A[0][0], A[1][1], A[2][2])] A += [(A[0][2], A[1][1], A[2][0])] ans = 'No' for x in A: _ans = [1 for _x in x if _x in B] if len(_ans) == 3: ans = 'Yes' break print(ans)