problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02922
s093797671
Accepted
from math import ceil a, b = map(int, input().split()) print(ceil((b - 1) / (a - 1)))
p02613
s556906776
Accepted
N = int(input()) result = [input() for i in range(N)] def f(s, result): return '%s x %d'%(s, result.count(s)) print(f('AC', result)) print(f('WA', result)) print(f('TLE', result)) print(f('RE', result))
p03862
s815095265
Accepted
N, x = map(int, input().split()) a = list(map(int, input().split())) result = 0 b = max(a[0] - x, 0) result += b a[0] -= b for i in range(1, N): b = max(a[i - 1] + a[i] - x, 0) result += b a[i] -= b print(result)
p02959
s297065434
Wrong Answer
N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) B.append(0) B.append(0) ans = 0 for i in range(N+1): if A[i] <= B[i]: ans += A[i] B[i+1] += B[i]-A[i] B[i] -= A[i] else: ans += B[i] B[i] -= B[i] print(ans)
p02814
s126567547
Wrong Answer
n, m = map(int, input().split()) a = list(map(int, input().split())) num1 = a[0] num2 = 0 while num1 % 2 == 0: num1 //= 2 num2 += 1 gc = 2 ** num2 b = [] for i in a: if i % gc != 0 or (i // gc) % 2 == 0: print(0) exit() else: b.append(i // gc) from fractions import gcd lcm = 1...
p02631
s007765666
Accepted
N = int(input()) A = tuple(map(int, input().split())) xor = 0 for a in A: xor ^= a for a in A: print(xor^a, '',end='') print()
p03474
s219043578
Wrong Answer
a,b = map(int,input().split()) s = input() print("Yes" if s[:a].isdigit() and s[a:].isdigit() else "No")
p03095
s423263742
Accepted
from collections import Counter N = int(input()) S = input() L = Counter(S) MOD = 10**9 + 7 ans = 1 for k in L.keys(): ans *= ((L[k]+1) % MOD) print((ans-1)%MOD)
p02922
s146721012
Wrong Answer
a, b = map(int, input().split()) if b >= a: if (b - a) % (a - 1) == 0: print((b - a) // (a - 1) + 1) else: print((b - a) // (a - 1) + 1 + 1) else: print(1)
p02694
s653195172
Wrong Answer
X = int(input()) money = 100 year = 0 while X > money : money = 1.01*money year += 1 print(year)
p02683
s245125964
Accepted
import sys input = sys.stdin.readline (n, m, x), cost = map(int, input().split()), sys.maxsize s = [list(map(int, input().split())) for i in range(n)] for i in range(1, 1 << n): k, y = [0 for i in range(m)], 0 for j in range(n): if (i >> j) & 1: for ii in range(1, m + 1): k[ii-1] += s[j][ii...
p03345
s315170764
Accepted
#print#!/usr/bin/env python3 #%% for atcoder uniittest use import sys input= lambda: sys.stdin.readline().rstrip() sys.setrecursionlimit(10**9) def pin(type=int):return map(type,input().split()) def tupin(t=int):return tuple(pin(t)) def lispin(t=int):return list(pin(t)) #%%code from collections import Counter def resol...
p03774
s651856905
Accepted
N,M=map(int,input().split()) ab=[] for i in range(N): ab.append(list(map(int,input().split()))) cd=[] for i in range(M): cd.append(list(map(int,input().split()))) def Mandis(x1,x2,y1,y2): e=abs(x1-x2)+abs(y1-y2) return e for i in range(N): g=0 for j in range(M-1): if Mandis(ab[i][0],cd[j...
p02755
s712588724
Accepted
A,B=map(int,input().split()) for money in range(1,1001): if int(money*0.08)==A and int(money*0.1)==B: print(money) break else: print(-1)
p02623
s644121068
Accepted
from itertools import accumulate import bisect N,M,K = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) #累積和 a_acc =[0] + list(accumulate(A)) b_acc =list(accumulate(B)) ans = 0 for an in range(len(a_acc)): rem = K - a_acc[an] if rem < 0: break ...
p03386
s472433564
Accepted
a,b,k=map(int,input().split()) if k>(b-a): k=b-a list1=[i for i in range(a,a+k)] list1.extend([i for i in range(b-k+1,b+1)]) ans=list(set(list1)) ans.sort() if a==b: ans=[a] for i in range(len(ans)): print(ans[i])
p02645
s294499333
Wrong Answer
str = input() print(str[0:2])
p02695
s418604671
Accepted
import sys input = sys.stdin.buffer.readline from itertools import combinations_with_replacement N, M, Q = map(int, input().split()) ABCD = [list(map(int, input().split())) for _ in range(Q)] lst = list(combinations_with_replacement(range(1, M + 1), N)) ans = 0 for l in lst: tmp = 0 for a, b, c, d in ABCD...
p02973
s058298213
Accepted
import bisect n, *a = map(int, open(0).read().split()) a = a[::-1] INF = 1 << 30 dp = [INF] * (n + 1) for e in a: dp[bisect.bisect_right(dp, e)] = e print(bisect.bisect_left(dp, INF))
p02972
s395022619
Accepted
n = int(input()) a = [int(i) for i in input().split()] box = [0] * n ans = [] for i in range(n, 0, -1): if sum(box[i - 1:n:i]) % 2 != a[i - 1]: box[i - 1] = 1 ans.append(i) print(len(ans)) print(*ans)
p03241
s311509978
Wrong Answer
def main(): N, M = map(int, input().split(" ")) i = M // N while True: if M % i == 0: break elif i == 2: break else: i -= 1 print(i) if __name__ == '__main__': main()
p03076
s873296551
Wrong Answer
import math m = [int(input()) for i in range(5)] last = min((m[i] - 1) % 10 +1 for i in range(5)) last1 = int(str(last)[-1]) sum = sum(math.ceil(m[i] / 10) * 10 for i in range(5)) print(sum+last1-10)
p02768
s507056878
Wrong Answer
mod = 10 ** 9 + 7 def f(n, r): X = 1 Y = 1 for i in range(r): X *= n - i # nCr の分子 X %= mod Y *= i + 1 # nCr の分母 Y %= mod # フェルマーの小定理より (X/Y)%mod = X*Y^(mod - 2) % mod return X * pow(Y, mod - 2, mod) % mod N, A, B = map(int, input().split()) res = pow(2, N,...
p02909
s190139332
Accepted
# ABC141 # A Weather Prediction s = input() if s == "Sunny": print("Cloudy") elif s == "Cloudy": print("Rainy") else: print("Sunny")
p02792
s231572015
Wrong Answer
import math N = int(input()) ans = 0 for i in range(1,N+1): if i % 10 == 0: continue x = int(math.log10(i)) if i // (10 ** x) == i % 10: ans += 1 if N > (i % 10) * 10: ans += 1 if N > (i % 10) * 100: ans += 10 if N > (i % 10) * 1000: ans += 10...
p03289
s854531821
Accepted
import string s = list(input()) flag = True if s[0] != "A": flag = False count = 0 for i in range(1, len(s)): if s[i] in string.ascii_uppercase: if i == 1 or i == len(s) - 1 or s[i] != "C": flag = False count += 1 if flag and count == 1: print("AC") else: print("WA")
p03001
s049695373
Wrong Answer
w,h,x,y = map(int,input().split()) left = x * h right = (w - x)*h under = w * y top = w * (h - y) arr = [left,right,under,top] arr.sort() if arr[0]==arr[1]: print(arr[1],1) else: print(arr[1],0)
p03632
s125677550
Accepted
a,b,c,d=map(int,input().split());print(max(0,min(b,d)-max(a,c)))
p03797
s874792888
Accepted
#!/usr/bin/env pytHon3 # -*- coding: utf-8 -*- def main(): N, M = map(int, input().split()) if M - 2 * N > 0: x = (M - 2 * N) // 4 print(N + x) else: print(M // 2) if __name__ == "__main__": main()
p03071
s813219829
Accepted
a, b = map(int, input().split()) c = max(a,b) print(max((2*c-1, a+b)))
p03309
s022366396
Accepted
import statistics n = int(input()) a = [] j = 1 for i in list(map(int, input().split())): a.append(i - j) j += 1 b = statistics.median((a)) res = 0 for i in range(n): res += abs(a[i] - b) print(int(res))
p03760
s465811808
Accepted
O=input() E=input() ans="" for i in range(len(E)): ans+=O[i]+E[i] if len(O)>len(E): ans+=O[-1] print(ans)
p03077
s336490548
Wrong Answer
n=int(input()) min1=9999999999999999999 for i in range(5): a=int(input()) min1=min(min1,a) print((n//min1+1)+4)
p03324
s917047774
Accepted
D,N = list(map(int, input().split())) if N == 100: N += 1 print(N*(100**D))
p02973
s874127275
Accepted
n=int(input()) a=[int(input())for _ in range(n)] dp=[2]*(n+1) from bisect import bisect_left,bisect_right for i in a: dp[bisect_left(dp,-i+1)]=-i print(dp.index(2))
p02678
s040508436
Accepted
import queue q = queue.Queue() N, M = map(int, input().split()) ans = [-1 for i in range(N+1)] path = [[] for i in range(N+1)] for i in range(M): A, B = map(int, input().split()) path[A].append(B) path[B].append(A) q.put(1) COUNTER = 0 while not q.empty() : now = q.get() for p in path[now]: if ans[p]==...
p03243
s954245552
Accepted
def answer(n: int) -> int: q = n // 111 if n % 111 != 0: q += 1 return 111 * q def main(): n = int(input()) print(answer(n)) if __name__ == '__main__': main()
p02753
s837022741
Wrong Answer
S=input() s=set(S) if len(s)==3: print("Yes") else: print("No")
p02747
s053584750
Accepted
s=input() a=0 if s=='hi': print('Yes') elif s=='hihi': print('Yes') elif s=='hihihi': print('Yes') elif s=='hihihihi': print('Yes') elif s=='hihihihihi': print('Yes') else: print('No')
p02993
s034864843
Wrong Answer
S = input() s = list(S) p = 1 for i in range(3): if s[i] == s[i+1]: p = 0 print('Bad') if p == 1: print('Good')
p03730
s523735547
Wrong Answer
a,b,c=map(int,input().split()) num = a if (a % 2 == 1 and c % 2 == 0) or (a % 2 == 0 and c % 2 == 1): print('NO') else: print('YES')
p02732
s486543286
Accepted
from collections import Counter N = int(input()) As = [int(n) for n in input().split()] C = Counter(As) ans = sum(v * (v - 1) // 2 for k, v in C.items()) M = [C[a] - 1 for a in As] for m in M: print(ans - m)
p02759
s610446592
Wrong Answer
N = int(input()) if N%2==0: print(N/2) else: print((N+1)/2)
p03773
s731771962
Wrong Answer
# 現在の時刻aと何時間後にコンテストが始めるかbを整数で入力 a,b = map(int,input().split()) # a+bが24より大きければ-24して表示 start_time = a + b if start_time >24: print(start_time - 24) # a+bが24より小さければそのまま表示 else: print(start_time)
p03852
s928511567
Accepted
N=input() ans=["a","i","u","e","o"] if N in ans: print("vowel") else: print("consonant")
p03835
s811871986
Accepted
def actual(K, S): count = 0 for x in range(K + 1): for y in range(K + 1): z = S - (x + y) if 0 <= z <= K: count += 1 return count K, S = map(int, input().split()) print(actual(K, S))
p03385
s030291481
Accepted
print("Yes" if len(set(input())) == 3 else "No")
p03695
s072471495
Accepted
n=int(input()) a=list(map(int, input().split())) l=[x // 400 for x in a if x < 3200] free=len([x for x in a if x >= 3200]) from collections import Counter c=Counter(l) print(max(len(c), 1), len(c) + free)
p02756
s474827205
Wrong Answer
from collections import deque S = input() Q = int(input()) deque = deque([S]) for _ in range(Q): pack = input().split() T = int(pack[0]) if T == 1: deque[0], deque[-1] = deque[-1], deque[0] if T == 2: F, C = int(pack[1]), pack[2] if F == 1: # 最初に追加するパターン deque.appendleft(C) if F ...
p02947
s429992175
Accepted
n = int(input()) d = dict() res = 0 for _ in range(n): s = input() s = list(s) s.sort() s = "".join(s) if s in d: res += d[s] d[s] += 1 else: d[s] = 1 print(res)
p03208
s822472851
Accepted
N , K = map(int,input().split()) h = [int(input()) for i in range(N)] h.sort() print(min(h[i + K - 1] - h[i] for i in range(N - K + 1)))
p03449
s696571833
Accepted
n = int(input()) A1 = tuple(map(int, input().split())) A2 = tuple(map(int, input().split())) from itertools import accumulate A1S = [0] + list(accumulate(A1)) A2S = [0] + list(accumulate(A2)) ma = 0 for i in range(1, n+1): ma = max(ma, A1S[i] + A2S[-1] - A2S[i-1]) print(ma)
p03407
s991000448
Accepted
a,b,c=map(int,input().split()) if a+b>=c: print("Yes") else: print("No")
p03145
s171393805
Accepted
c,a,b = map(int, input().split()) print((c*a)//2)
p03605
s056160677
Accepted
s = input() print('Yes') if s[0] == '9' or s[1] == '9' else print('No')
p03493
s599559104
Accepted
S=str(input()) n = len([1 for x in S if x=='1']) print(n)
p03796
s558924454
Wrong Answer
import math N = int(input()) print((math.factorial(N))%(10^9+7))
p03077
s771237428
Accepted
import sys input = sys.stdin.buffer.readline #sys.setrecursionlimit(10**9) #from functools import lru_cache def RD(): return input().rstrip().decode() def II(): return int(input()) def FI(): return int(input()) def MI(): return map(int,input().split()) def MF(): return map(float,input().split()) def LI(): return list...
p03699
s650173336
Accepted
from itertools import combinations n = int(input()) s = sorted([int(input()) for _ in range(n)]) ans = sum(s) if ans % 10 != 0: print(ans) elif all(i%10 == 0 for i in s): print(0) else: for i in range(1,n): for j in combinations(s,i): t = sum(j) if (ans-t)%10 != 0: print(ans-t) exit()
p02731
s414299691
Wrong Answer
def main(): l = int(input()) print((l//3)**3) if __name__ == '__main__': main()
p02723
s782149556
Accepted
import sys sys.setrecursionlimit(10 ** 6) input = sys.stdin.readline s = input().strip() if s[2] == s[3] and s[4] == s[5]: print('Yes') else: print('No')
p02727
s407555038
Wrong Answer
X,Y,A,B,C = list(map(int,input().split())) p = sorted(list(map(int,input().split())),key=lambda x:-x) q = sorted(list(map(int,input().split())),key=lambda x:-x) r = sorted(list(map(int,input().split()))) pq = sorted(p[:X] + q[:Y],lambda x:-x) for i in range(X+Y): if r[i] < pq[i]: break print(sum(r[:i] + pq[i:]))...
p02570
s401988167
Wrong Answer
d, t, s = map(int, input().split()) res = d / t if s <= res: print("no") else: print("yes")
p03817
s124206061
Accepted
x=int(input()) ans=2*(x//11) if x%11 == 0: print(ans) elif x%11 <= 6: print(ans+1) else: print(ans+2)
p02595
s196972464
Accepted
N,D = map(int,input().split()) ans = 0 D **= 2 for i in range(N): X,Y = map(int,input().split()) if D >= X**2 + Y**2: ans += 1 print(ans)
p02571
s784298959
Wrong Answer
S = input() T = input() Min = 100000 for i in range(len(S) - len(T) + 1): count = 0 for n in range(len(T)): if S[i + n] != T[n]: count += 1 if count < Min: Min = count print(count)
p02548
s817656237
Accepted
N = int(input()) ans = 0 for a in range(1,N+1): for b in range(1,int(N/a)+1): if a*b<N: ans += 1 print(ans)
p02663
s790305448
Accepted
H1,M1,H2,M2,K = map(int,input().split()) start = H1*60 + M1 finish = H2*60 + M2 - K if finish - start >= 0: print(finish - start) else: print(0)
p02900
s528868061
Accepted
a, b = map(int, input().split()) a_prime_factor = [] b_prime_factor = [] for i in range(2, int(a ** 0.5) + 1): if a % i == 0: a_prime_factor.append(i) while a % i == 0: a //= i if a != 1: a_prime_factor.append(a) for i in range(2, int(b ** 0.5) + 1): if b % i == 0: b_prime_factor...
p02690
s239842911
Accepted
# abc166 D x = int(input()) for a in range(-118, 120): ans = False for b in range(-119, 119): if a ** 5 - b** 5 == x: print("{} {}".format(a, b)) ans = True break if ans: break
p02897
s921870916
Accepted
n=int(input()) if n%2==0: print(1/2) else: print(((n-1)/2+1)/n)
p03456
s138374752
Accepted
a, b = input().split() s = int(a+b)**0.5 if s.is_integer(): print('Yes') else: print('No')
p03680
s297712750
Accepted
with open(0) as f: N, *a = map(int, f.read().split()) from itertools import count p = 0 seen = {0} for i in count(1,1): p = a[p]-1 if p == 1: ans = i break if p in seen: ans = -1 break seen.add(p) print(ans)
p02731
s977455217
Accepted
def main(): L = int(input()) print((L / 3) ** 3) if __name__ == '__main__': main()
p03778
s137687156
Accepted
W, a, b = map(int, input().split()) print(max(0, max(a, b) - (min(a, b) + W)))
p03719
s702394205
Accepted
a, b, c = map(int, input().split()) if (c >= a) and (c <= b): print("Yes") else: print("No")
p02879
s040576053
Accepted
A, B = map(int, input().split()) result = int(A*B) if A <= 9 and B <= 9 else -1 print(result)
p02555
s838980120
Accepted
n=input() z=[0]*(n+1) z[0]=1 for i in xrange(1,n+1): s=0 if i-3>=0: s=z[i-3] z[i]=(z[i-1]+s)%(pow(10,9)+7) print (z[-1]-z[-2])%(pow(10,9)+7)
p02642
s790981872
Wrong Answer
n = int(input()) a = set(map(int, input().split())) iter = 0 for i in a: lst = [i%j for j in a] if lst.count(0) == 1: iter = iter + 1 print(iter)
p02843
s845297078
Accepted
X = int(input()) if(0 <= X%100 <= 5*(X//100)): print(1) else: print(0)
p02791
s930962383
Wrong Answer
N = int(input()) P = input().split(" ") count = 1 for i in range(1,N) : if int(P[i]) <= int(P[i-1]) : count += 1 print (count)
p03817
s453725849
Wrong Answer
si = lambda: input().strip() ii = lambda: int(input()) mii = lambda: map(int, input().split()) lmii = lambda: list(map(int, input().split())) lmsi = lambda: list(map(str, input().split())) smii = lambda: sorted(map(int, input().split())) # ---------- x = ii() d = x // 11 m = x % 11 ans = 2 * d if m > 0: ans += 1...
p02957
s215230780
Wrong Answer
a, b = map(int, input().split()) if (a + b) % 2 == 0: print((a + b) / 2) else: print('IMPOSSIBLE')
p03644
s823767775
Accepted
N = int(input()) cnt_max = 0 ans = 1 for i in range(1, N + 1): cnt = 0 num = i while True: if num % 2 == 0: cnt += 1 num /= 2 else: break if cnt_max < cnt: cnt_max = cnt ans = i print(ans)
p03778
s438126040
Wrong Answer
W, a, b = map(int,input().split()) if (a+W)<=b: print(b-(a+W)) elif (a<= b)and (b<a): print(0) elif b<(a-W): print(a-(b+W))
p02760
s895659675
Wrong Answer
A = [] for i in range(3): A.append(list(map(int, input().split()))) B = [[0]*3]*3 N = int(input()) for i in range(N): b = int(input()) for j in range(3): for k in range(3): if A[j][k] == b: B[j][k] = 1 c = [] for i in range(3): c.append(B[i][0] | B[i][1] | B[i][2]) c.append(B[0][i] | B[1][i]...
p03221
s387159207
Accepted
n,m = list(map(int, input().split())) #data={} #l=[] data = [tuple(map(int, input().split())) for _ in range(m)] #for i in range(m): # tup = tuple(map(int, input().split())) # data[i]=tup # l.append(tup) m={} n=0 p=None for t in sorted(data): # print('p=',p,'t[0]=',t[0]) if p!=t[0]: p=t[0] ...
p03319
s107018497
Accepted
N,K=map(int,input().split()) A=list(map(int,input().split())) cnt=0 while True: N=N-K cnt+=1 if N<=0: break else: N=N+1 print(cnt)
p02775
s423795172
Accepted
S = input()[::-1] l = len(S) dp = [[0]*2 for _ in range(l+1)] dp[1][0]=dp[0][0]+int(S[0]) dp[1][1]=dp[0][1]+10-int(S[0]) for i in range(1,l): dp[i+1][0]=min(dp[i][0]+int(S[i]),dp[i][1]+int(S[i])+1) dp[i+1][1]=min(dp[i][0]+10-int(S[i]),dp[i][1]+10-int(S[i])-1) print(min(dp[-1][0],dp[-1][1]+1))
p03069
s060344896
Accepted
def main(): N = int(input()) S = input() Ws = [0]*(N+1) Bs = [0]*(N+1) for i in range(1, N + 1): Bs[i] = Bs[i - 1] + (1 if S[i-1] == '#' else 0) Ws[N - i] = Ws[N + 1 - i] + (1 if S[N - i] == '.' else 0) # print(Ws[:10], Bs[:10]) ans = Bs[0] + Ws[0] for i in range(1, N + 1...
p04045
s758248478
Wrong Answer
from itertools import product n, k = input().split() a = list(input().split()) l = set([str(i) for i in range(10)]).difference(a) ni = int(n) for j in range(len(n), len(n)+2): for i in product(l, repeat=j): t = ''.join(i) if int(t) >= ni: print(t) exit()
p03345
s347252553
Accepted
import sys a, b, c, k = map(int, input().split()) if abs(b-a) >= 10**18: print('Unfair') elif k%2 == 1: print(b-a) else: print(a-b)
p02843
s986486012
Wrong Answer
X = int(input()) X_ = X % 101 N = X // 101 ans = 0 for i in range(6): if X_ > N: X_ -= N else: print(1) break else: print(0)
p03475
s014359460
Accepted
n=int(input()) n-=1 c=[0]*n s=[0]*n f=[0]*n for i in range(n): c[i],s[i],f[i]=map(int,input().split()) for i in range(n): t=0 for j in range(i,n): if t<s[j]: t=s[j] elif t%f[j]==0: pass else: t=t+f[j]-t%f[j] t+=c[j] print(t) print(0)
p03951
s294938860
Wrong Answer
n = int(input()) a, b = [input() for i in range(2)] for i in range(n+1): if a[i:] == b[:n-i]: print(i + n)
p03778
s201607359
Accepted
w, a, b = map(int, input().split()) if b > a: print(max(0, b - a - w)) else: print(max(0, a - b - w))
p03910
s029294256
Accepted
a = int(input()) t =1 rps = 0 while a > rps: rps+=t t+=1 d = rps - a for i in range(1,t): if i!=d: print(i)
p03211
s396439820
Wrong Answer
s = list(input()) # print(''.join(s[0:3])) A = [] for i in range(0, len(s) - 2): A.append(abs(int(''.join(s[i:i+3])) - 753)) for i in range(0, len(s) - 4): A.append(abs(int(''.join(s[i:i+4])) - 753)) print(min(A))
p03998
s320518381
Wrong Answer
sa = input() sb = input() sc = input() now = sa[0] for i in range(320): if now == 'a': sa = sa[1:] elif now == 'b': sb = sb[1:] elif now == 'c': sc = sc[1:] if len(sa) == 0: print('A') break elif len(sb) == 0: print('B') break elif len(sc...
p03659
s437476130
Accepted
from itertools import*;*a,s=list(accumulate(map(int,open(0).read().split()[1:])));print(min(abs(s-x*2)for x in a))