Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03076 (python)

Fixed submission:
import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = a % 10
B = b % 10
C = c % 10
D = d % 10
E = e % 10

S = []
sum = 0
if A != 0:
  S.append(A)
if B != 0:
  S.append(B)
if C != 0:
  S.append(C)
if D != 0:
  S.append(D)
if E != 0:
  S.append(E)
if len(S) == 0:
  sum = a + b + c + d + e
else:
  sum = (a //10 + b //10 + c //10 + d //10 + e //10)*10 + 10*(len(S) - 1) +min(S)
print(sum)

Buggy submission (verdict: Runtime Error):
import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = list(str(a))
B = list(str(b))
C = list(str(c))
D = list(str(d))
E = list(str(e))

S = []
sum = 0
if A[-1] == "0":
  sum += a
else:
  S.append(A[-1])
  sum += a + (10 - int(A[-1]))

if B[-1] == "0":
  sum += b
else:
  S.append(B[-1])
  sum += b + (10 - int(B[-1]))

if C[-1] == "0":
  sum += c
else:
  S.append(C[-1])
  sum += c + (10 - int(C[-1]))

if D[-1] == "0":
  sum += d
else:
  S.append(D[-1])
  sum += d + (10 - int(D[-1]))

if E[-1] == "0":
  sum += e
else:
  S.append(E[-1])
  sum += e + (10 - int(E[-1]))

if len(S) != "0":
  k = np.argmin(S)
  sum += int(S[k]) - 10
print(sum)

Buggy submission (verdict: Runtime Error):
import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = list(str(a))
B = list(str(b))
C = list(str(c))
D = list(str(d))
E = list(str(e))

k = np.argmin([A[-1], B[-1], C[-1], D[-1], E[-1]])
sum = 0
if A[-1] == 0:
  sum += a
else:
  sum += a + (10 - int(A[-1]))
if B[-1] == 0:
  sum += b
else:
  sum += b + (10 - int(B[-1]))
if C[-1] == 0:
  sum += c
else:
  sum += c + (10 - int(C[-1]))
if D[-1] == 0:
  sum += d
else:
  sum += d + (10 - int(D[-1]))
if E[-1] == 0:
  sum += e
else:
  sum += e + (10 - int(E[-1]))
sum -= 10 - [A[-1], B[-1], C[-1], D[-1], E[-1]][k]
print(sum)
Problem p03369 (python)

Fixed submission:
s = list(input())
t = 700 + s.count("o") * 100
print(t)

Buggy submission (verdict: Runtime Error):
s = list(input())
t = 700 + s.count(o) * 100
print(t)

Buggy submission (verdict: Runtime Error):
s = input()
print("{}".format(700 + s.count(o)))
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())

B = N % 500
if B <= A:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
A = int(input())

N = N % 500
if N =< A:
  print("Yes")
else:
  print("No")
Problem p02534 (python)

Fixed submission:
print('ACL' * int(input()))

Buggy submission (verdict: Runtime Error):
print('ACL' * input())
Problem p02642 (python)

Fixed submission:
n = int(input())
a = sorted(list(map(int, input().split())))
MA = (max(a) + 1)
ans = [0] * MA

for i in range(n):
    for j in range(a[i],MA,a[i]):
        ans[j] += 1
print(sum(ans[i]==1 for i in a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

from collections import Counter
ca = Counter(a)

# 同じ数はまとめる
remain = []
ans=0
for i,cnt in ca.items():
    if cnt >1:
        ans+=cnt
    else:
        remain.append(i)

remain.sort(reverse=True)
print(ans)
for i in range(len(remain)):
    for j in range(i+1,n):
        if remain[i]%remain[j]==0:
            ans+=1
            break
print(n-ans)
Problem p02647 (python)

Fixed submission:
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

from itertools import accumulate

if N-min(A) <= K:
    print(*[N]*N)
    exit()
    
ans=[0]*(N+1)
for _ in range(K):
    for i,a in enumerate(A):
        ans[max(0,i-a)]+=1
        ans[min(i+a+1,N)]-=1
    A = list(accumulate(ans))[:-1]
    ans=[0]*(N+1)
    if all(i == N for i in A):
        break
print(*A)

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
A = list(map(int, input().split()))

from itertools import accumulate
    
for _ in range(K):
	ans=[0]*(N+1)
    for i,a in enumerate(A):
        ans[max(0,i-a)]+=1
        ans[min(i+a+1,N)]-=1
    A = list(accumulate(ans))[:-1]
    if all(i == N for i in A):
        break
print(*A)
Problem p02677 (python)

Fixed submission:
import math
a,b,h,m = list(map(int, input().split()))

hh=360*(60*h+m)/(60*12)
mm=360*(m/60)
rad=hh-mm
if rad > 180:
    rad=360-rad
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad))))

Buggy submission (verdict: Runtime Error):
a,b,h,m = list(map(int, input().split()))

hh=360*(60*h+m)/(60*12)
mm=360*(m/60)
rad=hh-mm
if rad > 180:
    rad=360-rad
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad))))

Buggy submission (verdict: Runtime Error):
a,b,h,m = list(map(int, input().split()))

hh=360*(60*h+m)/(60*12)
mm=360*(m/60)
rad=hh-mm
if rad > 180:
    rad=360-rad
print(rad)
print(math.sqrt(a**2+b**2-2*a*b*math.cos(math.radians(rad))))
Problem p02684 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

rem=k
nxt=1
visit=[]
visit_set=set([])
for i in range(k):
    visit.append(nxt)
    visit_set.add(nxt)
    nxt=a[nxt-1]
    # この判定をやめる
    if nxt in visit_set:
        break
    rem-=1

if rem==0:
    print(nxt)
else:
#    print('-'*60)
#    print('nxt=', nxt)
#    print('rem=', rem)
#    print('visit=', visit)
    
    loops=visit[visit.index(nxt):]
    print(loops[(rem-1)%len(loops)])    
    
#    print('-'*60)
#    print('loops=', loops)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

rem=k
nxt=1
visit=[]
visit_set={}
for i in range(k):
    visit.append(nxt)
    visit_set.add(nxt)
    nxt=a[nxt-1]
    # この判定をやめる
    if nxt in visit_set:
        break
    rem-=1

if rem==0:
    print(nxt)
else:
#    print('-'*60)
#    print('nxt=', nxt)
#    print('rem=', rem)
#    print('visit=', visit)
    
    loops=visit[visit.index(nxt):]
    print(loops[(rem-1)%len(loops)])    
    
#    print('-'*60)
#    print('loops=', loops)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

rem=k-1
nxt=1
visit=[]
for i in range(k):
    visit.append(nxt)
    nxt=a[nxt-1]
    if nxt in visit:
        break
    rem-=i

if rem==0:
    print(nxt)
else:
    loops=visit[visit.index(nxt):]
    print(loops[(rem-1)%len(loops)])
Problem p02696 (python)

Fixed submission:
a,b,n = list(map(int, input().split()))
def f(x):
    return a*x//b - a*(x//b)

left=1
right=n
for _ in range(100):
    delta=(right-left)/3
    midl=left+delta
    midr=midl+delta
#    print(f'left={left} midl={midl} midr={midr} right={right}')
    if f(midl)>f(midr):
        right=midr
    else:
        left=midl
print(max(f(int(midl)),f(min(int(midl)+1,n))))

Buggy submission (verdict: Runtime Error):
a,b,n = list(map(int, input().split()))
def f(x):
    return a*x//b - a*(x//b)

left=1
right=n
for _ in range(100):
    delta=(right-left)/3
    midl=left+delta
    midr=midl+delta
#    print(f'left={left} midl={midl} midr={midr} right={right}')
    if f(midl)>f(midr):
        right=midr
    else:
        left=midl
print(max(f(int(midl)),f(min(int(midl)+1),n)))
Problem p02741 (python)

Fixed submission:
# -*- coding: utf-8 -*-

K = int(input())
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][K-1])

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

K = int(input())
print([1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][K+1])
Problem p02756 (python)

Fixed submission:
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg and a[1]=='1' or not flg and a[1]=='2':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg ^ a[1]!='1':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque
s = input()
q = int(input())
que = deque([s])
flg=False
for _ in range(q):
    a = list(input().split())
    if a[0]=='1':
        flg=not(flg)
#        s=s[::-1]
    else:
        if flg ^ a[1]!='1':
            que.append(a[2])
        else:
            que.appendleft(a[2])

ans = ''.join(que)

if flg:
    ans = ans[::-1]
print(ans)
Problem p02780 (python)

Fixed submission:
n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

def exp(x):
    return (1+x)/2

total=sum([exp(i) for i in p[:k]])
ans=total
bk=ans
for i in range(1, n-k+1):
    start=i-1
    end=start+k
    total=bk-exp(p[start])+exp(p[end])
    ans=max(ans, total)
    bk=total
    
print(ans)

Buggy submission (verdict: Runtime Error):
p = list(map(int, input().split()))

def exp(x):
    return (1+x)/2

import numpy as np
cums=np.cumsum([0] + [exp(i) for i in p])

ans=0
for i in range(n-k+1):
    ans=max(ans, cums[i+k]-cums[i])

print(ans)
Problem p02795 (python)

Fixed submission:
h = int(input())
w = int(input())
n = int(input())

q,r = divmod(n, max(h,w))
print(q + int(bool(r)))

Buggy submission (verdict: Runtime Error):
n,k,s = list(map(int, input().split()))
if s<10**9:
    ans=[s]*k+[s+1]*(n-k)
else:
    ans=[s]*k+[1]*(n-k)
print(*ans)
Problem p02817 (python)

Fixed submission:
s,t = input().split()
print(t+s)

Buggy submission (verdict: Runtime Error):
s,t = list(map(int, input().split()))
print(s+t)
Problem p02981 (python)

Fixed submission:
n,a,b = list(map(int, input().split()))

print(min(n*a, b))

Buggy submission (verdict: Runtime Error):
n,a,b = list(map(int, input.split()))

print(min(n*a, b))
Problem p03231 (python)

Fixed submission:
n,m = list(map(int, input().split()))
s = input()
t = input()
import math

# 良い文字列が作れるなら、答えはLCM(n, m)となる
lcm = n * m // math.gcd(n, m)

x = {}
for i,c in enumerate(s):
    # (pos, char)
    x[lcm//n*i] = c

for i,c in enumerate(t):
    # (pos, char)
    pos, char = lcm//m*i, c
    if pos in x and x[pos] != char:
        print(-1)
        exit()

print(lcm)

Buggy submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
s = input()
t = input()
import math

# 良い文字列が作れるなら、答えはLCM(n, m)となる
lcm = n * m // math.gcd(n, m)

x = ['*'] * lcm
for i,c in enumerate(s):
    # (pos, char)
    x[lcm//n*i] = c

for i,c in enumerate(t):
    # (pos, char)
    pos, char = lcm//m*i, c
    if x[pos] != '*' and x[pos] != char:
        print(-1)
        exit()

print(lcm)

Buggy submission (verdict: Runtime Error):
n,m = list(map(int, input().split()))
s = input()
t = input()
import math

# 良い文字列が作れるなら、答えはLCM(n, m)となる
lcm = n * m // math.gcd(n, m)

S = len(s)
T = len(t)
x = ['*'] * lcm
for i,c in enumerate(s):
    # (pos, char)
    x[lcm//S*i] = c

for i,c in enumerate(t):
    # (pos, char)
    pos, char = lcm//T*i, c
    if x[pos] != '*' and x[pos] != char:
        print(-1)
        exit()

print(lcm)
Problem p03352 (python)

Fixed submission:
X = int(input())
tab = set([])
for i in range(1,1000):
    for j in range(2,1000):
        if i**j <= 1000:
            tab.add(i**j)
        else:
            break

print(max([i for i in tab if i <= X]))

Buggy submission (verdict: Runtime Error):
X = int(input())
tab = set([])
for i in range(1,X+1):
    for j in range(2,X+1):
        if i**j <= X:
            tab.add(i**j)
        else:
            break
print(max([i for i in tab]))

Buggy submission (verdict: Runtime Error):
X = int(input())
tab = set([])
for i in range(1,X+1):
    for j in range(2,X+1):
        if i**j <= X:
            tab.add(i**j)
        else:
            break
print(max([i for i in tab]))
Problem p03370 (python)

Fixed submission:
# -*- coding: utf-8 -*-
N, X = list(map(int, input().split()))
m = []
for i in range(N):
    m.append(int(input()))
    
ans = len(m)

X -= sum(m)
ans += X//min(m)
print(ans)

Buggy submission (verdict: Runtime Error):
N, X = list(map(int, input().split()))
m = []
for i in N:
    m.append(i)
    
ans = len(m)

X -= sum(m)
ans += X//min(m)
Problem p03433 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n = int(input())
a = int(input())

print('Yes' if n%500 <= a else 'No')

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n = int(input())
a = int(input())

print('Yes' if n%500 =< a else 'No')
Problem p03472 (python)

Fixed submission:
N,H = list(map(int, input().split()))
A=0
B=[]
for _ in range(N):
    a,b = list(map(int, input().split()))
    A = max(A, a)
    B.append(b)

B = sorted([b for b in B if b>A], reverse=True)
from itertools import accumulate
B = list(accumulate(B))
total_throw_damage = (B[-1] if len(B)>0 else 0)

HP_after_throw = H - total_throw_damage
if HP_after_throw <= 0:
    for i,b in enumerate(B,1):
        if H<=b:
            print(i)
            exit()
    raise AssertionError('error')
else:
    q,r = divmod(HP_after_throw, A)
    print(len(B)+q+min(1, r))

Buggy submission (verdict: Runtime Error):
N,H = list(map(int, input().split()))
A=0
B=[]
for _ in range(N):
    a,b = list(map(int, input().split()))
    A = max(A, a)
    B.append(b)

B = sorted([b for b in B if b>A], reverse=True)
from itertools import accumulate
B = list(accumulate(B))
HP_after_throw = H - B[-1]
if HP_after_throw <= 0:
    for i,b in enumerate(B,1):
        if H<=b:
            print(i)
            exit()
    raise AssertionError('error')
else:
    q,r = divmod(HP_after_throw, A)
    print(len(B)+q+min(1, r))

Buggy submission (verdict: Runtime Error):
N,H = list(map(int, input().split()))
A=0
B=[]
for _ in range(N):
    a,b = list(map(int, input().split()))
    A = max(A, a)
    B.append(b)

B.sort(reverse=True)
from itertools import accumulate
B = list(accumulate(B))
HP_after_throw = H - B[-1]
if HP_after_throw <= 0:
    for i,b in enumerate(B,1):
        if H<b:
            print(i)
            exit()
    raise AssertionError('error')
else:
    q,r = divmod(HP_after_throw, A)
    print(N+q+min(1, r))

Buggy submission (verdict: Runtime Error):
N,H = list(map(int, input().split()))
A=0
B=[]
for _ in range(N):
    a,b = list(map(int, input().split()))
    A = max(A, a)
    B.append(b)

B.sort(reverse=True)
from itertools import accumulate
B = list(accumulate(B))
HP_after_throw = H - B[-1]
print(HP_after_throw)
if HP_after_throw <= 0:
    for i,b in enumerate(B,1):
        if H<b:
            print(i)
            exit()
    raise AssertionError('error')
else:
    q,r = divmod(HP_after_throw, A)
    print(N+q+min(1, r))
Problem p03633 (python)

Fixed submission:
n = int(input())
t = [int(input()) for _ in range(n)]

import fractions
n = t[0]
for a,b in zip(t, t[1:]):
    g = fractions.gcd(n, b)
    n = n*b//g
print(n)

Buggy submission (verdict: Runtime Error):
n = int(input())
t = [int(input()) for _ in range(n)]

import math
n = t[0]
for a,b in zip(t, t[1:]):
    g = math.gcd(n, b)
    n = a*b//g
print(n)
Problem p04045 (python)

Fixed submission:
N,K = list(map(int, input().split()))
D = set(input().split())

# シミュレーションでいける
for ans in range(N,100000):
    if all(d not in D for d in str(ans)):
        print(ans)
        exit()

raise AssertionError('バグってる')

Buggy submission (verdict: Runtime Error):
N,K = list(map(int, input().split()))
D = set(input().split())

# シミュレーションでいける
for ans in range(N,10000):
    if all(d not in D for d in str(ans)):
        print(ans)
        exit()

raise AssertionError('バグってる')
Problem p02534 (python)

Fixed submission:
print('ACL'*int(input()))

Buggy submission (verdict: Runtime Error):
k = input()

for loop in range(k):
    print("ACL", end = "")
Problem p02579 (python)

Fixed submission:
from collections import deque

H,W=map(int,input().split())
Sx,Sy=map(int,input().split())
Gx,Gy=map(int,input().split())
Sx-=1
Sy-=1
Gx-=1
Gy-=1
tmp=False
check=deque()

M=[[0 if j=='.' else 1 for j in input()]for i in range(H)]

# 0通路 1壁 2確認済み

ans=0
check.append([Sx,Sy])
while True:
    hit=set()
    while check:
        x,y = check.pop()
        #goul
        if x==Gx and y==Gy:
            tmp=True
            break
        M[x][y]=2
        #壁があるか
        for dx,dy in [ [x+1,y],[x-1,y],[x,y-1],[x,y+1] ]:
            if not(0<=dx and dx<H and 0<=dy and dy<W):
                continue
            if M[dx][dy]==1:
                hit.add((x,y))
            if M[dx][dy]==0:
                check.append([dx,dy])
    if tmp:
        print(ans)
        break
    if len(hit)==0:
        print(-1)
        break
    for e in hit:
        x,y=e
        for i in range(-2,3):
            for j in range(-2,3):
                if 0<=x+i and x+i<H and 0<=y+j and y+j<W and M[x+i][y+j]==0:
                    check.append([x+i,y+j])
    if len(check)==0:
        print(-1)
        break

    ans+=1

Buggy submission (verdict: Runtime Error):
from collections import deque

H,W=map(int,input().split())
Sx,Sy=map(int,input().split())
Gx,Gy=map(int,input().split())
Sx-=1
Sy-=1
Gx-=1
Gy-=1
tmp=False

M=[[0 if j=='.' else 1 for j in input()]for i in range(H)]

# 0通路 1壁 2確認済み

ans=0
check.append([Sx,Sy])
while True:
    hit=set()
    while check:
        x,y = check.pop()
        #goul
        if x==Gx and y==Gy:
            tmp=True
            break
        M[x][y]=2
        #壁があるか
        for dx,dy in [ [x+1,y],[x-1,y],[x,y-1],[x,y+1] ]:
            if not(0<=dx and dx<H and 0<=dy and dy<W):
                continue
            if M[dx][dy]==1:
                hit.add((x,y))
            if M[dx][dy]==0:
                check.append([dx,dy])
    if tmp:
        print(ans)
        break
    if len(hit)==0:
        print(-1)
        break
    for e in hit:
        x,y=e
        for i in range(-2,3):
            for j in range(-2,3):
                if 0<=x+i and x+i<H and 0<=y+j and y+j<W and M[x+i][y+j]==0:
                    check.append([x+i,y+j])
    if len(check)==0:
        print(-1)
        break

    ans+=1
Problem p02585 (python)

Fixed submission:

N,K=map(int,input().split())
P=list(map(lambda x:int(x)-1,input().split()))
C=list(map(int,input().split()))

ans=0
check=set()

for i in range(N):
    
    if i in check:
        continue
    
    # create loop
    tmpK=K
    tmpans=0
    loop_check=set()
    tmp_idx=i
    loop=[]
    while tmp_idx not in loop_check:
        loop.append(C[tmp_idx])
        loop_check.add(tmp_idx)
        check.add(tmp_idx)
        tmp_idx=P[tmp_idx]
    
    S=sum(loop)
    L=len(loop)
    if S>=0 and tmpK//L>=2:
        tmpans=S*(tmpK//L-1)
        tmpK=tmpK%L+L
    
    # 部分最大列を検索
    #print('loop',loop)
    loop=[0]+loop*3
    for i in range(len(loop)-1):
        loop[i+1]+=loop[i]
    n=3*L+1
    def init_min(init_min_val):
        #set_val
        for i in range(n):
            seg_min[i+num_min-1]=init_min_val[i]    
        #built
        for i in range(num_min-2,-1,-1) :
            seg_min[i]=min(seg_min[2*i+1],seg_min[2*i+2])
    def query_min(p,q):
        if q<=p:
            return ide_ele_min
        p += num_min-1
        q += num_min-2
        res=ide_ele_min
        while q-p>1:
            if p&1 == 0:
                res = min(res,seg_min[p])
            if q&1 == 1:
                res = min(res,seg_min[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = min(res,seg_min[p])
        else:
            res = min(min(res,seg_min[p]),seg_min[q])
        return res
    #####単位元######
    ide_ele_min = 10**15
    #num_min:n以上の最小の2のべき乗
    num_min =2**(n-1).bit_length()
    seg_min=[ide_ele_min]*2*num_min

    init_min(loop)
    local_max=0
    for i,v in enumerate(loop):
        if i>=1:
            #print('v,min=',v,query_min(max(0,i-tmpK),i),v-query_min( max(0,i-tmpK),i ))
            local_max=max(local_max,v-query_min( max(0,i-tmpK),i ) )
    
    ans=max(ans,local_max+tmpans)

if ans==0:
    print(max(C))
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
def calc_max(P):
    p=P
    l=[]
    S=0
    max_range=0
    tmpM=0
    for _ in range(K):
        l.append(C[p])
        S+=C[p]
        if tmpM<S:
            tmpM=S
            max_range=_
        p=P[p]
        if p==P:
            break
    if S>0:
        t=len(l)
        tmpK=K-max_range
        return S*(tmpK//t)
    else:
        return S

N,K=map(int,input().split())
P=list(map(lambda x:int(x)-1,input().split()))
C=list(map(int,input().split()))
ans=max(map(calc_max,range(N)))
if ans==0:
    print(max(ans))
else:
    print(ans)
Problem p02630 (python)

Fixed submission:

N=int(input())
A=list(map(int,input().split()))
Q=int(input())

arg=[0]*(100005)
for a in A:
    arg[a]+=1
ans=sum(A)
for _ in range(Q):
    a,b=map(int,input().split())
    ans+=arg[a]*(b-a)
    print(ans)
    arg[b]+=arg[a]
    arg[a]=0

Buggy submission (verdict: Runtime Error):

N=int(input())
A=list(map(int,input().split()))
Q=int(input())

arg=[0]*(N+5)
for a in A:
    arg[a]+=1
ans=sum(A)
for _ in range(Q):
    a,b=map(int,input().split())
    ans+=arg[a]*(b-a)
    print(ans)
    arg[b]+=arg[a]
    arg[a]=0
Problem p02639 (python)

Fixed submission:
A=list(map(int,input().split()))
for i in range(1,6):
    if A[i-1]==0:
        print(i)

Buggy submission (verdict: Runtime Error):
A=list(map(int,input().split()))
for i in range(1,6):
    if A[i]==0:
        print(i)
Problem p02703 (python)

Fixed submission:
from heapq import *
n,m,s=map(int,input().split())
c=[0]*n
d=[0]*n
g=[[]for i in range(n)]

for i in range(m):
    u,v,a,b=map(int,input().split())
    u-=1
    v-=1
    g[u].append((v,a,b))
    g[v].append((u,a,b))
for i in range(n):
    c[i],d[i]=map(int,input().split())

flag=0 #if this == (1<<n)-1 then finish roop
lasttime=[[10**15]*2501 for i in range(n)]
lasttime[0][min(2500,s)]=0
mintimes=[10**15]*n
hp=[(0,min(2500,s),0)]#(time,silver,node)

while flag!=((1<<n)-1):
    time,silver,node = heappop(hp)
    flag=flag|(1<<node)
    mintimes[node]=min(mintimes[node],time)

    for atnode,costmoney,costtime in g[node]:
        nexttime,nextsilver=time+costtime,silver-costmoney
        if costmoney<=silver and lasttime[atnode][nextsilver]>nexttime:
            heappush(hp,(nexttime,nextsilver,atnode))
            lasttime[atnode][nextsilver]=min(lasttime[atnode][nextsilver],nexttime)

    nexttime,nextsilver=time+d[node],min(silver+c[node],2500)
    if silver!=2500 and lasttime[node][nextsilver]>nexttime:
        heappush(hp,(nexttime,min(silver+c[node],2500),node))
        lasttime[node][nextsilver]=min(lasttime[node][nextsilver],nexttime)
        
print(*mintimes[1:],sep="\n")

Buggy submission (verdict: Runtime Error):
from heapq import *
n,m,s=map(int,input().split())
c=[0]*n
d=[0]*n
g=[[]for i in range(n)]

for i in range(m):
    u,v,a,b=map(int,input().split())
    u-=1
    v-=1
    g[u].append((v,a,b))
    g[v].append((u,a,b))
for i in range(n):
    c[i],d[i]=map(int,input().split())

flag=0 #if this == (1<<n)-1 then finish roop
lasttime=[[10**15]*2501 for i in range(n)]
lasttime[0][min(2500,s)]=0
mintimes=[10**15]*n
hp=[(0,min(2500,s),0)]#(time,silver,node)

while flag!=((1<<n)-1):
    time,silver,node = heappop(hp)
    flag=flag|(1<<node)
    mintimes[node]=min(mintimes[node],time)

    for atnode,costmoney,costtime in g[node]:
        if costmoney<=silver and lasttime[atnode][silver-costmoney]>time+costtime:
            heappush(hp,(time+costtime,silver-costmoney,atnode))
            lasttime[atnode][silver-costmoney]=min(lasttime[atnode][silver-costmoney],time+costtime)

    if silver!=2500 and lasttime[node][min(silver+c[node],2500)]>time+d[node]:
        heappush(hp,(time+d[node],min(silver+c[node],2500),node))
        lasttime[node][silver+c[node]]=min(lasttime[node][min(silver+c[node],2500)],time+d[node])
        
print(*mintimes[1:],sep="\n")