import std;

ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "T", long, "A");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);

void main()
{
    auto n = lread();
    auto dishes = new Pair[](n);
    foreach (i; iota(n))
    {
        long t, a;
        scan(t, a);
        dishes[i] = Pair(t, a);
    }
    dishes.sort!"a.T-a.A>b.T-b.A"();
    auto cnt_t = iota(n).filter!(x => !(x % 2)).map!(i => dishes[i].T);
    auto cnt_a = iota(n).filter!(x => x % 2).map!(i => dishes[i].A);
    writeln(cnt_t.sum() - cnt_a.sum());
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}
