import numpy as np

N = int(eval(input()))



A = []

B = []

val = []



for i in range(N):

    a, b = list(map(int, input().split()))

    A.append(a)

    B.append(b)

    val.append(a + b)



A = np.array(A)

B = np.array(B)

val = np.array(val)



sort_index = val.argsort()



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

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



taka = (A[0::2])

aoki = (B[1::2])



print((sum(taka) - sum(aoki)))
n = int(eval(input()))

happiness_hash = {}

for i in range(n):

    a, b = tuple(map(int, input().split(' ')))

 

    happiness_hash[i] = (a, b)

 

sorted_happiness = sorted(list(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)
import numpy as np

N = int(eval(input()))
A = []
B = []
val = []
for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
    val.append(a + b)
A = np.array(A)
B = np.array(B)
val = np.array(val)
sort_index = val.argsort()
A = A[sort_index][::-1]
B = B[sort_index][::-1]
taka = A[0::2]
aoki = B[1::2]
print((sum(taka) - sum(aoki)))

n = int(eval(input()))
happiness_hash = {}
for i in range(n):
    a, b = tuple(map(int, input().split(" ")))
    happiness_hash[i] = (a, b)
sorted_happiness = sorted(
    list(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)

-import numpy as np - -N = int(eval(input())) -A = [] -B = [] -val = [] -for i in range(N): -    a, b = list(map(int, input().split())) -    A.append(a) -    B.append(b) -    val.append(a + b) -A = np.array(A) -B = np.array(B) -val = np.array(val) -sort_index = val.argsort() -A = A[sort_index][::-1] -B = B[sort_index][::-1] -taka = A[0::2] -aoki = B[1::2] -print((sum(taka) - sum(aoki))) +n = int(eval(input())) +happiness_hash = {} +for i in range(n): +    a, b = tuple(map(int, input().split(" "))) +    happiness_hash[i] = (a, b) +sorted_happiness = sorted( +    list(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)