qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n=int(input())
a_=[]
b_=[]

for i in range(n):
    a,b = map(int,input().split())
    a_.append([a+b,a,i])
    b_.append([a+b,b,i])

sa_ = sorted(
  a_,
  key = lambda x: (x[0], x[1]),
  reverse=True
)
sb_ = sorted(
  b_,
  key = lambda x: (x[0], x[1]),
  reverse=True
)

i_={}
res=0

for i in range(n):
    if i % 2 :
        item = sb_.pop()
        while ( item[2] in i_ ) :
            item = sb_.pop(0)
        res -= item[1]
        i_[item[2]]=1
    else :
        item = sa_.pop()
        while ( item[2] in i_ ) :
            item = sa_.pop(0)
        res += item[1]
        i_[item[2]]=1

print(res)

Fixed code:
n=int(input())
a_=[]
b_=[]

for i in range(n):
    a,b = map(int,input().split())
    a_.append([a+b,a,i])
    b_.append([a+b,b,i])

sa_ = sorted(
  a_,
  key = lambda x: (x[0], x[1]),
)
sb_ = sorted(
  b_,
  key = lambda x: (x[0], x[1]),
)

i_={}
res=0

for i in range(n):
    if i % 2 :
        item = sb_.pop()
        while ( item[2] in i_ ) :
            item = sb_.pop()
        res -= item[1]
        i_[item[2]]=1
    else :
        item = sa_.pop()
        while ( item[2] in i_ ) :
            item = sa_.pop()
        res += item[1]
        i_[item[2]]=1

print(res)
Buggy code:
n = int(input())
ab = []
bsum = 0
for i in range(n):
    a,b = map(int,input().split(' '))
    ab.append(a + b)
    bsum += b
ad.sort(reverse = True)
print(sum(ab[0::2]) - bsum)

Fixed code:
n = int(input())
ab = []
bsum = 0
for i in range(n):
    a,b = map(int,input().split(' '))
    ab.append(a + b)
    bsum += b
ab.sort(reverse = True)
print(sum(ab[0::2]) - bsum)
Buggy code:
n = int(input())
D = []
A = []
B = []
m = 1000000000
res = 0
for i in range(n):
    a,b = map(int,input().split())
    point = a+b
    D.append([point,i])
    A.append(a)
    B.append(b)
else:
    D.sort()
    D.reverse()

for i in range(n):
    if n%2 == 0:
        res += A[(D[i][1])]
    else:
        res -= B[(D[i][1])]
else:
    print(res)


Fixed code:
n = int(input())
D = []
A = []
B = []
m = 1000000000
res = 0
for i in range(n):
    a,b = map(int,input().split())
    point = a+b
    D.append([point,i])
    A.append(a)
    B.append(b)
else:
    D.sort()
    D.reverse()

ans_a = 0
ans_c = 0
for i in range(n):
    if i%2 == 0:
        res += A[(D[i][1])]
        ans_a += A[(D[i][1])]
    else:
        res -= B[(D[i][1])]
        ans_c += B[(D[i][1])]
else:
    #print(res)
    print(ans_a-ans_c)
Buggy code:
import numpy as np

N = int(input())
x = []
for i in range(N):
    x.extend(input().split())

a = np.array(x, dtype = 'int').reshape((3, 2))
s = a[:,0:1] + a[:,1:2]
a = np.hstack((a, s))
a = a[np.argsort(a[:, 2])][::-1, :]
n = np.sum(a[0::2, 0]) - np.sum(a[1::2, 1])
print(n)

Fixed code:
import numpy as np

N = int(input())
x = []
for i in range(N):
    x.extend(input().split())

a = np.array(x, dtype='int').reshape((N, 2))
s = a[:,0:1] + a[:,1:2]
a = np.hstack((a, s))
a = a[np.argsort(a[:, 2])][::-1, :]
n = np.sum(a[0::2, 0]) - np.sum(a[1::2, 1])
print(n)
Buggy code:
N = int(input())
F = []
for i in range(N):
  a,b = map(int,input().split())
  F.append([a+b],a,b)
F.sort(key=lambda x:x[0],reverse=True)
ans = 0
for i in range(N):
  if i%2==0:
    ans += F[i][1]
  else:
    ans -= F[i][2]
print(ans)

Fixed code:
N = int(input())

l= []
for i in range(N):

	a,b = map(int, input().split())
	l.append([a,b,a+b])

l.sort(key=lambda x:x[2])
l.reverse()


ans = 0
for i in range(N):
	if i%2 == 0:
		ans+= l[i][0]
	else:
		ans-= l[i][1]

print(ans)
Buggy code:
n = int(input())
happiness_hash = {}
for i in range(n):
    a, b = tuple(map(int, input().split(' ')))

    happiness_hash[i] = (a, b)

sorted_happiness = sorted(happiness_hash.items(), key = lambda x : x[1][0] + x[1][1], reverse = True)

total = 0
i = 0
for k, v in sorted_happiness:
    happiness, selected = (0, k)
    if i % 2 == 0:
        happiness = v[0]
        total += happiness
    else:
        happiness = v[1]
        total -= happiness
    print(selected, happiness)
    i += 1

print(total)


Fixed code:
n = int(input())
happiness_hash = {}
for i in range(n):
    a, b = tuple(map(int, input().split(' ')))
 
    happiness_hash[i] = (a, b)
 
sorted_happiness = sorted(happiness_hash.items(), key = lambda x : x[1][0] + x[1][1], reverse = True)
 
total = 0
i = 0
for k, v in sorted_happiness:
    happiness, selected = (0, k)
    if i % 2 == 0:
        happiness = v[0]
        total += happiness
    else:
        happiness = v[1]
        total -= happiness
    i += 1
 
print(total)
Buggy code:
n = int(input())
ans = 0
li = []
for i in range(n):
    a, b = map(int, input().split())
    li.append([a+b, a, b])

li = sorted(li)
li = reversed(li)
for i in range(n):
    if i%2 == 0:
        ans += li[i][1]
    else:
        ans -= li[i][2]

print(ans)




Fixed code:
n = int(input())
ans = 0
li = []
for i in range(n):
    a, b = map(int, input().split())
    li.append([a+b, a, b])

li = sorted(li)
li.reverse()
for i in range(n):
    if i%2 == 0:
        ans += li[i][1]
    else:
        ans -= li[i][2]

print(ans)
Buggy code:
n = int(input())
AB = [tuple(map(int,input().split())) for _ in range(n)]
all_b = sum([b for _,b in AB])
AB = sorted([a + b for a,b in AB],reverse=True)
print(AB)
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += AB[i]
print(ans - all_b)

Fixed code:
n = int(input())
AB = [tuple(map(int,input().split())) for _ in range(n)]
all_b = sum([b for _,b in AB])
AB = sorted([a + b for a,b in AB],reverse=True)
ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += AB[i]
print(ans - all_b)
Buggy code:
base = int(input())

data = [[0 for i in range(2)] for j in range(base)]

for num in range(base):
    _num = input()
    _num = _num.split()
    data[num][0] = float(_num[0])
    data[num][1] = float(_num[1])


takahashi = 0
aoki = 0

data.sort()
data.reverse()

_num = 0
for num in range(base):
    if(_num == 0):
        takahashi += data[num][0]
        _num = 1
    elif(_num == 1):
        aoki += data[num][1]
        _num = 0

print(takahashi-aoki)


Fixed code:
base = int(input())

data = [[0 for i in range(3)] for j in range(base)]

for num in range(base):
    _num = input()
    _num = _num.split()
    data[num][0] = int(_num[0])+int(_num[1])
    data[num][1] = int(_num[0])
    data[num][2] = int(_num[1])

takahashi = 0
aoki = 0
data.sort()
data.reverse()

_num = 0
for num in range(base):
    if(_num == 0):
        takahashi += data[num][1]
        _num = 1

    elif(_num == 1):
        aoki += data[num][2]
        _num = 0

print(takahashi-aoki)
Buggy code:
n=int(input())
l=[[i]+list(map(int,input().split())) for i in range(n)]

a=sorted(l,key=lambda x:(-x[1]+x[2],-x[1],-x[2]))
b=sorted(l,key=lambda x:(x[1]-x[2],-x[2],-x[1]))
pa,pb=0,0
used=set()

v=0
while pa<n and pb<n:
  while pa<n and a[pa][0] in used:
    pa+=1
  if pa<n:
    used.add(a[pa][0])
    v+=a[pa][1]
  while pb<n and b[pb][0] in used:
    pb+=1
  if pb<n:
    used.add(b[pb][0])
    v-=b[pb][2]

print(v)

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

l.sort(key=lambda x:-(x[1]+x[2]))
pa,pb=0,0
used=set()

v=0
while pa<n and pb<n:
  while pa<n and l[pa][0] in used:
    pa+=1
  if pa<n:
    used.add(l[pa][0])
    v+=l[pa][1]
  while pb<n and l[pb][0] in used:
    pb+=1
  if pb<n:
    used.add(l[pb][0])
    v-=l[pb][2]

print(v)
Buggy code:
N = int(input())
L = []
X = 0
for i in range(N):
    a, b = map(int, input().split())
    L += [a+b]
    X += b
L.sort(reverse=True)
j = N-N//2
print(sum(L[0:j])-X)

Fixed code:
N = int(input())
L = []
X = 0
for i in range(N):
    a, b = map(int, input().split())
    L += [a+b]
    X += b
L.sort(reverse=True)
print(sum(L[0::2])-X)
Buggy code:
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]

div = [[abs(ab[i][1] - ab[i][0]), ab[i][0], ab[i][1]] for i in range(n)]
div = sorted(div, key=lambda x: x[0], reverse=True)

print(div)
counta = 0
countb = 0
for i in range(n):
    if i % 2 == 0:
        counta += div[i][1]
    else:
        countb += div[i][2]

print(counta - countb)

Fixed code:
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
div = [[ab[i][1] + ab[i][0], ab[i][0], ab[i][1]] for i in range(n)]
div = sorted(div, key=lambda x: x[0], reverse=True)

counta = 0
countb = 0
for i in range(n):
    if i % 2 == 0:
        counta += div[i][1]
    else:
        countb += div[i][2]

print(counta - countb)
Buggy code:
N=int(input())
AB=[]
takahashi=0
aoki=0
for i in range(N):
    a,b=map(int,input().split())
    AB.append([a,b,abs(b-a)])
AB.sort(key=lambda AB:(AB[2],AB[1],AB[0]),reverse=True)
for i in range(N):
    if i%2==0:
        takahashi+=AB[i][0]
    else:
        aoki+=AB[i][1]
print(takahashi-aoki)

Fixed code:
N=int(input())
AB=[]
takahashi=0
aoki=0
for i in range(N):
    a,b=map(int,input().split())
    AB.append([a,b,a+b])
AB.sort(key=lambda AB:(AB[2],AB[1],AB[0]),reverse=True)
for i in range(N):
    if i%2==0:
        takahashi+=AB[i][0]
    else:
        aoki+=AB[i][1]
print(takahashi-aoki)
Buggy code:
# 2019/01/27
# NIKKEI Programming Contest 2019 - C
from operator import itemgetter

# Input
n = int(input())
ablist = list()

for idx in range(n):
    a, b = map(int, input().split())
    ablist.append([a, b, abs(a-b)]) #abs irankamo

ablist.sort(key=itemgetter(0, 1), reverse=True)

tsum = 0
asum = 0

# Sum
for idx in range(n):
    if idx % 2 == 0:
        # Turn of Takahashi
        tsum += ablist[idx][0]
    else:
        # Turn of Aoki
        asum += ablist[idx][1]

# Output
print(ablist,tsum,asum)
print(tsum - asum)


Fixed code:
# 2019/01/27
# NIKKEI Programming Contest 2019 - C
from operator import itemgetter

# Input
n = int(input())
ablist = list()

for idx in range(n):
    a, b = map(int, input().split())
    ablist.append([a, b, a+b])

ablist.sort(key=itemgetter(2), reverse=True)

tsum = 0
asum = 0

# Sum
for idx in range(n):
    if idx % 2 == 0:
        # Turn of Takahashi
        tsum += ablist[idx][0]
    else:
        # Turn of Aoki
        asum += ablist[idx][1]

ans1 = tsum - asum

# Output
print(ans1)
Buggy code:

N = int(input().strip())
arr = []
for n in range(N):
  A, B = list(map(int, input().split()))
  arr.append([ A + B - A , A, B])

arr = sorted(arr, reverse=True)
print(arr)
ta = sum([a[1] for a in arr[::2]])
ao = sum([a[2] for a in arr[1::2]])
print(ta - ao)

Fixed code:
N = int(input().strip())
arr = []
for n in range(N):
  A, B = list(map(int, input().split()))
  arr.append([ A + B , A, B])

arr = sorted(arr, reverse=True)
ta = sum([a[1] for a in arr[::2]])
ao = sum([a[2] for a in arr[1::2]])
print(ta - ao)
Buggy code:
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = sorted([[a[i][0] + a[i][1], a[i][0]] for i in range(n)])
taka = 0
aoki = 0

for i in range(n):
  if i % 2 == 0:
    taka += b[n - k - i - 1][1]
  else:
    aoki += b[n - k - i - 1][0] - b[n - k - i - 1][1]

print(taka - aoki)

Fixed code:
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
b = sorted([[a[i][0] + a[i][1], a[i][0]] for i in range(n)])
taka = 0
aoki = 0

for i in range(n):
  if i % 2 == 0:
    taka += b[n - i - 1][1]
  else:
    aoki += b[n - i - 1][0] - b[n - i - 1][1]

print(taka - aoki)
Buggy code:
import numpy as np
N=int(input())
AB=np.empty((N,2))
sum=np.empty(N)

for i in range(N):
    AB[i]=list(map(int,input().split()))
    sum[i]=AB[i][0]+AB[i][1]
lis = np.argsort(sum)
taka=0
aoki=0
for i in lis:
    if N%2==0:
        if i%2!=0:
            taka+=AB[lis[i]][0]
        else:
            i=AB[lis[i]][1]
    else:
        if i%2==0:
            taka+=AB[lis[i]][0]
        else:
            i=AB[lis[i]][1]

print(int(taka-aoki))


Fixed code:
import numpy as np
N=int(input())
AB=np.empty((N,2))
sum=np.empty(N)

for i in range(N):
    AB[i]=list(map(int,input().split()))
    sum[i]=AB[i][0]+AB[i][1]
lis = np.argsort(sum)
taka=0
aoki=0
for i in lis:
    if N%2==0:
        if i%2!=0:
            taka+=AB[lis[i]][0]
        else:
            aoki+=AB[lis[i]][1]
    else:
        if i%2==0:
            taka+=AB[lis[i]][0]
        else:
            aoki+=AB[lis[i]][1]

print(int(taka-aoki))
Buggy code:
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
    s=input().split()
    A,B=int(s[0]),int(s[1])
    a.append(A)
    b.append(B)
    c.append(A+B)
print(n,a,b,c,d)
c.sort(reverse=True)
s1=0
s2=0
for i in range(n):
    s1+=a[i]
    if i%2:
        s2+=c[i]
print(s1-s2)

Fixed code:
n=int(input())
a=[]
b=[]
c=[]
for i in range(n):
    s=input().split()
    A,B=int(s[0]),int(s[1])
    a.append(A)
    b.append(B)
    c.append(A+B)
c.sort(reverse=True)
s1=0
s2=0
for i in range(n):
    s1+=a[i]
    if i%2:
        s2+=c[i]
print(s1-s2)
Buggy code:
n = int(input())
box = [list(map(int, input().split())) for i in range(n)]

li = sorted(box, key = lambda x: sum(x), reverse = True)

taka = []
aoki = []

for i in range(len(li)):
    taka.append(li[0][0])
    del li[0]
    if li == []:
        print(sum(taka) - sum(aoki))
        quit()
    aoki.append(li[0][1])
    del li[0]

print(sum(taka) - sum(aoki))

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

li = list(sorted(box, key=lambda x: sum(x), reverse = True))

taka = []
aoki = []

for i in range(len(li)):
    taka.append(li[0][0])
    del li[0]
    if li == []:
        print(sum(taka) - sum(aoki))
        quit()
    aoki.append(li[0][1])
    del li[0]
    if li ==[]:
        print(sum(taka) - sum(aoki))
        quit()
Buggy code:
import numpy as np
N = int(input())

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

diff = []
for _ in range(N):
    diff.append(B[_] - A[_])

diff = np.array(diff)
A = np.array(A)
B = np.array(B)

sort_index = diff.argsort()

A = (A[sort_index])
B = (B[sort_index])

if N%2 == 0:
    taka = (A[1::2])
    aoki = (B[2::2])
else:
    taka = (A[0::2])
    aoki = (B[1::2])

print(sum(taka) - sum(aoki))


Fixed code:
import numpy as np
N = int(input())

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

diff = []
for _ in range(N):
    diff.append(B[_] + A[_])

diff = np.array(diff)
A = np.array(A)
B = np.array(B)

sort_index = diff.argsort()

A = (A[sort_index][::-1])
B = (B[sort_index][::-1])

taka = (A[0::2])
aoki = (B[1::2])

print(sum(taka) - sum(aoki))
Buggy code:
N = int(input())
A = []
B = []
su = []
for i in range(N):
    a, b = (int(i) for i in input().split())
    A.append(a)
    B.append(b)
    su.append( (a + b, a - b, a, b) )
su.sort()
su.reverse()

cc = 0
for i in range(N):
    if i < N-1 and su[i][0] == su[i+1][0]:
        cc += 1
    else:
        if cc:
            temp = []
            for j in range(i-cc, i+1):
                temp.append(su[j])
            temp2 = []
            for j in range(i-cc, i+1):
                if j % 2 == 0:
                    temp2.append(temp.pop(0))
                else:
                    temp2.append(temp.pop())
            for j in range(i-cc, i+1):
                su[j] = temp2[j-(i-cc)]
            cc = 0
ans = 0
print(su)
for i in range(N):
    if i%2 == 0:
        ans += su[i][2]
    else:
        ans -= su[i][3]

print(ans)

Fixed code:
N = int(input())
A = []
B = []
su = []
for i in range(N):
    a, b = (int(i) for i in input().split())
    A.append(a)
    B.append(b)
    su.append( (a + b, a - b, a, b) )
su.sort()
su.reverse()

cc = 0
for i in range(N):
    if i < N-1 and su[i][0] == su[i+1][0]:
        cc += 1
    else:
        if cc:
            temp = []
            for j in range(i-cc, i+1):
                temp.append(su[j])
            temp2 = []
            for j in range(i-cc, i+1):
                if j % 2 == 0:
                    temp2.append(temp.pop(0))
                else:
                    temp2.append(temp.pop())
            for j in range(i-cc, i+1):
                su[j] = temp2[j-(i-cc)]
            cc = 0
ans = 0
for i in range(N):
    if i%2 == 0:
        ans += su[i][2]
    else:
        ans -= su[i][3]

print(ans)
Buggy code:
n=int(input())
A=[]
for i in range(n):
    A.append(list(map(int,input().split())))
B=[]
for i in range(n):
    B.append([i,A[i][0]-A[i][1]])

B.sort(key=lambda x:x[1])

print(B)

S=[0,0]
for i in range(n):
    S[i%2]+=A[B[i][0]][i%2]

print(S[0]-S[1])


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

A.sort(reverse=1)

B=[]
for i in range(n):
    B.append([i,A[i][1]+A[i][0]])
    
B.sort(reverse=1,key=lambda x:x[1])




#print(B)
#print(C)


S=[0,0]

for i in range(n):
    S[i%2]+=A[B[i][0]][i%2]


print(S[0]-S[1])
Buggy code:
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy as np
import scipy

from collections import defaultdict
from pprint import pprint

N = int(input())
A = []
B = []
diff = []
points = [] # points[i] = [A,B,diff]
for i in range(N):
    a,b = [int(x) for x in input().split(" ")]
    points.append([a,b,a-b])

sorted_points = sorted(points, key=lambda x: x[2], reverse=False)
print(sorted_points)
point_a, point_b = 0,0

turn_A = True
for p in sorted_points:
    if turn_A:
        point_a += p[0]
        turn_A = False
    else:
        point_b += p[1]
        turn_A = True

print(point_a - point_b)


Fixed code:
#!/Users/takahiro.kida/git/atcorder/venv/bin/python

import numpy as np
import scipy

from collections import defaultdict
from pprint import pprint

N = int(input())
A = []
B = []
diff = []
points = [] # points[i] = [A,B,diff]
for i in range(N):
    a,b = [int(x) for x in input().split(" ")]
    points.append([a,b,a+b])

sorted_points = sorted(points, key=lambda x: x[2], reverse=True)
point_a, point_b = 0,0

turn_A = True
for p in sorted_points:
    if turn_A:
        point_a += p[0]
        turn_A = False
    else:
        point_b += p[1]
        turn_A = True

print(point_a - point_b)
Buggy code:
N = int(input())
happiness = []
for i in range(N):
    a, b = map(int, input().split())
    happiness.append((a, b, i))

T = []
A = []
eaten = [False]*N

happiness1 = sorted(happiness, key=lambda x:(x[0], x[1]))
happiness2 = sorted(happiness, key=lambda x:(x[1], x[0]))

print(happiness1)
print(happiness2)

for i in range(N):
    if i % 2 == 0: # Takahashi
        while True:
            a, _, idx = happiness1.pop()
            if not eaten[idx]:
                eaten[idx] = True
                T.append(a)
                break
    else: # Aoki
        while True:
            _, b, idx = happiness2.pop()
            if not eaten[idx]:
                eaten[idx] = True
                A.append(b)
                break

print(sum(T) - sum(A))

Fixed code:
N = int(input())
happiness = []
for i in range(N):
    a, b = map(int, input().split())
    happiness.append((a, b, a+b, i))

T = []
A = []
eaten = [False]*N

happiness1 = sorted(happiness, key=lambda x:(x[2], x[0], x[1]))
happiness2 = sorted(happiness, key=lambda x:(x[2], x[1], x[0]))

for i in range(N):
    if i % 2 == 0: # Takahashi
        while True:
            a, _, _, idx = happiness1.pop()
            if not eaten[idx]:
                eaten[idx] = True
                T.append(a)
                break
    else: # Aoki
        while True:
            _, b, _, idx = happiness2.pop()
            if not eaten[idx]:
                eaten[idx] = True
                A.append(b)
                break

print(sum(T) - sum(A))
Buggy code:
n = int(input())
info =[list(map(int,input().split())) for i in range(n)] 

diff = [[0] for i in range(n)]
sorted_diff = [[0] for i in range(n)]

for i in range(n):
  diff[i][0] = info[i][0]+info[i][1] 

for i in range(n):
  info[i].extend(diff[i])
#print(info)

sorted_diff = sorted(info, key=lambda x: x[2],reverse=True)

#print(sorted_diff)
takahashi =0
aoki = 0
for i in range(n):
  if i%2==0:
    takahashi+= sorted_diff[0][1]
    print(sorted_diff[0][1])
    del sorted_diff[0]
  else:
    aoki+=sorted_diff[0][1]
    print(sorted_diff[0][1])
    del sorted_diff[0]
    
print(takahashi-aoki)

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

diff = [[0] for i in range(n)]
sorted_diff = [[0] for i in range(n)]

for i in range(n):
  diff[i][0] = info[i][0]+info[i][1] 

for i in range(n):
  info[i].extend(diff[i])
#print(info)

sorted_diff = sorted(info, key=lambda x: x[2])

#print(sorted_diff)
takahashi =0
aoki = 0
for i in range(n):
  if i%2==0:
    takahashi+= sorted_diff[-1][0]
#    print(sorted_diff[0][1])
    del sorted_diff[-1]
  else:
    aoki+=sorted_diff[-1][1]
#    print(sorted_diff[0][1])
    del sorted_diff[-1]
    
print(takahashi-aoki)
Buggy code:
N = int(input())
C = [list(map(int, input().split())) for _ in range(N)]
C = sorted(map(lambda x: (abs(x[0] - x[1]), x), C), reverse=True)
print(sum(c[1][0] for c in C[::2]) - sum(c[1][1] for c in C[1::2]))


Fixed code:
N = int(input())
C = [list(map(int, input().split())) for _ in range(N)]
C = sorted(map(lambda x: ((x[0] + x[1]), x), C), reverse=True)
#print(C)
#print(C[::2])
#print(C[1::2])
print(sum(c[1][0] for c in C[::2]) - sum(c[1][1] for c in C[1::2]))
Buggy code:
N = int(input())
inputs = [list(map(int, input().split())) for _ in range(N)]

dicts = {}
for i in range(N):
    dicts[i] = sum(inputs[i])

ans = ~
count = 0
for key, value in sorted(dicts.items(), key=lambda x: -x[1]):
    if count % 2 == 0:
        ans += inputs[key][0]
    else:
        ans -= inputs[key][1]
    count += 1

print(ans)


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

dicts = {}
for i in range(N):
    dicts[i] = sum(inputs[i])

t = 0
a = 0
count = 0
for key, value in sorted(dicts.items(), key=lambda x: -x[1]):
    if count % 2 == 0:
        t += inputs[key][0]
    else:
        a += inputs[key][1]
    count += 1

print(t - a)
Buggy code:
N = int(input())
arr = []
for i in range(N):
    a,b = list(map(int, input().split()))
    arr.append([a,b])
arr = sorted(arr, key=lambda x: x[0]+x[1], reverse=True)
ans = 0
for i in range(N):
    if i%2 == 0:
        ans += arr[i][0]
    else:
        ans -= arr[i][1]
print(abs(ans))

Fixed code:
N = int(input())
arr = []
for i in range(N):
    a,b = list(map(int, input().split()))
    arr.append([a,b])
arr = sorted(arr, key=lambda x: x[0]+x[1], reverse=True)
ans = 0
for i in range(N):
    if i%2 == 0:
        ans += arr[i][0]
    else:
        ans -= arr[i][1]
print(ans)
Buggy code:
X,Y,Z = map(int, input().split())
print((X * Y)/2)

Fixed code:
X,Y,Z = map(int, input().split())
print((X * Y)//2)
Buggy code:
p,q,r=map(int,input().split())
print(p*q/2)

Fixed code:
p,q,r=map(int,input().split())
print(p*q//2)
Buggy code:
a,b,c = map(int,input().split())
print(min(a*b,b*c,c*a)/2)

Fixed code:
a, b, c= map(int, input().split())
print(a * b //2)
Buggy code:
AB, BC, CA = map(int, input().split())

print((BC*AB)/2)

Fixed code:
AB, BC, CA = list(map(int, input().split()))
print(AB * BC // 2)
Buggy code:
A, B, C = map(int, input().split())
print(A*B/2)

Fixed code:
A,B,C = map(int, input().split())
print(A*B//2)
Buggy code:
x, y, z = map(int,input().split())
print(x * y / 2)

Fixed code:
x, y, z = map(int,input().split())
print(x * y // 2)
Buggy code:
a, b, c = map(int, input().split())
print((a*b)/2)

Fixed code:
a, b, c = list(map(int, input().split()))

print((a * b) // 2)
Buggy code:
AB, BC, CA = map(int, input().split())
print(AB * BC / 2)

Fixed code:
AB, BC, CA = list(map(int, input().split()))

print((AB * BC)//2)
Buggy code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    print(a[0]*a[1]/2)

Fixed code:
import sys
import copy
import math
import bisect
import pprint
import bisect
from functools import reduce
from copy import deepcopy
from collections import deque

if __name__ == '__main__':
    a = [int(i) for i in input().split()]
    print(a[0]*a[1]//2)
Buggy code:
A , B , C=map(int , input().split())
print(A*B/2)

Fixed code:
A,B,C = map(int,input().split())
print( B * A // 2 )
Buggy code:
a,b,c = map(input().split())

print(a*b//2)

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

print(int(a*b//2))
Buggy code:
a, b, c=map(int,input().split())
print(a*b/2)

Fixed code:
a,b,c= map(int,input().split())
print(a*b//2)
Buggy code:
A,B,C=map(int, input().split())
print(A*B/2)

Fixed code:
A,B,C = map(int,input().split())

print(A*B//2)