Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

aa = []
for i in range(n):
	k,l = map(int,input().split())
	aa.append([k,l])
aa.sort(key = lambda x:x[1])
aa.reverse()
co = 0
ma = 0
kkk = 0
for i in range(n):
	if i % 2 == 0:
		ma = max(aa,key = lambda x:x[0])[0]
		for j in range(n-i):
			if ma == aa[j][0]:
				co += aa.pop(j)[0]
				break
	else:
		co -= aa.pop(0)[1]

print(co)


Fixed submission:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

po = []
su = 0
for i in range(n):
    a,b = m()
    po.append([a+b,a])
po.sort(reverse = True)

for i in range(n):
    if i % 2 == 0:
        su += po[i][1]
    else:
        su -= po[i][0] - po[i][1]
print(su)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

aa = []
for i in range(n):
	k,l = map(int,input().split())
	aa.append([k,l])
aa.sort(key = lambda x:x[1])
aa.reverse()
co = 0
ma = 0
kkk = 0
for i in range(n):
	if i % 2 == 0:
		ma = max(aa,key = lambda x:x[0])[0]
		for j in range(len(aa)):
			if ma == aa[j][0]:
				co += aa.pop(j)[0]
				break
	else:
		co -= aa.pop(0)[1]

print(co)


Fixed submission:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

po = []
su = 0
for i in range(n):
    a,b = m()
    po.append([a+b,a])
po.sort(reverse = True)

for i in range(n):
    if i % 2 == 0:
        su += po[i][1]
    else:
        su -= po[i][0] - po[i][1]
print(su)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

aa = []
for i in range(n):
	k,l = map(int,input().split())
	aa.append([k,l])
dp = [[0,0] for i in range(n+1)]
aa.sort(key = lambda x:x[1])
co = 0
ma = 0
kkk = 0
for i in range(n):
	if i % 2 == 0:
		for j in range(len(aa)):
			if ma < aa[j][0]:
				ma = aa[j][0]
				kkk = j
		co += aa.pop(j)[0]
	else:
		for j in range(len(aa)):
			if ma < aa[j][1]:
				ma = aa[j][1]
				kkk = j
		co -= aa.pop(j)[1]

print(co)

Fixed submission:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

po = []
su = 0
for i in range(n):
    a,b = m()
    po.append([a+b,a])
po.sort(reverse = True)

for i in range(n):
    if i % 2 == 0:
        su += po[i][1]
    else:
        su -= po[i][0] - po[i][1]
print(su)

Buggy python submission (verdict: Runtime Error):
n = int(input())

a = []
b = []
aa = []
for i in range(n):
	k,l = map(int,input().split())
	a.append(k)
	b.append(l)
	aa.append([k,l])
dp = [[0,0] for i in range(n+1)]
aa.sort(key = lambda x:x[1])
co = 0
for i in range(n):
	for j in range(n):
		if i % 2 == 0:		
			dp[i+1] = max(dp[i]+aa[j][i%2],dp[i+1])
		else:
			dp[i+1] = max(dp[i]-aa[j][i%2],dp[i+1])

print(dp[n+1])

Fixed submission:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

po = []
su = 0
for i in range(n):
    a,b = m()
    po.append([a+b,a])
po.sort(reverse = True)

for i in range(n):
    if i % 2 == 0:
        su += po[i][1]
    else:
        su -= po[i][0] - po[i][1]
print(su)