PROGRAM ATCODER

implicit none
integer(8) :: n,i,j,s,dif
integer(8),allocatable :: a(:), b(:), c(:)

read(*,*) n
allocate(a(n)) ; allocate(b(n)) ; allocate(c(n))

dif = 0
do i = 1, n
    read(*,*) a(i),b(i)
    c(i) = a(i) + b(i)
end do

dif = -sum(b)

do i = 1, n
    s = c(i)
    do j = i+1, n
        if (c(j) > c(i))then
            c(i) = c(j)
            c(j) = s
        end if
    end do
end do


do i = 1, n, 2
    dif = dif + c(i)
end do

deallocate(a) ; deallocate(b) ; deallocate(c)

write(*,'(i0)') dif

END PROGRAM ATCODER
