using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Collections;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ir = new Resolver(new ConsoleReader());
            Console.WriteLine(ir.Resolve());
        }
    }

    public class Resolver
    {
        IInputReader InputReader { get; }
        public List<string> Messages { get; set; } = new List<string>();

        int n;
        List<long[]> ls = new List<long[]>();

        public void ParseLines() {
            n = int.Parse(InputReader.ReadLine());
            foreach (var i in Enumerable.Range(0, n))
            {
                ls.Add(InputReader.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray());
            }

        }

        public class Table
        {
            public long PointA { get; set; } = 0;
            IPerson A { get; }
            IPerson B { get; }
            int[] _dishes;

            public Table(IPerson a, IPerson b, int ndish)
            {
                this.A = a;
                this.B = b;
                this._dishes = Enumerable.Range(0, ndish).ToArray();
            }

            public long CalculatePoint()
            {
                PointA += _dishes
                .Select(x => A.Taste[x] + B.Taste[x])
                .OrderBy(x => x).Reverse()
                .Where((x, i) => i % 2 == 0)
                .Sum();

                PointA -= B.Taste.Values.Sum(x => x);
                return PointA;
            }


        }

        public interface IPerson
    {
        long HappyScore { get; set; }
        Dictionary<int, long> Taste { get; }
    }

    public class Person:IPerson {
            public Dictionary<int, long> Taste { get; }
            public long HappyScore { get; set; } = 0;

            public Person(Dictionary<int, long> taste)
            {
                Taste = taste;
            }

            public IEnumerator EatWith(Person other)
            {
                var tmp = Taste.Keys.ToDictionary(key=>key, key =>
                {
                    return this.Taste[key] + other.Taste[key];
                }).OrderBy(x => x.Value).ToList();
                var i = 0;
                while (i < tmp.Count)
                {
                    if (i % 2 == 0)
                    {
                        this.HappyScore += this.Taste[i];
                    }
                    else
                    {
                        other.HappyScore += other.Taste[i];
                    }
                    i++;
                    yield return 0;
                }

            }

        }


        public string Resolve()
        {
            var a = new Person(Enumerable.Range(0, n).ToDictionary(i => i, i => ls[i][0]));
            var b = new Person(Enumerable.Range(0, n).ToDictionary(i => i, i => ls[i][1]));

            var table = new Table(a, b, n);

            return table.CalculatePoint().ToString();
        }


        public Resolver(IInputReader inputReader)
        {
            InputReader = inputReader;
            ParseLines();
        }

    }

    public interface IInputReader
    {
        string ReadLine();
    }

    class ConsoleReader : IInputReader
    {
        string IInputReader.ReadLine()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 41804