problem_id
stringclasses
428 values
submission_id
stringlengths
10
10
status
stringclasses
2 values
code
stringlengths
5
816
p02602
s374426128
Accepted
import math # a=int(input()) #b=int(input()) # c=[] # for i in b: # c.append(i) e1,e2 = map(int,input().split()) f = list(map(int,input().split())) #j = [input() for _ in range(3)] cal=1 for i in range(e1-e2): if f[i]>=f[i+e2]: print("No") else: print("Yes")
p04005
s507218664
Accepted
#!/usr/bin/env python3 def main(): A, B, C = map(int, open(0).read().split()) m = A*B*C ans = min(abs(2*A*C*(B//2) - m), abs(2*C*B*(A//2) - m), abs(2*B*A*(C//2) - m)) print(ans) main()
p02953
s707721797
Wrong Answer
import sys input = sys.stdin.readline N = int(input()) a = list(map(int, input().split())) if max(a) - min(a) <= 1: print("Yes") exit(0) for i in range(N - 1): if a[i + 1] - a[i] < 0: a[i] -= 1 if a[i] - a[i + 1] < 0: a[i + 1] -= 1 for i in range(N - 1): if a[i + 1] < a[i]: print("No") exit(0) print("Yes")
p02819
s035490845
Accepted
x = int(input()) for i in range(x,10**6): for k in range(2,i): if i % k != 0: continue else: break else: break print(i)
p03774
s445735144
Accepted
n,m=map(int,input().split()) st=[] ch=[] def mht(ax,ay,bx,by): return abs(ax-bx)+abs(ay-by) for i in range(n): st.append(list(map(int,input().split()))) for i in range(m): ch.append(list(map(int,input().split()))) for i in st: ax=i[0] ay=i[1] mn=1000000000 for (j,k) in zip(ch,range(len(ch))): bx=j[0] by=j[1] mh=mht(ax,ay,bx,by) if mh<mn: mn=mh nm=k print(nm+1)
p03951
s245754058
Accepted
n = int(input()) s = input() t = input() idx = 0 ct = 0 for i in s: if i == t[idx]: ct += 1 idx += 1 print(n*2 - ct)
p03624
s418989798
Wrong Answer
s=input() al = list('abcdefghijelmnopqrstuvwxyz') for s0 in s: if s0 in al: al.remove(s0) if len(al) == 0: print(None) else: print(al[0])
p02744
s605437888
Wrong Answer
n = int(input()) if n == 1: print("a") elif n == 2: print("aa") print("ab") elif n == 3: print("aaa") print("aab") print("aba") print("abb") print("abc")
p02689
s562994699
Accepted
n,m=map(int,input().split()) h=list(map(int,input().split())) good=[True]*n for i in range(m): a,b=map(int,input().split()) a-=1;b-=1 if h[a]<h[b]: good[a]=False elif h[b]<h[a]: good[b]=False elif h[b]==h[a]: good[a]=False good[b]=False print(good.count(True))
p03433
s499660333
Accepted
n = int(input()) a = int(input()) b = n % 500 if a >= b: print("Yes") else: print("No")
p02771
s161163779
Accepted
A,B,C=map(int,input().split()) if A==B==C: print('No') elif A!=B and B!=C and A!=C: print('No') else: print('Yes')
p03042
s999230230
Accepted
def check_month(month): return 1 <= int(month) <= 12 S = input() ls = S[:2] rs = S[2:] if check_month(ls) and check_month(rs): print('AMBIGUOUS') elif check_month(ls) and not check_month(rs): print('MMYY') elif not check_month(ls) and check_month(rs): print('YYMM') else: print('NA')
p03013
s493834824
Accepted
I=lambda : list(map(int,input().split())) n,m = I();md=10**9+7;p=0;a=1 dp=[0,1];l=[0]*(10**5+2) for _ in range(m): x=int(input()) l[x]=1 for i in range(1,n+1): if l[i]: dp.append(0) else: dp.append((dp[-1]+dp[-2])%md) print(dp[-1])
p03071
s964288365
Accepted
a,b = map(int, input().split()) if a-b >= 2: print(a+(a-1)) elif b-a >= 2: print(b+(b-1)) else: print(a+b)
p03556
s093650988
Accepted
N = int(input()) print(int(N**(1/2))**2)
p02678
s013020689
Accepted
n, m = map(int, input().split()) G = [[] for _ in range(n)] for i in range(m): a, b = map(int, input().split()) a, b = a - 1, b - 1 G[a].append(b) G[b].append(a) ans = [-1] * n from collections import deque d = deque([0]) while d: u = d.popleft() for v in G[u]: if ans[v] == -1: ans[v] = u d.append(v) if -1 in ans[1:]: print('No') else: print('Yes') for v in ans[1:]: print(v + 1)
p03951
s377449859
Wrong Answer
N=int(input()) s=list(input()) t=list(input()) f=s+t if s==t: print(''.join(s)) exit() for i in range(0,N): if s[-i:]==t[:i]: f=s+t[i:] print(''.join(f))
p02732
s029813068
Wrong Answer
n = 8 a = list(map(int, '1 2 1 4 2 1 4 1'.split())) count_dict = {} total_sum = 0 for i in a: if i not in count_dict: count_dict[i] = a.count(i) total_sum += (a.count(i))*(a.count(i)-1)//2 for i in a: print(total_sum - (a.count(i)*(a.count(i)-1)//2) + (a.count(i)-1)*(a.count(i)-2)//2)
p03319
s454638454
Wrong Answer
N, K = map(int, input().split()) a = list(map(int, input().split())) #index = a.index(1) #print(index) if K == 2: print(K-1) else: if N == K: print(1) elif (N-K) % (K-1) != 0: print(int((N-K)/(K-1))+2) else: print(int((N-K)/(K-1))+1)
p03910
s896106699
Accepted
N = int(input()) i = 0 total = 0 while True: total += i if total >= N: tmp = i break i += 1 for j in range(tmp, 0, -1): if N - tmp >= 0: N -= tmp print(tmp) if N == 0: break tmp -= 1
p02970
s108322698
Wrong Answer
n,d = map(int,input().split()) print(n//(2*d+1)+1)
p03109
s225330922
Accepted
S=input() if int(S[5:7])>=5: print("TBD") else: print("Heisei")
p02982
s907618640
Accepted
import math N,D = map(int,input().split()) X = [0]*N total = 0 cnt = 0 for i in range(N): X[i] = list(map(int,input().split())) for i in range(N-1): for j in range(i+1,N): for k in range(D): total += abs(X[j][k]-X[i][k])**2 if math.sqrt(total)%1==0: cnt += 1 total=0 print(cnt)
p03944
s041835977
Accepted
import sys W, H, N = map(int, sys.stdin.readline().split(" ")) Map = [list(map(int,sys.stdin.readline().split(" "))) for i in range(N)] L = 0 R = W B = 0 T = H for i in Map: if i[2] == 1: l = i[0] L = max(L, l) if i[2] == 2: r = i[0] R = min(R, r) if i[2] == 3: b = i[1] B = max(B, b) if i[2] == 4: t = i[1] T = min(T, t) if R - L > 0 and T - B > 0: print((R - L) * (T - B)) else: print(0)
p02624
s480499247
Accepted
def main(): num = int(input()) def ggg(): for divisor in range(1, num + 1): quotient = num // divisor yield (quotient + 1) * quotient * divisor // 2 print(sum(ggg())) if __name__ == '__main__': main() # Python 3.8.2: 1332 ms # Pypy 3 (7.3.0): 172 ms
p02639
s112831693
Accepted
li = list(map(int,input().split())) for i in range(len(li)): if 0==li[i]: print(i+1)
p02660
s498573424
Accepted
N = int(input()) ans = 0 d = 2 while d*d <= N: e = 0 while N%d == 0: e+=1 N//=d i=1 while i<=e: ans+=1 e-=i i+=1 d+=1 if N>1: ans+=1 print(ans)
p03475
s169567477
Wrong Answer
n = int(input()) stations = [] for _ in range(n-1): stations.append(list(map(int, input().split()))) me = 0 for i in range(n-1): remain = n - i - 1 cost = 0 time = 0 for r in range(remain): c, s, f = stations[r+i] if time < s: time = s else: if time - s < s: time = s*2 else: time = s + ((time - s)//f)*f time += c print(time) print(0)
p02948
s877590381
Wrong Answer
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines sys.setrecursionlimit(10 ** 7) n, m = map(int, readline().split()) ab = [list(map(int, readline().split())) for _ in range(n)] ab.sort(key=lambda x: (-x[1], -x[0])) day = 0 ans = 0 for a, b in ab: if day + a <= m: ans += b day += 1 print(ans)
p02838
s743935747
Accepted
n=int(input()) a=list(map(int, input().split())) mod=10**9+7 bins_zero=[0]*61 bins_one=[0]*61 for a_i in a: a_i_bin=list(str(bin(a_i))[2:].zfill(61)) for i in range(len(a_i_bin)): if a_i_bin[i]=='0': bins_zero[i]+=1 else: bins_one[i]+=1 ans=0 for i in range(61): ans+=(bins_one[i]*bins_zero[i]*(2**(60-i))) print(ans%mod)
p02761
s696242948
Accepted
N,M = map(int,input().split()) sc = [[0,0]]*M ans = [0]*N f = True ans = -1 for i in range(M): sc[i] = list(map(int,input().split())) for i in range(1000): str_i = list(str(i)) if (len(str_i) == N): f = True for j in range(M): f &= (str_i[sc[j][0]-1] == str(sc[j][1])) if (f): ans = i break print(ans)
p02833
s884418713
Wrong Answer
import math N = int(input()) if N < 2 or N % 2 == 1: print(0) exit() res = 0 de = 10 while 1: quot = math.floor(N / de) if quot == 0: break res += quot de *= 5 print(res)
p02555
s673010260
Wrong Answer
S = int(input()) memo = {1:0,2:0,3:1,4:1,5:1} def Redi(n): if n in memo: return memo[n] else: ans = 1 for i in range(3,n-2): ans += Redi(n-i) memo[n] = ans return memo[n] print(Redi(S))
p03095
s129200034
Wrong Answer
# A - Colorful Subsequence import numpy as np N,S = int(input()),input() count = np.zeros(26) for i in range(N): count[ord(S[i])-ord('a')] += 1 ans = 1 for i in range(26): ans *= (count[i]+1) print((ans-1)%(10**9+7))
p02951
s567402333
Wrong Answer
A,B,C=map(int,input().split()) x=A-B print(C-x)
p03145
s213802000
Accepted
a,b,c=map(int, input().split()) print(int(a*b/2))
p03721
s070147619
Wrong Answer
n, k = map(int, input().split()) l = [] for i in range(n): a, b = map(int, input().split()) l += [a] * b print(l[k-1])
p03250
s912643831
Wrong Answer
A=list(map(int, input().split())) A.sort() print(sum(A)+A[0]*9)
p03835
s930996489
Accepted
k,s=map(int,input().split()) ret=0 k+=1 for i in range(k): for j in range(k): d=s-i-j if k>d>=0: ret+=1 print(ret)
p03487
s266635878
Accepted
from collections import Counter n=int(input()) a=Counter(input().split()) ans=0 for i,j in a.items(): i=int(i) if i>j: ans+=j elif i<j: ans+=j-i print(ans)
p03645
s885731602
Wrong Answer
from scipy.sparse.csgraph import dijkstra def main(): N, M = map(int, input().split()) l = [[0] * N for _ in range(N)] for _ in range(M): a, b = map(int, input().split()) l[a-1][b-1] = 1 l[b-1][a-1] = 1 res = dijkstra(l) if 2 in res[0]: print("POSSIBLE") else: print("IMPOSSIBLE") if __name__ == "__main__": main()
p02663
s351403001
Accepted
h = list(map(int, input().split())) h1 = h[0] m1 = h[1] h2 = h[2] m2 = h[3] k = h[4] lh = h2 - h1 if lh < 0: lh = lh + 24 lm = m2 - m1 if lh == 0 and lm < 0: lm = lm + 24*60 l = lh * 60 + lm - k print(l)
p03774
s024539256
Accepted
n,m = map(int,input().split()) a = [list(map(int,input().split())) for _ in range(n)] c = [list(map(int,input().split())) for _ in range(m)] for i in range(n): x,y = a[i] count = 0 l = abs(x-c[0][0]) + abs(y-c[0][1]) for j in range(m): p,q = c[j] if l > abs(x-p) + abs(y-q): l = abs(x-p)+abs(y-q) count = j print(count+1)
p03986
s960464217
Accepted
X = input() result = len(X) n_S = 0 for c in X: if c == 'S': n_S += 1 elif c == 'T': if n_S > 0: n_S -= 1 result -= 2 else: raise ValueError print(result)
p02918
s486439103
Wrong Answer
(str_len,cng_cnt) = input().split(" ") str_input = list(input()) print(str_len) print(cng_cnt) cng_cnt= int(cng_cnt) #print(asd) tmp1="" cnt=0 cnt2=0 for st in str_input: if(tmp1 == st ): cnt = cnt+1 else: cnt2= cnt2 + 1 tmp1=st if (cng_cnt < cnt2 ): c_up = cng_cnt * 2 else: c_up= (cnt2 * 2) + (cng_cnt - cnt2) ans =cnt + c_up print(ans)
p02948
s554114254
Accepted
from heapq import heappush, heappop n, m = map(int, input().split()) ab = [list(map(int, input().split())) for _ in range(n)] day = [[] for _ in range(10 ** 5)] for a, b in ab: day[a - 1].append(b) work, ans = [], 0 for i in range(m): for j in day[i]: heappush(work, -j) if len(work) > 0: ans -= heappop(work) print(ans)
p02720
s827490202
Wrong Answer
K = int(input()) ans = [] i = 1 while len(ans) < K : l = len(str(i)) - 1 que = 'yes' for k in range(l): a = str(i) if abs( int(a[k])- int(a[k+1]) ) >= 2: que = 'no' break if que == 'yes': ans = ans + [i] i +=1 print(i)
p03281
s066183253
Accepted
N = int(input()) ans = 0 for i in range(1, N+1, 2): count = 0 for j in range(1, int(i ** 0.5) + 1): if i % j == 0: count += 2 if int(i ** 0.5) ** 2 == i: count -= 1 if count == 8: ans += 1 print(ans)
p02948
s424872117
Accepted
import heapq N,M = map(int,input().split()) AB = [[] for i in range(M+1)] for i in range(N): a,b = list(map(int,input().split())) if a <= M: AB[a].append(-b) work = 0 AB2 = [] heapq.heapify(AB2) for i in range(1,M+1): for j in AB[i]: heapq.heappush(AB2,j) if not AB2: continue b = heapq.heappop(AB2) work += -b print(work)
p03557
s993234875
Accepted
import sys import bisect input = sys.stdin.readline n=int(input()) a = sorted(list(map(int, input().split()))) b = sorted(list(map(int, input().split()))) c = sorted(list(map(int, input().split()))) ans=0 for j in range(n): al=bisect.bisect_left(a,b[j]) cl=n-bisect.bisect_right(c,b[j]) ans+=al*cl print(ans)
p03126
s932860396
Accepted
def main(): n, m = map(int, input().split()) kas = [list(map(int, input().split())) for _ in range(n)] question_dict = {i: 0 for i in range(1, m+1)} ans = 0 for ka in kas: a = ka[1:] for i in a: question_dict[i] += 1 for food, num in question_dict.items(): if num == n: ans += 1 print(ans) if __name__ == "__main__": main()
p02957
s864398195
Accepted
a,b = map(int,input().split()) k = (a+b)/2 if k.is_integer(): print(int(k)) else: print('IMPOSSIBLE')
p02797
s653627074
Wrong Answer
s = list(map(int, input().split())) N = s[0] K = s[1] S = s[2] t =[] a = K//701 b = K%701 c = (N - K)//701 d = (N - K)%701 for i in range(a): t = t + [S]*701 for i in range(b): t = t + [S] for j in range(c): t = t + [S + 1]*701 for j in range(d): t = t + [S + 1] print(*t)
p02547
s782540818
Accepted
import sys input = sys.stdin.readline n = int(input()) cnt = 0 for _ in range(n): d1, d2 = map(int, input().split()) if d1 == d2: cnt += 1 else: cnt = 0 if cnt == 3: break if cnt == 3: print('Yes') else: print('No')
p03962
s879267546
Wrong Answer
a, b, c= map(int, input().split()) if a==b and b==c: print(1) elif a==b: print(2) elif b==c: print(2) else: print(3)
p03162
s450298766
Wrong Answer
from sys import stdin def main(): n = int(input()) ary = [list(map(int, stdin.readline().split())) for _ in range(n)] dp = [[]] * n def max_act(abc,yesterday=None): if yesterday: del abc[yesterday] v = max(abc) i = abc.index(v) return [i,v] dp[0] = max_act(ary[0]) for i in range(1,n): dp[i] = max_act(ary[i],dp[i-1][0]) print(sum([i[1] for i in dp])) if __name__ == '__main__': main()
p02612
s148537856
Accepted
n = int(input()) if n % 1000 == 0: print(0) exit() print((n//1000+1) * 1000 - n)
p02628
s435624645
Wrong Answer
N,K,*P=map(int,open(0).read().split()) print(sum(sorted(P[:K])))
p03455
s345905064
Accepted
a, b = map(int, input().split()) n = a * b if n % 2 == 0: print('Even') else: print('Odd')
p02796
s298618783
Accepted
n=int(input()) import heapq q=[] for i in range(n): x,l=map(int,input().split()) heapq.heappush(q,(x+l,l)) largest=-float('inf') c=0 while q: a,l=heapq.heappop(q) if largest<=a-2*l: largest=a c+=1 print(c)
p02701
s301046945
Wrong Answer
p = input() .split() s = set() for i in range(1, len(p)): s.add(p[i]) print(len(set(s)))
p03455
s743125030
Accepted
a,b = map(int,input().split()) if (a*b) % 2 == 1: print('Odd') else: print('Even')
p02771
s080501740
Accepted
a,b,c=map(int,input().split()) if a==b and a==c: print('No') elif a!=b and a!=c and b!=c: print('No') else: print('Yes')
p03836
s438460365
Accepted
sx,sy,tx,ty=map(int,input().split()) x=tx-sx y=ty-sy for i in range(x): print("R",end="") for i in range(y): print("U",end="") for i in range(x): print("L",end="") for i in range(y): print("D",end="") #iki print("D",end="") for i in range(x+1): print("R",end="") for i in range(y+1): print("U",end="") print("L",end="") print("U",end="") for i in range(x+1): print("L",end="") for i in range(y+1): print("D",end="") print("R",end="")
p03038
s099461197
Accepted
import sys input = sys.stdin.readline N,M = map(int,input().split()) from collections import Counter A = list(map(int,input().split())) A=Counter(A) cnt = [(0,0) for _ in range(len(A)+M)] i = 0 for _ in A.most_common(): cnt[i]=_ i+=1 for j in range(M): B,C = map(int,input().split()) cnt[i]=(C, B) i+=1 cnt.sort(key=lambda x:x[0],reverse=True) nn = 0 ans = 0 for k in range(len(cnt)): d = min(N-nn,cnt[k][1]) nn += d ans += d * cnt[k][0] if nn == N: break print(ans)
p03761
s267958938
Accepted
from collections import Counter n = int(input()) s = input() c = Counter(s) for i in range(n-1): s = input() c &= Counter(s) ans = '' for i in sorted(c): ans += i*c[i] print(ans)
p03778
s920460460
Accepted
w,a,b = map(int,input().split()) if a + w <= b: print(b - (a + w)) elif b + w <= a: print(a - (b + w)) else: print(0)
p03433
s717068514
Wrong Answer
a=int(input()) b=int(input()) print("Yes" if a%500 - b <0 else "No")
p03448
s430338483
Accepted
a = int(input()) b = int(input()) c = int(input()) x = int(input()) x /= 50 cnt = 0 for i in range(a+1): for j in range(b+1): for k in range(c+1): if 10*i + 2*j + k == x: cnt += 1 print(cnt)
p03221
s147768709
Accepted
N, M = map(int, input().split()) ss = [[] for _ in range(N)] for i in range(M): p, y = map(int, input().split()) ss[p-1].append((i, y)) ls = [''] * M for p in range(N): s = ss[p] s.sort(key=lambda g: g[1]) for d, (i, y) in enumerate(s): ps = str(p+1).zfill(6) ds = str(d+1).zfill(6) ls[i] = ps+ds for l in ls: print(l)
p02552
s069615942
Accepted
x = int(input()) if x: print(0) else: print(1)
p03854
s302194136
Accepted
s = input() a = s.replace('eraser','') b = a.replace('erase','') c = b.replace('dreamer','') d = c.replace('dream','') if d == '': print('YES') else: print('NO')
p03720
s676806595
Accepted
N, M = map(int, input().split()) A = [[0]*(N+1) for _ in range(N+1)] for i in range(M): a, b = map(int, input().split()) A[a][b] += 1 A[b][a] += 1 for i in range(1, N+1): sum = 0 for j in range(1, N+1): sum += A[i][j] print(sum)
p03838
s698739423
Wrong Answer
x, y = map(int, input().split()) button = 0 if x<0 and y<0: button+=2 elif x<0 and y>=0: button+=1 elif y<0 and x>=0: button+=1 button+=abs(y)-abs(x) print(button)
p02766
s447042895
Accepted
#!/usr/bin/env python3 def Base_10_to_n(X, n): X_dumy = X out = '' while X_dumy>0: out = str(X_dumy%n)+out X_dumy = int(X_dumy/n) return out N, K = map(int, input().split()) print(len(Base_10_to_n(N, K)))
p02917
s620306536
Accepted
N=int(input()) B=[int(x) for x in input().rstrip().split()] A=[B[0]] for i in range(1,N-1): A.append(min(B[i-1],B[i])) A.append(B[N-2]) print(sum(A))
p03254
s306963031
Accepted
N,x=map(int, input().split()) A=sorted(list(map(int, input().split()))) cnt=0 for i in range(N): if i == N-1 and x > A[i]: break if x >= A[i]: x -= A[i] cnt+=1 else: break print(cnt)
p03495
s907621381
Accepted
n,k=map(int,input().split()) a=list(map(int,input().split())) d={} for x in range(n): if a[x] not in d: d[a[x]]=0 d[a[x]]+=1 ans=0 ans1=[] for g in d: ans1.append(d[g]) if len(ans1)<=k: print(0) else: ans1.sort() r=len(ans1)-k for t in range(r): ans+=ans1[t] print(ans)
p02848
s329077238
Accepted
l = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"*2 n = int(input()) print("".join([l[l.index(x)+n] for x in input()]))
p03723
s537189239
Accepted
a, b, c = map(int, input().split()) flag = 0 ans = 0 if a == b == c and a%2 == 0: ans = -1 else: while flag == 0: if a%2 == 0 and b%2 == 0 and c%2 == 0: a_tmp = (b+c)/2 b_tmp = (a+c)/2 c_tmp = (a+b)/2 a = a_tmp b = b_tmp c = c_tmp ans += 1 else: flag = 1 print(ans)
p02899
s365416416
Accepted
n = int(input()) a = list(map(int,input().split())) b = [0]*n for i in range(n): b[a[i]-1] = str(i+1) print(" ".join(b))
p02982
s290839572
Accepted
import math N,D=map(int,input().split()) X=[list(map(int,input().split()))for i in range(N)] ans=0 dist=0.0 for i in range(N): for j in range(i+1,N): dist=0.0 for k in range(D): dist+=(X[i][k]-X[j][k])**2 dist=math.sqrt(dist) if dist.is_integer() is True: ans+=1 print(ans)
p03317
s609865425
Accepted
n, k = map(int, input().split()) As = list(map(int, input().split())) a=n-1 b=k-1 if a % b == 0: print(a//b) else: print((a//b) + 1)
p03721
s887465485
Accepted
n,k = map(int, input().split()) ab = [] for i in range(n): a,b = map(int, input().split()) ab.append((a,b)) ab.sort() num = 0 for h in range(n): num += ab[h][1] if k <= num: print(ab[h][0]) break
p02814
s713174434
Accepted
def a(): N,M = map(int,input().split()) B = list(map(lambda x: int(x)//2,input().split())) def gcd(n,m): while n: m,n = [n,m%n] return m su = 1 for b in B: su *= b // gcd(su,b) if su > M: return 0 for _ in filter(lambda x:(su//x)%2==0,B): return 0 return M//su - M//(su*2) print(a())
p02939
s099637694
Wrong Answer
S=input() S+='0' L=len(S) cnt=0 for i in range(1,L): if S[i]==S[i-1]: cnt+=1 ans=L-cnt print(ans)
p02916
s929166686
Accepted
N = int(input()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) print(sum(B)+sum(C[A[n]-1] for n in range(N-1) if A[n]+1==A[n+1]))
p03472
s474216430
Wrong Answer
N, H = map(int, input().split()) A = [0]*N B = [0]*N for i in range(N): A[i], B[i] = map(int, input().split()) A.sort() B.sort() ans = 0 while len(B) > 0 and B[-1] >= A[-1]: H -= B.pop() ans += 1 print(ans+(-(-H//A[-1])))
p03131
s535515950
Accepted
k,a,b = map(int, input().split()) ans = 1+k if b-a<=2: print(ans) exit() ans = max(ans,(k-(a-1))//2*(b-a)+(k-(a-1))%2+a) print(ans)
p02731
s264439527
Accepted
n = int(input()) print((n / 3) ** 3)
p02684
s180021102
Accepted
from math import log2 n, k = map(int, input().split()) To = [] A = list(map(int, input().split())) A = list(map(lambda x: x - 1, A)) To.append(A) for i in range(int(log2(k))): N = [0 for i in range(n)] for j in range(n): N[j] = To[i][To[i][j]] To.append(N) v = 0 for i in reversed(range(int(log2(k)) + 1)): l = 1 << i if l <= k: v = To[i][v] k -= l else: pass print(v + 1)
p02623
s776742469
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 idx, num in enumerate(A): a.append(a[idx] + num) for idx, num in enumerate(B): b.append(b[idx] + num) ans = 0 j = 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(ans)
p03109
s367773228
Accepted
s=input() if int(s[5]+s[6])<=4: print("Heisei") else: print("TBD")
p02912
s699147128
Accepted
import heapq N,M = map(int,input().split()) A = [-int(_) for _ in input().split()] #print(A) heapq.heapify(A) for i in range(M): heapq.heappush(A,-(-heapq.heappop(A)//2)) print(-sum(A))
p03774
s651685438
Wrong Answer
n, m = map(int, input().split()) students = [list(map(int, input().split())) for i in range(n)] targets = [list(map(int, input().split())) for i in range(m)] x = 0 snumber = [(0, x)] * n def md(s, t): d = abs(s[0] - t[0]) + abs(s[1] - t[1]) return d for i in range(n): x = 2 * 10 ** 8 min_pos = 0 for j in range(m): dist = md(students[i], targets[j]) if x > dist: x = dist min_pos = j + 1 print(min_pos)
p02801
s345577227
Accepted
c = input() print(chr(ord(c)+1))
p03612
s167752945
Accepted
n=int(input()) p=list(map(int,input().split())) lis=[0]*n ans=0 i=0 while i<n-1: if i+1==p[i]: lis[i]=1 if i+2==p[i+1]: lis[i+1]=1 i+=1 ans+=1 i+=1 if lis[n-1]==0 and p[n-1]==n: ans+=1 print(ans)
p03360
s390555792
Accepted
a=list(map(int, input().split())) k=int(input()) print(max(a)*(2**k-1)+sum(a))
p04020
s240223447
Accepted
N=int(input()) ans=0 t=0 for _ in range(N): A=int(input()) if A==0: ans+=t//2 t=0 else: t+=A ans+=t//2 print(ans)
p04020
s210689460
Accepted
n=int(input()) a=[int(input()) for i in range(n)] ans=0 for i in range(n-1): ans+=a[i]//2 a[i]%=2 if a[i]==1 and a[i+1]>=1: ans+=1 a[i+1]-=1 ans+=a[-1]//2 print(ans)