fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ab = (1..n).map { readLine()!!.split(" ").map(String::toLong) }.sortedByDescending { it[0] + it[1] }
    print((0 until n step 2).map { ab[it][0] }.sum() - (1 until n step 2).map { ab[it][1] }.sum())
}