import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias AB = Tuple!(long, "a", long, "b");

AB[10^^5] ABS;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (i; 0..N) {
        auto ab = readln.split.to!(long[]);
        ABS[i] = AB(ab[0], ab[1]);
    }

    int t;
    long sum_a, sum_b;
    auto abs = ABS[0..N];
    while (!abs.empty) {
        ++t;
        sort!"a.a > b.a"(abs);
        auto head_a = abs[0];
        sort!"a.b > b.b"(abs);
        auto head_b = abs[0];
        if (head_a.a > head_b.b) {
            sort!"a.a > b.a"(abs);
            if (t % 2 == 1) {
                sum_a += head_a.a;
            } else {
                sum_b += head_a.b;
            }
        } else {
            if (t % 2 == 1) {
                sum_a += head_b.a;
            } else {
                sum_b += head_b.b;
            }
        }
        abs = abs[1..$];
    }
    writeln(sum_a - sum_b);
}