qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
T = list(map(int, input().split()))
sumT = sum(T)
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    print(sumT-T[i]+PX[i][1])

Fixed code:
N = int(input())
T = list(map(int, input().split()))
sumT = sum(T)
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    p, x = PX[i]
    print(sumT-T[p-1]+x)
Buggy code:
N = int(input())

t = input().split()
T = []
for i in range(N):
    T.append(int(t[i]))

M = int(input())

time = []
total = sum(T)
for i in range(M):
    p,x = (int(i) for i in input().split())
    time.append（total - T[p] + x)

print(time)

Fixed code:
N = int(input())

t = input().split()
T = []
for i in range(N):
    T.append(int(t[i]))

M = int(input())

time = []
total = sum(T)
for k in range(M):
    p,x = (int(i) for i in input().split())
    time.append(total - T[p-1] + x)

for i in range(M):
    print(time[i])
Buggy code:
N=int(input())
T=list(map(int,input().split()))
M=int(input())
ans=sum(T)
for i in range(len(M)):
  P,X=map(int,input().split())
  print(ans-T[P-1]+X)

Fixed code:
N=int(input())
T=list(map(int,input().split()))
M=int(input())
ans=sum(T)
for i in range(M):
  P,X=map(int,input().split())
  print(ans-T[P-1]+X)
Buggy code:
n=int(input())
s=list(map(int,input().split()))
k=int(input())
l=[]
for i in range(k):
    p,x=map(int,input().split())
    l.append(x+sum(s[:i])+sum(s[i+1:]))
    
for i in range(k):
    print(l[i])

Fixed code:
n=int(input())
s=list(map(int,input().split()))
k=int(input())
l=[]
for i in range(k):
    p,x=map(int,input().split())
    l.append(sum(s)-s[p-1]+x)
    
for i in range(k):
    print(l[i])
Buggy code:
def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())

    x = [0 for i in range(m)]

    for i in range(m):
        _, x[i] = map(int, input().split())

    for i in range(m):
        print(sum(t) - t[i] + x[i])


if __name__ == "__main__":

    main()


Fixed code:
def main():
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())

    p = [0 for i in range(m)]
    x = [0 for i in range(m)]

    for i in range(m):
        p[i], x[i] = map(int, input().split())

    for i in range(m):
        print(sum(t) - t[p[i] - 1] + x[i])


if __name__ == "__main__":

    main()
Buggy code:
N = int(input())
 
t = [int(input().split()) for i in range(N)]
 
M = int(input())
 
cal = sum(t)
 
for j in range(M):
    p, x = list(map(int, input().split()))
    print(cal - t[[p] - 1] + x)

Fixed code:
N = int(input())
 
t = list(map(int, input().split()))
 
M = int(input())
 
cal = sum(t)
 
for j in range(M):
    p, x = map(int, input().split())
    print(cal - t[p - 1] + x)
Buggy code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
s = sum(t)

for i in range(m):
  p,x = map(int,input().split())
  print(s-t[p+1]+x)

Fixed code:
n = input()
t = list(map(int,input().split()))
m = int(input())
s = sum(t)

for i in range(m):
  p,x = map(int,input().split())
  print(s-t[p-1]+x)
Buggy code:
# -*- coding: utf-8 -*-
from copy import deepcopy


def main():
    problems = int(input())
    solve_times = [int(e) for e in input().split()]
    drinks = int(input())

    for i in range(drinks):
        solve_times_copy = deepcopy(solve_times_copy)
        problem_idx, solve_time = [int(e) for e in input().split()]
        problem_idx -= 1
        solve_times_copy[problem_idx] = solve_time
        print(sum(solve_times_copy))


print(main())


Fixed code:
# -*- coding: utf-8 -*-
from copy import deepcopy


def main():
    problems = int(input())
    solve_times = [int(e) for e in input().split()]
    drinks = int(input())

    for i in range(drinks):
        solve_times_copy = deepcopy(solve_times)
        problem_idx, solve_time = [int(e) for e in input().split()]
        problem_idx -= 1
        solve_times_copy[problem_idx] = solve_time
        print(sum(solve_times_copy))


main()
Buggy code:
N = int(input())
time = list(map(int,input().split()))
M = int(input())
time_2 = time
for i in range(M):
    p, x = list(map(int,input().split()))
    time_2[p-1] = x
    ans = sum(time)
    print(ans)
    time_2[p-1] = time[p-1]


Fixed code:
N = int(input())
time = tuple(map(int,input().split()))
M = int(input())
time_2 = list(time)

for i in range(M):
    p, x = list(map(int,input().split()))
    time_2[p-1] = x
    ans = sum(time_2)
    print(ans)
    time_2[p-1] = time[p-1]
Buggy code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=[map(int,input().split()) for _ in range(m)]
for i in b:
    print(sum(a)-a[i[0]]+i[1])

Fixed code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
b=[list(map(int,input().split())) for _ in range(m)]
for i in b:
    print(sum(a)-a[i[0]-1]+i[1])
Buggy code:
n = int(input())
T = list(map(int, input().split()))
s = sum(T)
m = int(input())
for _ in range(m):
    p, x = map(int, input().split())
    sub = -x + T[p - 1]


Fixed code:
n = int(input())
T = list(map(int, input().split()))
s = sum(T)
m = int(input())
for _ in range(m):
    p, x = map(int, input().split())
    sub = -x + T[p - 1]
    print(s - sub)
Buggy code:
n = int(input())
t=list(map(int,input().split()))
m=int(input())
ans=0
for j in range(n):
    ans+=t[j]
for i in range(m):
    p,x=map(int,input().split())
    ans=ans-t[p-1]+x
    print(ans)

Fixed code:
n = int(input())
t=list(map(int,input().split()))
m=int(input())
ans=0
for j in range(n):
    ans+=t[j]
for i in range(m):
    y=ans
    p,x=map(int,input().split())
    y=y-t[p-1]+x
    print(y)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
sum_a=sum(a)
for i in range(m):
  s,t=map(int,input().split())
  print(sum_a+t-a[s])

Fixed code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
sum_a=sum(a)
for i in range(m):
  s,t=map(int,input().split())
  print(sum_a+t-a[s-1])
Buggy code:
n, t, m = int(input()), list(map(int, input().split())), int(input())
p, x = [], []
for i in range(m):
  q, y = map(int, input().split())
  p[i] = q
  x[i] = y
s = sum(t)
for j in range(m):
  print(sum - t[i] + x[i])

Fixed code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])
Buggy code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
s=sum(a)
for i in range(m):
    p,x=map(int,input().split())
    print(s-a[p]+x)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
s=sum(a)
for i in range(m):
    p,x=map(int,input().split())
    print(s-a[p-1]+x)
Buggy code:
n = int(input())
l = list(map(int,input().split()))
m = int(input())
p_x = []
for i in range(m):
  p_x.append(list(map(int,input()).split()))
for i in range(m):
  p = p_x[i][0]
  x = p_x[i][1]
  print(sum(l) - l[p-1] + x) 

Fixed code:
n = int(input())
l = list(map(int,input().split()))
m = int(input())
p_x = []
for i in range(m):
  p_x.append(list(map(int,input().split())))
for i in range(m):
  p = p_x[i][0]
  x = p_x[i][1]
  print(sum(l) - l[p-1] + x)
Buggy code:
N = int(input())
Tlist = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    print(sum(Tlist)-Tlist[i]+PX[i][1])

Fixed code:
N = int(input())
Tlist = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for i in range(M)]

for i in range(M):
    print(sum(Tlist)-Tlist[PX[i][0]-1]+PX[i][1])
Buggy code:
N = int(input())
T = list(int(input().split()))
S = sum(T)
M = int(input())

for _ in range(M):
    p,x = map(int,input().split())
    ans = S - T[] + x
    print(ans)

Fixed code:
N = int(input())
T = list(map(int,input().split()))
S = sum(T)
M = int(input())

for _ in range(M):
    p,x = map(int,input().split())
    ans = S - T[p-1] + x
    print(ans)
Buggy code:
#ABC050.B
N =int(input())
T = list(map(int,input().split()for _ in range(N)))
S = sum(T)
M = int(input())

for _ in range(M):
    p,x = map(int,input().split())
    S -= T[p-1]
    S += x
    print(S)

Fixed code:
#ABC050.B
N =int(input())
T = list(map(int,input().split()))
S = sum(T)
M = int(input())

for _ in range(M):
    a = S
    p,x = map(int,input().split())
    a -= T[p-1]
    a += x
    print(a)
Buggy code:
n = int(input())
T = list(map(int, input().split()))
sumT = sum(T)
m = int(input())
for i in range(m):
  a, b = map(int, input().split())
  print(sumT - T[a] + b)

Fixed code:
n = int(input())
T = list(map(int, input().split()))
sumT = sum(T)
m = int(input())
for i in range(m):
  a, b = map(int, input().split())
  print(sumT - T[a - 1] + b)
Buggy code:
N=int(input())
T= list(map(int, input().split()))
F=T
M=int(input())
Ml=[]
for i in range(0,M):
    P=list(map(int, input().split()))
    Ml.append(P)

for i in range(0,M):
    s=Ml[i][0]-1
    F[s]=Ml[i][1]
    print(sum(F))
    F[s]=T[s]

Fixed code:
N=int(input())
T= list(map(int, input().split()))
X=T
M=int(input())
Ml=[]
for i in range(0,M):
    P=list(map(int, input().split()))
    Ml.append(P)

for i in range(0,M):
    s=Ml[i][0]-1
    f=X[s]
    X[s]=Ml[i][1]
    print(sum(X))
    X[s]=f
Buggy code:
num_problems = int(input())
a = input()
seconds_per = a.split()
for i in seconds_per:
  total += int(i)
drinks = int(input())
for i in range(drinks):
  b = input()
  c = b.split()
  question = int(c[0])
  change = int(c[1])
  new = total-int(seconds_per[question-1]) + change
  print(new)


  

Fixed code:
num_problems = input()
a = input()
total = 0
seconds_per = a.split()
for i in seconds_per:
  total += int(i)
drinks = int(input())
for i in range(drinks):
  b = input()
  c = b.split()
  question = int(c[0])
  change = int(c[1])
  new = total-int(seconds_per[question-1]) + change
  print(new)
Buggy code:
import copy

N = int(input())
T = [int(i) for i in input().split()]
M = int(input())

P = []
X = []
for _ in range(M):
    p, x = [int(i) for i in input().split()]
    P.append(p)
    X.append(x)

print(P)
print(X)
for i in range(M):
    a = copy.deepcopy(T)
    a[P[i] - 1] = X[i]
    print(a)
    print(sum(a))

Fixed code:
import copy

N = int(input())
T = [int(i) for i in input().split()]
M = int(input())

P = []
X = []
for _ in range(M):
    p, x = [int(i) for i in input().split()]
    P.append(p)
    X.append(x)

for i in range(M):
    a = copy.deepcopy(T)
    a[P[i] - 1] = X[i]
    print(sum(a))
Buggy code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    print(sum(T) - (T[P-1] - X) + X)

Fixed code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    print(sum(T) - (T[P-1] - X))
Buggy code:
N = int(input())
Ts=list(map(int,input().split()))
M = int(input())
for i in range(M):
    p,x = map(int,input().split())
    anslist = copy.deepcopy(Ts)
    anslist[p-1]=x
    print(sum(anslist))

Fixed code:
import copy
N = int(input())
Ts=list(map(int,input().split()))
M = int(input())
for i in range(M):
    p,x = map(int,input().split())
    anslist = copy.deepcopy(Ts)
    anslist[p-1]=x
    print(sum(anslist))
Buggy code:
n=int(input())
T=list(map(int,input()))
m=int(input())
for i in range(m):
    p,k=map(int,input().split())
    T[p-1]=k
    print(sum(T))  

Fixed code:
n=int(input())
T=list(map(int,input().split()))
m=int(input())
for i in range(m):
    p,k=map(int,input().split())
    tmp=T[p-1]
    T[p-1]=k
    print(sum(T))
    T[p-1]=tmp
Buggy code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p=list(map(int,input().split()))
  tmp=t[:]
  tmp[p[0]]=p[1]
  print(sum(tmp))
  

Fixed code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p=list(map(int,input().split()))
  tmp=t[:]
  tmp[p[0]-1]=p[1]
  print(sum(tmp))
Buggy code:
n = int(input())
list = list(map(int, input().split(" ")))
sum = sum(list)
num = int(input())
for x in range(num):
    a = list(map(int, input().split()))
    ans = sum + a[1] - list[a[0]-1]
    print(ans)

Fixed code:
n = int(input())
l = list(map(int, input().split(" ")))
s = sum(l)
num = int(input())
for x in range(num):
    a = list(map(int, input().split()))
    ans = s + a[1] - l[a[0]-1]
    print(ans)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
s=sum(a)
for i in range(m):
    p,x=map(int,input().split())
    print(s+x-a[p+1])

Fixed code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
s=sum(a)
for i in range(m):
    p,x=map(int,input().split())
    print(s+x-a[p-1])
Buggy code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []

s = sum(t)

for i in range(m):
    p.append(input().split())

for i in range(m):
    print(s-t[i]+int(p[i][1]))

Fixed code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
s = sum(t)
for i in range(m):
  p, x = map(int, input().split())
  print(s - t[p - 1] + x)
Buggy code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [list(map(int,input().split())) for _ in range(m)]

for i in range(m):
    print(sum(t)-t[i]+px[i][1])

Fixed code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
px = [list(map(int,input().split())) for _ in range(m)]

for i in range(m):
    print(sum(t)-t[px[i][0]-1]+px[i][1])
Buggy code:
import copy

n = int(input())
t_li = list(map(int, input().split()))
m = int(input())
px_li = []
result = []

for i in range(m):
  p, x = map(int, input().split())
  px_li.append([p, x])

for j in range(m):
  c_li = copy.copy(t_li)
  c_li[j] = px_li[j][1]
  result.append(str(sum(c_li)))

string = "\n".join(result)
print(string)


Fixed code:
import copy

n = int(input())
t_li = list(map(int, input().split()))
m = int(input())
px_li = []
result = []

for i in range(m):
  p, x = map(int, input().split())
  px_li.append([p, x])

for j in range(m):
  c_li = copy.copy(t_li)
  c_li[px_li[j][0] - 1] = px_li[j][1]
  result.append(str(sum(c_li)))

string = "\n".join(result)
print(string)
Buggy code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p1=[]
x1=[]
for i in range(m):
    p,x=map(int,input().split())
    p1.append(p)
    x1.append(x)
for i in range(m):
    print(sum(t)-t[p1[i]-1]+x1[p1[i]-1])

Fixed code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p1=[]
x1=[]
for i in range(m):
    p,x=map(int,input().split())
    p1.append(p)
    x1.append(x)
for i in range(m):
    print(sum(t)-t[p1[i]-1]+x1[i])
Buggy code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
px=[list(map(int,input().split())) for _ in range(m)]

ans=sum(t)-t[0]-t[1]

for i in range(m):
    
    print(ans+sum(px[i]))



Fixed code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
px=[list(map(int,input().split())) for _ in range(m)]

ans=sum(t)

for i in range(m):
    print(ans-t[px[i][0]-1]+px[i][1])
Buggy code:
def main(n, t, m, p_x):
    for p, x in p_x:
        _t = t.copy()
        _t[p - 1] = x

        print(sum(_t))


if __name__ == "__main__":
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    p_x = [int(input()) for _ in range(m)]

    main(n, t, m, p_x)


Fixed code:
def main(n, t, m, p_x):
    for p, x in p_x:
        _t = t.copy()
        _t[p - 1] = x

        print(sum(_t))


if __name__ == "__main__":
    n = int(input())
    t = list(map(int, input().split()))
    m = int(input())
    p_x = [list(map(int, input().split()))
    for _ in range(m)]

    main(n, t, m, p_x)
Buggy code:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  test[a-1] = b
  print(sum(test))

Fixed code:
N = int(input())
test = list(map(int,input().split()))
M = int(input()) 
  
for _ in range(M):
  a,b = map(int,input().split())
  print(sum(test) - test[a-1] + b)
Buggy code:
n=int(input())
l=list(input())
m=int(input())
time=0
for i in l:
  time+=i
for i in range(m):
  p,x=map(int,input().split())
  print(time-l(p-1)+x)

Fixed code:
n=int(input())
l=list(map(int,input().split()))
m=int(input())
time=0
for i in l:
  time+=int(i)
for i in range(m):
  p,x=map(int,input().split())
  print(time-l[p-1]+x)
Buggy code:
n = int(input())
*a0, = map(int, input().split())
m = int(input())
for _ in range(m):
    k, b = map(int, input().split())
    a = a0[:]
    a[k] = b
    print(sum(a))


Fixed code:
n = int(input())
*a0, = map(int, input().split())
m = int(input())
for _ in range(m):
    k, b = map(int, input().split())
    a = a0[:]
    a[k-1] = b
    print(sum(a))
Buggy code:
import numpy as np
#import copy
N = int(input())
#time=list(map(int,input().split()))
time=np.array(input().split(),dtype=np.int64)
M = int(input())

p={}
x={}
for i in range(M):
    p[i],x[i] = map(int, input().split())
#print(x[1])
sumT=np.sum(time)
for i in range(M):
    PP = p[i]
#    print(np.sum(time_new))
    print(sumT - time[PP-1] + x[PP-1])

Fixed code:
import numpy as np
N = int(input())
#time=list(map(int,input().split()))
time=np.array(input().split(),dtype=np.int64)
M = int(input())

p={}
x={}
for i in range(M):
    p[i],x[i] = map(int, input().split())
#print(x[1])

sumT=np.sum(time)
for i in range(M):
    PP = p[i]
#    print(np.sum(time_new))
    tot = sumT - time[PP-1] + x[i]
    print(tot)
Buggy code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
drink=[]
all=sum(t)
for i in range(m):
  drink.append(list(map(int,input().split())))
for j in range(n):
  if j<m:
    print(all-t[j]+drink[j][1])
  else:
    print(all)

Fixed code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
drink=[]
all=sum(t)
for i in range(m):
  drink.append(list(map(int,input().split())))
for j in range(m):
  if drink[j][0]<=n:
    print(all-t[drink[j][0]-1]+drink[j][1])
  else:
    print(all)
Buggy code:
n=int(input())
t=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=t[i]
m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  sumi=sum-t[p]+x
  print(sumi)
  

Fixed code:
n=int(input())
t=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=t[i]

m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  sumi=sum-t[p-1]+x
  print(sumi)
Buggy code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())
SUM = 0
for i in range(N):
    SUM = SUM + T[i]

for i in range(M):
    P,X = map(int, input().split())
    print(25-(T[P-1]-X))

Fixed code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())



for i in range(M):
    SUM = 0
    P,X= map(int, input().split())
    for i in range(N):
        Z = T[P-1]
        T[P-1] = X
        SUM = SUM + T[i]
        T[P-1] = Z
    print(SUM)
Buggy code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
d = [list(map(int,input().split())) for i in range(M)]
time = sum(T)
for i in range(len(d)):
    time += d[i][0] - T[d[i][1]-1]
print(time)

Fixed code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
d = [list(map(int,input().split())) for i in range(M)]
t = sum(T)
for i in range(len(d)):
    time = t + d[i][1] - T[d[i][0]-1]
    print(time)
Buggy code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
    p,x=map(int,input().split())
    print(sum(t)-t[i]+x)

Fixed code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())

for i in range(m):
    p, x = list(map(int, input().split()))
    print(sum(t) - t[p-1] + x)
Buggy code:
n = int(input())
tt = list(map(int, input().split()))
m = int(input())
drinks = [list(map(int,input().split())) for _ in range(m)]

ans = sum(tt)
for i in range(m):
    print(ans - (tt[i] - drinks[i][1]))

Fixed code:
n = int(input())
tt = list(map(int, input().split()))
m = int(input())
drinks = [list(map(int,input().split())) for _ in range(m)]

ans = sum(tt)
for i in range(m):
    print(ans - (tt[drinks[i][0]-1] - drinks[i][1]))
Buggy code:
n = int(input())
p = list(map(int, input().split()))
k = int(input())
for i in range(k):
  a, b = map(int, input().split())
  p[a - 1] = b
  print(sum(p))


Fixed code:
n = int(input())
p = list(map(int, input().split()))
k = int(input())
for i in range(k):
  a, b = map(int, input().split())
  c = p[a-1]
  p[a-1] = b
  print(sum(p))
  p[a-1] = c
Buggy code:
input()
ts = list(map(int, input().split()))
t_sum = sum(ts)
m = int(input())
for _ in range(m):
    p, x = map(int, input().split())
    print(t_sum - ts[p] + x)


Fixed code:
input()
ts = list(map(int, input().split()))
t_sum = sum(ts)
m = int(input())
for _ in range(m):
    p, x = map(int, input().split())
    print(t_sum - ts[p - 1] + x)
Buggy code:
print(a)
n = int(input())
t = list(map(int,input().split()))
m = int(input())

for i in range(m):
    lst = list(t)
    p,x = map(int,input().split())
    lst[p-1] = x
    print(sum(lst))
    print(lst)

Fixed code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())

for i in range(m):
    lst = list(t)
    p,x = map(int,input().split())
    lst[p-1] = x
    print(sum(lst))
Buggy code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []
for _ in range(M):
  p,x = map(int,input().split())
  P.append(p)
  X.append(x)

sumT = sum(T)

for i,p,x in enumerate(zip(P,X)):
  print(sumT - (T[p]-x))

Fixed code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = []
X = []
for _ in range(M):
  p,x = map(int,input().split())
  P.append(p)
  X.append(x)

sumT = sum(T)

for p,x in zip(P,X):
  print(sumT - (T[p-1]-x))
Buggy code:
N = int(input())
Tlist = [int(N) for N in input().split()]
M = int(input())
PXlist = [[int(i) for i in input().split()]for j in range(M)]
def time_sum():
    s = 0
    for i in range(0,N):
        s = s+Tlist[i]
    return s
def time_cal():
    empty = []
    for i in range(0,M):
        empty.append(time_sum() - Tlist[i] + PXlist[i][1])
    return empty
for i in time_cal():
    print(i)

Fixed code:
N = int(input())
Tlist = [int(N) for N in input().split()]
M = int(input())
PXlist = [[int(i) for i in input().split()]for j in range(M)]
def time_sum():
    s = 0
    for i in range(0,N):
        s = s+Tlist[i]
    return s
def time_cal():
    empty = []
    for i in range(0,M):
        empty.append(time_sum() - Tlist[PXlist[i][0]-1] + PXlist[i][1])
    return empty
for i in time_cal():
    print(i)
Buggy code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  print(sum(a)-a[p]+x)

Fixed code:
n=int(input())
a=list(map(int,input().split()))
m=int(input())
for i in range(m):
  p,x=map(int,input().split())
  print(sum(a)-a[p-1]+x)
Buggy code:
num_prob = int(input())
prob = input()
new = prob.split()
sum = 0
num_drinks = input()
for j in new:
  sum += j

for i in range(num_drinks):
  line = input()
  new_line = line.split()
  if new_line[1] != new[new_line[0]]:
    sum -= new[new_line[0]]
    sum += new_line[1]
    


Fixed code:
num_prob = int(input())
prob = input()
new = prob.split()
sum = 0

for j in new:
  sum += int(j)

  
num_drinks = int(input())
for i in range(num_drinks):
  line = input()
  new_line = line.split()
  if int(new_line[1]) != int(new[int(new_line[0])-1]):
    temp = sum - int(new[int(new_line[0])-1]) + int(new_line[1])
    print(temp)
  else:
    print(sum)
Buggy code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
res = sum(t)
px = [list(map(int,input().split()))for _ in range(m)]
for i in range(m):
    p = px[i][0]-1
    x = px[i][1]
    ans = res -t[i]+x
    print(ans)
    

Fixed code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
res = sum(t)
px = [list(map(int,input().split()))for _ in range(m)]
for i in range(m):
    p = px[i][0]-1
    x = px[i][1]
    ans = res -t[p]+x
    print(ans)
Buggy code:
num = int(input())
time = list(map(int, input().split()))
drink = int(input())
eff = [list(map(int, input().split())) for i in range(drink)]

baseT = sum(time)
print(baseT)
for i in range(drink):
    print(baseT - time[eff[i][0]-1] + eff[i][1])

Fixed code:
num = int(input())
time = list(map(int, input().split()))
drink = int(input())
eff = [list(map(int, input().split())) for i in range(drink)]

baseT = sum(time)
for i in range(drink):
    print(baseT - time[eff[i][0]-1] + eff[i][1])