n = int(eval(input()))

A, B, C = [], [], []

for i in range(n):

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

    A.append(a)

    B.append(b)

    C.append([a + b, i])

C = sorted(C, reverse=True)



suma, sumb = 0, 0

for i in range(n):

    if i % 2:

        sumb += B[C[i][1]]

    else:

        suma += A[C[i][1]]

print((suma - sumb))
import sys



sys.setrecursionlimit(10 ** 7)

input = sys.stdin.readline

f_inf = float('inf')

mod = 10 ** 9 + 7





def resolve():

    n = int(eval(input()))

    AB = [list(map(int, input().split())) for _ in range(n)]

    for i in range(n):

        a, b = AB[i]

        AB[i] = [a + b, a, b]

    AB.sort(key=lambda x: x[0], reverse=True)



    score_t, score_a = 0, 0

    for i in range(n):

        if i % 2 == 0:

            score_t += AB[i][1]

        else:

            score_a += AB[i][2]



    print((score_t - score_a))





if __name__ == '__main__':

    resolve()

n = int(eval(input()))
A, B, C = [], [], []
for i in range(n):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)
    C.append([a + b, i])
C = sorted(C, reverse=True)
suma, sumb = 0, 0
for i in range(n):
    if i % 2:
        sumb += B[C[i][1]]
    else:
        suma += A[C[i][1]]
print((suma - sumb))

import sys

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
f_inf = float("inf")
mod = 10**9 + 7


def resolve():
    n = int(eval(input()))
    AB = [list(map(int, input().split())) for _ in range(n)]
    for i in range(n):
        a, b = AB[i]
        AB[i] = [a + b, a, b]
    AB.sort(key=lambda x: x[0], reverse=True)
    score_t, score_a = 0, 0
    for i in range(n):
        if i % 2 == 0:
            score_t += AB[i][1]
        else:
            score_a += AB[i][2]
    print((score_t - score_a))


if __name__ == "__main__":
    resolve()

-n = int(eval(input())) -A, B, C = [], [], [] -for i in range(n): -    a, b = list(map(int, input().split())) -    A.append(a) -    B.append(b) -    C.append([a + b, i]) -C = sorted(C, reverse=True) -suma, sumb = 0, 0 -for i in range(n): -    if i % 2: -        sumb += B[C[i][1]] -    else: -        suma += A[C[i][1]] -print((suma - sumb)) +import sys + +sys.setrecursionlimit(10**7) +input = sys.stdin.readline +f_inf = float("inf") +mod = 10**9 + 7 + + +def resolve(): +    n = int(eval(input())) +    AB = [list(map(int, input().split())) for _ in range(n)] +    for i in range(n): +        a, b = AB[i] +        AB[i] = [a + b, a, b] +    AB.sort(key=lambda x: x[0], reverse=True) +    score_t, score_a = 0, 0 +    for i in range(n): +        if i % 2 == 0: +            score_t += AB[i][1] +        else: +            score_a += AB[i][2] +    print((score_t - score_a)) + + +if __name__ == "__main__": +    resolve()