Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ps=[]
#for i in range(N):
#tmp=input()
ps = [list(map(int, input().split())) for _ in range(N)]

    

tg=[]
tp=[]

ag=[]
ap=[]
for p in ps:
  tg.append((p[1]+p[0]))
  tp.append(p[0])
  ag.append((p[0]+p[1]))
  ap.append(p[1])
    
import numpy as np
def is_even(num):
  if num % 2 == 0:
    return True
  else:
    return False
    
T=0
A=0

for i in range(N):
  if is_even(i):
    if tg[np.argmax(tg)]!=0:
      tmpIndex=np.argmax(tg)
      T+=tp.pop(tmpIndex)
      tg.pop(tmpIndex)
      ag.pop(tmpIndex)
      ap.pop(tmpIndex)
    else:
      tmpIndex=np.argmax(tp)
      T+=tp.pop(tmpIndex)
      tg.pop(tmpIndex)
      ag.pop(tmpIndex)
      ap.pop(tmpIndex)
  else:
    if ag[np.argmax(ag)]!=0:
      tmpIndex=np.argmax(ag)
      A+=ap.pop(tmpIndex)
      ag.pop(tmpIndex)
      tg.pop(tmpIndex)
      tp.pop(tmpIndex)
    else:
      tmpIndex=np.argmax(ap)
      A+=ap.pop(tmpIndex)
      ag.pop(tmpIndex)
      tg.pop(tmpIndex)
      tp.pop(tmpIndex)
print(T-A)


Fixed submission:
N=int(input())
ps=[]
tp=[]
ap=[]
for i in range(N):
  p=input().split()
  ps.append([int(p[0])+int(p[1]),i])
  tp.append(int(p[0]))
  ap.append(int(p[1]))
    
def is_even(num):
  if num % 2 == 0:
    return True
  else:
    return False

T=0
A=0
calc=sorted(ps,reverse=True)
#print(calc)
i=0
for p,j in calc:
  if is_even(i):
    T+=tp[j]
  else:
    A+=ap[j]
  i+=1
print(T-A)

Buggy python submission (verdict: Time Limit Exceeded):

import numpy as np
def is_even(num):
  if num % 2 == 0:
    return True
  else:
    return False
  
N=int(input())
ps=[]
for i in range(N):
  tmp=input()
  ps.append([int(tmp.split()[0]),int(tmp.split()[1])])
    

tg=[]
tp=[]

ag=[]
ap=[]
for p in ps:
  tg.append((p[1]+p[0]))
  tp.append(p[0])
  ag.append((p[0]+p[1]))
  ap.append(p[1])
    
    
    
    
T=0
A=0

for i in range(N):
  if is_even(i):
    if tg[np.argmax(tg)]!=0:
      tmpIndex=np.argmax(tg)
      T+=tp.pop(tmpIndex)
      tg.pop(tmpIndex)
      ag.pop(tmpIndex)
      ap.pop(tmpIndex)
    else:
      tmpIndex=np.argmax(tp)
      T+=tp.pop(tmpIndex)
      tg.pop(tmpIndex)
      ag.pop(tmpIndex)
      ap.pop(tmpIndex)
  else:
    if ag[np.argmax(ag)]!=0:
      tmpIndex=np.argmax(ag)
      A+=ap.pop(tmpIndex)
      ag.pop(tmpIndex)
      tg.pop(tmpIndex)
      tp.pop(tmpIndex)
    else:
      tmpIndex=np.argmax(ap)
      A+=ap.pop(tmpIndex)
      ag.pop(tmpIndex)
      tg.pop(tmpIndex)
      tp.pop(tmpIndex)
print(T-A)


Fixed submission:
N=int(input())
ps=[]
tp=[]
ap=[]
for i in range(N):
  p=input().split()
  ps.append([int(p[0])+int(p[1]),i])
  tp.append(int(p[0]))
  ap.append(int(p[1]))
    
def is_even(num):
  if num % 2 == 0:
    return True
  else:
    return False

T=0
A=0
calc=sorted(ps,reverse=True)
#print(calc)
i=0
for p,j in calc:
  if is_even(i):
    T+=tp[j]
  else:
    A+=ap[j]
  i+=1
print(T-A)

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
ps=[]
for i in range(N):
  tmp=input()
  ps.append([int(tmp.split()[0]),int(tmp.split()[1])])
    

tg=[]
tp=[]

ag=[]
ap=[]
for p in ps:
  tg.append((p[1]+p[0]))
  tp.append(p[0])
  ag.append((p[0]+p[1]))
  ap.append(p[1])
    
    
    
import numpy as np
def is_even(num):
  if num % 2 == 0:
    return True
  else:
    return False
    
import operator
T=0
A=0

for i in range(N):
  if is_even(i):
    if tg[np.argmax(tg)]!=0:
      tmpIndex=np.argmax(tg)
      T+=tp.pop(tmpIndex)
      tg.pop(tmpIndex)
      ag.pop(tmpIndex)
      ap.pop(tmpIndex)
    else:
      tmpIndex=np.argmax(tp)
      T+=tp.pop(tmpIndex)
      tg.pop(tmpIndex)
      ag.pop(tmpIndex)
      ap.pop(tmpIndex)
  else:
    if ag[np.argmax(ag)]!=0:
      tmpIndex=np.argmax(ag)
      A+=ap.pop(tmpIndex)
      ag.pop(tmpIndex)
      tg.pop(tmpIndex)
      tp.pop(tmpIndex)
    else:
      tmpIndex=np.argmax(ap)
      A+=ap.pop(tmpIndex)
      ag.pop(tmpIndex)
      tg.pop(tmpIndex)
      tp.pop(tmpIndex)
print(T-A)


Fixed submission:
N=int(input())
ps=[]
tp=[]
ap=[]
for i in range(N):
  p=input().split()
  ps.append([int(p[0])+int(p[1]),i])
  tp.append(int(p[0]))
  ap.append(int(p[1]))
    
def is_even(num):
  if num % 2 == 0:
    return True
  else:
    return False

T=0
A=0
calc=sorted(ps,reverse=True)
#print(calc)
i=0
for p,j in calc:
  if is_even(i):
    T+=tp[j]
  else:
    A+=ap[j]
  i+=1
print(T-A)