Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int,input().split())
for n in range(a, b+1):
    if n <= a+k-1 or n >= b-k+1:
        print(n)

Fixed submission:
a, b, k = map(int,input().split())
if 2*k > b - a + 1:
    for n in range(a, b+1):
        print(n)
    exit()
for n in range(a, a+k):
    print(n)
for n in range(b-k+1, b+1):
    print(n)
Buggy python submission (verdict: Runtime Error):
 = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a, b) + min(c, d))


Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
print(min(a, b) + min(c, d))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
cost = [abs(x - y) for x, y in zip(a[:-1], a[1:])]
for i in range(n):
    print(sum(cost) - cost[i] - cost[i + 1] + abs(a[i] - a[i + 2]))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
c = [abs(x - y) for x, y in zip(a[:-1], a[1:])]
c_sum = sum(c)
for i in range(n):
    print(c_sum - c[i] - c[i + 1] + abs(a[i] - a[i + 2]))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
a.append(0)
cost = [abs(x - y) for x ,y in zip(a[:-1], a[1:])]
for i in range(n):
    c = cost.copy()
    c.pop(i + 1)
    c.pop(i)
    c.append(abs(a[i] - a[i+2]))
    print(sum(c))

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
c = [abs(x - y) for x, y in zip(a[:-1], a[1:])]
c_sum = sum(c)
for i in range(n):
    print(c_sum - c[i] - c[i + 1] + abs(a[i] - a[i + 2]))
Buggy python submission (verdict: Runtime Error):
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if (b > a) & (h > 0):
        h -= b
        count += 1
count += (h + a - 1) // a
#output
print(count)

Fixed submission:
s = input()
s = '2018' + s[4:]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
B = [b for b in B if b >= max(A)]
count += len(B)
h -= sum(B)
count += h // max(A)
if h % max(A) != 0:
    count += 1
#output
print(count)

Fixed submission:
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if (b > a) & (h > 0):
        h -= b
        count += 1
if h > 0:
    count += (h + a - 1) // a
#output
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
for b in B:
    if b >= max(A):
        h -= b
        count += 1
count += h // max(A)
if h % max(A) != 0:
    count += 1
#output
print(count)

Fixed submission:
#input
n, h = map(int, input().split())
A = []
B = []
for i in range(n):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
#manipulation
count = 0
a = max(A)
B.sort(reverse=True)
for b in B:
    if (b > a) & (h > 0):
        h -= b
        count += 1
if h > 0:
    count += (h + a - 1) // a
#output
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left
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 c in C:
    i = bisect_left(B, c)
    for b in B[:i]:
        j = bisect_left(A, b)
        ans += j
print(ans)

Fixed submission:
import bisect
N = int(input())
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))
ans = 0
for b in B:
    i = bisect.bisect_left(A, b)
    j = N - bisect.bisect_right(C, b)
    ans += i * j
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b, c, d, e, f = map(int, input().split())
density = 0
for water_a in range(0,3001,a * 100):
    for water_b in range(0,3001,b * 100):
        if water_a + water_b > f:
            break
        for suger_c in range(0,3001,c):
            if water_a + water_b + suger_c > f:
                break
            for suger_d in range(0,3001,d):
                if water_a + water_b + suger_c + suger_d > f:
                    break
                if e * (water_a + water_b) - 100 * (suger_c + suger_d) < 0:
                    break
                water = water_a + water_b
                suger = suger_c + suger_d
                if water + suger == 0:
                    break
                if 1 >= suger / (water + suger) > density:
                    sugerwater = water + suger
                    meltsuger = suger
                    density = suger / (water + suger)
print(sugerwater, meltsuger)

Fixed submission:
a, b, c, d, e, f = map(int, input().split())
density = 0
for water_a in range(0,3001,a * 100):
    for water_b in range(0,3001,b * 100):
        if water_a + water_b > f:
            break
        for suger_c in range(0,3001,c):
            if water_a + water_b + suger_c > f:
                break
            for suger_d in range(0,3001,d):
                if water_a + water_b + suger_c + suger_d > f:
                    break
                if e * (water_a + water_b) - 100 * (suger_c + suger_d) < 0:
                    break
                water = water_a + water_b
                suger = suger_c + suger_d
                if water + suger == 0:
                    break
                if 1 >= suger / (water + suger) >= density:
                    sugerwater = water + suger
                    meltsuger = suger
                    density = suger / (water + suger)
print(sugerwater, meltsuger)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
b = []
for i in range(n):
    b.append(A[i])
    b = b[::-1]
print(*b)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))[::-1]
b = []
c = []
for i in range(n):
    if i % 2 == 0:
        b.append(A[i])
    else:
        c.append(A[i])
b.extend(c[::-1])
print(*b)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
mod = 10 ** 9 + 7


def n_factorial_mod(n, mod):
    ret = 1
    while n != 1:
        ret = ret * n % mod
        n -= 1
    return ret


if abs(n - m) > 1:
    print(0)
elif abs(n - m) == 1:
    print(n_factorial_mod(n, mod) * n_factorial_mod(m, mod) % mod)
else:
    print(2 * n_factorial_mod(n, mod) * n_factorial_mod(m, mod) % mo
d)

Fixed submission:
n, m = map(int, input().split())
mod = 10 ** 9 + 7


def n_factorial_mod(n, mod):
    ret = 1
    while n != 1:
        ret = ret * n % mod
        n -= 1
    return ret


if abs(n - m) > 1:
    print(0)
elif abs(n - m) == 1:
    print(n_factorial_mod(n, mod) * n_factorial_mod(m, mod) % mod)
else:
    print(2 * n_factorial_mod(n, mod) * n_factorial_mod(m, mod) % mod)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
if n == 1:
    print(1)
    exit()
a = 1
b = n
for i in range(1, 10**10):
    if n % i == 0:
        if i > n // i:
            print(min(len(str(i)), len(str(b))))
            exit()
        a = i
        b = n // i

Fixed submission:
n = int(input())
if n == 1:
    print(1)
    exit()
a = 1
b = n
for i in range(1, 10**5):
    if n % i == 0:
        if i > n // i:
            print(min(len(str(i)), len(str(b))))
            exit()
        a = i
        b = n // i
print(len(str(b)))
Buggy python submission (verdict: Time Limit Exceeded):
INF = 10**9 + 7
n = int(input())
ans = 1
for i in range(1, n+1):
    ans *= i
print(ans % INF)

Fixed submission:
INF = 10**9 + 7
n = int(input())
ans =1
while n != 0:
    ans = n*ans % INF
    n -= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
c = m - 2*n
if c <= 0:
    pirnt(m//2)
else:
    print(n + c//4)

Fixed submission:
n, m = map(int, input().split())
c = m - 2*n
if c <= 0:
    print(m//2)
else:
    print(n + c//4)

Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
c = m - 2*n
if c <= 0:
    pirnt(n)
else:
    print(n + c//4)

Fixed submission:
n, m = map(int, input().split())
c = m - 2*n
if c <= 0:
    print(m//2)
else:
    print(n + c//4)
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
dif = [X[i+1] - X[i] for i in range(N-1)]
dif = sorted(dif)
ans = 10**100
for k in range(N):
    ans = min(ans, B*k + A*sum(dif[:N-1-k]))
print(ans)

Fixed submission:
N, A, B = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    ans += min((X[i+1] - X[i]) * A, B) 
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
    if x > k:
        break
    for y in range(k + 1):
        if y > k:
            break
        z = s - x - y
        if (z >= 0) & (z <= k):
            ans += 1

print(ans)

Fixed submission:
k, s = map(int, input().split())
ans = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if (z >= 0) & (z <= k):
            ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
T = 1
A = 1
for _ in range(n):
    i = 1
    t, a = map(int, input().split())
    while i * t < T or i * a < A:
        i += 1
    T = i * t
    A = i * a
print(T + A)

Fixed submission:
from copy import deepcopy as copy
n = int(input())
T = [1]
A = [1]
for i in range(n):
    t, a = map(int, input().split())
    tc = copy(t)
    ac = copy(a)
    if T[-1] > t or A[-1] > a:
        multi = max(T[-1] // t, A[-1] // a) + 1
        t *= multi
        a *= multi
        while t - tc >= T[-1] and a - ac >= A[-1]:
            t -= tc
            a -= ac
    T.append(t)
    A.append(a)
print(T[-1] + A[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0 for s in range(n * 60)] for k in range(n + 1)] for j in range(n + 1)]
for j in range(n + 1):
    for k in range(n + 1):
        for s in range(n * 60):
            if (j == 0) and (k == 0) and (s == 0):
                dp[j][k][s] = 1
            elif (j > 0) and (s < x[j - 1]):
                dp[j][k][s] = dp[j - 1][k][s]
            elif (j > 0) and (k > 0) and (s >= x[j - 1]):
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
ans = 0
for k in range(1, n + 1):
    ans += dp[j][k][k * a]
print(ans)

Fixed submission:
n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(x)
y = [i - a for i in x]
dp = [[0 for t in range(2 * n * X + 10)] for j in range(n + 1)]
dp[0][n * X] = 1
for j in range(1, n + 1):
    for t in range(2 * n * X + 1):
        if 0 <= t - y[j - 1] <= 2 * n * X:
            dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y[j - 1]]
        else:
            dp[j][t] = dp[j - 1][t]
print(dp[n][n * X] - 1)

Buggy python submission (verdict: Runtime Error):
n, a = map(int, input().split())
x = list(map(int, input().split()))
dp = [[[0 for s in range(n * 50)] for k in range(n + 1)] for j in range(n + 1)]
for j in range(n + 1):
    for k in range(n + 1):
        for s in range(n * 50):
            if (j == 0) and (k == 0) and (s == 0):
                dp[j][k][s] = 1
            elif (j > 0) and (s < x[j - 1]):
                dp[j][k][s] = dp[j - 1][k][s]
            elif (j > 0) and (k > 0) and (s >= x[j - 1]):
                dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]]
ans = 0
for k in range(1, n + 1):
    ans += dp[j][k][k * a]
print(ans)

Fixed submission:
n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(x)
y = [i - a for i in x]
dp = [[0 for t in range(2 * n * X + 10)] for j in range(n + 1)]
dp[0][n * X] = 1
for j in range(1, n + 1):
    for t in range(2 * n * X + 1):
        if 0 <= t - y[j - 1] <= 2 * n * X:
            dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y[j - 1]]
        else:
            dp[j][t] = dp[j - 1][t]
print(dp[n][n * X] - 1)
Buggy python submission (verdict: Runtime Error):
a, b = input().split()
count = 0
for i in range(len(a)):
  if (a[i]!= b[i]):
    count += 1
print(count)

Fixed submission:
a = input()
b = input()
count = 0
for i in range(len(a)):
  if (a[i]!= b[i]):
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
a, b = input().split()
count = 0
for i in range(len(a)):
  if (a[i]!= b[i]):
    count += 1
print(count)

Fixed submission:
a = input()
b = input()
count = 0
for i in range(len(a)):
  if (a[i]!= b[i]):
    count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
a = map(int, input().split())
if(a[0] >a[1]):
  print("No")
else:
  print("Yes")

Fixed submission:

a = list(map(int, input().split()))
if(a[0] >a[1]):
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print(ans%k)
else:
    print(ans)


Fixed submission:
D, T, S = map(int, input().split())

if T*S >= D:
    print("Yes")
else:
    print ("No")
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

if T in S:
    print("0")
else:
    slen = len(S)
    tlen = len(T)
    ansCnt = tlen

    for i in range(slen-tlen):
        cnt = 0
        for j in range(tlen):
            if T[j]!=S[i+j]:
                cnt += 1
        
        if ansCnt>cnt:
            ansCnt = cnt

print(ansCnt)


Fixed submission:
S = input()
T = input()

if T in S:
    print("0")
else:
    slen = len(S)
    tlen = len(T)
    ansCnt = tlen

    for i in range(slen-tlen+1):
        cnt = 0
        for j in range(tlen):
            if T[j]!=S[i+j]:
                cnt += 1
        
        if ansCnt>cnt:
            ansCnt = cnt

    print(ansCnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    #ans += A[s]*sm

print(ans%mod)

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

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print(ans%k)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

k = 1000000007

ans = 0
for s in range(len(A)-1):
    ans += A[s]*sum(A[s+1:])

if ans>1000000007:
    print(ans%k)
else:
    print(ans)

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

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print(ans%k)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

k = 1000000007

ans = 0
for s in range(len(A)-1):
    ans += A[s]*sum(A[s+1:])

print(ans%k)


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

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print(ans%k)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

k = 10**9+7

ans = 0
for s in range(len(A)-1):
    ans += A[s]*sum(A[s+1:])

print(ans%k)

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

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print(ans%k)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

ans = 0
for s in range(len(A)-1):
    ans += A[s]*sum(A[s+1:])

print(np.mod(ans,10**9+7))

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

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print(ans%k)
else:
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np

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

combi = list(itertools.combinations(A, 2))

ans = 0
for i in combi:
    ans +=i[0]*i[1]

print(np.mod(ans,10**9+7))


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

k = 1000000007

sm = sum(A)

ans = 0
for s in range(len(A)-1):
    #ans += A[s]*sum(A[s+1:])
    sm -= A[s]
    ans += A[s]*sm

if ans>1000000007:
    print(ans%k)
else:
    print(ans)
Buggy python submission (verdict: Runtime Error):
n = input()
tmp = int(n[-3])
if tmp==0:
    print(0)
else:
    print((10-tmp)*100)

Fixed submission:
n = int(input())
tmp = 10000-n
s = tmp%1000

print(s)
Buggy python submission (verdict: Runtime Error):
N, M, K = map(int, input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])

for i in range(M):
    b.append(b[i]+B[i])

#print(a)
#print(b)
    
ans =0
j = M

for i in range(N+1):
    if a[i]>k:
        break
    
    while b[j]+a[i] > K :
        j -= 1
    ans = max(ans, i + j)

print(ans)



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

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])

for i in range(M):
    b.append(b[i]+B[i])

#print(a)
#print(b)
    
ans =0
j = M

for i in range(N+1):
    if a[i]>K:
        break
    
    while b[j]+a[i] > K :
        j -= 1
    ans = max(ans, i + j)

print(ans)
Buggy python submission (verdict: Runtime Error):
# 371 ms, 27032 KB
n = int(input())
a = list(map(int, input().split()))
q = int(input())
b = []
c = []
 
bc = [map(int, input().split()) for _ in range(q)]
b, c = [list(i) for i in zip(*bc)]
 
dic = {}
for aa in a:
    dic[aa] = dic.get(aa, 0) + 1
 
s = sum(a)
for i in range(q):
    if b[i] not in dic:
        print (str(s))
        continue
    s += (c[i]-b[i]) * dic[b[i]]
    dic[c[i]] = dic.get(c[i], 0) + dic[b[i]]
    del dic[b[i]]
    print(s)

Fixed submission:
s = input()
if s.isupper():
    print("A")
else:
    print("a")
Buggy python submission (verdict: Runtime Error):
from math imort*
m,n=input.split()
c=0
for i in range(int(m)):
  a,b=input.split()
  d=(int(a)**2)+(int(b)**2)
  if d>=int(n):
    c=c+1
print(c)

Fixed submission:
n=int(input())
if n<30:
  print("No")
else:
  print("Yes")

Buggy python submission (verdict: Runtime Error):
n=int(input)
if n<30:
    print("No")
else:
    print("Yes")

Fixed submission:
n=int(input())
if n<30:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
n= int(input())
aas= list(map(int, input().split(' ')))

ans=0
for i in range(n-1):
  for j in range(i+1, n):
    ans+= aas[i]*aas[j]
    if ans>(10**9+7):
      ans= ans% (10**9+7)

print(ans)

Fixed submission:
d,t,s= map(int, input().split(' '))

if s*t<d:
  print('No')
else:
  print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n= input()

def digit_sum(s):
	ans=0
	for digit in s:
		ans+= int(s)
	return ans

if digit_sum(n)%9==0:
	print('Yes')
else:
	print('No')

Fixed submission:
n= int(input())

def digit_sum(s):
	ans=0
	for digit in str(s):
		ans+= int(digit)
	return ans

if digit_sum(digit_sum(digit_sum(n)))%9==0:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
n= int(input())
ans= ''
trans= {}
for x in range(1, 27):
	trans[x]= chr(x+96)

while n!=0:
	ans= trans[n%26] + ans
	n= n//26
print(ans)

Fixed submission:
n= int(input())
ans= ''
trans= {}
for x in range(1, 27):
	trans[x]= chr(x+96)

while n!=0:
	if n%26==0:
		ans= 'z'+ ans
		n= n//26-1
	else:
		ans= trans[n%26] + ans
		n= n//26
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

def tot(x):
	tot= 0
	for d in x:
		tot+= d
	return tot

n = int(input())
start= np.array(list(map(int, input().split())))
q= int(input())
for _ in range(q):
	b,c= map(int, input().split())
	for index in range(len(start)):
		if start[index]==b:
			start[index]=c
	print(tot(start))

Fixed submission:
n = int(input())
l= list(map(int, input().split()))
table= {}
for num in l:
	if num in table:
		table[num]+=1
	else:
		table[num]=1

tot= 0
for num in l:
	tot+= num

q= int(input())
for _ in range(q):
	b,c= map(int, input().split())
	if b in table:
		if c in table:
			table[c]+= table[b]
			tot+= table[b]*(c-b)
		else:
			table[c]=table[b]
			tot+= table[b]*(c-b)
	table[b]=0
	print(tot)

Buggy python submission (verdict: Time Limit Exceeded):
def tot(x):
	tot= 0
	for d in x:
		tot+= d
	return tot

n = int(input())
start= list(map(int, input().split()))
q= int(input())
for _ in range(q):
	b,c= map(int, input().split())
	for index in range(len(start)):
		if start[index]==b:
			start[index]=c
	print(tot(start))

Fixed submission:
n = int(input())
l= list(map(int, input().split()))
table= {}
for num in l:
	if num in table:
		table[num]+=1
	else:
		table[num]=1

tot= 0
for num in l:
	tot+= num

q= int(input())
for _ in range(q):
	b,c= map(int, input().split())
	if b in table:
		if c in table:
			table[c]+= table[b]
			tot+= table[b]*(c-b)
		else:
			table[c]=table[b]
			tot+= table[b]*(c-b)
	table[b]=0
	print(tot)
Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
line= input().split(' ')
 
tot=1
for a in line:
	tot*= int(a)
	if a=='0':
		tot=0
		break

if tot>10**18:
	print(-1)
else:
	print(tot)

Fixed submission:
n= int(input())
line= input().split(' ')
 
tot=1

for a in line:
	if a=='0':
		tot=0
		break

if tot==1:
	for a in line:
		tot*= int(a)
		if tot>10**18:
			tot=-1
			break

print(tot)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
line= input().split(' ')
 
tot=1
for a in line:
	tot*= int(a)
if tot>10**18:
	print(-1)
else:
	print(tot)

Fixed submission:
n= int(input())
line= input().split(' ')
 
tot=1

for a in line:
	if a=='0':
		tot=0
		break

if tot==1:
	for a in line:
		tot*= int(a)
		if tot>10**18:
			tot=-1
			break

print(tot)
Buggy python submission (verdict: Runtime Error):
n= int(input())
line= input().split(' ')
 
tot=1

for a in line:
	if a=='0':
		tot=0
		break

if tot==1:
	for a in line:
		tot*= int(a)
		if tot>10**18:
			tot=-1
			break

print(tot)

Fixed submission:
from decimal import *

line= input().split(' ')
a= Decimal(int(line[0]))
b= Decimal((line[1]))

x= Decimal(a)*Decimal(b)
x= Decimal(x)-Decimal(x)%1
print(int(x))