fun main(args: Array<String>) {
    nikkei2019qual_c()
}

fun nikkei2019qual_c() {
    val n = readLine()!!.toInt()
    val abList = (1..n).map { readLine()!!.split(' ').map { it.toLong() } }
        .map { Pair(it[0], it[1]) }

    val answer = abList.sortedByDescending { it.first + it.second }
        .mapIndexed { index, pair -> if (index % 2 == 0) pair.first else -pair.second }.sum()

    println(answer)
}
