table2 = []
exhausted = {}

n.times do |index|
  a = gets.chomp.split(" ").map(&:to_i)
  table << [a[0] + a[1], index, a[0]]
  table2 << [a[1] + a[0], index, a[1]]
end

table.sort_by!{|k| [-k[0], -k[2]]}
table2.sort_by!{|k| [-k[0], -k[2]]}
#table2.reverse!
total = 0

table_idx = 0
table2_idx = 0

#p table
#p table2

for i in 0..n-1
  if i.even?
    while exhausted[table[table_idx][1]]
      table_idx += 1
    end
    exhausted[table[table_idx][1]] = 1
    total += table[table_idx][2]
  else
    while exhausted[table2[table2_idx][1]]
      table2_idx += 1
    end
    exhausted[table2[table2_idx][1]] = 1
    total -= table2[table2_idx][2]
  end
  #p [table_idx, table2_idx]
  #p exhausted
end

puts total