qyliang/CodeNanoFix huggingface dataset:
Buggy code:
x,y = map(int,input().split())
ans = 0

if x == 1 :
    ans = 300000
elif x == 2:
    ans = 200000
elif x == 3:
    ans = 100000


if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000


if x == 1:
    ans += 400000
if y == 1:
    ans += 400000
print(ans)


Fixed code:
x,y = map(int,input().split())
ans = 0
if x==3:
    ans += 100000
elif x==2:
    ans+=200000
elif x==1:
    ans+=300000

if y == 3:
    ans += 100000
elif y == 2:
    ans += 200000
elif y == 1:
    ans += 300000

if x==1 and y==1:
    ans+=400000
print(ans)
Buggy code:
X, Y = map(int, input().split())
price = [0, 300000, 200000, 100000]
ans = price[X] + price[Y] + 400000*(X == Y == 1)

print(ans)

Fixed code:
X, Y = map(int, input().split())
price = [0, 300000, 200000, 100000] + [0]*300
ans = price[X] + price[Y] + 400000*(X == Y == 1)

print(ans)
Buggy code:
from collections import defaultdict
X, Y = map(int, input().split())
d = defaultdict(int)
d[1] = 300000
d[2] = 200000
d[3] = 100000
ans = d[X]+d[Y]
if X==1 and Y==1:
  ans += 400000
print(ans

Fixed code:
from collections import defaultdict
X, Y = map(int, input().split())
d = defaultdict(int)
d[1] = 300000
d[2] = 200000
d[3] = 100000
ans = d[X]+d[Y]
if X==1 and Y==1:
  ans += 400000
print(ans)
Buggy code:
X, Y = map(int, input().split())

KANE = [
    300000,
    200000,
    100000
]
ans=0
if X <= 3:
    ans = KANE[X-1]
    
if Y <= 3:
    ans = KANE[Y-1]
    
if X == 1 and Y == 1:
    ans += 400000 
    
print(ans)

Fixed code:
X, Y = map(int, input().split())

KANE = [
    300000,
    200000,
    100000
]
ans=0
if X <= 3:
    ans += KANE[X-1]
    
if Y <= 3:
    ans += KANE[Y-1]
    
if X == 1 and Y == 1:
    ans += 400000 
    
print(ans)
Buggy code:
x, y = map(int, input().split())
ans = max(0,4-x) + max(0,3-y)
if x==1==y: ans += 4
print(ans*100000)

Fixed code:
x, y = map(int, input().split())
ans = max(0,4-x) + max(0,4-y)
if x==1==y: ans += 4
print(ans*100000)
Buggy code:
x,y=map(int,input().split())
ans=0
if x<4:
    ans += x*100000
if y<4:
    ans += y*100000
if x==y and x==1:
    ans += 400000
print(ans)

Fixed code:
x,y=map(int,input().split())
ans=0
if x<4:
    ans += (4-x)*100000
if y<4:
    ans += (4-y)*100000
if x==y and x==1:
    ans += 400000
print(ans)
Buggy code:
X,Y=map(int,input().split())
awa=0

if X==3:
  awa += 100000
elif X==2:
  awa += 200000
else X==1:
  awa += 300000
  
if Y==3:
  awa += 100000
elif Y==2:
  awa += 200000
else Y==1:
  awa += 300000
  
if X==1 and Y==1:
  awa += 400000
  
print(awa)

Fixed code:
X,Y=map(int,input().split())
awa=0

if X==3:
  awa += 100000
elif X==2:
  awa += 200000
elif X==1:
  awa += 300000
  
if Y==3:
  awa += 100000
elif Y==2:
  awa += 200000
elif Y==1:
  awa += 300000
  
if X==1 and Y==1:
  awa += 400000
  
print(awa)
Buggy code:
x,y=map(int,input().split())
ans=max(0,8-(x+y))
if ans==6:
  ans+=4
print(ans*100000)

Fixed code:
x,y=map(int,input().split())
ans=max(0,4-x)+max(0,4-y)
if ans==6:
  ans+=4
print(ans*100000)
Buggy code:
l = [300000,200000,100000]
a,b = map(int,input().split())
res = 0 
if a in range(1,4):
    res +=l[a-1]
if b in range(1,4):
    res +=l[b-1]

print(res)

Fixed code:
l = [300000,200000,100000]
a,b = map(int,input().split())
res = 0 
if a in range(1,4):
    res +=l[a-1]
if b in range(1,4):
    res +=l[b-1]
if a == b and a==1:
    res+=400000
print(res)
Buggy code:
x, y = map(int, input().split())

ans = 0

if x < 4:
  ans += (4-x)＊ 100000
  
if y < 4:
  ans += (4-y)＊ 100000
  
if x + y == 2:
  ans += 400000
  
print(ans)

Fixed code:
x, y = map(int, input().split())

ans = 0

if x < 4:
  ans += (4-x)* 100000
  
if y < 4:
  ans += (4-y)* 100000
  
if x + y == 2:
  ans += 400000
  
print(ans)
Buggy code:
a,b=map(int,input().split())
s=0
g=0
if a==1:
  s=300000
elif a==2:
  s=200000
elif a==3:
  s=100000
else:
  pass
if b==1:
  g=300000
elif b==2:
  g=200000
elif b==3:
  g=100000
else:
  pass
if a=1 and b=2:
  print(300000+300000+400000)
else:
  print(s+g)

Fixed code:
a,b=map(int,input().split())
s=0
g=0
if a==1:
  s=300000
elif a==2:
  s=200000
elif a==3:
  s=100000
else:
  s=0
if b==1:
  g=300000
elif b==2:
  g=200000
elif b==3:
  g=100000
else:
  g=0
if a==1 and b==1:
  print(g+s+400000)
else:
  print(s+g)
Buggy code:
x,y=map(int,input().split())
if x==1 and y==1:
    print(1000000)
    exit()
a=[300000,200000,100000]
if x>3:
    x=0
if y>3:
    y=0
if x==0 and y==0:
    print(0)
    exit()
print(a[x-1]+a[y-1])

Fixed code:
x,y=map(int,input().split())
if x==1 and y==1:
    print(1000000)
    exit()
a=[300000,200000,100000,0]
if x>3:
    x=0
if y>3:
    y=0
if x==0 and y==0:
    print(0)
    exit()
print(a[x-1]+a[y-1])
Buggy code:
codePlace, implePlace = map(int, input().split(" "))

priceDict = {
    "1":300000,
    "2":200000,
    "3":100000
}

totalPrice = priceDict[codePlace] if codePlace in priceDict.keys() else 0
totalPrice += priceDict[implePlace] if implePlace in priceDict.keys() else 0
totalPrice += 400000 if codePlace == 1 and implePlace == 1 else 0

print(totalPrice)


Fixed code:
codePlace, implePlace = map(int, input().split(" "))

priceDict = {
    1:300000,
    2:200000,
    3:100000
}

totalPrice = priceDict[codePlace] if codePlace in priceDict.keys() else 0
totalPrice += priceDict[implePlace] if implePlace in priceDict.keys() else 0
totalPrice += 400000 if codePlace == 1 and implePlace == 1 else 0

print(totalPrice)
Buggy code:
X, Y = map(int,input().split())
sum = 0
def get_money(X, sum):
    if X == 1:
        sum += 300000
    elif X == 2:
        sum += 200000

    elif X == 3:
        sum += 100000

get_money(X, sum)
get_money(Y, sum)

if X == 1 and Y ==1:
    sum += 400000

print(sum)

Fixed code:
X, Y = map(int,input().split())

def get_money(X):
    if X == 1:
        return 300000
    elif X == 2:
        return 200000
    elif X == 3:
        return 100000
    else:
        return 0

def double_money(X, Y):
    if X == 1 and Y == 1:
        return 400000
    else:
        return 0

sum = get_money(X) + get_money(Y) +double_money(X, Y)

print(sum)
Buggy code:
x, y = map(int, input().split())
prize = [300000, 100000, 200000]
total = 0
if x <= 3:
    total += prize[x-1]
if y <= 3:
    total += prize[y-1]
if x == y == 1:
    total += 400000
print(total)

Fixed code:
x, y = map(int, input().split())
prize = [300000, 200000, 100000]
total = 0
if x <= 3:
    total += prize[x-1]
if y <= 3:
    total += prize[y-1]
if x == y == 1:
    total += 400000
print(total)
Buggy code:
a = list(map(int,input().split()))
ans = 0
for v in a:
    if v == 1:
        ans += 300000
    elif v == 2:
        ans += 200000
    else:
        ans += 100000
if sum(a) == 2:
    ans += 400000
print(ans)

Fixed code:
a = list(map(int,input().split()))
ans = 0
for v in a:
    if v == 1:
        ans += 300000
    elif v == 2:
        ans += 200000
    elif v == 3:
        ans += 100000
if sum(a) == 2:
    ans += 400000
print(ans)
Buggy code:
def main():
    x,y=list(map(int,input().split(" ")))
    ans=0
    if x==1 and y==1:
        print(300000+300000+400000)
    else:
        if x==1:
            ans=300000
        elif x==2:
            ans=200000
        else:
            ans=100000
        if y==1:
            ans+=300000
        elif y==2:
            ans+=200000
        else:
            ans+=100000
        print(ans)

if __name__=="__main__":
    main()

Fixed code:
def main():
    x,y=list(map(int,input().split(" ")))
    ans=0
    if x==1 and y==1:
        print(300000+300000+400000)
    else:
        if x==1:
            ans=300000
        elif x==2:
            ans=200000
        elif x==3:
            ans=100000
        if y==1:
            ans+=300000
        elif y==2:
            ans+=200000
        elif y==3:
            ans+=100000
        print(ans)

if __name__=="__main__":
    main()
Buggy code:
# -*- coding: utf-8 -*-

X, Y = map(int, input().split())

sum = 0
if(X == 1):
  sum = 300000
elif(X == 2):
  sum = 200000
elif(X == 3):
  sum = 10000

if(Y == 1):
  sum += 300000
elif(Y == 2):
  sum += 200000
elif(Y == 3):
  sum += 100000

if(X == 1 and Y == 1):
  sum += 400000

print(sum)


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

X, Y = map(int, input().split())

sum = 0
if(X == 1):
  sum = 300000
elif(X == 2):
  sum = 200000
elif(X == 3):
  sum = 100000

if(Y == 1):
  sum += 300000
elif(Y == 2):
  sum += 200000
elif(Y == 3):
  sum += 100000

if(X == 1 and Y == 1):
  sum += 400000

print(sum)
Buggy code:
a = {1:300000,2:200000,3:100000}

x,y = map(int,input().split())

if x == 1 and y == 1:
	print(a[x] + a[y] + 400000)
else:
	if x > 3 and y <=  3:
		print(a[y])
	elif x <= 3 and y >  3:
		print(a[x])
	else:
		print(a[x] + a[y])

Fixed code:
a = {1:300000,2:200000,3:100000}

x,y = map(int,input().split())

if x == 1 and y == 1:
	print(a[x] + a[y] + 400000)
else:
	if x > 3 and y <= 3:
		print(a[y])
	elif x <= 3 and y > 3:
		print(a[x])
	elif x>3 and y >3:
		print(0)
	else:
		print(a[x] + a[y])
Buggy code:
X, Y = map(int, input().split())
r = 0
if(X == 1):
  r += 300000
elif(X == 2):
  r += 200000
elif(X == 3):
  r += 300000
else:
  pass

if(Y == 1):
  r += 300000
elif(Y == 2):
  r += 200000
elif(Y == 3):
  r += 300000

if(X == Y == 1):
  r += 400000

print(r)

Fixed code:
X, Y = map(int, input().split())
r = 0
if(X == 1):
  r += 300000
elif(X == 2):
  r += 200000
elif(X == 3):
  r += 100000
else:
  pass

if(Y == 1):
  r += 300000
elif(Y == 2):
  r += 200000
elif(Y == 3):
  r += 100000
else:
  pass

if(X == Y == 1):
  r += 400000

print(r)
Buggy code:
x,y=map(int,input().split())
a=0
if x==y==1:a=40000
a+=10000*((4-x)+(4-y))x,y=map(int,input().split())
a=0
x=min(x,4)
y=min(y,4)
if x==y==1:a=400000
a+=100000*((4-x)+(4-y))
print(a)

Fixed code:
x,y=map(int,input().split())
a=0
x=min(x,4)
y=min(y,4)
if x==y==1:a=400000
a+=100000*((4-x)+(4-y))
print(a)
Buggy code:
X, Y = map(int, input().split())
ranks = [X, Y]
ans = 0

for i in ranks:
    if i == 1:
        ans += 300000
    elif i == 2:
        ans += 200000
    elif i == 3:
        ans += 100000

if (X, Y) == (1, 1):
    ans = 700000

print(ans)

Fixed code:
X, Y = map(int, input().split())
ranks = [X, Y]
ans = 0

for i in ranks:
    if i == 1:
        ans += 300000
    elif i == 2:
        ans += 200000
    elif i == 3:
        ans += 100000

if (X, Y) == (1, 1):
    ans = 1000000

print(ans)
Buggy code:
x, y = list(map(int, input().split()))
ans = 0
if x  == 1 and y == 1:
  ans += 400000
elif x == 1:
  ans += 300000
elif x == 2:
  ans += 200000
elif x == 3:
  ans += 100000
elif y == 1:
  ans += 300000
elif y == 2:
  ans += 200000
elif y == 3:
  ans += 100000
print(ans)

Fixed code:
x, y = list(map(int, input().split()))
ans = 0
if x  == 1 and y == 1:
  ans += 400000
if x == 1:
  ans += 300000
elif x == 2:
  ans += 200000
elif x == 3:
  ans += 100000
if y == 1:
  ans += 300000
elif y == 2:
  ans += 200000
elif y == 3:
  ans += 100000
print(ans)
Buggy code:
X=list(map(int, input()))
t=0
for i in range(len(X)):
  if X[i]==1:
    t+=300000
  elif X[i]==2:
    t+=200000
  elif X[i]==3:
    t+=100000
if X[0]==X[1] and X[0]==1:
  t+=400000
print(t)


Fixed code:
X=list(map(int, input().split()))
t=0
for i in range(len(X)):
  if X[i]==1:
    t+=300000
  elif X[i]==2:
    t+=200000
  elif X[i]==3:
    t+=100000
if X[0]==X[1] and X[0]==1:
  t+=400000
print(t)
Buggy code:
x,y=map(int, input())
coin=0
if x==1 and y==1:
  coin+=400000
if x==1:
  coin+=300000
if y==1:
  coin+=300000
if x==2:
  coin+=200000
if y==2:
  coin+=200000
if x==3:
  coin+=100000
if y==3:
  coin+=100000
print(coin)

Fixed code:
x,y=map(int, input().split())
coin=0
if x==1 and y==1:
  coin+=400000
if x==1:
  coin+=300000
if y==1:
  coin+=300000
if x==2:
  coin+=200000
if y==2:
  coin+=200000
if x==3:
  coin+=100000
if y==3:
  coin+=100000
print(coin)
Buggy code:
x,y = map(int,input().split())

p = 0
pr = [300000,200000,100000]

if(x < 3):p += pr[x-1]
if(y < 3):p += pr[y-1]

if(x == y and x == 1):p += 400000

print(p)

Fixed code:
x,y = map(int,input().split())

p = 0
pr = [300000,200000,100000]

if(x <= 3):p += pr[x-1]
if(y <= 3):p += pr[y-1]

if(x == y and x == 1):p += 400000

print(p)
Buggy code:
x,y = map(int,input().split())
a = [0]*210
a[:3] = [300000, 200000, 100000]
if x == y and x == 1:
    print(400000)
else:
    print(a[x-1] + a[y-1])


Fixed code:
x,y = map(int,input().split())
a = [0]*210
a[:3] = [300000, 200000, 100000]
if x == y and x == 1:
    print(1000000)
else:
    print(a[x-1] + a[y-1])
Buggy code:
x,y = map(int,input().split())
ans =0
if x == 1:
	ans += 300000
elif x == 2:
	ans += 200000
elif x == 3 :
	ans += 100000

if y == 1:
	ans += 300000
elif y == 2:
	ans += 200000
elif y == 3 :
	ans += 100000

if x == 1 and y == 1:
	ans += 400000
	print(ans)

Fixed code:
x, y = map(int, input().split())
ans = 0
if x == 1:
    ans += 300000
elif x == 2:
    ans += 200000
elif x == 3:
    ans += 100000

if y == 1:
    ans += 300000
elif y == 2:
    ans += 200000
elif y == 3:
    ans += 100000

if x == 1 and y == 1:
    ans += 400000
print(ans)
Buggy code:
x,y=map(int,input().split())
if x==y==1:
    print(1000000)
A=[300000,200000,100000]+[0]*1000
print(A[x-1]+A[y-1])


Fixed code:
x,y=map(int,input().split())
if x==y==1:
    print(1000000);exit()
A=[300000,200000,100000]+[0]*1000
print(A[x-1]+A[y-1])
Buggy code:
x,y = map(int, input().split())
d = {1:300000, 2:200000, 3:100000}
if x == y == 1:
  print(1000000)
  exit()
a = 0, b = 0
if 1 <= x <= 3:
  a = d[x]
if 1 <= y <= 3:
  b = d[x]

print(a+b)

Fixed code:
x,y = map(int, input().split())
d = {1:300000, 2:200000, 3:100000}
if x == y == 1:
  print(1000000)
  exit()
a = 0
b = 0
if 1 <= x <= 3:
  a = d[x]
if 1 <= y <= 3:
  b = d[y]

print(a+b)
Buggy code:
def solve():
    x, y = map(int, input().split())
    ans = 0
    if x == 1:
        ans += 300000
    elif x == 2:
        ans += 200000
    else:
        ans += 100000
    if y == 1:
        ans += 300000
    elif y == 2:
        ans += 200000
    else:
        ans += 100000
    if x == 1 and y == 1:
        ans += 400000
    print(ans)
    


if __name__ == '__main__':
    solve()

Fixed code:
def solve():
    x, y = map(int, input().split())
    ans = 0
    if x == 1:
        ans += 300000
    elif x == 2:
        ans += 200000
    elif x == 3:
        ans += 100000
    if y == 1:
        ans += 300000
    elif y == 2:
        ans += 200000
    elif y == 3:
        ans += 100000
    if x == 1 and y == 1:
        ans += 400000
    print(ans)



if __name__ == '__main__':
    solve()
Buggy code:
#!/usr/bin/env python
# coding: utf-8

# In[15]:


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


# In[16]:


total = sum(A)
ans = total
left = 0
for i in A:
    left += i
    right = total - left
    ans = min(ans, abs(left - right))
    print(left, right, ans)
print(ans)


# In[ ]:






Fixed code:
#!/usr/bin/env python
# coding: utf-8

# In[15]:


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


# In[17]:


total = sum(A)
ans = total
left = 0
for i in A:
    left += i
    right = total - left
    ans = min(ans, abs(left - right))
#     print(left, right, ans)
print(ans)


# In[ ]:
Buggy code:
N = int(input())
# A = input().split()
# A = list(map(int, input().split()))
f = open("tmp.text")
A = list(map(int, f.read().split()))



# left = 0
# right = N - 1
# tmp = 10**9
# while True:
#     # print(left)
#     # print(right)
#     mid = (left + right) // 2
#     # print("mid: " + str(mid))
#     lnum = A[:mid+1]
#     rnum = A[mid+1:]
#     # print(lnum)
#     # print(rnum)
#     new = abs(sum(lnum) - sum(rnum))
#     if tmp == new:
#         break
#     if tmp > new:
#         tmp = new
#     if lnum > rnum:
#         right = mid

#     # print("tmp: "+str(tmp))
#     # input()
#     if left == right:
#         break

# print(tmp)



left = A[0]
right = A[-1]

front = 1
back = 1
for _ in range(N-2):
    if left > right:
        right += A[-1 - back]
        back += 1
    else:
        left += A[front]
        front += 1

print(abs(left-right))


Fixed code:
N = int(input())
# A = input().split()
A = list(map(int, input().split()))
# f = open("tmp.text")
# A = list(map(int, f.read().split()))



# left = 0
# right = N - 1
# tmp = 10**9
# while True:
#     # print(left)
#     # print(right)
#     mid = (left + right) // 2
#     # print("mid: " + str(mid))
#     lnum = A[:mid+1]
#     rnum = A[mid+1:]
#     # print(lnum)
#     # print(rnum)
#     new = abs(sum(lnum) - sum(rnum))
#     if tmp == new:
#         break
#     if tmp > new:
#         tmp = new
#     if lnum > rnum:
#         right = mid

#     # print("tmp: "+str(tmp))
#     # input()
#     if left == right:
#         break

# print(tmp)



left = A[0]
right = A[-1]

front = 1
back = 1
for _ in range(N-2):
    if left > right:
        right += A[-1 - back]
        back += 1
    else:
        left += A[front]
        front += 1

print(abs(left-right))
Buggy code:
n=int(input())
a=list(map(int,input().split()))
harf=sum(a)//2
l,r,i=0,a[0],0
while r<harf:
    i+=1
    l=r
    r+=a[i]
print(min(harf-l,r-harf))

Fixed code:
n=int(input())
a=list(map(int,input().split()))
harf=sum(a)/2
l,r,i=0,a[0],0
while r<harf:
    i+=1
    l=r
    r+=a[i]
print(int(min(harf-l,r-harf)*2))
Buggy code:
n = int(input())
a= [int(x) for x in input().split(" ",n-1)]
print(a)
s = 0
for x in range(n):
    s += a[x-1]
r = 0
l = 0
x = 0
while r < s/2:
    r += a[x]
    x += 1
y = 1
while l < s/2:
    l += a[n-y]
    y += 1
if r == s//2:
    print(0)
else:
    k = min(r,l)  
    v = k - s/2
    m = v // 0.5
    print(int(m))

Fixed code:
n = int(input())
a= [int(x) for x in input().split(" ",n-1)]
s = 0
for x in range(n):
    s += a[x-1]
r = 0
l = 0
x = 0
while r < s/2:
    r += a[x]
    x += 1
y = 1
while l < s/2:
    l += a[n-y]
    y += 1
if r == s//2:
    print(0)
else:
    k = min(r,l)  
    v = k - s/2
    m = v // 0.5
    print(int(m))
Buggy code:
n = int(input())
lis = list(map(int,input().split()))
ans = 10 ** 10
num = sum(lis)
nu = 0
for i in range(n):
  nu += lis[i]
  ans = min(ans,abs(nu-num//2))
print(ans)

Fixed code:
n = int(input())
lis = list(map(int,input().split()))
ans = 10 ** 10
num = sum(lis)
nu = 0
for i in range(n):
  nu += lis[i]
  ans = min(ans,abs(nu-num/2))
print(int(ans//0.5))
Buggy code:
N ,*A  = map(int,open(0).read().split())

L = [0 for i in range(N+1)]
D = [0 for i in range(N)]

for i,a in enumerate(A,1):
  L[i] = L[i-1] + a
for i in range(N):
  D[i] = L[-1]-L[i]
#L.pop(0)
  
print(L)
print(D)
ans = 1e19
for i in range(N):
  #print(L[i],D[i],L[i]-D[i])
  ans = min(abs(L[i]-D[i]),ans)
print(ans)

Fixed code:
N ,*A  = map(int,open(0).read().split())

L = [0 for i in range(N+1)]
D = [0 for i in range(N)]

for i,a in enumerate(A,1):
  L[i] = L[i-1] + a
for i in range(N):
  D[i] = L[-1]-L[i]
#L.pop(0)
  
#print(L)
#print(D)
ans = 1e19
for i in range(N):
  #print(L[i],D[i],L[i]-D[i])
  ans = min(abs(L[i]-D[i]),ans)
print(ans)
Buggy code:
n = int(input())
A = list(map(int,input().split()))
for i in A:
    i = int(i)

def h(n,A):
    res = float('inf')
    f = []
    b = []
    t = 0
    for i in range(len(A)):
        t+=A[i]
        f.append(t)
    t = 0
    for i in range(len(A)-1,-1,-1):
        t += A[i]
        b.append(t)
    for i in range(len(A)-1):
        temp1 = f[i]
        temp2 = b[i+1]
        res = min(res,abs(temp1-temp2))
        
    #print(f)
    #print(b)
    print(res)
    
h(n,A)

Fixed code:
n = int(input())
A = list(map(int,input().split()))
for i in A:
    i = int(i)

def h(n,A):
    res = float('inf')
    f = []
    b = []
    t = 0
    for i in range(len(A)):
        t+=A[i]
        f.append(t)
    t = 0
    for i in range(len(A)-1,-1,-1):
        t += A[i]
        b.append(t)
    b.reverse()
    for i in range(len(A)-1):
        temp1 = f[i]
        temp2 = b[i+1]
        res = min(res,abs(temp1-temp2))
        
    #print(f)
    #print(b)
    print(res)
    
    
    
h(n,A)
Buggy code:
import numpy as np
N=int(input())
A=list(map(int, input().split()))
A=np.array(A)
left=0 
right=N-1
while left<right:
  mid=(left+right)//2
  if A[:mid+1].sum()<A[mid+1:].sum():
    left=mid+1
  else:
    right=mid
if A[:left+1].sum()-A[left+1:].sum()>A[:left].sum()-A[left:].sum():
  print((abs(A[:left].sum()-A[left:].sum())))
else:
  print((abs(A[:left+1].sum()-A[left+1:].sum())))

Fixed code:
import numpy as np
N=int(input())
A=list(map(int, input().split()))
A=np.array(A)
left=0 
right=N-1
while left<right:
  mid=(left+right)//2
  if A[:mid+1].sum()<A[mid+1:].sum():
    left=mid+1
  else:
    right=mid
if (abs(A[:left+1].sum()-A[left+1:].sum()))>(abs(A[:left].sum()-A[left:].sum())):
  print((abs(A[:left].sum()-A[left:].sum())))
else:
  print((abs(A[:left+1].sum()-A[left+1:].sum())))
Buggy code:
#B
N = int(input())
A = list(map(int, input().split()))

A_sum = sum(A)
a_half = 0
for ai in A:
    a_half_next = a_half + ai
    if a_half_next >= A_sum // 2:
        a_half_next_dif = abs((A_sum // 2) - a_half_next)
        a_half_dif = abs((A_sum // 2) - a_half)
        break
    a_half = a_half_next

if a_half_next_dif <= a_half_dif:
    a_half_dif = a_half_next_dif
    a_half = a_half_next
    
if A_sum % 2 == 0:
    dif = a_half_dif
else:
    dif = a_half_dif
print(dif)

Fixed code:
#B
N = int(input())
A = list(map(int, input().split()))

A_sum = sum(A)
a_half = 0
for ai in A:
    a_half_next = a_half + ai
    if a_half_next >= A_sum / 2:
        break
    a_half = a_half_next
    
a_half_dif =  abs((A_sum - a_half) - a_half)
a_half_next_dif = abs((A_sum - a_half_next) - a_half_next)
if a_half_next_dif <= a_half_dif:
    a_half_dif = a_half_next_dif

    
print(a_half_dif)
Buggy code:
N = int(input())
A = list(map(int, input().split()))
ans = 1000000000000
sum_A = sum(A)
left = 0
for i in range(N - 1):
    print(left)
    left += A[i]
    ans = min(ans, abs(sum_A -  left - left))
print(ans)

Fixed code:
N = int(input())
A = list(map(int, input().split()))
ans = 1000000000000
sum_A = sum(A)
left = 0
for i in range(N - 1):
    left += A[i]
    ans = min(ans, abs(sum_A -  left - left))
print(ans)
Buggy code:
n= int(input())
a = list(int(i) for i in input().split())
import math
import sys

sta=sum(a)/2
sum=0
ans=0
for i in range(0,n-1):
    if sum==sta:
        print(0)
        sys.exit()
    elif sum<sta and sum+a[i]>sta:
        ans=min(sta-sum,sum+a[i+1]-sta)/0.5
        print(int(ans))
        sys.exit()
    else:
        sum+=a[i]

ans=min(sta-sum,sum+a[n-1]-sta)/0.5
print(abs(int(ans)))

Fixed code:
n= int(input())
a = list(int(i) for i in input().split())
import math
import sys

sta=sum(a)/2
sum=0
ans=0
for i in range(0,n-1):
    if sum==sta:
        print(0)
        sys.exit()
    elif sum<sta and sum+a[i]>sta:
        ans=min(sta-sum,sum+a[i]-sta)/0.5
        print(int(ans))
        sys.exit()
    else:
        sum+=a[i]

ans=min(sta-sum,sum+a[n-1]-sta)/0.5
print(abs(int(ans)))
Buggy code:
n=int(input())
A=list(map(int,input().split()))

L=sum(A)
l=0
for i in range(n):
  l+=A[i]
  if l >= L/2:
    r=l-A[i]
    break
print(l,r)
print(min(abs((L-r)-r),abs((L-l)-l)))

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

L=sum(A)
l=0
for i in range(n):
  l+=A[i]
  if l >= L/2:
    r=l-A[i]
    break
print(min(abs((L-r)-r),abs((L-l)-l)))
Buggy code:
import sys
import collections
import bisect


def main():
    n = int(input())
    AList = list(map(int, input().split()))
    ASum = sum(a)
    c = 0
    for i in range(n):
        c += AList[i]
        if c >= ASum / 2:
            k = i
            break
    ans = min(2 * c - ASum, ASum - 2 * c + 2 * AList[k])
    print(ans)


if __name__ == '__main__':
    main()


Fixed code:
import sys
import collections
import bisect


def main():
    n = int(input())
    AList = list(map(int, input().split()))
    ASum = sum(AList)
    c = 0
    for i in range(n):
        c += AList[i]
        if c >= ASum / 2:
            k = i
            break
    ans = min(2 * c - ASum, ASum - 2 * c + 2 * AList[k])
    print(ans)


if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
A = list(map(int, input().split()))

ca = [0]
for i in range(n):
    ca.append(A[i]+ca[i])

print(ca)
ans = 2020202020
for i in range(n):
    ans = min(ans, abs(ca[i]-(ca[-1]-ca[i])))

print(ans)


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

ca = [0]
for i in range(n):
    ca.append(A[i]+ca[i])

ans = 2020202020
for i in range(n):
    ans = min(ans, abs(ca[i]-(ca[-1]-ca[i])))

print(ans)