//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

  int N;
void main() {
  Scanner sc = new Scanner;

  sc.scan(N);
  int[] A = new int[N];
  int[] B = new int[N];

  foreach (i; 0 .. N)
    sc.scan(A[i], B[i]);

  long Asum = 0;
  long Bsum = 0;

  int[] finish = new int[N];
  foreach (i; 0 .. N)
    finish[i] = i;

  int j = 0;
  while (j != N) {
    sort(zip(A, B));
    reverse(zip(A, B));

    Asum += A.front;
    A.popFront;
    B.popFront;

    j++;
    if (j >= N)
      break;

    sort(zip(B, A));
    reverse(zip(B, A));

    Bsum += B.front;
    A.popFront;
    B.popFront;
    j++;
  }

  writeln(Asum - Bsum);
}
