Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import heapq
N, M =map(int, input().split())
A = [[] for i in range(10**5+1)]
 
for i in range(N):
    a, b = map(int,input().split())
    if a > m:
        continue
    A[a].append(-b)
 
work_cand = []
sum = 0
 
for i in range(M+1):
    add_jobs = A[i]
    if len(add_jobs) != 0:
        for j in add_jobs:
            heapq.heappush(work_cand, j)
    if len(work_cand) == 0:
        continue
    sum += heapq.heappop(work_cand)
ans = -(sum)
print(ans)

Fixed submission:
import heapq
N, M =map(int, input().split())
A = [[] for i in range(10**5+1)]
 
for i in range(N):
    a, b = map(int,input().split())
    if a > M:
        continue
    A[a].append(-b)
 
work_cand = []
sum = 0
 
for i in range(M+1):
    add_jobs = A[i]
    if len(add_jobs) != 0:
        for j in add_jobs:
            heapq.heappush(work_cand, j)
    if len(work_cand) == 0:
        continue
    sum += heapq.heappop(work_cand)
ans = -(sum)
print(ans)

Buggy python submission (verdict: Runtime Error):
import heapq
N, M =map(int, input().split())
A = [[] for i in range(10**5+1)]

for i in range(M):
    a, b = map(int,input().split())
    A[a].append(-b)

work_cand = []
sum = 0

for i in range(M+1):
    add_jobs = A[i]
    if len(add_jobs) != 0:
        for j in add_jobs:
            heapq.heappush(work_cand, j)
    if len(work_cand) == 0:
        continue
    sum += heapq.heappop(work_cand)
ans = -(sum)
print(ans)

Fixed submission:
import heapq
N, M =map(int, input().split())
A = [[] for i in range(10**5+1)]
 
for i in range(N):
    a, b = map(int,input().split())
    if a > M:
        continue
    A[a].append(-b)
 
work_cand = []
sum = 0
 
for i in range(M+1):
    add_jobs = A[i]
    if len(add_jobs) != 0:
        for j in add_jobs:
            heapq.heappush(work_cand, j)
    if len(work_cand) == 0:
        continue
    sum += heapq.heappop(work_cand)
ans = -(sum)
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M =map(int, input().split())
A = [[] for i in range(10**5+1)]

for i in range(M):
    a, b = map(int,input().split())
    A[a].append(-b)

work_cand = []
sum = 0

for i in range(M+1):
    add_jobs = A[i]
    if len(add_jobs) != 0:
        for j in add_jobs:
            heapq.heappush(work_cand, j)
    sum += heapq.heappop(work_cand)
ans = -(sum)
print(ans)

Fixed submission:
import heapq
N, M =map(int, input().split())
A = [[] for i in range(10**5+1)]
 
for i in range(N):
    a, b = map(int,input().split())
    if a > M:
        continue
    A[a].append(-b)
 
work_cand = []
sum = 0
 
for i in range(M+1):
    add_jobs = A[i]
    if len(add_jobs) != 0:
        for j in add_jobs:
            heapq.heappush(work_cand, j)
    if len(work_cand) == 0:
        continue
    sum += heapq.heappop(work_cand)
ans = -(sum)
print(ans)
Buggy python submission (verdict: Runtime Error):
A, B, C = input().split()
if (A-B) >= C:
    print(0)
    
else:
    print(C - (A-B))

Fixed submission:
A, B, C = map(int, input().split())
if (A-B) >= C:
    print(0)
    
else:
    print(C - (A-B))
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = map(int, input().split())
H.append(1000000001)

max = H[0]
for i in range(N):
    if max >= H[i+1] + 2:
        print('No')
        break
    if max < H[i+1]:
        max = H[i+1]
        
else:
    print('Yes')
        

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
H.append(1000000001)

max = H[0]
for i in range(N):
    if max >= H[i+1] + 2:
        print('No')
        break
    if max < H[i+1]:
        max = H[i+1]
        
else:
    print('Yes')
Buggy python submission (verdict: Runtime Error):
a,b = map(int, input().split())

if ((a%2 == 1)and(b%2==1)):
    c = (a+b)/2
    print(int(c))

if ((a%2==0)and(b%2==0)):
    c =(a+b)/2
    print(int(c))

if ((a%2==0)and(b%2==1)) or ((a%2==1)and(b%==0)):
    print("IMPOSSIBLE")

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

if ((a%2 == 1)and(b%2==1)):
    c = (a+b)/2
    print(int(c))

elif ((a%2==0)and(b%2==0)):
    c =(a+b)/2
    print(int(c))

else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]

a1 = max(A)
B = [i for i in A if i!= a1]
a2 = max(B)

for i in range(N):
    if A[i] != a1:
        print(a1)
    else:
        print(a2)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

B = A[:]

a1 = max(A)
A.remove(a1)
a2 = max(A)

for i in range(N):
    if B[i] != a1:
        print(a1)
    else:
        print(a2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]

a1 = max(A)
B = A.remove(a1)
a2 = max(B)

for i in range(N):
    if A[i] != a1:
        print(a1)
    else:
        print(a2)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

B = A[:]

a1 = max(A)
A.remove(a1)
a2 = max(A)

for i in range(N):
    if B[i] != a1:
        print(a1)
    else:
        print(a2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]

B = sorted(A)
for i in range(N):
    if A[i] != B[N-1]:
        print(B[N-1])
    else:
        for j in range(N):
            if A[i] != B[(N-1)-j]
            print(B[N-1-j])
            break

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

B = A[:]

a1 = max(A)
A.remove(a1)
a2 = max(A)

for i in range(N):
    if B[i] != a1:
        print(a1)
    else:
        print(a2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    X = A[0:i] + A[i+1:]
    Y = set(X)
    print(max(Y))

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

B = A[:]

a1 = max(A)
A.remove(a1)
a2 = max(A)

for i in range(N):
    if B[i] != a1:
        print(a1)
    else:
        print(a2)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(input()) for i in range(N)]

for i in range(N):
    X = A[0:i] + A[i+1:]
    MAX = max(X)
    print(MAX)

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]

B = A[:]

a1 = max(A)
A.remove(a1)
a2 = max(A)

for i in range(N):
    if B[i] != a1:
        print(a1)
    else:
        print(a2)
Buggy python submission (verdict: Runtime Error):
L, R = map(int, input().split())
X = list(range(L, R+1))
ans = 2020

if (R-L) >= 2018:
    print(0)
else:
    for i in X[:len(X)-1]:
        for j in X[1:]:
            a = ((i%2019)*(j%2019))%2019
            if ans > a:
                ans = a
    print(ans)

    


Fixed submission:
L, R = map(int, input().split())

ans = 2020

if (R-L) >= 2018:
    print(0)
else:
    X = list(range(L, R+1))
    for i in X[:len(X)-1]:
        for j in X[1:]:
            a = ((i%2019)*(j%2019))%2019
            if ans > a:
                ans = a
    print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
D = list(map(int, input().split()))
B = sorted(D)

if B[N/2] == B[(N/2)-1]:
    print(0)
else:
    print(B[N/2]-B[(N/2)-1])

Fixed submission:
N = int(input())
D = list(map(int, input().split()))
B = sorted(D)

if B[int(N/2)] == B[int(N/2)-1]:
    print(0)
else:
    print(B[int(N/2)]-B[int(N/2)-1])

Buggy python submission (verdict: Runtime Error):
N = int(input())
D = map(int, input().split())
B = sorted(D)

if B[N/2] == B[(N/2)-1]:
    print(0)
else:
    print(B[N/2]-B[(N/2)-1])

Fixed submission:
N = int(input())
D = list(map(int, input().split()))
B = sorted(D)

if B[int(N/2)] == B[int(N/2)-1]:
    print(0)
else:
    print(B[int(N/2)]-B[int(N/2)-1])
Buggy python submission (verdict: Runtime Error):
L = input()
def dp(index,tight):
    if index == -1:
        return tight == 1
    if not (index,tight) in memo:
        if L[index] == "1" and tight:
            memo[(index,tight)] = 2*dp(index-1,1)
        elif L[index] == "1" and not tight:
            memo[(index,tight)] = 3*dp(index-1,0) + dp(index-1,1)
        elif L[index] == "0" and tight:
            memo[(index,tight)] = dp(index-1,1)
        else:
            memo[(index,tight)] = 3*dp(index-1,0)
    return memo[(index,tight)]
memo = {}
a = dp(len(L)-1,1)
memo = {}
b = dp(len(L)-1,0)
print(a+b)

Fixed submission:
L = input()
n = len(L)
mod = 10**9+7
dp1 = [0]*(n+1)
dp2 = [0]*(n+1)
dp1[0] = 1
for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp1[i]*2)%mod
        dp2[i+1] = (dp1[i] + dp2[i]*3)%mod
    else:
        dp1[i+1] = dp1[i]
        dp2[i+1] = (dp2[i]*3)%mod
print((dp1[n]+dp2[n])%mod)

Buggy python submission (verdict: Runtime Error):
L = input()
memo = {}
def dp(index,tight):
    if index == -1:
        return tight == 1
    if not (index,tight) in memo:
        if L[index] == "1" and tight:
            memo[(index,tight)] = 2*dp(index-1,1)
        elif L[index] == "1" and not tight:
            memo[(index,tight)] = 3*dp(index-1,0) + dp(index-1,1)
        elif L[index] == "0" and tight:
            memo[(index,tight)] = dp(index-1,1)
        else:
            memo[(index,tight)] = 3*dp(index-1,0)
    return memo[(index,tight)]
print(dp(len(L)-1,0)+dp(len(L)-1,1))

Fixed submission:
L = input()
n = len(L)
mod = 10**9+7
dp1 = [0]*(n+1)
dp2 = [0]*(n+1)
dp1[0] = 1
for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp1[i]*2)%mod
        dp2[i+1] = (dp1[i] + dp2[i]*3)%mod
    else:
        dp1[i+1] = dp1[i]
        dp2[i+1] = (dp2[i]*3)%mod
print((dp1[n]+dp2[n])%mod)

Buggy python submission (verdict: Runtime Error):
L = input()
n = len(L)
mod = 10**9+7
dp1 = [0]*(n+1)
dp2 = [0]*(n+1)
dp1[0] = 1
for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp[i]*2)%mod
        dp2[i+1] = (dp1[i] + dp2[i]*3)%mod
    else:
        dp1[i+1] = dp1[i]
        dp2[i+1] = (dp2[i]*3)%mod
print((dp1[n]+dp2[n])%mod)

Fixed submission:
L = input()
n = len(L)
mod = 10**9+7
dp1 = [0]*(n+1)
dp2 = [0]*(n+1)
dp1[0] = 1
for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp1[i]*2)%mod
        dp2[i+1] = (dp1[i] + dp2[i]*3)%mod
    else:
        dp1[i+1] = dp1[i]
        dp2[i+1] = (dp2[i]*3)%mod
print((dp1[n]+dp2[n])%mod)

Buggy python submission (verdict: Runtime Error):
L = input()
n = len(L)
mod = 10**9+8
dp1 = [0]*(n+1)
dp2 = [0]*(n+1)
dp1[0] = 1
for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp[i]*2)%mod
        dp2[i+1] = (dp1[i] + dp2[i]*3)%mod
    else:
        dp1[i+1] = dp1[i]
        dp2[i+1] = (dp2[i]*3)%mod
print((dp1[n]+dp2[n])%mod)

Fixed submission:
L = input()
n = len(L)
mod = 10**9+7
dp1 = [0]*(n+1)
dp2 = [0]*(n+1)
dp1[0] = 1
for i in range(n):
    if L[i] == "1":
        dp1[i+1] = (dp1[i]*2)%mod
        dp2[i+1] = (dp1[i] + dp2[i]*3)%mod
    else:
        dp1[i+1] = dp1[i]
        dp2[i+1] = (dp2[i]*3)%mod
print((dp1[n]+dp2[n])%mod)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

sum = 0
isAffectedSwitch=[[False for _ in range(n)] for _ in range(m)]
for i in range(m):
    for j in range(1,s[i][0]+1):
        isAffectedSwitch[i][s[i][j]-1]=True

C = []
for i in range(N):
    B = 0
    for j in range(M):
        if isAffectedSwitch[j][i] = True:
            B += 2**(M-j-1)
    C.append(B)

for i in range(2**N):
    A = 0
    for j in range(N):
        if (i >> j):
            A = A^C[j]
    if A == p:
        sum += 1
        
print(sum)

Fixed submission:
n,m=map(int,input().split())
s=[list(map(int,input().split())) for _ in range(m)]
p=list(map(int,input().split()))

P = 0
for i in range(m):
    if p[i] == 1:
        P += 2**(m-i-1)
    
sum = 0
isAffectedSwitch=[[False for _ in range(n)] for _ in range(m)]
for i in range(m):
    for j in range(1,s[i][0]+1):
        isAffectedSwitch[i][s[i][j]-1]=True

C = []
for i in range(n):
    B = 0
    for j in range(m):
        if isAffectedSwitch[j][i] == True:
            B += 2**(m-j-1)
    C.append(B)

for i in range(2**n):
    A = 0
    for j in range(n):
        if ((i >> j)&1):
            A = A ^ C[j]
           
    if A == P:
        sum += 1
        
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int, input().split())
A = []
for i in range(M):
    L, R = map(int, input().split())
    B = list(range(L,R+1))
    A.append(B)
S = set(A[0])
for i in range(M):
    S = set(S) & set(A[i])
print(len(S))
    

Fixed submission:
N, M = map(int, input().split())
L = 0
R = 10**5 +2
for i in range(M):
    l,r = map(int, input().split())
    if L < l:
        L = l
    if R > r:
        R = r
ans = 0
for i in range(1,N+1):
    if L <= i <= R:
        ans += 1
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
n,m,k = map(int,input().split())
mod = 10**9+7
memo = {}
def factorial(num):
    if num == 0:
        return 1
    if not num in memo:
        memo[num] = num*factorial(num-1)
    return memo[num]

temp = math.factorial(n*m-2)//(math.factorial(k-2)*math.factorial(n*m-k))
ans = 0
for d in range(1,n):
    ans += d*((n-d)*(m**2))*temp
for d in range(1,m):
    ans += d*((m-d)*(n**2))*temp
print(ans%mod)

Fixed submission:
n,m,k = map(int,input().split())
mod = 10**9+7
def combination(n,r,p):
    if n < r or r < 0:
        return 0
    r = min(n-r,r)
    
    fact = [1,1]
    factinv = [1,1]
    inv = [0,1]
    for i in range(2,n+1):
        fact.append((fact[-1]*i)%p)
        inv.append((-inv[p%i]*(p//i))%p)
        factinv.append((factinv[-1]*inv[-1])%p)
    return fact[n]*factinv[r]*factinv[n-r]%p
temp = combination(n*m-2,k-2,mod)
ans = 0
for d in range(1,n):
    ans += d*((n-d)*(m**2))*temp
for d in range(1,m):
    ans += d*((m-d)*(n**2))*temp
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
import math
n,m,k = map(int,input().split())
mod = 10**9+7
memo = {}
def factorial(num):
    if num == 0:
        return 1
    if not num in memo:
        memo[num] = num*factorial(num-1)
    return memo[num]

temp = math.factorial(n*m-2)//(math.factorial(k-2)*math.factorial(n*m-4-k))
ans = 0
for d in range(1,n):
    ans += d*((n-d)*(m**2))*temp
for d in range(1,m):
    ans += d*((m-d)*(n**2))*temp
print(ans%mod)

Fixed submission:
n,m,k = map(int,input().split())
mod = 10**9+7
def combination(n,r,p):
    if n < r or r < 0:
        return 0
    r = min(n-r,r)
    
    fact = [1,1]
    factinv = [1,1]
    inv = [0,1]
    for i in range(2,n+1):
        fact.append((fact[-1]*i)%p)
        inv.append((-inv[p%i]*(p//i))%p)
        factinv.append((factinv[-1]*inv[-1])%p)
    return fact[n]*factinv[r]*factinv[n-r]%p
temp = combination(n*m-2,k-2,mod)
ans = 0
for d in range(1,n):
    ans += d*((n-d)*(m**2))*temp
for d in range(1,m):
    ans += d*((m-d)*(n**2))*temp
print(ans%mod)

Buggy python submission (verdict: Runtime Error):
n,m,k = map(int,input().split())
mod = 10**9+7
memo = {}
def factorial(num):
    if num == 0:
        return 1
    if not num in memo:
        memo[num] = num*factorial(num-1)
    return memo[num]

temp = factorial(n*m-2)//(factorial(k-2)*factorial(n*m-k))
ans = 0
for d in range(1,n):
    ans += d*((n-d)*(m**2))*temp
for d in range(1,m):
    ans += d*((m-d)*(n**2))*temp
print(ans%mod)

Fixed submission:
n,m,k = map(int,input().split())
mod = 10**9+7
def combination(n,r,p):
    if n < r or r < 0:
        return 0
    r = min(n-r,r)
    
    fact = [1,1]
    factinv = [1,1]
    inv = [0,1]
    for i in range(2,n+1):
        fact.append((fact[-1]*i)%p)
        inv.append((-inv[p%i]*(p//i))%p)
        factinv.append((factinv[-1]*inv[-1])%p)
    return fact[n]*factinv[r]*factinv[n-r]%p
temp = combination(n*m-2,k-2,mod)
ans = 0
for d in range(1,n):
    ans += d*((n-d)*(m**2))*temp
for d in range(1,m):
    ans += d*((m-d)*(n**2))*temp
print(ans%mod)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()
a = S[K-1]
S[K-1] = a.lower()
print(S)

Fixed submission:
N, K = map(int, input().split())
S = input()
a = S[K-1].lower()
A = S[0:K-1] + a + S[K:]
print(A)
Buggy python submission (verdict: Runtime Error):
def find(x):
    if x == par[x]:
        return x
    par[x] = find(par[x])
    return par[x]

def union(x,y):
    x,y = find(x),find(y)
    if x == y:
        return
    par[y] = x

n,m = map(int,input().split())
par = {i:i for i in range(1,n+1)}
for _ in range(m):
    a,b,c = map(int,input().split())
    union(a,b)
print(len(set(par.values()))

Fixed submission:
def find(x):
    if x == par[x]:
        return x
    par[x] = find(par[x])
    return par[x]
 
def union(x,y):
    x,y = find(x),find(y)
    if x == y:
        return
    par[y] = x
 
n,m = map(int,input().split())
par = {i:i for i in range(1,n+1)}
for _ in range(m):
    a,b,c = map(int,input().split())
    union(a,b)
print(sum([1 for i in range(1,n+1) if par[i] == i]))
Buggy python submission (verdict: Runtime Error):
A = [input() for i in range(6)]
X = map(int, A)
a = X[0]
e = X[4]
k = X[5]
if e-a > k:
    print(":(")
else:
    print("Yay!")

Fixed submission:
A = [input() for i in range(6)]
X = list(map(int, A))
a = X[0]
e = X[4]
k = X[5]
if e-a > k:
    print(":(")
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
A = [input() for i in range(6)]
a, b, c, d, e, k = A
B = [a-b, a-c, a-d, a-e,b-c,b-d,b-e,c-d,c-e,d-e]
for i in range(10):
    if abs(B[i]) > k:
        print(":(")
        break
else:
    print("Yay!")

Fixed submission:
A = [input() for i in range(6)]
X = list(map(int, A))
a = X[0]
e = X[4]
k = X[5]
if e-a > k:
    print(":(")
else:
    print("Yay!")

Buggy python submission (verdict: Runtime Error):
A = [input() for i in range(6)]
a, b, c, d, e, k = A
B = [a-b, a-c, a-d, a-e,b-c,b-d,b-e,c-d,c-e,d-e]
for i in range(10):
    if abs(B[i]) > k:
        print(":(")
        break
else:
    print("Yay!")

Fixed submission:
A = [input() for i in range(6)]
X = list(map(int, A))
a = X[0]
e = X[4]
k = X[5]
if e-a > k:
    print(":(")
else:
    print("Yay!")
Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u = 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Fixed submission:
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u = 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Fixed submission:
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
    x,u = map(int,input().split())
    if u == 'BTC':
        x = float(x)
        x *= 380000.0
    sum += x
print(sum)

Fixed submission:
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0.0
sum = float(sum)
for i in range(N):
    x,u = map(float,input().split())
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Fixed submission:
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0.0
for i in range(N):
    x,u = map(float,input().split())
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Fixed submission:
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0.0
for i in range(N):
    x,u = map(int,input().split())
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Fixed submission:
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
    x,u = map(int,input().split())
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Fixed submission:
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Buggy python submission (verdict: Runtime Error):
N = int(input())
sum = 0
for i in range(N):
    x,u = map(int,input().split())
    if u = 'BTC':
        x *= 380000.0
    sum += x
print(sum)

Fixed submission:
N = int(input())
sum = 0.0
for i in range(N):
    x,u = input().split()
    x = float(x)
    if u == 'BTC':
        x *= 380000.0
    sum += x
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
h = list(map(int,input().split()))
INF = 2**31
dp = [INF for i in range(N+1)]
dp[0],dp[1] = 0,0
dp[2] = abs(h[1]-h[0])
for i in range(3,N+1):
    dp[i] = min([dp[i-k]+abs(h[i-1]-h[i-1-k]) for k in range(1,min(i,K+1))])
print(dp[N])

Fixed submission:
import numpy as np
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
h = [int(x) for x in input().split()]
h = np.array(h)
dp = np.zeros(N, dtype=int)
for i in range(1, N):
  j = max(0, i-K)
  dp[i] = min(dp[j:i]+np.abs(h[i]-h[j:i]))
print(dp[N-1])

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
h = list(map(int,input().split()))
INF = 2**31
dp = [INF for i in range(N+1)]
dp[0],dp[1] = 0,0
dp[2] = abs(h[1]-h[0])
for i in range(3,N+1):
    for k in range(1,min(i,K+1)):
        dp[i] = min(dp[i],dp[i-k]+abs(h[i-1]-h[i-1-k]))
print(dp[N])

Fixed submission:
import numpy as np
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
h = [int(x) for x in input().split()]
h = np.array(h)
dp = np.zeros(N, dtype=int)
for i in range(1, N):
  j = max(0, i-K)
  dp[i] = min(dp[j:i]+np.abs(h[i]-h[j:i]))
print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N,W = map(int,input().split())
dp = [0 for _ in range(W+1)]
for i in range(N):
    w,v = map(int,input().split())
    for j in range(W+1):
        if j+w <= W:
            dp[j] = max(dp[j],dp[j+w]+v)
print(max(dp))

Fixed submission:
N, capW = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]
 
def knapsack01(items, capW):
    dp = [0] * (capW+1)
    for wi, vi in items:
        for w in reversed(range(wi, capW+1)):
            v0 = dp[w-wi] + vi
            if v0 > dp[w]:
                dp[w] = v0
    return max(dp)
 
print(knapsack01(items, capW))