qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

print(A)
B = sorted(A, key=lambda x: x[1])
#print(sorted(A, key=lambda x: x[1]))

count = 0
limit = 0
for i in range(N):
    count += B[i][0]
    if count <= B[i][1]:
        continue
    else:
        print("No")
        exit()
print("Yes")


Fixed code:
N = int(input())
A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

#print(A)
B = sorted(A, key=lambda x: x[1])
#print(sorted(A, key=lambda x: x[1]))

count = 0
limit = 0
for i in range(N):
    count += B[i][0]
    if count <= B[i][1]:
        continue
    else:
        print("No")
        exit()
print("Yes")
Buggy code:
n = int(input())
a_b_list = [list(map(int,input().split())) for x in range(n)]
a_b_list_kai = [[int(a_b_list[x]),int(a_b_list[x+1])] for x in range(0,n*2,2)]
sorted(a_b_list_kai,key = lambda x:x[1])
limit = 0
result = 0
sum_task = 0
for x in a_b_list_kai:
    sum_task += x[0]
    limit = max(limit,x[1])
    if sum_task > limit:
        result = 1

if result == 1:
    print('No')
else:
    print('Yes')

Fixed code:
n = int(input())
a_b_list_kai = [list(map(int,input().split())) for x in range(n)]

a_b_list_kai = sorted(a_b_list_kai,key = lambda x:x[1])
limit = 0
result = 0
sum_task = 0
for x in a_b_list_kai:
    sum_task += x[0]
    limit = max(limit,x[1])
    if sum_task > limit:
        result = 1

if result == 1:
    print('No')
else:
    print('Yes')
Buggy code:
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]

ab.sort(key= lambda x:x[1],reverse = True)
time = ab[0][1]

for i in range(n):
    time -= ab[i][0]
else:
    if time >= 0:
        ans = "yes"
    else:
        ans = "No"

print(ans)

Fixed code:
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]

ab.sort(key= lambda x:x[1],reverse = True)
time = ab[0][1]

for i in range(n):
    if time > ab[i][1]:
        time = ab[i][1]
    time -= ab[i][0]
else:
    if time >= 0:
        ans = "Yes"
    else:
        ans = "No"

print(ans)
Buggy code:
a = [int(input()) for i in range(1)]
n = a[0] 
works = [list(map(int, input().split())) for i in range(n)]
#print(works)
works = sorted(works, key=lambda x: x[1])

time = 0
flag = 0
#print(works[1][0])

for k in range(n):
  time += works[k][0]
  if time > works[k][1]:
    flag = 1
    
if flag == 0:
  print('YES')
else:
  print('No')

Fixed code:
a = [int(input()) for i in range(1)]
n = a[0] 
works = [list(map(int, input().split())) for i in range(n)]
#print(works)
works = sorted(works, key=lambda x: x[1])

time = 0
flag = 0
#print(works[1][0])

for k in range(n):
  time += works[k][0]
  if time > works[k][1]:
    flag = 1
#  print(time)
    
if flag == 0:
  print('Yes')
else:
  print('No')
Buggy code:
N = int(input())
ab = [list(map(int,input().split())) for i in range(N)]
ab.sort(key=lambda x:x[1])
p = ab.pop()
suma = 0
for i in range(N-1):
    suma += ab[i][0]
    print(suma,ab[i][1])
    if suma > ab[i][1]:
        print("No")
        exit()
    
print("Yes" if suma+p[0]<=p[1] else "No")

Fixed code:
N = int(input())
ab = [list(map(int,input().split())) for i in range(N)]
ab.sort(key=lambda x:x[1])
p = ab.pop()
suma = 0
for i in range(N-1):
    suma += ab[i][0]
    if suma > ab[i][1]:
        print("No")
        exit()
    
print("Yes" if suma+p[0]<=p[1] else "No")
Buggy code:
N=int(input())
tasks={}
for i in range(N):
    A,B=[int(i) for i in input().split(" ")]
    tasks[B]=tasks.get(B,0)+A

time=0
tasks=sorted(tasks.items(),key=lambda w:w[0])
for task in tasks:
    time+=task[1]
    if time>task[0]:
        print("NO")
        break
else:
    print("YES")


Fixed code:
N=int(input())
tasks={}
for i in range(N):
    A,B=[int(i) for i in input().split(" ")]
    tasks[B]=tasks.get(B,0)+A

time=0
tasks=sorted(tasks.items(),key=lambda w:w[0])
for task in tasks:
    time+=task[1]
    if time>task[0]:
        print("No")
        break
else:
    print("Yes")
Buggy code:
N = int(input() )
for i in range(N):
  C[i] = [map(int, input().split() ) ]
 
C.sort(key= lambda s:(s[1],s[0]) )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)

Fixed code:
N = int(input() )
C = []
for i in range(N):
  A, B = map(int, input().split() )
  C.append([A, B])
C.sort(key=lambda s:s[1] )
 
judge = "Yes"
time = 0
for i in range(N):
  time += C[i][0]
  if time > C[i][1]:
    judge = "No"
    break
print(judge)
Buggy code:
n = int(input())
job = [list(map(int,input().split())) for i in range(n)]


job.sort(key = lambda x: x[1])
print(job)
time = 0
ans = 0
for i in range(n):
    time += job[i][0]
    if time > job[i][1]:
        print("No")
        break
else:
    print("Yes")

Fixed code:
n = int(input())
job = [list(map(int,input().split())) for i in range(n)]


job.sort(key = lambda x: x[1])
time = 0
ans = 0
for i in range(n):
    time += job[i][0]
    if time > job[i][1]:
        print("No")
        break
else:
    print("Yes")
Buggy code:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
lis = []
for i in range(N):
    a,b = Is()
    lis.append([b,a])
lis = sorted(lis)
print(lis)
t = 0
for e in lis:
    t += e[1]
    if e[0] < t:
        print("No")
        exit()
print("Yes")

Fixed code:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
lis = []
for i in range(N):
    a,b = Is()
    lis.append([b,a])
lis = sorted(lis)
t = 0
for e in lis:
    t += e[1]
    if e[0] < t:
        print("No")
        exit()
print("Yes")
Buggy code:
n=int(input())
list_a = []
list_b = []
for i in range(n):
    a,b=map(int,input().split())
    list_a.append(a)
    list_b.append(b)
"""n=5
list_a = [2,1,1,4,3]
list_b = [4,9,8,9,12]"""


list_dd =[]
for d in zip(list_b, list_a):

    #print(d)
    list_dd.append(list(d))
    
#print(list_dd)

#print(sorted(list_dd))
ss=0
for i in range(n):
    tmp=list_dd[i][1]
    ss+=tmp
    list_dd[i][1]=ss

#print(list_dd)

for i in range(n):
    if list_dd[i][0]<list_dd[i][1]:
        
        print("No")
        break
    elif i == n-1:
        print("Yes")


Fixed code:
n=int(input())
list_a = []
list_b = []
for i in range(n):
    a,b=map(int,input().split())
    list_a.append(a)
    list_b.append(b)
"""n=5
list_a = [2,1,1,4,3]
list_b = [4,9,8,9,12]"""


list_dd =[]
for d in zip(list_b, list_a):

    #print(d)
    list_dd.append(list(d))
    
#print(list_dd)

list_dd=sorted(list_dd)
ss=0
for i in range(n):
    tmp=list_dd[i][1]
    ss+=tmp
    list_dd[i][1]=ss

#print(list_dd)

for i in range(n):
    if list_dd[i][0]<list_dd[i][1]:
        
        print("No")
        break
    elif i == n-1:
        print("Yes")
Buggy code:
import numpy as np

N = int(input())  

A = np.zeros(N) 
B = np.zeros(N) 

for i in range(N):
    A[i], B[i] = map(int, input().split())
    
B1 = B[np.argsort(B)]

ans = "Yes"
 
k = 0
for i in range(N):
    k += A[i]
    if k > B[i]:
        ans = "No"
 
print(ans)

Fixed code:
import numpy as np

N = int(input())  

A = np.zeros(N) 
B = np.zeros(N) 

for i in range(N):
    A[i], B[i] = map(int, input().split())
    
B1 = np.argsort(B)

ans = "Yes"
 
k = 0
for i in range(N):
    k += A[B1[i]]
    if k > B[B1[i]]:
        ans = "No"
 
print(ans)
Buggy code:
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
A = sorted(A,key=lambda x:x[1])
t = 0
print(A)
for i in range(N):
    t += A[i][0]
    if t > A[i][1]:
        print("No")
        exit()
print("Yes")

Fixed code:
N = int(input())
A = [list(map(int,input().split())) for _ in range(N)]
A = sorted(A,key=lambda x:x[1])
t = 0
for i in range(N):
    t += A[i][0]
    if t > A[i][1]:
        print("No")
        exit()
print("Yes")
Buggy code:
def main():
    n=int(input())
    task=[]
    for i in range(n):
        a,b=map(int,input().split())
        task.append([b,a])
    task.sort()
    t=0
    ans="Yes"
    for i in range(n):
        t+=task[i][1]
        if t>task[i][0]:
            ans="No"
            break
    print(ans)
if __name__=="__main__":
    main()def main():
    n=int(input())
    task=[]
    for i in range(n):
        a,b=map(int,input().split())
        task.append([b,a])
    task.sort()
    t=0
    ans="Yes"
    for i in range(n):
        t+=task[i][1]
        if t>task[i][0]:
            ans="No"
            break
    print(ans)
if __name__=="__main__":
    main()

Fixed code:
def main():
    n=int(input())
    task=[]
    for i in range(n):
        a,b=map(int,input().split())
        task.append([b,a])
    task.sort()
    t=0
    ans="Yes"
    for i in range(n):
        t+=task[i][1]
        if t>task[i][0]:
            ans="No"
            break
    print(ans)
if __name__=="__main__":
    main()
Buggy code:
N = int(input())

l = []
for i in range(N):
    A, B = map(int, input().split())
    l.append((B, A))
    
ans = 0
t = 0
for i in range(N):
    if (t + l[i][1] < l[i][0]):
        ans += 1
        t += l[i][1]

if ans == N:
    print('Yes')
else:
    print('No')

Fixed code:
N = int(input())

l = []
for i in range(N):
    A, B = map(int, input().split())
    l.append((B, A))
l.sort()
    
ans = 0
t = 0
for i in range(N):
    if (t + l[i][1] <= l[i][0]):
        ans += 1
        t += l[i][1]

if ans == N:
    print('Yes')
else:
    print('No')
Buggy code:
#m = imt(imput())
#L = list(map(imt, imput().split()))
import math
import sys

N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]


def aa(N,AB):
    AB.sort(key=lambda x: x[1])
    for i in range(N-1):
        clk += AB[i][0]
        if clk >= AB[i][1]:
            flg = False
            break
    if flg:
        return "Yes"
    else:
        return "No"


Fixed code:
#m = imt(imput())
#L = list(map(imt, imput().split()))
import math
import sys

N = int(input())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x: x[1])

def aa(N,AB):
    clk = 0
    flg = True
    for i in range(N):
        clk += AB[i][0]
        if clk > AB[i][1]:
            flg = False
            break
    if flg:
        return "Yes"
    else:
        return "No"
print(aa(N,AB))
Buggy code:
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[0]
  if t>a[1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")

Fixed code:
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
a.sort(key=lambda x: x[1])
t=0
for i in range(n):
  t+=a[i][0]
  if t>a[i][1]:
    print("No")
    break
  elif i==n-1:
    print("Yes")
Buggy code:
n = int(input())

tasks = []
for _ in range(n):
  a,b = list(map(int,input().split(" ")))
  tasks.append(a,b)

tasks = sorted(tasks,key = lambda x:x[1])

now_time = 0
flag = True
for a,b in tasks:
  if now_time + a > b:
    flag = False
    break
  now_time += a
if flag:
  print("Yes")
else:
  print("No")

Fixed code:
n = int(input())

tasks = []
for _ in range(n):
  a,b = list(map(int,input().split(" ")))
  tasks.append((a,b))

tasks = sorted(tasks,key = lambda x:x[1])

now_time = 0
flag = True
for a,b in tasks:
  if now_time + a > b:
    flag = False
    break
  now_time += a
if flag:
  print("Yes")
else:
  print("No")
Buggy code:
import numpy as np

N  = int(input())

AB = []
time = 0

for _ in range(N):
    AB.append(list(map(int, input().split())))

AB = np.array(AB)
sorted_AB = AB[AB[:,1].argsort(), :]

for i in range(N):
    time += sorted_AB[i,0]
    print(sorted_AB[i,0])

    if time > sorted_AB[i,1]:
        print('No')
        exit()

print('Yes')

Fixed code:
import numpy as np

N  = int(input())

AB = []
time = 0

for _ in range(N):
    AB.append(list(map(int, input().split())))

AB = np.array(AB)

sorted_AB = AB[AB[:,1].argsort(), :]

for i in range(N):
    time += sorted_AB[i,0]

    if time > sorted_AB[i,1]:
        print('No')
        exit()

print('Yes')
Buggy code:
N  = int(input())

AB = []
time = 0

for _ in range(N):
    AB.append(list(map(int, input().split())))

NewAB = sorted(AB, key=lambda x: x[1])

for i in range(N):

    time += NewAB[i][0]

    if time > NewAB[i][1]:
        print(time)
        print('No')
        exit()

print('Yes')


Fixed code:

N  = int(input())

AB = []
time = 0

for _ in range(N):
    AB.append(list(map(int, input().split())))

NewAB = sorted(AB, key=lambda x: x[1])

for i in range(N):
    time += NewAB[i][0]

    if time > NewAB[i][1]:
        print('No')
        exit()

print('Yes')
Buggy code:
N = int(input())
A = [0] * N
B = [0] * N
AB = [0] * N
BA = [0] * N
need = {}
for i in range(N):
    A[i], B[i] = [int(x) for x in input().split()]
    need[B[i]] = A[i]
    BA[i] = [B[i], A[i]]
list.sort(BA)
t = 0
fail = 0
for n in range(N):å
    t += BA[n][1]
    if t > BA[n][0]:
        fail = 1
        break
if fail:
    print('No')
else:
    print('Yes')

Fixed code:
N = int(input())
A = [0] * N
B = [0] * N
AB = [0] * N
BA = [0] * N
for i in range(N):
    A[i], B[i] = [int(x) for x in input().split()]
    BA[i] = [B[i], A[i]]
list.sort(BA)
t = 0
fail = 0
for n in range(N):
    t += BA[n][1]
    if t > BA[n][0]:
        fail = 1
        break
if fail:
    print('No')
else:
    print('Yes')
Buggy code:
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x:x[1])

cost = ab[0][0]
limit = ab[0][1]

for i in range(1, n):
    cost += ab[i][0]
    limit = ab[i][1]
    if limit > cost:
        print('Yes')
    else:
        print('No')
        exit()

Fixed code:
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x:x[1])

cost = 0
limit = 0

for i in range(n):
    cost += ab[i][0]
    limit = ab[i][1]
    if limit < cost:
        print('No')
        exit()

print('Yes')
Buggy code:
N = int(input())
L = [tuple(map(int,input().split())) for i in range(N)]
X = sorted(L, key = lambda k:k[1])
cnt = 0
ans = True
for i,j in X:
    cnt += i
    if cnt > j:
        ans = False
        print(cnt,j)
        break
        
if ans:
    print("Yes")
else:
    print("No")

Fixed code:
N = int(input())
L = [tuple(map(int,input().split())) for i in range(N)]
X = sorted(L, key = lambda k:k[1])
cnt = 0
ans = True
for i,j in X:
    cnt += i
    if cnt > j:
        ans = False
        break
        
if ans:
    print("Yes")
else:
    print("No")
Buggy code:
n=int(input())
x=[]
for _ in range(n):
    a,b=map(int,input().split())
    x.append([a,b,b-a])

x.sort(key=lambda x:x[2])
t=0
ans='Yes'
for i in range(n):
    if t<=x[i][2]:
        t+=x[i][0]
    else:
        ans='No'
        break
print(ans)

Fixed code:
n=int(input())
x=[]
for _ in range(n):
    a,b=map(int,input().split())
    x.append([a,b,b-a])

x.sort(key=lambda x:(x[1],x[0]))
t=0
ans='Yes'
for i in range(n):
    if t+x[i][0]<=x[i][1]:
        t+=x[i][0]
    else:
        ans='No'
        break
print(ans)
Buggy code:
n = int(input())
from bisect import bisect 
ab = [list(map(int,input().split())) for i in range(n)]

ab.sort(key = lambda x: x[1])
ok = True
last = 0
for a,b in ab:
    if b-a>last:
        last += a
    else:
        ok = not ok
print('Yes' if ok else 'No')

Fixed code:
n = int(input())
from bisect import bisect 
ab = [list(map(int,input().split())) for i in range(n)]

ab.sort(key = lambda x: x[1])
ok = True
last = 0
for a,b in ab:
    if b-a>=last:
        last += a
    else:
        ok = not ok
        break
print('Yes' if ok else 'No')
Buggy code:
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]

sort_AB = sorted(AB, key= lambda x: x[1])
ans = 'Yes'
tmp = 0

for i in range(N):
    tmp += sortedAB[i][0]
    if tmp > sortedAB[i][1]:
        ans = 'No'
        break
        
print(ans)

Fixed code:
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]

sort_AB = sorted(AB, key= lambda x: x[1])
ans = 'Yes'
tmp = 0

for i in range(N):
    tmp += sort_AB[i][0]
    if tmp > sort_AB[i][1]:
        ans = 'No'
        break
        
print(ans)
Buggy code:
n = int(input())
b = []
for i in range(n):
    x,y = map(int,input().split())
    b.append([y,x])
b.sort()
ans = 'Yes'
t = 0
for i in range(n):
    t += b[i][1]
    if t>b[i][0]:
        ans='No'
    print(t)
print(ans)


Fixed code:
n = int(input())
b = []
for i in range(n):
    x,y = map(int,input().split())
    b.append([y,x])
b.sort()
ans = 'Yes'
t = 0
for i in range(n):
    t += b[i][1]
    if t>b[i][0]:
        ans='No'
print(ans)
Buggy code:
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]

sortedAB = sorted(AB, key= lambda x: x[1])

import sys
work = 0

for i in range(N):
    work += AB[i][0]
    if work > sortedAB[i][1]:
        print('No')
        sys.exit()
        
print('Yes')

Fixed code:
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]

sortedAB = sorted(AB, key= lambda x: x[1])

import sys
work = 0

for i in range(N):
    work += sortedAB[i][0]
    if work > sortedAB[i][1]:
        print('No')
        sys.exit()
        
print('Yes')
Buggy code:
n = int(input())
li = [tuple(map(int,input().split())) for _ in range(n)]
li.sort(key=lambda x: x[1])
t = 0
for i in range(n-1):
    if t + li[i][0] > li[i][1]:
        print("No")
        exit()
    else:
        t += li[i][0]
print("Yes")


Fixed code:
n = int(input())
li = [tuple(map(int,input().split())) for _ in range(n)]
li.sort(key=lambda x: x[1])
t = 0
for i in range(n):
    if t + li[i][0] > li[i][1]:
        print("No")
        exit()
    else:
        t += li[i][0] 
print("Yes")
Buggy code:
n = int(input())

i = 0
ab = []
while i < n:
    a, b = map(int, input().split())
    ab.append((a, b)) 
    i += 1

ab.sort(key=lambda x: x[1])

days = ab[0][0]

i = 1
ans = 'Yes'
while i < n:
    days += ab[i][0]
    print(days)
    if days > ab[i][1]:
        ans = 'No'
        break
    i += 1
print(ans)

Fixed code:
n = int(input())

i = 0
ab = []
while i < n:
    a, b = map(int, input().split())
    ab.append((a, b)) 
    i += 1

ab.sort(key=lambda x: x[1])

i = 0
ans = 'Yes'
days = 0
while i < n:
    days += ab[i][0]
    if days > ab[i][1]:
        ans = 'No'
        break
    i += 1
print(ans)
Buggy code:
from operator import itemgetter

N = int(input())
AB = [[int(x) for x in input().split()]for _ in range(N)]
sum_time = sum([a for a,b in AB])
AB.sort(key=itemgetter(0))
AB.sort(key=itemgetter(1),reverse=True)
for a,b,t in AB:
    if(sum_time>b):
        print('No')
        break
    else:
        sum_time-=a
else:
    print('Yes')


Fixed code:
from operator import itemgetter

N = int(input())
AB = [[int(x) for x in input().split()]for _ in range(N)]
sum_time = sum([a for a,b in AB])
AB.sort(key=itemgetter(0))
AB.sort(key=itemgetter(1),reverse=True)
for a,b in AB:
    if(sum_time>b):
        print('No')
        break
    else:
        sum_time-=a
else:
    print('Yes')
Buggy code:
N = int(input())
ls=[]
for i in range(N):
    a,b=map(int,input().split())
    ls.append([a,b])
ls = sorted(ls,key=lambda x:x[1])

time=0
for i in range(N):
    time+=ls[i][0]
    print(time,i)
    if time > ls[i][1]:
        print("No")
        break
    if i == N-1:
        print("Yes")

Fixed code:
N = int(input())
ls=[]
for i in range(N):
    a,b=map(int,input().split())
    ls.append([a,b])
ls = sorted(ls,key=lambda x:x[1])

time=0
for i in range(N):
    time+=ls[i][0]
    if time > ls[i][1]:
        print("No")
        break
    if i == N-1:
        print("Yes")
Buggy code:
n=int(inuput())
l=sorted(list(map(int,input().split())) for nd in range(n),key=lambda x:x[1])
now=0
for a,s in l:
  if a+now>s:print("No");exit()
  now+=a
else:print("Yes")

Fixed code:
n=int(input())
l=sorted([list(map(int,input().split())) for nd in range(n)],key=lambda x: x[1])
now=0
for a,s in l:
  if a+now>s:print("No");exit()
  now+=a
else:print("Yes")
Buggy code:
N = input().strip()
N = int(N)
dic = collections.defaultdict(lambda: 0)

for i in range(N):
    x,y = input().strip().split(" ")
    x = int(x)
    y = int(y)

    dic[y] += x

prev_time = 0
result = "Yes"

for k,v in dic.items():
    if v > k:
        result = "No"
        break
    prev_time += v

print(result)

Fixed code:
import collections

N = input().strip()
N = int(N)
dic = collections.defaultdict(lambda: 0)

for i in range(N):
    x,y = input().strip().split(" ")
    x = int(x)
    y = int(y)

    dic[y] += x

prev_time = 0
result = "Yes"

for k,v in sorted(dic.items(),key=lambda x:x[0]):
    if v+prev_time > k:
        result = "No"
        break
    prev_time += v

print(result)
Buggy code:
N = int(input())

a_b_lis = [0] * N

for i in range(N):
    a_b_lis[i] = list(map(int, input().split()))

count = 0
a_b_lis = sorted(a_b_lis, key=lambda x: x[1], X[0])

on_time = True
for item in a_b_lis:
    if item[0] + count <= item[1]:
        count += item[0]
        on_time = True
    else:
        on_time = False

if on_time:
    print('Yes')
else:
    print('No')

Fixed code:
N = int(input())

a_b_lis = [0] * N

for i in range(N):
    a_b_lis[i] = list(map(int, input().split()))

count = 0
#print(a_b_lis)
a_b_lis = sorted(a_b_lis, key=lambda x: x[1])

on_time = True
for item in a_b_lis:
    count += item[0]
    if count > item[1]:
        on_time = False
if on_time:
    print('Yes')
else:
    print('No')
Buggy code:
N=int(input().strip())
a=[]
for i in range(N):
    array=list(map(int,input().strip().split()))
    a.append(array)
b=sorted(a, key=lambda x:x[1])
print(b)
n,t,f=0,0,0
while True:
    t+=b[n][0]
    if t>b[n][1]:
        f=1
        break
    n+=1
    if n==N:
        break
if f==1:
    print('No')
else:
    print('Yes')


Fixed code:
N=int(input().strip())
a=[]
for i in range(N):
    array=list(map(int,input().strip().split()))
    a.append(array)
b=sorted(a, key=lambda x:x[1])
n,t,f=0,0,0
while True:
    t+=b[n][0]
    if t>b[n][1]:
        f=1
        break
    n+=1
    if n==N:
        break
if f==1:
    print('No')
else:
    print('Yes')
Buggy code:
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
A = sorted(A, key = lambda x: x[1])
t = 0
for a, b in A:
    if t > b:
        print('No')
        exit()
    else:
        t += a
print('Yes')

Fixed code:
n = int(input())
A = [list(map(int, input().split())) for _ in range(n)]
A = sorted(A, key = lambda x: x[1])
t = 0
for a, b in A:
    t += a
    if t > b:
        print('No')
        exit()
print('Yes')
Buggy code:
import heapq

n = int(input())
abs = [tuple(map(int, input().split())) for _ in range(n)]

pq = []

for ab in abs:
  a,b = ab[0],ab[1]
  heapq.heappush(pq, tuple([b,a]))
  
dl = 0
tc = 0

ans = "Yes"

for i in range(n):
  ba = pq.pop()
  dl += ba[0]
  tc += ba[1]
  if dl < tc:
    ans = "No"
    break
print(ans)

Fixed code:
import heapq

n = int(input())
abs = [tuple(map(int, input().split())) for _ in range(n)]

pq = []

for ab in abs:
  a,b = ab[0],ab[1]
  heapq.heappush(pq, tuple([b,a]))
  
dl = 0
tc = 0

ans = "Yes"

for i in range(n):
  ba = heapq.heappop(pq)
  dl = ba[0]
  tc += ba[1]
  if dl < tc:
    ans = "No"
    break
print(ans)
Buggy code:
N=int(input())
a=[]
tmp=0
ex=0
for i in range(1,N+1):
    a.append(input().split())
a_sorted=a.sort(key=lambda x: x[1])
for i in range(N):
    b=int(a[i][0])
    c=int(a[i][0])
    tmp=tmp+b
    if tmp>c:
        ex=1
        print("No")
        break
if ex==0:
    print("Yes")

Fixed code:
N=int(input())
a=[]
tmp=0
ex=0
for i in range(1,N+1):
    x,y=map(int,input().split())
    a.append([x,y])
a.sort(key=lambda x: x[1])
for i in range(N):
    b=int(a[i][0])
    c=int(a[i][1])
    tmp=tmp+b
    if tmp>c:
        ex=1
        print("No")
        break
if ex==0:
    print("Yes")
Buggy code:
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
print(AB)
AB.sort(key=lambda x: (x[1], -x[0]))
print(AB)
time = 0
for a, b in AB:
    time += a
    if time > b:
        print('No')
        break
else:
    print('Yes')


Fixed code:
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(key=lambda x: (x[1], -x[0]))
time = 0
for a, b in AB:
    time += a
    if time > b:
        print('No')
        break
else:
    print('Yes')