qyliang/CodeNanoFix huggingface dataset:
Buggy code:

from operator import itemgetter

N = int(input())
a = [0] * N
b = [0] * N
c = [0] *N


for i in range(N):
    a[i],b[i] = map(int,input().split())
    c[i] = [b[i],a[i]]
   
c.sort()
sums = 0
correct = 1
for i in range(N):
    if sums > c[i][0]:
        correct=0
        break
    else:
        sums += c[i][1]


if correct:
    print("Yes")
else:
    print("No")

Fixed code:
from operator import itemgetter

N = int(input())
a = [0] * N
b = [0] * N
c = [0] *N


for i in range(N):
    a[i],b[i] = map(int,input().split())
    c[i] = [b[i],a[i]]
   
c.sort()
sums = 0
correct = 1
for i in range(N):
    sums+=c[i][1]
    if c[i][0] < sums:
        correct=0
        break
        
if correct:
    print("Yes")
else:
    print("No")
Buggy code:
N=int(input())
A=[tuple(map(int,input().split())) for i in range(N)]
A.sort(key=lambda x: x[1])
a=0
b=0 
c=0   
for i in range(len(A)):
   a+=A[i][0]
   b+=A[i][1]
   if a>b:
      c+=1
      print('No')
      break
if c==0:
  print('Yes')

Fixed code:
N=int(input())
A=[tuple(map(int,input().split())) for i in range(N)]
A.sort(key=lambda x: x[1])
a=0
b=0 
c=0 
for i in range(len(A)):
   a+=A[i][0]
   b=A[i][1]
   if a>b:
      c+=1
      print('No')
      break
if c==0:
  print('Yes')
Buggy code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
from operator import itemgetter

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

l.sort(key=itemgetter(1))
t = 0
for i in l:
    t += i[0]
    if t > i[1]:
        print('NO')
        exit()

print('YES')


Fixed code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
from operator import itemgetter

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

l.sort(key=itemgetter(1))
t = 0
for i in l:
    t += i[0]
    if t > i[1]:
        print('No')
        exit()

print('Yes')
Buggy code:
N=int(input())
task=[list(map(int,input().split())) for _ in range(N)]
time=0
flag=1
task.sort(lambda x:x[1])
#print(task)
for i in range(N):
    time=time+task[i][0]
    if not(time<=task[i][1]):
        flag=0
        break
if flag==1:
    print("Yes")
else:
    print("No")


Fixed code:
N=int(input())
task=[list(map(int,input().split())) for _ in range(N)]
time=0
flag=1
task.sort(key=lambda x:x[1])
#print(task)
for i in range(N):
    time=time+task[i][0]
    if not(time<=task[i][1]):
        flag=0
        break
if flag==1:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
AB = []
for i in range(N):
    s = input().split()
    AB.append([int(s[0]), int(s[1])])

AB.sort( key = lambda x:x[1])
#print(AB)
ans = 0
flag = False
for i in range(N):
    ans = ans + AB[i][0]
    if ans >= AB[i][1]:
        flag = True

if flag:
    print("No")
else:
    print("Yes")

Fixed code:
N = int(input())
AB = []
for i in range(N):
    s = input().split()
    AB.append([int(s[0]), int(s[1])])

AB.sort( key = lambda x:x[1])
#print(AB)
ans = 0
flag = True
for i in range(N):
    ans = ans + AB[i][0]
    if ans > AB[i][1]:
        flag = False

if flag:
    print("Yes")
else:
    print("No")
Buggy code:
n = int(input())
lis = []
for i in range(n):
    a,b = list(map(int,input().split()))
    lis.append([a,b])
lis.sort(key=lambda x:x[1])
print(lis)
ans = 0
time = 0
for item in lis:
    time += item[0]
    if time > item[1]:
        ans += 1

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

Fixed code:
n = int(input())
lis = []
for i in range(n):
    a,b = list(map(int,input().split()))
    lis.append([a,b])
lis.sort(key=lambda x:x[1])
ans = 0
time = 0
for item in lis:
    time += item[0]
    if time > item[1]:
        ans += 1

if ans == 0:
    print('Yes')
else:
    print('No')
Buggy code:
n=int(input())
a=[]
for i in range(n):
  m,n=(int(i) for i in input().split())
  a.append([n,m])
a.sort()
r="Yes"
s=0
for i in range(n):
  s=s+a[i][1]
  if s>a[i][0]:
    r="No"
    break
print(r)

Fixed code:
l=int(input())
a=[]
for i in range(l):
  m,n=(int(i) for i in input().split())
  a.append([n,m])
a.sort()
r="Yes"
s=0
for i in range(l):
  s=s+a[i][1]
  if s>a[i][0]:
    r="No"
    break
print(r)
Buggy code:
N = int(input())
A_B = [list(map(int, input().split())) for _ in range(N)]
A_B.sort(key=lambda x: x[1])
count = 0
print(A_B)
for i in range(N):
    if count + A_B[i][0] <= A_B[i][1]:
        count += A_B[i][0]
        continue
    print("No")
    print(i)
    break
else:
    print("Yes")

Fixed code:
N = int(input())
A_B = [list(map(int, input().split())) for _ in range(N)]
A_B.sort(key=lambda x: x[1])
count = 0
for i in range(N):
    if count + A_B[i][0] <= A_B[i][1]:
        count += A_B[i][0]
        continue
    print("No")
    break
else:
    print("Yes")
Buggy code:
#ABC131 D
from operator import itemgetter as ig
N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    A[i], B[i] = (int(_) for _ in input().split())
AB = sorted([(A[i], B[i])for i in range(N)], key = ig(1))
last = 0
ans = True
for i in range(N):
    last += AB[i][0]
    if last < AB[i][1]:
        continue
    else:
        ans = False
        break
if ans:
    print("Yes")
else:
    print("No")

Fixed code:
#ABC131 D
from operator import itemgetter as ig
N = int(input())
A = [0 for i in range(N)]
B = [0 for i in range(N)]
for i in range(N):
    A[i], B[i] = (int(_) for _ in input().split())
AB = sorted([(A[i], B[i])for i in range(N)], key = ig(1))
last = 0
ans = True
for i in range(N):
    last += AB[i][0]
    if last <= AB[i][1]:
        continue
    else:
        ans = False
        break
if ans:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
H = []
for _ in range(N):
    A, B = map(int,input().split())
    H.append((B - A, A))
H.sort()
t = 0
for i in range(N):
    S, A = H[i]
    if S < t:
        print("No")
        break
    t += A
    if len(H) == 0:
        print("Yes")

Fixed code:
N = int(input())
H = []
for _ in range(N):
    A, B = map(int,input().split())
    H.append((B, A))
H.sort()
t = 0
for i in range(N):
    B, A = H[i]
    t += A
    if B < t:
        print("No")
        break 
    if i == N - 1:
        print("Yes")
Buggy code:
N = int(input())
start = []
end = []
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key = lambda AB:AB[1])
sum = 0
flag = 0
for i in range(len(AB)-1):
    sum += AB[i][0]
    if sum > AB[i][1]:
        flag = 1
if flag == 0:
    print('Yes')
else:
    print('No')

Fixed code:
N = int(input())
AB = [list(map(int,input().split())) for i in range(N)]
AB.sort(key = lambda AB:AB[1])
sum = 0
flag = 0
for i in range(len(AB)):
    sum += AB[i][0]
    if sum > AB[i][1]:
        flag = 1

if flag == 0:
    print('Yes')
else:
    print('No')
Buggy code:
# 2019 6/22
# ABC 131 D MEgalomania

N = int(input())
work = []

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

work.sort()

time = 0

is_ok = True

for i in range(N):
    time += work[i][2]
    if time > work[i][1]:
        is_ok = False
        break

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


Fixed code:
# 2019 6/22
# ABC 131 D MEgalomania

N = int(input())
work = []

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

work.sort()

time = 0

is_ok = True

for i in range(N):
    time += work[i][1]
    if time > work[i][0]:
        is_ok = False
        break

if is_ok:
    print('Yes')
else:
    print('No')
Buggy code:
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0
 
z = zip(B,A)
s = sorted(z)
for i in range(N):
  if time + s[i][1] <= s[i][0]:
    time = time + = s[i][1]
    endflg[i] = 1
  else :
    break
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")

Fixed code:
N = int(input())
A = [None for _ in range(N)]
B = [None for _ in range(N)]
endflg = [0 for _ in range(N)]
for i in range(N):
  A[i],B[i] = map(int,input().split())
time = 0
 
z = zip(B,A)
s = sorted(z)
for i in range(N):
  if time + s[i][1] <= s[i][0]:
    time = time +  s[i][1]
    endflg[i] = 1
  else :
    break
    
if endflg == [1 for _ in range(N)]:
  print("Yes")
else:
  print("No")
Buggy code:
N = int(input())
s = [list(input().split( )) for i in range(N)]
#print(s[1][0])
t = sorted(s, key=lambda x:int(x[1]), reverse = True)
#print(t)
count = 0
sum1 = sum([int(t[j][0]) for j in range(len(t))])
for i in range(len(t)):
  if int(t[i][1]) < sum1 :
    sum1 = sum1 - int(t[i][0])
  else:
    count += 1
if count != 0:
  print("No")
else:
  print("Yes")

Fixed code:
N = int(input())
s = [list(input().split( )) for i in range(N)]
#print(s[1][0])
t = sorted(s, key=lambda x:int(x[1]), reverse = True)
#print(t)
count = 0
sum1 = sum([int(t[j][0]) for j in range(len(t))])
for i in range(len(t)):
  if int(t[i][1]) >= sum1 :
    sum1 = sum1 - int(t[i][0])
  else:
    count += 1
    sum1 = sum1 - int(t[i][0])
if count == 0:
  print("Yes")
else:
  print("No")
Buggy code:
#  --*-coding:utf-8-*--


def f(AB):
    s = 0
    for a, b in sorted(AB, key=lambda x:x[1]):
        s += a

        if s > b:
            return 'No'

    return 'Yes'


def main():
    N = int(input())
    AB = [tuple(map(int, input().split())) for i in range(N)]
    print(f(AB))



Fixed code:
#  --*-coding:utf-8-*--


def f(AB):
    s = 0
    for a, b in sorted(AB, key=lambda x:x[1]):
        s += a

        if s > b:
            return 'No'

    return 'Yes'


def main():
    N = int(input())
    AB = [tuple(map(int, input().split())) for i in range(N)]
    print(f(AB))


if __name__ == '__main__':
    main()
Buggy code:

N=int(input())
A=[0]*N
B=[0]*N
C=[0]*N
for i in range(N):
    A[i],B[i]=map(int,input().split())
    C[i]=[A[i],B[i]]
C.sort(key=lambda x:(x[1],x[0]))
print(C)
t=0
for i in range(N):
    t+=C[i][0]
    if C[i][1]<t:
        print('No')
        exit()
print('Yes')

Fixed code:

N=int(input())
A=[0]*N
B=[0]*N
C=[0]*N
for i in range(N):
    A[i],B[i]=map(int,input().split())
    C[i]=[A[i],B[i]]
C.sort(key=lambda x:(x[1],x[0]))
t=0
for i in range(N):
    t+=C[i][0]
    if C[i][1]<t:
        print('No')
        exit()
print('Yes')
Buggy code:
N = int(input())
X = []
for _ in range(N):
    buffX = list(map(int, input().split()))
    X.append(buffX)

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

result = True
time = 0
for i in range(N):
    time += X[i][0]
    if time > X[i][1]:
        result = False
        break

print( 'Yes' if result else 'No' )


Fixed code:
N = int(input())
X = []
for _ in range(N):
    buffX = list(map(int, input().split()))
    X.append(buffX)

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

result = True
time = 0
for i in range(N):
    time += X[i][0]
    if time > X[i][1]:
        result = False
        break

print( 'Yes' if result else 'No' )
Buggy code:
import numpy as np

N = int(input())

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


def yes_or_no():
    for c in C:
        if c < 0:
            return 0
    
    sorted_index = np.argsort(B)
    sum_A = [A[sorted_index[0]]]
    for i in range(1, N):
        next_num = sum_A[i-1] + A[sorted_index[i]]
        sum_A.append(next_num)
        if next_num > B[sorted_index[i]]:
            print(sum_A)
            return 0
        
    return 1

if yes_or_no():
    print("Yes")
else:
    print("No")

Fixed code:
import numpy as np

N = int(input())

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


def yes_or_no():
    sorted_index = np.argsort(B)
    if A[sorted_index[0]] > B[sorted_index[0]]:
        return 0
    sum_A = [A[sorted_index[0]]]
    for i in range(1, N):
        next_num = sum_A[i-1] + A[sorted_index[i]]
        sum_A.append(next_num)
        if next_num > B[sorted_index[i]]:
            return 0
        
    return 1

if yes_or_no():
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]

for i in range(N):
    ab[i].append(ab[i][1] - ab[i][0])

from operator import itemgetter
ab.sort(key=itemgetter(2))

cnt = 0
max_ = 0
flag = True
for i in range(N):
    cnt += ab[i][0]
    if cnt > ab[i][1]:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

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

from operator import itemgetter
ab.sort(key=itemgetter(1))

cnt = 0
flag = True
for i in range(N):
    cnt += ab[i][0]
    if cnt > ab[i][1]:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')
Buggy code:
N = int(input())
A = [0] * N
B = [0] * N
C = [0] * N
for i in range(N):
    A[i],B[i]=map(int,input().split())
    C[i] = [B[i],A[i]]
C.sort()
print(C)
time = 0

for i in range(len(C)):
    time += C[i][1]
    if C[i][0] < time:
        print("No")
        exit()
print("Yes")

Fixed code:
N = int(input())
A = [0] * N
B = [0] * N
C = [0] * N
for i in range(N):
    A[i],B[i]=map(int,input().split())
    C[i] = [B[i],A[i]]
C.sort()
time = 0

for i in range(len(C)):
    time += C[i][1]
    if C[i][0] < time:
        print("No")
        exit()
print("Yes")
Buggy code:
print("Yes")
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key= lambda x:x[1])
time = 0
for i in ab:
    time += i[0]
    if time <= i[1]:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Fixed code:
import sys
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key= lambda x:x[1])
time = 0
for i in ab:
    time += i[0]
    if time <= i[1]:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")
Buggy code:
N=int(input())
data=[]
a=[]
for i in range(0,N):
  a=list(map(int,input().split()))
  data.append(a)
  
data=sorted(data,key=lambda x: x[1])
#print(data)
b=[]
time=0
out=0

for j in range(0,N):
  b=data[j]
  time=time+b[0]
  #print(j,time)
  if time>b[1]:
    out=out+1
    #print(j,time,b[1])
    
if out>0:
  print("No",out)
  
else:
  print("Yes")

Fixed code:
N=int(input())
data=[]
a=[]
for i in range(0,N):
  a=list(map(int,input().split()))
  data.append(a)
  
data=sorted(data,key=lambda x: x[1])
#print(data)
b=[]
time=0
out=0

for j in range(0,N):
  b=data[j]
  time=time+b[0]
  #print(j,time)
  if time>b[1]:
    out=out+1
    #print(j,time,b[1])
    
if out>0:
  print("No")
  
else:
  print("Yes")
Buggy code:
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]

AB.sort(key=lambda x:(x[1],x[0]), reverse=True)
time = 0
for A, B in AB:
    time += A
    if B < time:
        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 B < time:
        print("No")
        break
else:
    print("Yes")
Buggy code:
import numpy as np
import sys

N = int(input())

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

for i in range(N):
    A[i] = A[b[i]]
    B[i] = B[b[i]]

wt = 0
for i in range(N):
    l = B[i]
    wt += A[i]
    if wt > l:
        print("No")
        sys.exit()
        
print("Yes")

Fixed code:
import numpy as np
import sys

N = int(input())

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

aa = [0] * N
bb = [0] * N
for i in range(N):
    aa[i] = A[b[i]]
    bb[i] = B[b[i]]

wt = 0
for i in range(N):
    l = bb[i]
    wt += aa[i]
    if wt > l:
        print("No")
        sys.exit()
        
print("Yes")
Buggy code:
n = int(input())
pairs = []
for i in range(0, n):
  pairs.append(list(map(int, input().split())))

def canFinishJobs(arr):
  arr.sort(key=lambda x: x[1])
  sum = 0
  for i in arr:
    sum += i[0]
    if sum > i[1]:
      return "NO"
  return "YES"

result = canFinishJobs(pairs)
print(result)
  
 

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

def canFinishJobs(arr):
  arr.sort(key=lambda x: x[1])
  sum = 0
  for i in arr:
    sum += i[0]
    if sum > i[1]:
      return "No"
  return "Yes"

result = canFinishJobs(pairs)
print(result)
Buggy code:
import itemgetter()
N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  task.append(M)
task.sort(key = itemgetter(1))
K = 0
ans = 1
for i in range(N):
  K += task[i,0]
  if (K>task[i,1]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")
  

Fixed code:
N = int(input())
task = []
for i in range(N):
  M = list(map(int,input().split()))
  M[0],M[1]=M[1],M[0]
  task.append(M)
task.sort()
K = 0
ans = 1
for i in range(N):
  K += task[i][1]
  if (K>task[i][0]):
    ans = 0
    break
if ans:
  print("Yes")
else:
  print("No")
Buggy code:
N=int(input())
lst=[]
for i in range(N):
    A,B=map(int,input().split())
    if A>B:
        print('No')   
    lst.append([A,B,B-A])
lst.sort(key=lambda x: x[2])

def judge(N):
    worktime=0
    for i in range(N):
        worktime += lst[i][0]
        if worktime > lst[i][1]:
            return('No')
        if (i+1)==N:
            return('Yes')
print(judge(N))

Fixed code:
N=int(input())
lst=[]

for i in range(N):
    A,B=map(int,input().split())
    lst.append([A,B])
lst.sort(key=lambda x: x[1])

def judge(N):
    worktime=0
    for i in range(N):
        worktime += lst[i][0]
        if worktime > lst[i][1]:
            return('No')
        if (i+1)==N:
            return('Yes')        
print(judge(N))
Buggy code:
from sys import stdin
from collections import deque
N=list(map(int,stdin.readline().strip().split()))[0]

t=0
data = [list(map(int,stdin.readline().rstrip().split())) for _ in range(N)]

data=sorted(data,key=lambda x:(x[1]))
d=deque(data)
while(len(d)!=0):
    A,B=d.popleft()
    if B>=t:
        t+=A
    else:
        print("No")
        exit()
print("Yes")


Fixed code:
from sys import stdin
from collections import deque
N=list(map(int,stdin.readline().strip().split()))[0]

t=0
data = [list(map(int,stdin.readline().rstrip().split())) for _ in range(N)]

data=sorted(data,key=lambda x:(x[1]))
d=deque(data)
while(len(d)!=0):
    A,B=d.popleft()
    if B>=t+A:
        t+=A
    else:
        print("No")
        exit()
print("Yes")
Buggy code:
n = int(input())
a = [0] * n
b = [0] * n
task = []
temp = 0
for i in range(n):
  a[i],b[i] = map(int, input().split())
  temp = [a[i],b[i]]
  task.append(temp)
task.sort(key=lambda x: x[1])

suma = 0
output = 'Yes'
for i in range(n):
  suma += a[i]
  if suma > b[i]:
    output = 'No'
    break
print(output)

Fixed code:
n = int(input())
a = [0] * n
b = [0] * n
task = []

for i in range(n):
  a[i],b[i] = map(int, input().split())
  temp = [a[i],b[i]]
  task.append(temp)
  
task.sort(key=lambda x: x[1])
suma = 0
output = 'Yes'

for i in range(n):
  suma += task[i][0]
  if suma > task[i][1]:
    output = 'No'
    break

print(output)
Buggy code:
import sys
input = sys.stdin.readline
N=int(input())
lst=[0]*N
lst=[list(map(int,input().split())) for i in range(N)]
lst.sort
ans=0
t=0
for i in range(N):
 t+=lst[i][0]
 if t>lst[i][1]:
  ans+=1
if ans==0:
 print("Yes")
else:
 print("No")


Fixed code:
import sys
input = sys.stdin.readline
N=int(input())
lst=[0]*N
lst=[list(map(int,input().split())) for i in range(N)]
lst.sort(key=lambda x: x[1])
ans=0
t=0
for i in range(N):
 t+=lst[i][0]
 if t>lst[i][1]:
  ans+=1
if ans==0:
 print("Yes")
else:
 print("No")
Buggy code:
n=int(input())
A = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
  A[i][0],A[i][1]=map(int,input().split())
  

std = sorted(A, key=lambda x: x[1])
sum=0
for i in range(n):
  sum+=A[i][0]
  if sum>=A[i][1]:
    print('No')
    break
  if i==n-1:
    print('Yes')

Fixed code:
n=int(input())
A = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
  A[i][0],A[i][1]=map(int,input().split())
  

A = sorted(A, key=lambda x: x[1])
sum=0
for i in range(n):
  sum+=A[i][0]
  if sum>A[i][1]:
    print('No')
    break
  if i==n-1:
    print('Yes')
Buggy code:
N = int(input())

works = []
for i in range(N):
    A, B = map(int, input().split())
    works.append([A, B])

works = sorted(works, key=lambda x: x[1], reverse=False)

flag = TabError
spend_time = 0
for i in range(len(works)):
    if spend_time < works[i][1]:
        spend_time += works[i][0]
    else:
        flag = False
        break

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


Fixed code:
N = int(input())

works = []
for i in range(N):
    A, B = map(int, input().split())
    works.append([A, B])

works = sorted(works, key=lambda x: x[1], reverse=False)

flag = TabError
spend_time = 0
for i in range(len(works)):
    spend_time += works[i][0]
    if spend_time > works[i][1]:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')
Buggy code:
N = int(input())

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

AB.sort(key=lambda x: x[1],reverse=True)
print(AB)
time = AB[0][1]
for i in range(1,N):
    if time-AB[i-1][0] < AB[i][1]:
        time = time-AB[i-1][0]
    else:
        time = AB[i][1]
    print(i,time)
time = time - AB[N-1][0]
print(time)
if time < 0:
    print("No")
else:
    print("Yes")

Fixed code:
N = int(input())

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

AB.sort(key=lambda x: x[1],reverse=True)

time = AB[0][1]
for i in range(1,N):
    if time-AB[i-1][0] < AB[i][1]:
        time = time-AB[i-1][0]
    else:
        time = AB[i][1]

time = time - AB[N-1][0]

if time < 0:
    print("No")
else:
    print("Yes")
Buggy code:
    n = int(input())
    tasks = []
    for i in range(n):
        a,b = map(int, input().split())
        tasks.append((a,b))

    tasks.sort(key=lambda x:x[1])
    #print(tasks)

    cur = 0
    c = True
    for i in range(n):
        cur += tasks[i][0]
        if cur > tasks[i][1]:
            c = False

    print("Yes" if c else "No")

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

tasks.sort(key=lambda x:x[1])
#print(tasks)

cur = 0
c = True
for i in range(n):
    cur += tasks[i][0]
    if cur > tasks[i][1]:
        c = False

print("Yes" if c else "No")
Buggy code:
n = int(input())
ba = []
for i in range(n):
    a, b = (int(j) for j in input().split())
    tmp = []
    tmp.append(b)
    tmp.append(a)
    ba.append(tmp)
ba.sort()
print(ba)
s = 0
f = True
for i in range(n):
    s += ba[i][1]
    if ba[i][0] < s:
        f = False
        break
if f:
    print("Yes")
else:
    print("No")

Fixed code:
n = int(input())
ba = []
for i in range(n):
    a, b = (int(j) for j in input().split())
    tmp = []
    tmp.append(b)
    tmp.append(a)
    ba.append(tmp)
ba.sort()

s = 0
f = True
for i in range(n):
    s += ba[i][1]
    if ba[i][0] < s:
        f = False
        break
if f:
    print("Yes")
else:
    print("No")
Buggy code:
n = int(input())
ab = [[0] * 2 for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    ab[i][0], ab[i][1] = a, b
ab = sorted(ab, key=lambda x: x[1])
#print(ab)
time = 0
for task in ab:
    time += task[0]
    if time <= task[1]:
        print(time, task[1])
        continue
    else:
        print('No')
        exit()
print('Yes')


Fixed code:
n = int(input())
ab = [[0] * 2 for _ in range(n)]
for i in range(n):
    a, b = map(int, input().split())
    ab[i][0], ab[i][1] = a, b
ab = sorted(ab, key=lambda x: x[1])
#print(ab)
time = 0
for task in ab:
    time += task[0]
    if time <= task[1]:
        #print(time, task[1])
        continue
    else:
        print('No')
        exit()
print('Yes')
Buggy code:
N = int(input())
C = {}

for i in range(N):
  a, b = map(int,input().split())
  C[b] = a
    
time = 0
D = sorted(C.items())

for i in range(len(D)):
  time += D[i][1]
  if time > D[i][0]:
    print('No')
    break
else:
  print('Yes')


Fixed code:
N = int(input())
C = {}

for i in range(N):
  a, b = map(int,input().split())
  if b in C.keys():
    C[b] += a
  else:
    C[b] = a
    
time = 0
D = sorted(C.items())

for i in range(len(D)):
  time += D[i][1]
  if time > D[i][0]:
    print('No')
    break
else:
  print('Yes')