qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key = lambda X:X[1])
time = 0
ans = 'Yes'
for i in range(N):
  time += X[0][i]
  line = X[i][1]
  if line < time :
    ans = 'No'
print(ans)

Fixed code:
N = int(input())
X = [list(map(int, input().split())) for _ in range(N)]
X.sort(key = lambda X:X[1])
time = 0
ans = 'Yes'
for i in range(N):
  time += X[i][0]
  line = X[i][1]
  if line < time :
    ans = 'No'
print(ans)
Buggy code:
n = int(input())
Jobs = []
for i in range(n):
    Jobs.append(list(map(int, input().split())))

Jobs.sort(key=lambda x: x[1], reverse=True)
#print(Jobs)
now = Jobs[0][1]
for time, deadline in Jobs:
    if now < deadline:
        now -= time
    else:
        now = deadline
        now -= time
    #print(now)
if now < 0:
    print("NO")
else:
    print("YES")

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

Jobs.sort(key=lambda x: x[1], reverse=True)
#print(Jobs)
now = Jobs[0][1]
for time, deadline in Jobs:
    if now < deadline:
        now -= time
    else:
        now = deadline
        now -= time
    #print(now)
if now < 0:
    print("No")
else:
    print("Yes")
Buggy code:
N = int(input())
#N=5
#A,B = [2,1,1,4,3],[4,9,8,9,12]
A,B = [],[]
for i in range(N):
    a,b = input().split()
    A.append(int(a))
    B.append(int(b))


import numpy as np
C = np.array([A,B])

C = C[:,C[1,:].argsort()]
A,B = C[0],C[1]
print(C)
i=0
while(i<N):
    n=0
    #ind = i+n
    while((i+n<N) and (B[i]==B[i+n])):
        n += 1
    if(n>1):
        #print(n,i,A[i:i+n] )
        #pdb.set_trace()
        A[i:i+n] = A[i:i+n][::-1]
    i+=n
"""
print(A,B)
sum_ = 0
y=[]
b = []
for i in range(N):
    sum_ += A[i]
    y.append(sum_)
    b.append(B[i])
plt.plot(y)
plt.plot(b)
plt.show()
plt.close()"""
time = 0
hantei = 0
for i in range(N):
    time += A[i]
    if(time>B[i]):
        hantei = 1
        break
        
print("Yes") if hantei==0 else print("No")

Fixed code:
N = int(input())
#N=5
#A,B = [2,1,1,4,3],[4,9,8,9,12]
A,B = [],[]
for i in range(N):
    a,b = input().split()
    A.append(int(a))
    B.append(int(b))


import numpy as np
C = np.array([A,B])

C = C[:,C[1,:].argsort()]
A,B = C[0],C[1]
i=0
while(i<N):
    n=0
    #ind = i+n
    while((i+n<N) and (B[i]==B[i+n])):
        n += 1
    if(n>1):
        #print(n,i,A[i:i+n] )
        #pdb.set_trace()
        A[i:i+n] = A[i:i+n][::-1]
    i+=n
"""
print(A,B)
sum_ = 0
y=[]
b = []
for i in range(N):
    sum_ += A[i]
    y.append(sum_)
    b.append(B[i])
plt.plot(y)
plt.plot(b)
plt.show()
plt.close()"""
time = 0
hantei = 0
for i in range(N):
    time += A[i]
    if(time>B[i]):
        hantei = 1
        break
        
print("Yes") if hantei==0 else print("No")
Buggy code:
from operator import itemgetter


def solve(string):
    *ab, = map(int, open(0).read().split())
    ab = sorted(zip(*[iter(ab)] * 2), key=itemgetter(1))
    past = 0
    for a, b in ab:
        past += a
        if past > b:
            return "No"
    return "Yes"


if __name__ == '__main__':
    n = int(input())
    print(solve(""))


Fixed code:
from operator import itemgetter


def solve(string):
    n, *ab = map(int, open(0).read().split())
    ab = sorted(zip(*[iter(ab)] * 2), key=itemgetter(1))
    past = 0
    for a, b in ab:
        past += a
        if past > b:
            return "No"
    return "Yes"


if __name__ == '__main__':
    print(solve(""))
Buggy code:
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
  lis[i].append(lis[i][1]-lis[i][0])
lis.sort(key = lambda x:x[2])
time = 0
for i in range(n):
  time += lis[i][0]
  if time > lis[i][1]:
    print("No")
    exit()
print("Yes")

Fixed code:
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
  lis[i].append(lis[i][1]-lis[i][0])
lis.sort(key = lambda x:x[1])
time = 0
for i in range(n):
  time += lis[i][0]
  if time > lis[i][1]:
    print("No")
    exit()
print("Yes")
Buggy code:
n = int(input())
a_lst = []
b_lst = []

for i in range(0, n):
    a, b = [int(elem) for elem in input().split()]
    a_lst.append(a)
    b_lst.append(b)

tmp = zip(b_lst, a_lst)
tmp = sorted(tmp)
b_lst, a_lst = zip(*tmp)   
print(b_lst, a_lst)

flag = 0
sums = 0
for i in range(0, len(a_lst)):
    sums += a_lst[i]
    if sums > b_lst[i]:
        flag = 1
        break

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

Fixed code:
n = int(input())
a_lst = []
b_lst = []

for i in range(0, n):
    a, b = [int(elem) for elem in input().split()]
    a_lst.append(a)
    b_lst.append(b)

tmp = zip(b_lst, a_lst)
tmp = sorted(tmp)
b_lst, a_lst = zip(*tmp)   

flag = 0
sums = 0
for i in range(0, len(a_lst)):
    sums += a_lst[i]
    if sums > b_lst[i]:
        flag = 1
        break

if flag == 0:
    print("Yes")
else:
    print("No")
Buggy code:
import sys
import math


N = int(input())

timelis = []
for _ in range(N):
    A,B = map(int, input().split())
    if A >= B:
        print("No")
        sys.exit()
    timelis.append([A,B])

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

sum_time = 0
for i in timelis:
    need = i[0]
    deadline = i[1]

    sum_time = sum_time + need

    if sum_time > deadline:
        print(sum_time,need,deadline)
        print("No")
        sys.exit()

print("Yes")

Fixed code:
import sys
import math


N = int(input())

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

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

sum_time = 0
for i in timelis:
    need = i[0]
    deadline = i[1]

    sum_time = sum_time + need

    if sum_time > deadline:
        print("No")
        sys.exit()

print("Yes")
Buggy code:
N = int(input())
AB = [[int(x) for x in input().split(" ")] for _ in range(N)]
AB = sorted(AB, key=lambda e: e[1])

time = 0

for i, a, b in AB:
    time += a
    if time > b:
        print("No")
        break
else:
    print("Yes")


Fixed code:
N = int(input())
AB = [[int(x) for x in input().split(" ")] for _ in range(N)]

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

time = 0


for a, b in AB:
    time += a
    if time > b:
        print("No")
        break
else:
    print("Yes")
Buggy code:
import sys
N = int(input())
List = []
for i in range(N):
    tmp_a,tmp_b = map(int,input().split())
    List.append([tmp_b,tmp_a])
List.sort()
Sum_a= 0

for i in range(N):
    Sum_a += List[i][1]
    if Sum_a > List[i][0]:
        print('No')
        sys.exit()
print('YES')


Fixed code:
import sys
N = int(input())
List = []
for i in range(N):
    tmp_a,tmp_b = map(int,input().split())
    List.append([tmp_b,tmp_a])
List.sort()
Sum_a= 0

for i in range(N):
    Sum_a += List[i][1]
    if Sum_a > List[i][0]:
        print('No')
        sys.exit()
print('Yes')
Buggy code:
N = int(input())

dic = {}
B = []

for i in range(N):
    a, b = map(int,input().split())
    B.append(b)
    if '{}'.format(b) in dic:
        dic['{}'.format(b)] += a
    else:
        dic['{}'.format(b)] = a

Bs = sorted(B)

time = 0

for i, num in enumerate(Bs):
    time += dic['{}'.format(num)]
    if num < time:
        print('NO')
        break

    if i == len(Bs)-1:
        print('Yes')


Fixed code:
N = int(input())

dic = {}
B = []

for i in range(N):
    a, b = map(int,input().split())
    B.append(b)
    if '{}'.format(b) in dic:
        dic['{}'.format(b)] += a
    else:
        dic['{}'.format(b)] = a

Bs = sorted(list(set(B)))

time = 0

for i, num in enumerate(Bs):
    time += dic['{}'.format(num)]
    if num < time:
        print('No')
        break

    if i == len(Bs)-1:
        print('Yes')
Buggy code:
n = int(input())
work = [[int(j) for j in input().split(" ")] for i in range(n)]
work = sorted(work,key = lambda x:(x[1],x[0]))

time = 0
for work_time, limit_time in work:
    time += work_time
    print(time,limit_time)
    if time > limit_time:
        print("No")
        break

else:
    print("Yes")

Fixed code:
n = int(input())
work = [[int(j) for j in input().split(" ")] for i in range(n)]
work = sorted(work,key = lambda x:(x[1],x[0]))

time = 0
for work_time, limit_time in work:
    time += work_time
    if time > limit_time:
        print("No")
        break

else:
    print("Yes")
Buggy code:
N = int(input())

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

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

now = 0
flag = False
for l in L:
    print(now)
    now += l[0]
    
    if now > l[0] + l[1]:
        flag = True
        break

    

if flag:
    print('No')

else:
    print('Yes')



Fixed code:
N = int(input())

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

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

now = 0
flag = False
for l in L:
    now += l[0]
    
    if now  > l[1]:
        flag = True
        break


if flag:
    print('No')

else:
    print('Yes')
Buggy code:
N = int(input())
J = [tuple(map(int, input().split())) for _ in range(N)]

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

t = J[0][1]

for a, b in J:
    if t >= 0:
        t -= a
    else:
        res = 'No'
        break
else:
    res = 'Yes'

print(res)


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

J.sort(key=lambda x: (x[1], -x[0]))

t = 0
for a, b in J:
    if t + a > b:
        res = 'No'
        break
    else:
        t += a
else:
    res = 'Yes'

print(res)
Buggy code:
N = int(input())
task = [list(map(int,input().split())) for i in range(N)]
task.sort(key= lambda x:x[1])

curtime = 0
for i in task:
  curtime += i[0]
  if curtime > i[1]:
    print("No")
    break
  print(curtime)
if curtime <= task[-1][1]:
  print("Yes")

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

curtime = 0
for i in task:
  curtime += i[0]
  if curtime > i[1]:
    print("No")
    break

if curtime <= i[1]:
  print("Yes")
Buggy code:
N = int(input())
AB = []
for n in range(N):
    AB.append(list(map(int,input().split())))
AB = sorted(AB, key=lambda x: (x[1],x[0]))
time = 0
result = True
for n in range(N):
    if AB[n][1] < time + AB[n][0]:
        result = False
        print(n)
        break
    else:
        time += AB[n][0]
print("Yes") if result else print("No")

Fixed code:
N = int(input())
AB = []
for n in range(N):
    AB.append(list(map(int,input().split())))
AB = sorted(AB, key=lambda x: (x[1],x[0]))
time = 0
result = True
for n in range(N):
    if AB[n][1] < time + AB[n][0]:
        result = False
        break
    else:
        time += AB[n][0]
print("Yes") if result else print("No")
Buggy code:
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key = lambda x:x[1])

c = sum([i for i,j in ab])
abmax = max([j for i,j in ab])

ab.reverse()
ans = "Yes"
x = c + 0
for i,j in ab:
    x -= i
    if x <= j:
        continue
    else:
        ans = "No"
        break

print(ans)

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

c = sum([i for i,j in ab])
abmax = max([j for i,j in ab])

ab.reverse()
ans = "Yes"
x = c + 0
for i,j in ab:
    if not x <= j:
        ans = "No"
        break
    x -= i

print(ans)
Buggy code:
import numpy as np

N = 3

hyo = np.zeros((N,2))

for NN in range(N):
    hyo[NN] = input().split(' ')

hyo_sorted = hyo[np.argsort(hyo[:,1])]

tooktime = hyo_sorted[:,0].cumsum()

timeup = hyo_sorted[:,1]

if any(tooktime > timeup) ==True:
    print("No")
else:
    print("Yes")

Fixed code:
import numpy as np

N = int(input())

hyo = np.zeros((N,2))

for NN in range(N):
    hyo[NN] = input().split(' ')

hyo_sorted = hyo[np.argsort(hyo[:,1])]

tooktime = hyo_sorted[:,0].cumsum()

timeup = hyo_sorted[:,1]

if any(tooktime > timeup) ==True:
    print("No")
else:
    print("Yes")
Buggy code:
n = int(input())
work = [list(map(int,input().split())) for _ in range(n)]
work = sorted(work,key = lambda x:x[1])
a = [0] * n
a[0] = work[0][0]
for i in range(1,N):
    a[i] = a[i-1] + work[i][0]
ans = 'Yes'
for j in range(N):
    if a[j] > work[j][1]:
        ans = 'No'
        break
print(ans)

Fixed code:
n = int(input())
work = [list(map(int,input().split())) for _ in range(n)]
work = sorted(work,key = lambda x:x[1])
a = [0] * n
a[0] = work[0][0]
for i in range(1,n):
    a[i] = a[i-1] + work[i][0]
ans = 'Yes'
for j in range(n):
    if a[j] > work[j][1]:
        ans = 'No'
        break
print(ans)
Buggy code:
N = int(input())
job = []
for i in range(N):
    A,B = map(int,input().split())
    job.append([B,A])
job = sorted(job)time = 0
flag = 0
for i in job:
    time += i[1]
    if i[0] < time:
        print('No')
        flag = 1
        break
        
if flag == 0:
    print('Yes')

Fixed code:
N = int(input())
job = []
for i in range(N):
    A,B = map(int,input().split())
    job.append([B,A])
job = sorted(job)
time = 0
flag = 0
for i in job:
    time += i[1]
    if i[0] < time:
        print('No')
        flag = 1
        break
        
if flag == 0:
    print('Yes')
Buggy code:
n = int(input())
tsk = []
for i in range(n):
	a,b = map(int,input().split())
	tsk.append([a,b,b-a])

tsk.sort(key = lambda x:x[2])

t = 0
ans = 'Yes'

for i in range(n):
	l = tsk[i]
	t += l[0]
	if l[1]<t:
		ans = 'No'
		break
print(ans)

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

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

t = 0
ans = 'Yes'

for i in range(n):
	l = tsk[i]
	t += l[0]
	if t > l[1]:
		ans = 'No'
		break
print(ans)
Buggy code:
from sys import stdin, exit
N = int(stdin.readline().rstrip())
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])

time=0
for a, b in AB:
    time += time
    if time > b:
        print('No')
        exit()
print('Yes')

Fixed code:
from sys import stdin, exit
N = int(stdin.readline().rstrip())
AB = [list(map(int, stdin.readline().rstrip().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])

time = 0
for a, b in AB:
    time += a
    if time > b:
        print('No')
        exit()
print('Yes')
Buggy code:
n=int(input())

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

time=0
for item in ba:
  b=item[0]
  a=item[1]
  
  time+=b
  if time>a:
    print("No")
    exit()
print("Yes")
  

Fixed code:
n=int(input())

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

time=0
for item in ba:
  b=item[0]
  a=item[1]
  #print(a,b,time)
  
  time+=a
  if time>b:
    print("No")
    exit()
print("Yes")
Buggy code:
s=sorted([list(map(int,input().split()))for i in range(int(input()))],key=lambda x:x[1])
d=0
for i in s:
    if d+i[0]>i[1]:
        print("No")
    else:
        d+=i[0]
else:
    print("Yes")

Fixed code:
s=sorted([list(map(int,input().split()))for i in range(int(input()))],key=lambda x:x[1])
d=0
for i in s:
    if d+i[0]>i[1]:
        print("No")
        break
    else:
        d+=i[0]
else:
    print("Yes")
Buggy code:
#!/usr/bin/env python3

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


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

weight = 0
for w, d in ab:
    print(weight, d)
    weight += w
    if weight > d:
        print("No")
        exit()
# print(weight, d)
print("Yes")


Fixed code:
#!/usr/bin/env python3

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


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

weight = 0
for w, d in ab:
    # print(weight, d)
    weight += w
    if weight > d:
        print("No")
        exit()
# print(weight, d)
print("Yes")
Buggy code:
N = int(input())
ls = []
now = 0
simekiri = 0
flag = 0
for i in range(N):
    a,b = map(int,input().split())
    ls.append([b,a])
ls.sort()
print(ls)
for i in range(len(ls)):
    simekiri = ls[i][0]
    now += ls[i][1]
    if now > simekiri:
        print("No")
        flag += 1
        break
if flag == 0:
    print("Yes")

Fixed code:
N = int(input())
s = []
now = 0
simekiri = 0
flag = 0
for i in range(N):
    a,b = map(int,input().split())
    s.append([b,a])
s.sort()
for i in range(N):
    now += s[i][1]
    simekiri = s[i][0]
    if now>simekiri:
        print("No")
        flag = 1
        break
if flag == 0:
    print("Yes")
Buggy code:
def main():
    N = int(input())
    A, B = [], []
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        A.append(a)
        B.append(b)
        AB.append([a, b])

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

    time = 0
    while (len(AB) > 0):
        flag = True
        a, b = AB
        if time + a <= b:
            time += a
            AB.pop(0)
            flag = False
        if flag:
            break
    if len(AB) == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

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

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

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

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

if __name__ == "__main__":
    main()
Buggy code:
N=int(input())
AB={}
B=[]
base=0
answer="Yes"

for i in range(N):
    a,b=map(int,input().split())
    if b not in AB.keys():
        AB[b]=a
        B.append(b)
    else:
        AB[b]+=a
        
B=sorted(B)

for j in B:
    base+=AB[j]
    print(base,j)
    if base>j:
        answer="No"

print(answer)

Fixed code:
N=int(input())
AB={}
B=[]
base=0
answer="Yes"

for i in range(N):
    a,b=map(int,input().split())
    if b not in AB.keys():
        AB[b]=a
        B.append(b)
    else:
        AB[b]+=a
        
B=sorted(B)

for j in B:
    base+=AB[j]
    #print(base,j)
    if base>j:
        answer="No"

print(answer)
Buggy code:
n = int(input())
b_list = []
for i in range(n):
    ba_tmp = list(map(int, input().split()))
    ba_list.append([ba_tmp[1], [ba_tmp[0]])
ba_list.sort()
now_time = 0
for i in range(n):
    now_time += ba_list[i][1]
    if now_time > ba_list[i][0]:
        print('No')
        exit()
print('Yes')

Fixed code:
n = int(input())
ba_list = []
for i in range(n):
    ba_tmp = list(map(int, input().split()))
    ba_list.append(ba_tmp[::-1])
ba_list.sort()
now_time = 0
for i in range(n):
    now_time += ba_list[i][1]
    if now_time > ba_list[i][0]:
        print('No')
        exit()
print('Yes')
Buggy code:
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,key=lambda x:x[1])
print(arr)
sa=0
for i in range(n):
  sa+=arr[i][0]
  if sa>arr[i][1]:
    print('No')
    break
else:
  print('Yes')

Fixed code:
n=int(input())
arr=[list(map(int,input().split())) for _ in range(n)]
arr=sorted(arr,key=lambda x:x[1])
sa=0
for i in range(n):
  sa+=arr[i][0]
  if sa>arr[i][1]:
    print('No')
    break
else:
  print('Yes')
Buggy code:
ef main():
    N = int(input())
    jobs = [list(map(int, input().split())) for _ in range(N)]
    time = 0
    jobs = sorted(jobs, key=lambda x: x[1])
    for j in jobs:
        time += j[0]
        if time > j[1]:
            print("No")
            return
        
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Fixed code:
def main():
    N = int(input())
    jobs = [list(map(int, input().split())) for _ in range(N)]
    time = 0
    jobs = sorted(jobs, key=lambda x: x[1])
    for j in jobs:
        time += j[0]
        if time > j[1]:
            print("No")
            return
        
    else:
        print("Yes")


if __name__ == '__main__':
    main()
Buggy code:
n = int(input())

works = list()
for num in range(n):
    a = list(map(int, input().split()))
    works.append(a)

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

time = 0

counter = 0

for row in works:
    time += row[0]
    counter += 1
    if time >= row[1]:
        print("No")
        exit()

print("Yes")

Fixed code:
n = int(input())

works = list()
for num in range(n):
    a = list(map(int, input().split()))
    works.append(a)

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

time = 0
limit = 0

for row in works:
    time += row[0]
    limit = row[1]
    if time > limit:
        print("No")
        exit()

print("Yes")
Buggy code:
 int(input())
 
A = []
B = []
for i in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
 
C = zip(B, A)
C = sorted(C)
B, A = zip(*C)
 
ans = 1
t = 0
for i, j in zip(A, B):
    t += i
    if t <= j:
        continue
    else:
        print("No")
        ans = 0
        break
if ans:
    print("Yes")

Fixed code:
n = int(input())

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

C = zip(B, A)
C = sorted(C)
B, A = zip(*C)

ans = 1
t = 0
for i, j in zip(A, B):
    t += i
    if t <= j:
        continue
    else:
        print("No")
        ans = 0
        break
if ans:
    print("Yes")
Buggy code:
N = int(input())

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

lst.sort(key=lambda tup: tup[1])
count = 0
for x in lst:
  if count > x[0]:
    print("No")
    exit()
  count += x[1]

print("Yes")


Fixed code:
N = int(input())

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

lst.sort(key=lambda tup: tup[1])
time = 0
for x in lst:
  time += x[0]
  if time > x[1]:
    print("No")
    exit()

print("Yes")
Buggy code:
N = int(input())
data = []
for _ in range(N):
    A, B = map(int, input().split())
    data.append([B, A])
data.sort()

prefix_cost = []
current_cost = 0
for i in range(N):
    current_cost += data[i][1]
    prefix_cost.append(current_cost)

for i in range(N):
    if not prefix_cost[i] <= data[i][0]:
        exit()

print('Yes')


Fixed code:
N = int(input())
data = []
for _ in range(N):
    A, B = map(int, input().split())
    data.append([B, A])
data.sort()

prefix_cost = []
current_cost = 0
for i in range(N):
    current_cost += data[i][1]
    prefix_cost.append(current_cost)

for i in range(N):
    if not prefix_cost[i] <= data[i][0]:
        print('No')
        exit()

print('Yes')
Buggy code:
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N = int(input())

AB = []

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

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

print(AB)

sumV = 0

for i in range(N):
    sumV += AB[i][0]
    if sumV > AB[i][1]:
        print("No")
        exit()

print("Yes")


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

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

N = int(input())

AB = []

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

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


sumV = 0

for i in range(N):
    sumV += AB[i][0]
    if sumV > AB[i][1]:
        print("No")
        exit()

print("Yes")
Buggy code:
def sol(inp=input):
    n=int(inp())
    lines=[list(map(int,inp().split())) for _ in range(n)]
    lines=sorted(lines,key=lambda l:l[1])
    
    for i in range(n-1):
        lines[i+1][0]+=lines[i][0]

    return('Yes' if all(l[0]<=l[1] for l in lines) else 'No')

Fixed code:
def sol(inp=input):
    n=int(inp())
    lines=[list(map(int,inp().split())) for _ in range(n)]
    lines=sorted(lines,key=lambda l:l[1])
    
    for i in range(n-1):
        lines[i+1][0]+=lines[i][0]

    return('Yes' if all(l[0]<=l[1] for l in lines) else 'No')

print(sol())
Buggy code:
N=int(input())
AB = [tuple(map(int,input().spilt())) for i in range(N)]
AB.sort(key = lambda x:x[1])
curtime = 0
clear = True
for a,b in range(AB):
    if curtime > b:
        clear = False
        break
    curtime += a
if clear:print("Yes")
else:print("No")

Fixed code:
N=int(input())
AB = [tuple(map(int,input().split())) for i in range(N)]
AB.sort(key = lambda x:x[1])
curtime = 0
clear = True
for a,b in AB:
    curtime += a
    if curtime > b:
        clear = False
        break
if clear:print("Yes")
else:print("No")