fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ab = (1..n).map {
        val (a, b) = readLine()!!.split(" ").map(String::toInt)
        Pair(a, b)
    }.sortedByDescending { e -> e.first + e.second }
    var ap = 0L
    var bp = 0L
    for (i in 0 until n) {
        if (i % 2 == 0) {
            ap += ab[i].first
        } else {
            bp += ab[i].second
        }
    }
    println(ap - bp)
}
