def main():

    n = int(eval(input()))

    df = []

    for _ in range(n):

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

        df.append([a+b, a, b])

    df.sort(reverse = True)

    result = 0

    for i in range(n):

        if i%2 == 0:

            x = df.pop(0)

            result += x[1]

        else:

            x = df.pop(0)

            result -= x[2]

    print(result)

if __name__ == '__main__':

    main()
n = int(eval(input()))

ab = []

for i in range(n):

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

    ab.append([a+b, a, b])

ab.sort(reverse = True)

result = 0

for i in range(n):

    if i%2 == 0:

        result += ab[i][1]

    else:

        result -= ab[i][2]

print(result)
def main():
    n = int(eval(input()))
    df = []
    for _ in range(n):
        a, b = list(map(int, input().split(" ")))
        df.append([a + b, a, b])
    df.sort(reverse=True)
    result = 0
    for i in range(n):
        if i % 2 == 0:
            x = df.pop(0)
            result += x[1]
        else:
            x = df.pop(0)
            result -= x[2]
    print(result)


if __name__ == "__main__":
    main()

n = int(eval(input()))
ab = []
for i in range(n):
    a, b = list(map(int, input().split(" ")))
    ab.append([a + b, a, b])
ab.sort(reverse=True)
result = 0
for i in range(n):
    if i % 2 == 0:
        result += ab[i][1]
    else:
        result -= ab[i][2]
print(result)

-def main(): -    n = int(eval(input())) -    df = [] -    for _ in range(n): -        a, b = list(map(int, input().split(" "))) -        df.append([a + b, a, b]) -    df.sort(reverse=True) -    result = 0 -    for i in range(n): -        if i % 2 == 0: -            x = df.pop(0) -            result += x[1] -        else: -            x = df.pop(0) -            result -= x[2] -    print(result) - - -if __name__ == "__main__": -    main() +n = int(eval(input())) +ab = [] +for i in range(n): +    a, b = list(map(int, input().split(" "))) +    ab.append([a + b, a, b]) +ab.sort(reverse=True) +result = 0 +for i in range(n): +    if i % 2 == 0: +        result += ab[i][1] +    else: +        result -= ab[i][2] +print(result)