problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02783
s211852229
Accepted
a, b = map(int, input().split()) print(-(-a//b))
p02933
s109412337
Accepted
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # -------------------------------------------------...
p04034
s231823249
Accepted
import sys readline = sys.stdin.readline sys.setrecursionlimit(10**8) mod = 10**9+7 #mod = 998244353 INF = 10**18 eps = 10**-7 N,M = map(int,readline().split()) c = [1]*N r = [0]*N r[0] = 1 for _ in range(M): x,y = map(int,readline().split()) x,y = x-1,y-1 if r[x]: if c[x] == 1: r[x] ...
p02971
s758802051
Accepted
n = int(input()) a = [int(input()) for _ in range(n)] m1 = 0 m2 = 0 mp = 0 for i in range(n): if (m1 < a[i]): m2 = m1 m1 = a[i] mp = i elif (m2 < a[i]): m2 = a[i] #print(m1,m2,mp) for i in range(n): if (mp == i): print(m2) else: print(m1)
p03605
s554075560
Wrong Answer
N = input() if "9" in N: print( "YES" ) else: print( "NO" )
p03821
s627517920
Accepted
import sys input = sys.stdin.readline n = int(input()) a = [] b = [] for i in range(n): aa,bb = map(int,input().split()) a.append(aa) b.append(bb) s = 0 res = 0 for i in range(n-1,-1,-1): a[i] += res if a[i]%b[i] == 0: continue res += b[i]-(a[i]%b[i]) print(res)
p03408
s813191181
Accepted
N = int(input()) S = [] for i in range(N): S.append(input()) T = [] M = int(input()) for j in range(M): T.append(input()) C = [] for i in range(N): count = 0 for j in range(N): if S[i] == S[j]: count = count + 1 for k in range(M): if S[i] == T[k]: count = count -1 C.append(count) pri...
p02811
s808219596
Wrong Answer
# -*- coding: utf-8 -*- #入力 n,k = map(int,input().split()) if (500*n > k): print("Yes") else: print("No")
p03221
s697960186
Wrong Answer
n , m = map(int, input().split()) id =[] ch = 1 for i in range(m): p , y = input().split() p = p.zfill(6) id.append([p,y,i]) id.sort(key = lambda x:x[1]) id.sort(key = lambda x:x[0]) id.append(['X','X','X']) for i in range(m): id[i][1]=str(ch).zfill(6) if id[i][0]==id[i+1][0]: ch+=1 else...
p03478
s863372888
Accepted
N, A, B = map(int, input().split()) print(sum(x for x in range(1, N+1) if A<=sum((map(int, str(x))))<=B))
p03680
s931657430
Wrong Answer
n = int(input()) a = [int(input()) for _ in range(n)] ans = 0 for i in range(n): if i == 0: now = a[0]-1 ans += 1 else: now = a[now]-1 ans += 1 if now == 1: print(ans) break if i == n: print(-1)
p03427
s646465834
Accepted
N=input() NL=len(N) if N[1:]=='9'*(NL-1): ans=int(N[0])+9*(NL-1) else: ans=int(N[0])+9*(NL-1)-1 print(ans)
p02555
s494099456
Accepted
n = int(input()) m = n//3 mod = 10**9+7 dp = [[0]*n for _ in range(m)] for i in range(2, n): dp[0][i] = 1 for i in range(1, m): for j in range(3, n): dp[i][j] = dp[i-1][j-3] + dp[i][j-1] ans = 0 for i in range(m): ans += dp[i][-1] ans %= mod print(ans)
p02910
s961595709
Wrong Answer
S = input() odd = S[0::2] even = S[1::2] ans = 'No' if odd not in 'L': if even not in 'R': ans = 'Yes' print(ans)
p03105
s382914228
Accepted
a,b,c=map(int,input().split()) print(min(c,b//a))
p03548
s197461680
Wrong Answer
x,y,z = map(int,input().split()) count = 0 t = 0 for i in range(10**6): t += y if t<=x: count += 1 else: exit() t += z print(count)
p03657
s178114376
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")
p03659
s499730435
Accepted
N=int(input()) A=list(map(int,input().split())) S=sum(A) T=[0]*N for i in range(N-1): T[i+1]=T[i]+A[i] print(min(abs(S-2*T[i]) for i in range(1,N)))
p03720
s327014420
Wrong Answer
N, M = map(int, input().split()) ABs = [input().split() for i in range(M)] MPs = {} for a, b in sorted(ABs, key=lambda i: i[1]): if a not in MPs: MPs[a] = 1 else: MPs[a] += 1 if b not in MPs: MPs[b] = 1 else: MPs[b] += 1 for x, y in sorted(MPs.items(), key=lambda j: j...
p03773
s769873320
Accepted
x=eval(input().replace(' ','+'));print(x%24)
p02700
s578986781
Accepted
a, b, c, d = map(int, input().split()) while True: c -= b if c <= 0: print('Yes') break a -= d if a <= 0: print('No') break
p03705
s803910649
Wrong Answer
if __name__ == '__main__': n,a,b = map(int, input().split()) minN = a+ b+ (n-2)*a maxN = a+ b+ (n-2)*b print(maxN-minN+1)
p02748
s442629873
Wrong Answer
#B - Nice Shopping A,B,M = map(int,input().split()) a = list(map(int,input().split())) b = list(map(int,input().split())) X = [] Y = [] C = [] for i in range(M): x,y,c = map(int,input().split()) X.append(x) Y.append(y) C.append(c) #割引券を使う場合 best_M_idx = C.index(max(C)) pay_M = a[X[best_M_idx]-1] + b[Y...
p02838
s651751825
Wrong Answer
import numpy as np n = int(input()) a = list(map(int, input().split())) p = 7 + 10**9 b = [tuple(map(int, format(i, "061b"))) for i in a] bits1 = np.array(b) bits0 = bits1 ^ 1 accum1 = np.add.accumulate(bits1[::-1])[::-1] accum0 = np.add.accumulate((bits0)[::-1])[::-1] sum1 = bits1[:-1] * accum0[1:] sum0 = bits0[:-...
p02756
s149522903
Accepted
from collections import deque s = list(input()) q = int(input()) t = [list(map(str,input().split())) for _ in range(q)] d = deque(s) cnt = 0 for i in range(q): if len(t[i]) == 1: cnt += 1 else: if (int(t[i][1])+cnt) % 2 != 0: d.appendleft(t[i][2]) else: d.append(t[i][2]) if cnt%2 !...
p03427
s636631331
Accepted
n = list(map(int, list(input()))) ans = len(n)*9 - (9 - n[0]) -1 print(max(ans, sum(n)))
p03472
s104753965
Accepted
from functools import reduce from math import ceil n, h = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] ab.sort(key=lambda x: x[0], reverse=True) max_a = ab[0][0] ab = list(filter(lambda x: x[1] >= max_a, ab)) ab.sort(key=lambda x: x[1], reverse=True) for i, v in enumerate(ab): ...
p02916
s670450263
Wrong Answer
n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) c = list(map(int,input().split())) sum_satisfaction = sum(b) for i in range(1,n): if(i < n-1 and a[i] == a[i-1] + 1 ): sum_satisfaction = sum_satisfaction + c[i] print(sum_satisfaction)
p02706
s710131421
Accepted
N,M = map(int, input().split()) A = list(map(int, input().split())) # 入力のときに N を使う必要はありません # print(A[0]) F=N-sum(A) if F>=0: print(F) if F<0: print(-1)
p04033
s063255546
Accepted
def main(): a, b = map(int, input().split()) if a > 0 and b > 0: print('Positive') elif (a > 0) ^ (b > 0) or a == 0 or b == 0: print('Zero') else: if (a - b) % 2 != 0: print('Positive') else: print('Negative') if __name__ == '__main__': main(...
p02708
s940504798
Wrong Answer
n, k = map(int, input().split()) MOD = 1e9+7 a = [0] * (n+2) s = [0] * (n+2) a[1] = (n+1) s[1] = a[1] for i in range(2,n+2): add = ( a[i-1] + n - 2 * (i-1) ) % MOD if add < 0: add += MOD a[i] = add add = (s[i-1] + a[i]) % MOD if add < 0: add += MOD s[i] = add print(int(s[n+1...
p02583
s499057593
Accepted
#template def inputlist(): return [int(j) for j in input().split()] #template N = int(input()) L = inputlist() L.sort() ans = 0 for i in range(N): for j in range(i+1,N): for k in range(j+1,N): if L[i]+ L[j] > L[k] and L[i] != L[j] and L[j] != L[k]: ans +=1 print(ans)
p02819
s389305294
Accepted
X = int(input()) while True: flag = True for i in range(2,X): if X%i == 0: flag = False break if flag: break X += 1 print(X)
p03131
s773390000
Accepted
k, a, b = map(int, input().split()) if b-a<=2 or a>k-1: print(k+1) else: k -= a-1 print(a + (b-a) * (k//2) + k %2)
p04020
s011535958
Accepted
N = int(input()) ans = 0 tmp = -10 for i in range(N): a = int(input()) if tmp == i-1 and a > 0: ans += 1 a -= 1 ans += a//2 if a%2 == 1: tmp = i print(ans)
p03721
s797124927
Wrong Answer
import sys N,K=map(int,input().split()) D=dict() for i in range(N): a,b=input().split() try: D[a]+=int(b) except: D[a]=int(b) D=sorted(D.items(),key=lambda x:x[0]) for k,v in D: K-=v if K<=0: print(k) break
p02688
s850932722
Wrong Answer
n,k = map(int,input().split()) d = int(input()) ans = n-d print(ans)
p03862
s588884290
Wrong Answer
import sys readline = sys.stdin.buffer.readline n,m = map(int,readline().split()) lst1 = list(map(int,readline().split())) ans = 0 for i in range(1,n): if lst1[i-1]+lst1[i] > m: res = max(0,lst1[i]-(m-lst1[i-1])) #print(res) ans += res lst1[i] = lst1[i]-res if lst1[0]+lst1[1] > m: ...
p03485
s586617187
Wrong Answer
a,b = map(int,input().split()) print((a*b)//2 if (a*b)%2 == 0 else ((a*b)//2)+1)
p03220
s502901614
Accepted
n = int(input()) t, a = [int(x) for x in input().split()] h_list = [int(x) for x in input().split()] temp_list = sorted([(abs((t - h * 0.006) - a), i + 1) for i, h in enumerate(h_list)]) print(temp_list[0][1])
p03804
s446694035
Wrong Answer
N, M = map(int, input().split()) A = [] B = [] for _ in range(N): A.append(input()) for __ in range(M): B.append(input()) for i in range(N-M): if B[0] in A[i]: for j in range(N-M): for k in range(M): if B[k] != A[i+k][j:j+M]: break print('...
p03379
s530563339
Wrong Answer
import copy N = int(input()) X = list(map(int,input().split())) length = len(X) X.sort() bef = int(length/2) aft = bef+1 for i in range(bef): print(X[bef-1]) for i in range(length-bef): print(X[aft-1])
p02916
s559634417
Wrong Answer
N = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) score = B[A[0]-1] for i in range(1,N): score += B[A[i]-1] for j in range(0, N-1): if A[j+1] - A[j] == 1 and j != 0: score += C[j-1] print(score)
p02835
s949739314
Wrong Answer
a1,a2,a3 = map(int,input().split()) if a1+a2+a3>=22: print("burst") else: print("win")
p02933
s071204355
Wrong Answer
a = input() input_s = input() b = int(a) if 3200 <= b: output_s = ("input_s") elif b <3200: output_s = ("red") print(output_s)
p02627
s752093598
Accepted
a = input() if a == a.upper(): print("A") else: print("a")
p02879
s049022386
Accepted
A,B = map(int, input().split()) print(A*B if max(A,B) <= 9 else -1)
p02665
s237456885
Wrong Answer
N = int(input()) X = list(map(int, input().split())) cnt = [0] * (N + 1) cnt[0] = 1 for i in range(N): cnt[i + 1] = (cnt[i] - X[i]) * 2 ans = 0 cur = 0 for i in reversed(range(N + 1)): cur += X[i] ans += min(cnt[i], cur) if all(cnt[i] >= X[i] for i in range(N)): print(ans) else: print(-1)
p03360
s794052575
Wrong Answer
a, b, c = map(int, input().split()) k = int(input()) ans = 0 ans = max(a * (2 * k) + b + c, b * (2 * k) + a + c, c * (2 * k) + a + b) print(ans)
p03328
s868767772
Accepted
A, B = map(int, input().split()) diff = B - A height_A = diff * (diff - 1) // 2 ans = height_A - A print(ans)
p03037
s126727966
Accepted
N, M = map(int, input().split()) maxL = 0 minR = N for i in range(M): L, R = map(int, input().split()) maxL = max(maxL, L) minR = min(minR, R) if minR - maxL >= 0: print(minR - maxL + 1) else: print(0)
p02612
s773271888
Accepted
N = int(input()) if N%1000 == 0: print(0) else: print(1000-(N%1000))
p02787
s945035927
Accepted
H,N = map(int,input().split()) AB = [list(map(int,input().split())) for _ in range(N)] dp = [0]+[float("inf")]*H for i in range(N): for h in range(H+1): t = h + AB[i][0] if h + AB[i][0] > H: t = H dp[t] = min(dp[t],dp[h]+AB[i][1]) print(dp[H])
p02677
s245879021
Wrong Answer
import math a,b,h,m = map(int,input().split()) short = h*30+m/2 long = m*6 ang = abs(short-long) ang = ang if ang <= 180 else ang-180 hen = math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(ang))) print(hen)
p02802
s298794707
Accepted
n, m = map(int, input().split()) wa = [0]*n ac = [0]*n for i in range(m): p, s = input().split() p = int(p) - 1 if s == 'AC' and ac[p] == 0: ac[p] = 1 elif s =='WA' and ac[p] == 0: wa[p] += 1 for j in range(n): if ac[j] == 0: wa[j] = 0 print(sum(ac), sum(wa))
p03773
s974500946
Wrong Answer
A, B = map(int, input().split()) T = A+B if (T <= 24): print(T) else: print(T-24)
p02742
s885732786
Accepted
import sys h, w = map(int, input().split()) if h == 1 or w == 1: print(1) sys.exit() if h % 2 == 1 and w % 2 == 1: print(int(h*w//2 + 1)) else: print(int(h*w//2))
p02663
s309744640
Wrong Answer
print("aaa")
p02795
s739554122
Wrong Answer
h = int(input()) w = int(input()) n = int(input()) count=1 if(h>=w): big=h small=w else: big=w small=h n=n-small count=count+int(n/(big)) print(count)
p03493
s184444340
Accepted
print(input().count('1'))
p02771
s221985485
Wrong Answer
a,b,c = input().split(' ') # aとbが等しい かつ aはcと等しくない if a == b and a != c: print("Yes") # それ以外の時 else: print("No")
p03730
s910946493
Wrong Answer
a, b, c = map(int, input().split()) L = [0] * b for i in range(1, b): s = (a * i) % b if L[s] == 1: print('No') break elif s == c: print('Yes') break else: L[s] = 1 else: print('No')
p03645
s897246908
Wrong Answer
n,m = map(int,input().split()) graph = [[0 for i in range(n)] for j in range(n)] for i in range(m): a,b = map(int,input().split()) graph[a-1][b-1] = 1 graph[b-1][a-1] = 1 flag = False for i in range(n): if graph[0][i] == 1: for j in range(n): if graph[i][j] == 1: fla...
p02953
s221466031
Accepted
N = int(input()) h = list(map(int, input().split())) for i in range(1, N): if h[i] - h[i - 1] >= 1: h[i] -= 1 for i in range(1, N): if h[i] - h[i - 1] < 0: print('No') exit() print('Yes')
p03545
s553388214
Accepted
s = input() for bit in range(1<<len(s)-1): f = s[0] for i in range(len(s)-1): if (bit>>i) & 1: f += '+' else: f += '-' f += s[i+1] if eval(f) == 7: print(f+'=7') exit()
p03359
s461095226
Accepted
a,b=map(int,input().split()) if b>=a: print(a) else: print(a-1)
p03160
s771897832
Accepted
def main(): footing = int(input()) height = list(map(int, input().split())) answer = [0] * footing answer[1] = abs(height[1] - height[0]) for i in range(2, footing): answer[i] = min(answer[i - 2] + abs(height[i] - height[i - 2]), answer[i - 1] + abs(height[i] - height[i - 1])) print(answ...
p02881
s272041831
Accepted
n = int(input()) def divisor(n): i = 1 table = [] while i * i <= n: if n%i == 0: table.append(i) table.append(n//i) i += 1 table = list(set(table)) return table nums = divisor(n) total = [] for i in range(len(nums)): s = int(n/nums[i]) total.append(s...
p02640
s138303954
Wrong Answer
X,Y= map(int, input().split()) ans='Yes' for i in range(X+1): if Y!=2*i+4*(X-i): print('No') break print('No')
p02796
s656056211
Wrong Answer
N = int(input()) l = list() for i in range(N): X, L = map(int, input().split()) left = X - L right = X + L l.append([left, right]) l.sort() cnt = 0 n = 0 t = 1 while t < N: if l[n][1] > l[t][0]: cnt += 1 else: n = t t += 1 print(N - cnt)
p02713
s724462266
Wrong Answer
import math from functools import reduce def gcd(*numbers): return reduce(math.gcd, numbers) def gcd_list(numbers): return reduce(math.gcd, numbers) k = int(input()) output = 0 for i in range(k): for j in range(k): for h in range(k): output += gcd(i,j,h) print(output)
p03994
s268398405
Accepted
S = input() K = int(input()) A = [" " for _ in range(len(S))] zan = K for i in range(len(S)): n = (ord('z') - ord(S[i]) + 1) % 26 # aに変換するのに必要な回数 if zan >= n: zan -= n A[i] = 'a' else: A[i] = S[i] if zan > 0: A[-1] = chr((ord(A[-1]) - ord('a') + zan)%26 + ord('a')) print("".join(A))
p02922
s747674341
Accepted
import sys [A, B] = [int(x) for x in sys.stdin.readline().strip().split(" ")] current = 1 result = 0 while current < B: result += 1 current += A - 1 print(result)
p03264
s189994077
Accepted
K = int(input()) if K % 2 == 0: print((K//2)**2) else: print((K//2)*((K//2)+1))
p03821
s775560559
Wrong Answer
N = int(input()) AB = [list(map(int,input().split())) for _ in range(N)] AB.reverse() count = 0 for a,b in AB: num_a = a+count if b == 1: if num_a == 0: count += 1 else: continue elif a%b == 0: continue else: count += (b-num_a%b) print(count)
p02801
s396900769
Accepted
def p_a(): import string l = string.ascii_lowercase c = input() print(l[l.index(c) + 1]) p_a()
p02712
s252990210
Wrong Answer
for number in range(1, 30 + 1): if (number % 3 == 0) and (number % 5 == 0): print('FizzBuzz') elif number % 3 == 0: print('Fizz') elif number % 5 == 0: print('Buzz') else: print(str(number))
p02552
s057841451
Accepted
def main(): x = int(input()) x ^= 1 print(x) if __name__ == "__main__": main()
p02866
s931917256
Accepted
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) from collections import Counter n = int(readline()) d = list(map(int, readline().split())) counter = Counter(d) mod = 998244353 ans = 1 if d[0] != 0 or counter[0] != 1: ...
p03264
s013707275
Accepted
k = int(input()) l = [0] for i in range(1, k + 1): l.append(l[-1] + i // 2) # l = [0, 0, 1, 2, 4, 6, 9, 12, ... k] print(l[-1])
p02786
s880432400
Accepted
import math print(2 ** (math.floor(math.log2(int(input())))+1) - 1)
p02596
s270142711
Accepted
k = int(input()) mod = 7 % k counter = 1 memo = 1 mod_map = set() mod_map.add(mod) while mod != 0: mod = ((mod * 10) % k + 7) % k if mod not in mod_map: mod_map.add(mod) else: counter = -1 break counter += 1 if mod == 0: break print(counter)
p02982
s853165916
Wrong Answer
import math n,d=map(int,input().split()) X=[] for i in range(n): x=list(map(int,input().split())) X.append(x) cnt=0 for i in range(n): for j in range(i+1,n): s=0 for a,b in zip(X[i],X[j]): s+=(a-b)**2 s=math.sqrt(s) print(s) if s.is_integer(): ...
p03986
s296637095
Accepted
from collections import deque s=input() d=deque() for i in s: if i=="S": d.append("S") elif i=="T" and (not d or d[-1]=="T"): d.append("T") else: d.pop() print(len(d))
p03657
s434994236
Wrong Answer
a, b = map(int, input().split()) print("Possible" if a % 3 == 3 or b % 3 == 0 or (a + b) % 3 == 0 else "Impossible")
p02659
s163886046
Accepted
from decimal import Decimal a, b = map(Decimal, input().split()) print(a * b //1)
p02899
s112997997
Accepted
n = int(input()) a = list(map(int, input().split())) l = [(a[i], i) for i in range(n)] l = sorted(l) ans = [] for i in range(n): ans.append(str(l[i][1] + 1)) ans = " ".join(ans) print(ans)
p02724
s702722472
Wrong Answer
x=int(input()) import math a=x//500 b=(x-a*500)//50 print(1000*a+5*b)
p02833
s018210923
Accepted
n=int(input()) if n%2==1: print(0) else: cnt=1 ans=0 while 2*5**cnt<=n: ans+=n//(2*5**cnt) cnt+=1 print(ans)
p02933
s357698204
Accepted
a=int(input()) s=input() if(a>=3200): print(s) else: print("red")
p03059
s001215039
Accepted
x,y,z=map(int,input().split()) s=0 c=0 i=0 while(s<z+0.5): c+=y s+=x if(s>z): c-=y print(c)
p03210
s537915802
Wrong Answer
n = input() print("YES" if "753" in n else "NO")
p03639
s292708414
Wrong Answer
n = int(input()) a = list(map(int, input().split())) c4 = 0 c2 = 0 for i in a: if i%4 == 0: c4 += 1 elif i%2 == 0: c2 += 1 c0 = n - c4 - c2 ans = False if c2 < 2: if c0 + c2 <= 2*c4: ans = True else: if c0 <= c4*2: ans = True if ans: print("Yes") else: print("No"...
p02624
s992778648
Accepted
import sys input = lambda: sys.stdin.readline().rstrip() def main(): n = int(input()) ans = 0 for i in range(1, n + 1): # k = n // i # kk = int((k + 1) * (k / 2) * i) # ans += kk for j in range(i, n + 1, i): ans += j print(ans) if __name__ == '__main__'...
p03264
s582763134
Wrong Answer
N = int(input()) if N % 2 ==0: print((N/2)**2) else: print(((N-1)/2)*(1+(N-1)/2))
p03243
s262349154
Wrong Answer
N = input() h = int(N[0]) t = int(N[1]) o = int(N[2]) if h == t and t == o: print(N) elif h == 9: print(999) else: h += 1 print(h*111)
p03997
s653856765
Accepted
print((int(input())+int(input()))*int(input())//2)
p03086
s156799521
Accepted
from operator import itemgetter s = input() l = len(s) ans = [] flag = False for i in range(l): if flag: if s[i] in "AGCT": continue else: ans.append([i-start,start,i]) flag = False if s[i] in "AGCT": flag = True start = i else: if flag: ...
p03962
s680239994
Wrong Answer
a=list(map(int, input().split())) sum=3 if a[0]==a[1]: sum-=1 if a[0]==a[2]: sum-=1 if a[1]==a[2]: sum-=1 print(sum)
p03067
s463407952
Wrong Answer
a,b,c=map(int,input().split()) if c in list(range(a,b)): print('YES') else: print('NO')