Problem:
 Score: 400 points    Problem Statement  Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.  Let the current time be time 0 . Kizahashi has N jobs numbered 1 to N .  It takes A_i units of time for Kizahashi to complete Job i . The deadline for Job i is time B_i , and he must complete the job before or at this time.  Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.  Can Kizahashi complete all the jobs in time? If he can, print Yes ; if he cannot, print No .      Constraints   All values in input are integers.  1 \leq N \leq 2 \times 10^5  1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)         Input  Input is given from Standard Input in the following format:  N  A_1  B_1  .  .  .  A_N  B_N       Output  If Kizahashi can complete all the jobs in time, print Yes ; if he cannot, print No .        Sample Input 1 5
2 4
1 9
1 8
4 9
3 12      Sample Output 1 Yes  He can complete all the jobs in time by, for example, doing them in the following order:   Do Job 2 from time 0 to 1 .  Do Job 1 from time 1 to 3 .  Do Job 4 from time 3 to 7 .  Do Job 3 from time 7 to 8 .  Do Job 5 from time 8 to 11 .   Note that it is fine to complete Job 3 exactly at the deadline, time 8 .       Sample Input 2 3
334 1000
334 1000
334 1000      Sample Output 2 No  He cannot complete all the jobs in time, no matter what order he does them in.       Sample Input 3 30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720      Sample Output 3 Yes

Solution (Python):
N = int(input())
waku = []
for i in range(N):
    a,b = map(int, input().split())
    waku.append([b,a])
waku1 = sorted(waku)
ans = True
p1 = p2 = 0
for i,j in waku1:
    p1 += j
    if p1 > i:
        ans = False
        break

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

Solution (Python):
n = int(input())
list = []

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

list = sorted(list)

tpast = 0
flag = 0

for i in range(n):
    b,a = list[i][0],list[i][1]
    if tpast+a > b:
        flag = 1
        break
    else:
        tpast = tpast+a

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

Solution (Python):
from operator import itemgetter
N = int(input())

A = [[0] * 2 for i in range(N)]
for i in range(N):
  A[i] = list(map(int, input().split()))
  
A.sort(key=itemgetter(1))

now = 0
for a in A:
  now += a[0]
  if now > a[1]:
    print('No')
    exit(0)
    
print('Yes')

Solution (Python):
from operator import itemgetter
N = int(input())

A = []
for i in range(N):
  A.append(list(map(int, input().split())))
  
A.sort(key=itemgetter(1))

now = 0
for a in A:
  now += a[0]
  if now > a[1]:
    print('No')
    exit(0)
    
print('Yes')

Solution (Python):
from operator import itemgetter
N = int(input())

A = []
for i in range(N):
  A.append(list(map(int, input().split())))
  
A.sort(key=itemgetter(1))

now = 0
for a in A:
  now += a[0]
  if now > a[1]:
    print('No')
    exit(0)
    
print('Yes')

Solution (Python):
n=int(input())
bag=[]
ans="Yes"
total=0
for i in range(n):
    a,b=map(int,input().split())
    bag.append([a,b])
d=sorted(bag, key=lambda x:x[1])

for j in range(n):
    total=total+d[j][0]
    if total>d[j][1]:
        ans="No"
        

print(ans)

Solution (Python):
n=int(input())
bag=[]
ans="Yes"
total=0
for i in range(n):
    a,b=map(int,input().split())
    bag.append([a,b])
d=sorted(bag, key=lambda x:x[1])

for j in range(n):
    total=total+d[j][0]
    if total>d[j][1]:
        ans="No"
        break

print(ans)

Solution (Python):
import numpy as np

N = int(input())
A = np.zeros((N,2))

for i in range(N):
	A[i, 0], A[i, 1] = [int(j) for j in input().split()]

A = A[np.argsort(A[:,1]), :]

for i in range(N-1):
	A[i+1, 0] = A[i, 0]+A[i+1, 0]

ans = ['Yes', 'No']
t = np.sum((A[:,1]-A[:,0])<0)

print(ans[t>0])

Solution (Python):
n=int(input())
a=[0]*n
b=[0]*n
c=[[0,0] for _ in range(n)]

for i in range(n):
    a[i],b[i]=map(int,input().split())
    c[i][0]=a[i]
    c[i][1]=b[i]

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

t=0
ans='Yes'

for j in range(n):
    t=t+d[j][0]
    if t > d[j][1]:
        ans='No'
        break

print(ans)

Solution (Python):
N = int(input())
ABs = [list(map(int, input().split())) for i in range(N)]
ABs.sort(key=lambda AB: AB[1])
t = 0
for i in range(N):
  AB = ABs[i]
  A = AB[0]
  B = AB[1]
  t = t + A
  if t > B:
    print("No")
    break
  if i == N-1:
    print("Yes")

Solution (Python):
N = int(input())
AB = []
for i in range(N):
  AB_1,AB_2 = map(int,input().split())
  AB.append([AB_1,AB_2])
AB.sort(key=lambda AB: AB[1])
time = 0
count = 0
ans = "Yes"

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

Solution (Python):
def main():
  N = int(input())
  work_list = []
  for n in range(N):
    work_list.append(list(map(int, input().split())))
  work_list = sorted(work_list, key=lambda x:x[1])
  time = 0
  for work in work_list:
    time += work[0]
    if time > work[1]:
      print('No')
      break
  else:
    print('Yes')

main()

Solution (Python):
N = int(input())
A=[0]*N
B=[0]*N
class Job:
    def __init__(self, a, b):
        self.time = a
        self.limit = b

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

jobs.sort(key = lambda job: job.limit)
used_time = 0
for job in jobs:
    used_time += job.time
    if used_time > job.limit:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
N = int(input())
ab = sorted([[0, 0]] + [list(map(int, input().split())) for i in range(N)], key=lambda x: x[1])
for i in range(len(ab) - 1):
    ab[i + 1][0] += ab[i][0]
    if ab[i + 1][1] < ab[i + 1][0]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
N = int(input())
ab = [[0, 0]] + [list(map(int, input().split())) for i in range(N)]
ab = sorted(ab, key=lambda x: x[1])
for i in range(len(ab) - 1):
    ab[i + 1][0] += ab[i][0]
    if ab[i + 1][1] < ab[i + 1][0]:
        print("No")
        exit()

print("Yes")

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

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


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

Solution (Python):
N = int(input())
li = []
for i in range(N):
    a,b = map(int,input().split())
    li.append([b,a])
li.sort()
t = 0
co = 1
for i in range(N):
    t += li[i][1]
    if li[i][0] < t:
        co = 0
        break
if co:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())

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

list.sort(key=lambda x:x[1])
  
result='Yes'
time=0
for i in range(len(list)):
  time+=list[i][0]
  if(time>list[i][1]):
    result='No'
    
print(result)

Solution (Python):
n = int(input())
task = [[0 for i in range(2)] for j in range(n)]
frag = True
total = 0
for i in range(0, n):
    task[i][0], task[i][1] = map(int, input().split())
task = sorted(task, key=lambda x: x[1])

for i in range(n):
    total += task[i][0]
    if total > task[i][1]:
        frag = False

if frag == True:
    print("Yes")
if frag == False:
    print("No")

Solution (Python):
import sys
N = int(input())

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

pa, pb = (0, 10**9)
for a, b in sorted(a_b_list, key=lambda x: x[1]):
    pa += a
    pb = b
    if pb < pa:
        print('No')
        sys.exit(0)

print('Yes')

Solution (Python):
n = int(input())
sche = []
for i in range(n):
    a,b = map(int,input().split())
    sche.append((b,a))
sche.sort(reverse = True)
now = 1e18
for dead,ti in sche:
    if(dead < now):
        now = dead
    now -= ti

if now < 0:
    print("No")
else:
    print("Yes")

Solution (Python):
N = int(input())
works = [[int(i) for i in input().split()] for _ in range(N)]
elapsed = 0

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

for work in works:
    time, deadline = work
    if elapsed + time <= deadline:
        elapsed += time
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
n=int(input())
li=[]
for i in range (0,n):
  a,b=map(int,input().split())
  li.append([b,a])
li.sort()
t=0
j=0
for i in range (0,n):
  t=t+li[i][1]
  if t>li[i][0]:
    j=j+1
if j==0:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
tensai = []
for i in range(n):
    a,b = map(int,input().split())
    tensai.append(b * 10000000000 + a)
tensai.sort()
time = 0
ans = "Yes"
for i in range(n):
    time += tensai[i] % 10000000000
    deadline = tensai[i] // 10000000000
    if time > deadline:
        ans = "No"
        break
    else:
        continue
print(ans)

Solution (Python):
N = int(input())
tasks = [list(map(int, input().split())) for _ in range(N)]
tasks.sort(key = lambda x: x[1])
now = 0
flag = True
for a, b in tasks:
    now += a
    if now > b:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import deque

n = int(input())
ab = [(0, 0) for _ in range(n)]

for i in range(n):
    ab[i] = tuple(map(int, input().split()))
    
def mergesort(ab, l, r):
    if r - l == 1:
        return [ab[l]]
    m = (l + r) // 2
    ab1 = mergesort(ab, l, m)
    ab2 = mergesort(ab, m, r)
    res = []
    i1, i2 = 0, 0
    while i1 < len(ab1) or i2 < len(ab2):
        if i1 == len(ab1):
            res.append(ab2[i2])
            i2 += 1
        elif i2 == len(ab2):
            res.append(ab1[i1])
            i1 += 1
        else:
            if ab1[i1][1] <= ab2[i2][1]:
                res.append(ab1[i1])
                i1 += 1
            else:
                res.append(ab2[i2])
                i2 += 1
    return res
    
sorted_ab = mergesort(ab, 0, n)

now = 0
flag = True
for task in sorted_ab:
    now += task[0]
    if now > task[1]:
        print('No')
        flag = False
        break

if flag:
    print('Yes')

Solution (Python):
n = int(input())
ab = [[int(_) for _ in input().split()] for _ in range(n)]
ab.sort(key=lambda x: x[1])

t = 0
for v in ab:
    t += v[0]
    if t > v[1]:
        print('No')
        exit()

print('Yes')

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


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


sumtime = 0
flg = 0
for i in range(N):
    if(sumtime + Data[i][0] <= Data[i][1]):
        sumtime += Data[i][0]
    else:
        flg += 1
        break

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

Solution (Python):
num_lines = int(input())
if num_lines<1 or num_lines>2*10**5:
	print ('Illegal')
	exit()
a=[]
for i in range(num_lines):
	x,y=map(int,input().split(" "))
	if x<1 or y <=0 or y>10**9:
		print ('Illegal')
		exit()
	a.append([y,x,i])
a.sort()
r='Yes'
s=0
for i in range(num_lines):
	s+=a[i][1]
	if(s>a[i][0]):
		r='No'
		break;
print(r)

Solution (Python):
sortsecond = lambda val:val[1]
n = int(input())
l = []
t=0
for _ in range(n):
    a,b = map(int,input().split())
    l.append((a,b))
l.sort(key=sortsecond)
i=0
while(i<n):
    t+=l[i][0]
    if t>l[i][1]:
        print("No")
        break
    if i==n-1:
        print("Yes")
    i+=1

Solution (Python):
n = int(input())
x = [[int(i) for i in input().split()] for i in range(n)]
x.sort(key = lambda x: x[1])
total = 0
flag = 0
for i in range(n):
    if x[i][1]-total >= x[i][0]:
        total += x[i][0]
    else:
        flag = 1
        break
if flag == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
from operator import itemgetter

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

total = 0
work.sort(key=itemgetter(1))

flag = True
for [a, b] in work:
    total = total + a
    if total > b:
        flag = False
        break

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

Solution (Python):

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

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

i = 0
t = 0
while i < n:
    t += a[i][0]
    if t > a[i][1]:
        break
    i += 1

print("Yes" if i >= n else "No")

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

time = 0
flg = "Yes"
for b,a in elist:
    time = time + a
    if time > b:
        flg = "No"
        break

print(flg)

Solution (Python):
a = int(input())
b = []
for i in range(a):
    c, d = map(int, input().split())
    b.append([d, c])
b.sort()
c = 0
for i in range(a):
    c += b[i][1]
    if c > b[i][0]:
        print("No")
        exit()
print("Yes")

Solution (Python):
N = int(input())

ABs = []
for _ in range(N):
    ABs.append([int(j) for j in input().split()])

ABs = sorted(sorted(ABs, key=lambda x: x[0], reverse=True), key=lambda x: x[1])
t = 0
for i, AB in enumerate(ABs):
    t += AB[0]
    if t > AB[1]:
        print('No')
        break

    if i == N-1:
        print('Yes')

Solution (Python):
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]

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

time = 0
for ab in AB:
    time += ab[0]
    if time > ab[1]:
        print("No")
        exit()
print("Yes")

Solution (Python):
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

N = read_int()[0]
AB = [read_int() for _ in range(N)]

def solve():
    AB.sort(key=lambda x: x[1])
    ans = True
    res = 0
    for i in range(N):
        res += AB[i][0]
        if res > AB[i][1]:
            ans = False
            break
    return "Yes" if ans else "No"

if __name__ == "__main__":
    print(solve())

Solution (Python):
work = []

n = int(input())

for _ in range(n):
    work.append(tuple([int(x) for x in input().split()]))



work_sorted_by_b = sorted(work, key=lambda t: t[1])



sum_a = 0
for t in work_sorted_by_b:
    sum_a += t[0]
    if sum_a > t[1]:
        print('No')
        exit(0)

print('Yes')

Solution (Python):
import numpy as np
from collections import defaultdict
from functools import reduce


n = int(input())

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

tasks.sort()

current = 0

for b, a, _ in tasks:
    current += a
    if current > b:
        break
else:
    print("Yes")
    exit()
print("No")

Solution (Python):

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')

Solution (Python):
n = int(input())
arr = []
for i in range(n):
  a,b = map(int,input().split())
  arr.append([a,b])
time = 0
k = 1
arr = sorted(arr,key=lambda x: x[1])
for i in range(n):
  time += arr[i][0]
  if time > arr[i][1]:
    k = 0
    break
if k == 1:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
T = [tuple(map(int, input().split())) for _ in range(n)]
T.sort(key=lambda pair: pair[1])

time = 0

for a, b in T:
    time += a
    if time > b:
        print("No")
        exit()

print("Yes")

Solution (Python):
import fractions

if __name__ == '__main__':
  n = int(input())
  work_list = []
  for i in range(n):
    a, b = map(int, input().split(" "))
    work_list.append((a, b))
      
  work_sorted = sorted(work_list, key=lambda x:x[1])
  total_work = 0
  success = "Yes"
  for key, value in work_sorted:
    total_work = total_work + int(key)
    if total_work > value:
      success = "No"
      break

  print (success)

Solution (Python):



def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    mod_ab = sorted(ab, key=lambda x: (x[1], x[0]))
    time = 0

    for ai, bi in mod_ab:
        time += ai

        if time > bi:
            print('No')
            exit()

    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
ab = []
for i in range(n):
    ab.append([int(item) for item in input().split()])
ab.sort(key=lambda x : x[1])

task_time = 0
for a, b in ab:
    task_time += a
    if task_time > b:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
task = []

for i in range(n):
    task.append([int(j) for j in input().split()])

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

ans = "Yes"
cur = 0
remaining = 0
for i in task:
    remaining += i[1] - cur - i[0]
    if remaining < 0:
        ans = "No"
        break
    cur = i[1]

print(ans)

Solution (Python):
from operator import itemgetter

N = int(input())

wl = [tuple(map(int, input().split())) for _ in range(N)]
wl.sort(key=itemgetter(1))


cur = 0
can = True
for t, lmt in wl:
    cur += t
    if cur > lmt:
        can = False
        break
print('Yes' if can else 'No')

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

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

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

Solution (Python):
N=int(input())
L=[]

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

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

t = 0
for a,b in L:
   t += a
   if (t>b):
      break;

print('Yes' if (t<=b) else 'No')

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

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

cnt = 0
for i in range(n):
    cnt += a[i][0]
    
    if cnt > a[i][1]:
        print('No')
        exit()

print('Yes')

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

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

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

Solution (Python):
N = int(input())

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

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

t = 0
flag = True
for i in range(N):
    t += q[i][0]
    if t > q[i][1]:
        flag = False
        break

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

Solution (Python):
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]


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


for i, (a, _) in enumerate(ab):
    if i == 0:
        continue
    ab[i][0] = ab[i-1][0] + a

if all(ab[i][0] <= ab[i][1] for i in range(n)):
    print('Yes')
else:
    print('No')

Solution (Python):
N = input()
jobs = []
for i in range(int(N)):
  t = input().split()
  t = [int(i) for i in t]
  jobs.append(t)

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

time = 0
flag = 0
for  i in range(int(N)):
  time +=  int(jobs[i][0])

 
  if time > int(jobs[i][1]):
    flag = 1
    break
if flag == 0:
  print("Yes")
else:
  print("No")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, W: "Tuple[int, int]"):
    W = sorted(sorted(W, key=lambda work: work[0], reverse=True), key=lambda work: work[1])
    t = 0
    for i in range(N):
        t += W[i][0]
        if t > W[i][1]:
            return NO
    return YES



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    W = [(int(), int())] * (N)  
    for i in range(N):
        a = int(next(tokens))
        b = int(next(tokens))
        W[i] = (a, b)
    print(solve(N, W))

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
li = [list(map(int, input().split())) for i in range(n)]
li.sort(key=lambda x: x[1])
time = 0
for i in range(n):
    time += li[i][0]
    if time > li[i][1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
N = int(input())

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

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


time = 0
for t, deadline in job:
    time += t
    if time > deadline:
        print("No")
        exit()
print("Yes")

Solution (Python):
N = int(input())
tasks = [list(map(int, input().split())) for _ in range(N)]
sorted_tasks = sorted(tasks, key=lambda x: x[1] )

def solve():
  sum_cost = 0
  for task in sorted_tasks:
    sum_cost+=task[0]
    if(task[1]<sum_cost):
      return False
  return True

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

Solution (Python):
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)

Solution (Python):
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')

Solution (Python):
n = int(input())
jobs = [list(map(int, input().split())) for i in range(n)]
jobs = sorted(jobs, key=lambda x: x[1])

elapsed_time = 0
possible = True
for job in jobs:
  if elapsed_time + job[0] <= job[1]:
    elapsed_time += job[0]
  else:
    possible = False
    break

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

Solution (Python):
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")

Solution (Python):
N=int(input())
AB_list=list()
for _ in range(N):
    AB_list.append(list(map(int,input().split())))
AB_list.sort(key=lambda x:x[1])
time=0
boolean=True
for l in AB_list:
    time+=l[0]
    if time>l[1]:
        print("No")
        boolean=False
        break
    else:
        continue
if boolean:
    print("Yes")

Solution (Python):
N = int(input())
a = [input() for i in range(N)]
listA = []
for i in range(N):
    ai,bi = map(int, a[i].split())
    listA.append([ai,bi])
listA.sort(key = lambda x:x[1])

time = 0
able = True

for i in range(N):
    time += listA[i][0]
    if time > listA[i][1]:
        able = False
        break
if able == True:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
readline = sys.stdin.readline
N = int(readline())
T = []
S = 0
for i in range(N):
    a, b = map(int, readline().split())
    T.append((b, a))
    S += a
T.sort(reverse=1)
cur = 0
while cur < N:
    t, v = T[cur]; cur += 1
    if t < S:
        print("No")
        break
    S -= v
    while cur < N and t == T[cur][0]:
        S -= T[cur][1]
        cur += 1
else:
    print("Yes")

Solution (Python):
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')

Solution (Python):
n=int(input())
data=[list(map(int,input().split()))for _ in range(n)]
data=sorted(data, key=lambda x: x[0])
data=sorted(data, key=lambda x: x[1])
time=0
for i in data:
  time+=i[0]
  if time>i[1]:
    print("No")
    exit()
print("Yes")

Solution (Python):
import numpy as np
n=int(input())
a=[]
b=[]
time=0
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
bsort=np.sort(b)
bsoeji=np.argsort(b)
for i in range(n):
    time=a[bsoeji[i]]+time
    if time>bsort[i]:
        print("No")
        exit()
print("Yes")

Solution (Python):
import sys
input= sys.stdin.readline
n=int(input())
time=0
tasks=[]
for i in range(n):
  tasks.append(list(map(int,input().split())))
tasks.sort(key=lambda x:x[1])
flag=0
for i in range(n):
  time+=tasks[i][0]
  if time>tasks[i][1]:
    flag=1
    break
if flag==0:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
jobL = []
index=0
while index < n:
    a, b = map(int, input().split())
    jobL.append([b, a])
    index+=1
jobL.sort()
timeCounter=0
index2=0
while index2 < len(jobL):
    timeCounter+=jobL[index2][1]
    if timeCounter <= jobL[index2][0]:
        index2+=1
    else:
        break
if index2 == len(jobL):
    print("Yes")
else:
    print("No")

Solution (Python):
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')

Solution (Python):
N = int(input())
L = []
count = 0
flag = 0
for i in range(N):
    L.append(list(map(int, input().split())))

L.sort(key = lambda x:x[1] )
for i in range(N):
    count += L[i][0]
    if L[i][1] < count:
        print("No")
        flag = 1
        break

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

Solution (Python):
from operator import itemgetter
import sys

n=int(input())
ls=[]
work=lim=0
i=0

for i in range(n):
    a,b=map(int,input().split())
    ls.append([a,b])
ls=sorted(ls,key=itemgetter(1))

for i in range(n):
    
    work+=ls[i][0]
    
    lim=ls[i][1]
    

    if lim<work:
        print("No")
        sys.exit()

print("Yes")

Solution (Python):
N = int(input())
AB = sorted([list(map(int,input().split())) for _ in [0]*N],key=lambda x:x[1])
T=0
for A,B in AB:
  T+=A
  if T>B:
    print("No")
    break
else:
  print("Yes")

Solution (Python):
n = int(input())
ab = [[int(x) for x in  input().split(" ")] for _ in range(n)]

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

t = 0

for a, b in ab:
    t += a
    if t > b:
        print("No")
        exit(0)
print("Yes")

Solution (Python):
from operator import itemgetter

N = int(input())
tasks = []
for i in range(N):
  A, B = list(map(int, input().split()))
  tasks += [[A, B]]
tasks = sorted(tasks, key=itemgetter(1))

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

Solution (Python):
from operator import itemgetter
N = int(input())
AB = [(0,0)]*N

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

AB.sort(key=itemgetter(1,0))

t = 0
flag = True

for a,b in AB:
    t += a
    if b < t:
        flag=False
print("Yes") if flag else print("No")

Solution (Python):
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])

flag = True
time = 0

for i in range(n):
    time += works[i][0]
    if works[i][1] < time:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())

ab = []

for _ in range(n):

	ab.append(list(map(int, input().split())))
	

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




limit = 0

work = 0

fail = 0


for i in range(n):

	limit = ab[i][1]

	work += ab[i][0]

	if work > limit:

		fail = 1

		break


if fail == 1:

	print("No")

else:

	print("Yes")

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    T = [ tuple( map( int, input().split())) for _ in range(N)]
    T = sorted(T,key=lambda x:x[1])
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][0]
        if time > T[i][1]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):


def main():
    N = int( input())
    T = [ tuple( map( int, input().split())) for _ in range(N)]
    T = sorted(T,key=lambda x:x[1])
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][0]
        if time > T[i][1]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int( input())
    T = [ (0,0)]*N
    for i in range(N):
        a, b = map( int, input().split())
        T[i] = (b,a)
    T.sort()
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][1]
        if time > T[i][0]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):


def main():
    N = int( input())
    T = [ (0,0)]*N
    for i in range(N):
        a, b = map( int, input().split())
        T[i] = (b,a)
    T.sort()
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][1]
        if time > T[i][0]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
data = [list(map(int, input().split())) for _ in range(n)]
data.sort(key=lambda x: x[1])
_sum = 0
for a, b in data:
    _sum += a
    if _sum > b:
        print('No')
        exit()
print('Yes')

Solution (Python):
N, = list(map(int, input().split()))
d = {}
for i in range(N):
  ai,bi = list(map(int, input().split()))
  if bi in d:
    d[bi].append(ai)
  else:
    d[bi] = [ai]
B = list(d.keys())
B.sort()
ret = 'Yes'
s = 0
for b in B:
  s += sum(d[b])
  if s>b:
    ret = 'No'
print(ret)

Solution (Python):
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)




n = ip()                      




a = []
for i in range(n):
    b = iprow()
    a.append([b[1],b[0]])
a.sort()
sumtime = 0
for i in range(n):
    sumtime += a[i][1]
    if sumtime > a[i][0]:
        j(0)
j(1)

Solution (Python):
N=int(input())
work=[None]*N
for i in range(N):
    work[i]= list(map(int, input().split()))
work=sorted(work,key=lambda work:work[1])
time=0
flag=0
for i,j in work:
    time += i
    if time > j:
        print("No")
        flag=1
        break
if flag==0:
    print("Yes")

Solution (Python):
import numpy as np
a = []
b = []
time_tmp = 0
ans = True
N = int(input())
for i in range(N):
    atmp, btmp = (int(x) for x in input().split())
    a.append(atmp)
    b.append(btmp)
b_sort = np.argsort(b)
for i in range(N):
    work_num = b_sort[i]
    time_tmp += a[work_num]
    if time_tmp > b[work_num]:
        ans = False
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())

task = []
for i in range(N):
	task.append([int(x) for x in input().split()])

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

sum = 0
for i in range(N):
	sum += task[i][0]
	if sum > task[i][1]:
		print('No')
		break
	elif i == N - 1:
		print('Yes')

Solution (Python):
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")

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

AB = sorted(AB, key=lambda x: x[1])
time = 0
for ab in AB:
  time += ab[0]
  if time > ab[1]:
    print('No')
    break
else: print('Yes')