qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
origin,ans = [],[]

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

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

for _ in range(m):
	p,x = map(int,input().split())
	origin.append(t[p-1])
	t[p-1] = x
	ans.append(sum(t))
	t[p-1] = origin[0]
	origin = []

for i in range(m):
	print(ans[i])
Buggy code:
N = int(input())
T = list(map(int, input().split()))
S = sum(T)

M  = int(input())
PX = [int(input()) for _ in range(M)]

for px in PX:
    P, X = px
    print(S - T[P-1] + X)


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

M  = int(input())
PX = [input() for _ in range(M)]

for px in PX:
    P, X = map(int, px.split())
    print(S - T[P-1] + X)
Buggy code:
#n,l = map(int,input().split())
#l = kist(input())

n = int(input())
l = list(map(int,input()))

ttl = sum(l)

m = int(input())

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

Fixed code:
#n,l = map(int,input().split())
#l = kist(input())

n = int(input())
l = list(map(int,input().split()))

ttl = sum(l)

m = int(input())

for i in range(m):
    p,x = map(int,input().split())
    print(ttl-l[p-1]+x)
Buggy code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P_X = []
for i in range(M):
	P_X.append(list(map(int,input().split())))

temp_sum = sum(T)
print(temp_sum)
for i in range(M):
	print(temp_sum - T[P_X[i][0] - 1] + P_X[i][1])

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

temp_sum = sum(T)
for i in range(M):
	print(temp_sum - T[P_X[i][0] - 1] + P_X[i][1])
Buggy code:
def execute(n, tn, m, pxm):
    result = []
    for px in pxm:
        cp = tn[:]
        cp[px[0] - 1] = px[1]
        result.append(sum(cp))
    return result


if __name__ == '__main__':
    n = int(input())
    tn = map(int, input().split())
    m = int(input())
    pxm = []
    for _ in range(m):
        p, x = map(int, input().split())
        pxm.append([p, x])
    print(execute(n, tn, m, pxm))


Fixed code:
def execute(n, tn, m, pxm):
    result = []
    for px in pxm:
        cp = tn[:]
        cp[px[0] - 1] = px[1]
        result.append(sum(cp))
    return result


if __name__ == '__main__':
    n = int(input())
    tn = list(map(int, input().split()))
    m = int(input())
    pxm = []
    for _ in range(m):
        p, x = map(int, input().split())
        pxm.append([p, x])
    result = execute(n, tn, m, pxm)
    print("\n".join(map(str, result)))
Buggy code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
px = [list(map(int, input().split())) for _ in range(m)]

sum_t = sum(t)
for i in range(m):
    print(min(sum_t, sum_t - t[px[i][0] - 1] +  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)]

sum_t = sum(t)
for i in range(m):
    print(sum_t - t[px[i][0] - 1] +  px[i][1])
Buggy code:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    t = Intl()
    m = I()
    px = [Intl() for i in range(m)]
    s = sum(t)
    ps = s
    print(s)
    for i in range(m):
        a,b = px[i][0],px[i][1]
        s -= t[a-1]
        s += b
        print(s)
        s -= b
        s += t[a-1]

Fixed code:
import sys
import math
import itertools as it
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    n = I()
    t = Intl()
    m = I()
    px = [Intl() for i in range(m)]
    s = sum(t)
    ps = s
    for i in range(m):
        a,b = px[i][0],px[i][1]
        s -= t[a-1]
        s += b
        print(s)
        s -= b
        s += t[a-1]
Buggy code:
n = int(input())
t = list(map(int,input(),split()))
m = int(input())
p = [0]* m 
x = [0]* m 
for i in range(m):
    p[i],x[i]= map(int(input(),split()))
print(sum(t)-t[p[i]-1]+x[i])


Fixed code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
p=[0]*m
x=[0]*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])
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]-X))

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

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

Fixed code:
n=int(input())
A=list(map(int,input().split()))
B=A
m=int(input())
for i in range(m):
  a,b=map(int,input().split())
  print(sum(A)-A[a-1]+b)
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)

t_sum = sum(T)

for i in range(M):
    print(t_sum - T[P[i]-1] + X[P[i] - 1])

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)

t_sum = sum(T)

for i in range(M):
    print(t_sum - T[P[i]-1] + X[i])
Buggy code:
import copy
n = int(input())
t = list(map(int,input().split()))
m = int(input())
for i in range(m):
    c_t = copy.deepcopy(t)
    p,x = list(map(int,input().split()))
    c_t[p-1]=x
    print(c_t)
    print(sum(c_t))

Fixed code:
import copy
n = int(input())
t = list(map(int,input().split()))
m = int(input())
for i in range(m):
    c_t = copy.deepcopy(t)
    p,x = list(map(int,input().split()))
    c_t[p-1]=x
    print(sum(c_t))
Buggy code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    t1,t2 = map(int,input().split())
    p.append(t1)
    x.append(t2)
sum_t = sum(t)
for i in range(m):
    print(sum_t - (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):
    t1,t2 = map(int,input().split())
    p.append(t1)
    x.append(t2)
sum_t = sum(t)
for i in range(m):
    sa = t[p[i] - 1] - x[i]
    print(sum_t-sa)
Buggy code:
N = int(input())
T = [int(i) for i in input().split()]
M = int(input())

PX = []

for i in range(M):
    # 0-indexed
    PX.append([int(j) for j in input().split()])
    PX[i][0] -= 1

ans = sum(T)

for i in range(M):
    print(ans - T[PX[i][0]] + T[PX[i][1]])


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

PX = []

for i in range(M):
    # 0-indexed
    PX.append([int(j) for j in input().split()])
    PX[i][0] -= 1

ans = sum(T)

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

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

Fixed code:
N=int(input())
T=list(map(int,input().split()))
M=int(input())
total=0
for i in range(N):
    total+=T[i]
for i in range(M):
    K=total
    P,X=map(int,input().split())
    K=K-T[P-1]
    K+=X
    print(K)
Buggy code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())
PX = [list(map(int, input().split())) for _ in range(M)]

sum_before = sum(T)
for i in range(M):
    sum_after = sum_before - T[PX[i][0]] + PX[i][1]
    print(sum_after)

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

sum_before = sum(T)
for i in range(M):
    sum_after = sum_before - T[PX[i][0]-1] + PX[i][1]
    print(sum_after)
Buggy code:
n = int(input())
l = list(map(int,input()))
m = int(input())
sum = sum(l)
copy = sum

for i in range(m):
  sum = copy
  a,b = map(int,input().split())
  sum += b - l[a-1]
  print(sum)

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

for i in range(m):
  sum = copy
  a,b = map(int,input().split())
  sum += b - l[a-1]
  print(sum)
Buggy code:
import copy
n = int(input())

t = list(map(int, input().split()))
m = int(input())

for i in range(M):
    copy_t = copy.copy(t)
    p, x  = map(int, input().split())
    copy_t[p-1] = x
    print(sum(copy_t))

Fixed code:
import copy
n = int(input())

t = list(map(int, input().split()))
m = int(input())

for i in range(m):
    copy_t = copy.copy(t)
    p, x  = map(int, input().split())
    copy_t[p-1] = x
    print(sum(copy_t))
Buggy code:
#Beginner 050 B

N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = [input() for _ in range(M)]
print(PX)

for _ in range(M):
    PX[_] = list(map(int, PX[_].split()))
print(PX)

lst = []
for i in range(M):
    lst.append(sum(T) - T[PX[i][0]-1] + PX[i][1])
print(lst)

for j in range(M):
    print(lst[j])

Fixed code:
#Beginner 050 B

N = int(input())
T = list(map(int,input().split()))
M = int(input())
PX = [input() for _ in range(M)]

for _ in range(M):
    PX[_] = list(map(int, PX[_].split()))

lst = []
for i in range(M):
    lst.append(sum(T) - T[PX[i][0]-1] + PX[i][1])

for j in range(M):
    print(lst[j])
Buggy code:
import copy
t=input()
qlist = list(map(int,input().split()))
hmd = int(input())
for i in range(hmd):
    drk=list(map(int,input().split()))
    alist = copy.copy(qlist)
    alist[drk[0]-1]=drk[1]
    print(alist)
    print(sum(alist))


Fixed code:
import copy
t=input()
qlist = list(map(int,input().split()))
hmd = int(input())
for i in range(hmd):
    drk=list(map(int,input().split()))
    alist = copy.copy(qlist)
    alist[drk[0]-1]=drk[1]
    print(sum(alist))
Buggy code:
a=int(input())
b=list(map(int,input().split()))
c=int(input())
d=[int(input()) for i in range(c)]
for i in range(c):
  print(sum(b)-b[d[i][0]]+d[i][1])

Fixed code:
a=int(input())
b=list(map(int,input().split()))
c=int(input())
d=[input().split() for i in range(c)]
for i in range(c):
  print(sum(b)-b[int(d[i][0])-1]+int(d[i][1]))
Buggy code:
ProNum = int(input())
time = input()
time = time.split()
TotalTime = 0

for t in time:
  TotalTime += t

DrinkNum = int(input())

for d in range(DrinkNum):
  line = input()
  line = line.split()
  diff = int(line[1]) - int(time(int(line[0])))
  print(TotalTime+diff)

Fixed code:
ProNum = int(input())
time = input()
time = (time.split())
TotalTime = 0

for t in time:
  TotalTime += int(t)
                  
DrinkNum = int(input())

for d in range(DrinkNum):
  line = input()
  line = line.split()
  diff = int(line[1]) - int(time[int(line[0])-1])
  print(TotalTime+diff)
Buggy code:
N = int(input())
T = list(map(int, input().split()))
M = int(input())

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(len(X)):
    count = c
    count += X[i]
    count -= T[i]
    print(count

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

P, X = [], []
for i in range(M):
    p1, x1 = map(int, input().split())
    P.append(p1)
    X.append(x1)

count = 0
for i in range(len(T)):
    count += T[i]

c = count

for i in range(M):
    count = c
    count += X[i]
    count -= T[P[i] - 1]
    print(count)
Buggy code:
N = int(input())
Ts = input().split()
Ts = [int(i) for i in Ts]
Tsum = sum(Ts)
M = int(input())
for i in range(M):
    P,X = map(int,input().split())
    res = Tsum - Ts[i] + X
    print(res)

Fixed code:
N = int(input())
Ts = input().split()
Ts = [int(i) for i in Ts]
Tsum = sum(Ts)
M = int(input())
res_list = []
for i in range(M):
    P,X = map(int,input().split())
    res = Tsum - Ts[P-1] + X
    print(res)
Buggy code:
N = int(input())
T = list(map(int,input().split()))
ans = sum(T)
M = int(input())
for i in range(M):
    P,X = map(int,input().split())
    t = A[P-1] - X
    print(ans-t)

Fixed code:
N = int(input())
T = list(map(int,input().split()))
ans = sum(T)
M = int(input())
for i in range(M):
    P,X = map(int,input().split())
    t = T[P-1] - X
    print(ans-t)
Buggy code:
n = int(input())
listA = list(int, input().split())
m = int(input())
listB = []
while True:
  try:
    listB.append(list(map(int,input().split())))
  except:
    break;
for i in range(1,m+1):
  x=listA[listB[i][0]]
  listA[listB[i][0]] = listB[i][1]
  s=0
  for j in range(n):
    s = s+listA[j]
  print(s)
  listA[listB[i][0]]=x

    

Fixed code:
n = int(input())
listA = list(map(int, input().split()))
m = int(input())
listB = []
while True:
  try:
    listB.append(list(map(int,input().split())))
  except:
    break;
for i in range(m):
  x=listA[listB[i][0]-1]
  listA[listB[i][0]-1] = listB[i][1]
  s=0
  for j in range(n):
    s = s+listA[j]
  print(s)
  listA[listB[i][0]-1]=x
Buggy code:
n = int(input())
ts = list(map(int, input(.split())))
su = sum(ts)
m = int(input())
for _ in range(m):
  p, x = list(map(int, input(.split())))
  ans = su - ts[p] + x
  print(ans)

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

for i in range(m):
    px = [list(map(int, input().split())) for _ in range(m)]
    a=t[px[i][0]-1]
    b=px[i][1]
    print(sumt-a+b)

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):   
    a=t[px[i][0]-1]
    b=px[i][1]
    print(sumt-a+b)
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())
  print(sum(Ts)-T[p-1]+x)

Fixed code:
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
for i in range(M):
  p, x = map(int, input().split())
  print(sum(Ts)-Ts[p-1]+x)
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)
s=sum(t)
ans=s
for i in range(m):
  ans=min(ans,s-t[p[i]]+x[p[i]])
print(ans)

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-1)
  x.append(_x)
s=sum(t)
for i in range(m):
  print(s-t[p[i]]+x[i])
Buggy code:
N = int(input())
Ts = list(map(int, input().split()))
M = int(input())
base_ = sum(Ts)

for m in range(1,M+1):
  p, t = map(int, input().split())
  print(base_ - (Ts[p]-t))

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

for m in range(M):
  p, t = map(int, input().split())
  #print(Ts[p-1])
  #print(t)
  #print((Ts[p-1]-t))
  print(base_ - (Ts[p-1]-t))
Buggy code:
import copy
N = int(input())
t = [int(x) for x in input().split()]
p = []
for _ in range(int(input())):
	p.append([int(x) for x in input().split()])

result = []
ori_t = copy.deepcopy(t)
for i,j in zip(t,p):
	t = copy.deepcopy(ori_t)
	t[j[0]-1] = j[1]
	result.append(sum(t))

print(result)


Fixed code:
import copy
N = int(input())
t = [int(x) for x in input().split()]
p = []
for _ in range(int(input())):
	p.append([int(x) for x in input().split()])

result = []
ori_t = copy.deepcopy(t)
for i in p:
	t = copy.deepcopy(ori_t)
	t[i[0]-1] = i[1]
	result.append(sum(t))

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

Fixed code:
n = int(input())
T = list(map(int,input().split()))
ans = sum(T)
m = int(input())
for i in range(m):
  p, x = map(int,input().split())
  print(ans-T[p-1]+x)
Buggy code:
n = int(inout())
time_list = [ int(v) for v in input().split() ]
total_time = sum(time_list)
m = int(input())

for i in range(m):
  p, t = [ int(v) for v in input().split() ]
  print(total_time - time_list[p-1] + t)

Fixed code:
n = int(input())
time_list = [ int(v) for v in input().split() ]
total_time = sum(time_list)
m = int(input())

for i in range(m):
	p, t = [ int(v) for v in input().split() ]
	print(total_time - time_list[p-1] + t)
Buggy code:
n = int(input())

time_list = list(map(int,input().split()))

m = int(input())

drink_num_time = []
drink_time = []

for i in range(m):
    drink_num_time.append(list(map(int,input().split())))

normal_time = sum(time_list)


for i in range(m):
    drink_time.append(normal_time+drink_num_time[i][1]-time_list[i])

for i in range(m):
    print(drink_time[i])


Fixed code:
n = int(input())

time_list = list(map(int,input().split()))

m = int(input())

drink_num_time = []
drink_time = []

for i in range(m):
    drink_num_time.append(list(map(int,input().split())))

normal_time = sum(time_list)


for i in range(m):
    drink_time.append(normal_time+drink_num_time[i][1]-time_list[(drink_num_time[i][0])-1])

for i in range(m):
    print(drink_time[i])
Buggy code:
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = [list(map(int, input().split())) for i in range(m)]

for i in range(m):
    time = t
    time[p[i][0] - 1] = p[i][1]
    print(sum(time))

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

for i in range(m):
    time = [x for x in t]
    time[p[i][0] - 1] = p[i][1]
    print(sum(time))
Buggy code:
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int(input().split()))
    
    T_new = T
    T_new[P[i]] = X
    print(np.array(T_new).sum())

Fixed code:
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    
    T_new = T.copy()
    T_new[P-1] = X
    print(np.array(T_new).sum())
Buggy code:
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
    a,b=map(int,input().split())
    total=t
    total[a-1]=b
    print(sum(total))

Fixed code:
import copy
n=int(input())
t=list(map(int,input().split()))
m=int(input())
for i in range(m):
    a,b=map(int,input().split())
    total=copy.copy(t)
    total[a-1]=b
    print(sum(total))
Buggy code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = [0]*M
X = [0]*M
for i in range(M):
	P[i],X[i] = map(int,input().split())

for i in range(M):         
	print(sum(T)-T[i]+X[i]) 

Fixed code:
N = int(input())
T = list(map(int,input().split()))
M = int(input())
P = [0]*M
X = [0]*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])
Buggy code:
# -*- coding: utf-8

n = int(input())
t = list(map(int, input().split()))

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

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

n = int(input())
t = list(map(int, input().split()))

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

for i in range(M):
    T[P[i][0]] -= P[i][1]
    print(sum(T))
    T[P[i][0]] += P[i][1]

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

for i in range(M):
    temp = T[P[i][0] - 1]
    T[P[i][0] - 1] = P[i][1]
    print(sum(T))
    T[P[i][0] - 1] = temp
Buggy code:
I=input;I();t=[int(i)for i in I().S()]
for i in' '*int(input()):p,x=map(int,I().split());print(sum(t)+x-t[p-1])

Fixed code:
I=input
I()
t=[int(i)for i in I().split()]
for i in' '*int(input()):p,x=map(int,I().split());print(sum(t)+x-t[p-1])
Buggy 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()))
  xx=Ans+x-T[p-1]
  print(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())
  xx=Ans+x-T[p-1]
  print(xx)
Buggy code:
n = int(input())
t = list(map(int,input().split()))
for _ in int(input()):
  p,x = map(int,input().split())
  l=t.copy()
  l[p-1] = x
  print(sum(l))



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

m = int(input())

drink = []
for i in range(m):
    effect = [int(x) for x in input().split()]
    effect[0] -= 1
    drink.append(effect)
    
print(drink)
    
for i in range(m):
    score = sum(t) - t[drink[i][0]] + drink[i][1]
    print(score)

Fixed code:
n = int(input())
t = [int(x) for x in input().split()]

m = int(input())

drink = []
for i in range(m):
    effect = [int(x) for x in input().split()]
    effect[0] -= 1
    drink.append(effect)

for i in range(m):
    score = sum(t) - t[drink[i][0]] + drink[i][1]
    print(score)
Buggy code:
N=int(input())
T=list(map(int,input().split()))
TA=sum(T)
M=int(input())
for i in range(M):
  P,X=map(int,input().split())
  ans=TA+X+T[p-1]
  print(ans)

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

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

for i in range(M):
  P,X=map(int,input().split())
  ans=T_ALL+X-T[P-1]
  print(ans)
Buggy code:
n=int(input())
l=list(map(int,input().split()))
m=int(input())

sum_l=sum(l)

for i in range(m):
  p,x=map(int,input().split())
  ams=sum_l-l[p-1]+x
  print(ans)

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

sum_l=sum(l)

for i in range(m):
  p,x=map(int,input().split())
  ans=sum_l-l[p-1]+x
  print(ans)
Buggy code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    a,b = map(int,input().split())
    p.append(a)
    x.append(b)

for i in range(m):
    print(t)
    s = list(t)
    j = p[i] - 1
    s[j] = x[i]
    print(sum(s))

Fixed code:
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = []
x = []
for i in range(m):
    a,b = map(int,input().split())
    p.append(a)
    x.append(b)

for i in range(m):
    s = list(t)
    j = p[i] - 1
    s[j] = x[i]
    print(sum(s))