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

Solution (Python):
def examA():
    S = SI()
    ans = "Good"
    for i in range(len(S)-1):
        if S[i+1]==S[i]:
            ans = "Bad"
    print(ans)
    return

def examB():
    N, L = LI()
    ans = 0
    if L>=0:
        for i in range(N - 1):
            ans += (L + i + 1)
    else:
        for i in range(N):
            ans += (L+i)
        if L+N-1<0:
            ans -=(L+N-1)
    print(ans)
    return

def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x
def lcm(x, y):
    return x * y // gcd(x, y)
def examC():
    A, B, C, D = LI()
    CD = lcm(C,D)
    ans = B - (B//C + B//D - B//CD) - ((A-1) - ((A-1)//C + (A-1)//D - (A-1)//CD))
    print(ans)
    return

def examD():
    N = I()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x:x[1])
    cur = 0; ans = "Yes"
    for a,b in AB:
        cur +=a
        if b<cur:
            ans = "No"
            break
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examD()

Solution (Python):
n=int(input())
L=[]
for i in range(n):
      a,b=map(int,input().split())
      L+=[[a,b]]
L.sort(key=lambda x:x[1])

sm=0
for i in range(n):
      sm+=L[i][0]
      if L[i][1]<sm:
            print("No")
            exit()
print("Yes")

Solution (Python):
import sys
n = int(input())
l = [[int(i) for i in input().split()] for i in range(n)] 
l = sorted(l, key=lambda x: x[1])  
t=0

for i in range(n):
    t+=l[i][0]
    if t > l[i][1]:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
from operator import itemgetter


def solve():
    N = int(input())
    AB = [[0, 0] for _ in range(N)]
    for i in range(N):
        AB[i] = list(map(int, input().split()))
    AB = sorted(AB, key=itemgetter(1))

    t = 0
    for i in range(N):
        t += AB[i][0]
        if t <= AB[i][1]:
            continue
        else:
            print('No')
            exit()
    print('Yes')


if __name__ == '__main__':
    solve()

Solution (Python):
from itertools import accumulate
from operator import itemgetter
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=itemgetter(1))
def g():
    acc = 0
    for a, b in AB:
        acc += a
        yield acc <= b
print("Yes" if all(g()) else "No")

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

for j in range(n):
    t = t + d[j][0]
    if t > d[j][1]:
        answer = "No"
print(answer)

Solution (Python):
from operator import itemgetter
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
l2=sorted(l,key=itemgetter(1))
cnt=0
for i in range(n):
  cnt+=l2[i][0]
  if cnt>l2[i][1]:
    print('No')
    exit()
print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from operator import itemgetter

N = int(input())
AB = sorted([[int(i) for i in input().split()] for _ in range(N)], key=itemgetter(1))

time = 0
for a,b in AB:
    time += a
    if time <= b:
        continue
    else:
        print("No")
        exit()

print("Yes")

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

Solution (Python):
N = int(input())
jobs = []
for _ in range(N):
    A, B = map(int, input().split())
    jobs.append((B, A))
jobs.sort(reverse=True)
now = 10 ** 9
for b, a in jobs:
    if now < b:
        now -= a
    else:
        now = b - a
print("Yes" if now >= 0 else "No")

Solution (Python):
import sys
readline=sys.stdin.readline
n=int(input())
a=[list(map(int, readline().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")

Solution (Python):
from operator import itemgetter
n=int(input())
a=sorted([list(map(int,input().split())) for i in range(n)], key=itemgetter(1))
b=0
for i in a:
    b+=i[0]
    if b>i[1]:
        print("No")
        exit()
print("Yes")

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

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

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

Solution (Python):
N = int(input())
AB = [tuple(map(int, input().split())) for i in range(N)]
AB = sorted(AB, key=lambda x: -x[1])
deadline = float('inf')
for a, b in AB:
    deadline = min(deadline, b) - a
    if deadline < 0:
        print('No')
        break
else:
    print('Yes')

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

suma = 0
c = 0
for i in range(N):
    suma += array[i][0]
    if suma > array[i][1]:
        c = 1
        break
if c == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
from operator import itemgetter
from collections import deque
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
AB = deque(sorted(AB,key = itemgetter(1)))
ans = "Yes"
time = 0
while len(AB) != 0:
    tmp = AB.popleft()
    time += tmp[0]
    if time > tmp[1]:
        ans = "No"
        break
print(ans)

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

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


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

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

Solution (Python):

import math
import heapq
import bisect


MOD = 10**9+7

N = int(input())

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

t = 0
for a in A:
    if a[0]+t <= a[1]:
        t += a[0]
    else:
        print("No")
        exit()

print("Yes")

Solution (Python):
n=int(input())
a=[list(map(int,input().split())) for i 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")
    exit()
print("Yes")

Solution (Python):
from operator import itemgetter
import sys

n = int(input())

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

ABs.sort(key=itemgetter(1))


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

print('Yes')

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

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

flag = True
time = 0
for task in X:
    if time + task[0] > task[1]:
        flag = False
        break
    time += task[0]

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

Solution (Python):
from operator import itemgetter

N = int(input())

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

AB = sorted(AB, key=itemgetter(1))

t = 0
ans = 'Yes'
for A, B in AB:
    if t + A > B:
        ans = 'No'
        break
    else: t += A
    
print(ans)

Solution (Python):
from operator import itemgetter

N = int(input())

AB = []

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

AB = sorted(AB, key=itemgetter(1))

t = 0
ans = 'Yes'
for A, B in AB:
    if t + A > B:
        ans = 'No'
        break
    else: t += A
    
print(ans)

Solution (Python):
n = int(input())
L = [[int(i) for i in input().split()] for j in range(n)]
L = sorted(L, key=lambda x:x[1])
num = 0
for l in L:
  num += l[0]
  if num <= l[1]:
    continue
  else:
    print("No")
    exit()
print("Yes")

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

Solution (Python):
import sys
input = sys.stdin.readline

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
ab = sorted(ab, key=lambda x:x[1])
now = 0
for i in range(N):
    now += ab[i][0]
    if ab[i][1] < now:
        print('No')
        quit()
print('Yes')

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

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

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

Solution (Python):
from operator import itemgetter


N = int(input())


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





AB_sort = sorted(AB, key=itemgetter(1, 0))

out = "Yes"
count = 0
for i in range(N):
    count += AB_sort[i][0]
    if count > AB_sort[i][1]:
        out = "No"
        break

print(out)

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

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

s = 0
for A, B in AB:
    s += A
    if s > B:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
def resolve():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]
    ab = sorted(ab, key=lambda x:x[1])
    now = 0
    for i in range (n):
        if now + ab[i][0] > ab[i][1]:
            print("No")
            return None
        else:
            now += ab[i][0]
    print("Yes")
    
resolve()

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

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

Solution (Python):
n=int(input())
table=[[]*2 for i in range(n)]
for i in range(n):
  table[i]=list(map(int,input().split()))
table=sorted(table,key=lambda x:x[1])
T=0
t=0
for i in range(n):
  T=table[i][1]
  t=t+table[i][0]
  if t>T:
    print("No")
    break
if i==n-1 and t<=T:
  print("Yes")

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

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

count = 0
for i in range(n):
    li_sorted[i][1] -= count
    count += li_sorted[i][0]
    
for i in li_sorted:
    if i[1] >= i[0]:
        continue
    elif i[0] > i[1]:
        print("No")
        exit()

print("Yes")

Solution (Python):
n=int(input())
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
for j in range(n):
    tmp=ab[j][1]
    ab[j][1]=ab[j][0]
    ab[j][0]=tmp
ans='Yes'
cnt=0
cnt1=0
ab.sort()
for k in range(n):
    cnt=ab[k][0]
    cnt1+=ab[k][1]
    if cnt1>cnt:
        ans='No'
        break
print(ans)

Solution (Python):
n = int(input())
l = []
for i in range(n):
    l.append([int(_) for _ in input().split()])
l = sorted(l, key=lambda x:x[1], reverse=True)

t = 0
ans = 'Yes'
for i in range(n):
    a,b  = l.pop()
    t += a
    if t > b:
        ans = 'No'
print(ans)

Solution (Python):
N = int(input())
work = []
for i in range(N):
  work.append(list(map(int,input().split())))
  
work.sort(key = lambda x:x[1])
sumtime = 0
result = 'Yes'
for i in range(N):
  sumtime += work[i][0]
  if sumtime > work[i][1]:
    result = 'No'
    break
print(result)

Solution (Python):
n = int(input())
works = [[]] * n
for i in range(n):
  a, b = map(int, input().split(' ')) 
  works[i] = [a, b]

ans = 'Yes'
sorted_works = sorted(works, key=lambda x: x[1]) 
total = 0

for work in sorted_works:
  total += work[0]
  if total > work[1]:
    ans = 'No'
    break
  
print(ans)

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

W=[[int(_) for _ in input().split()] for __ in range(N)]  

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

sum = 0
flg = False

for i in range(N):
    sum += W[i][0]
    if (sum > W[i][1]):
        flg = True
        break

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

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

Solution (Python):
import sys
input=sys.stdin.readline
n=int(input())

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

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

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

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

Solution (Python):
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
a.sort(key=lambda x:x[1])
t=[0]*n
t[0]=a[0][0]
for i in range(n-1):
    t[i+1]=t[i]+a[i+1][0]
judge=True
for i in range(n):
    if a[i][1]<t[i]:
        judge=False
print("Yes") if judge else print("No")

Solution (Python):
import numpy as np

N = int(input())

A = []
B = []

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


A = np.array(A)
B = np.array(B)

time = 0
ans = "Yes"
A = A[np.argsort(B)]
B = np.sort(B)

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

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

count_time = 0
for AB in ABn:
    count_time += AB[0]
    if count_time <= AB[1]:
        continue
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines



























def main():
	n=int(input())
	li=[]
	for i in range(n):
		a,b=map(int,input().split())
		li.append((a,b))
	li.sort(key=lambda x:x[1])
	
	ans="Yes"
	now=0
	for a,b in li:
		now+=a
		if now>b:
			ans="No"
			break
	
	print(ans)



if __name__ == '__main__':
	main()

Solution (Python):
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines



























def main():
	n=int(input())
	li=[]
	for i in range(n):
		a,b=map(int,input().split())
		li.append((a,b))
	li.sort(key=lambda x:x[1])
	
	ans="Yes"
	now=0
	for a,b in li:
		now+=a
		if now>b:
			ans="No"
			break
	
	print(ans)



if __name__ == '__main__':
	main()

Solution (Python):
from operator import itemgetter

N= int(input())

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

AB.sort(key=itemgetter(1))

ans = 'Yes'
t = 0

for a, b in AB:
    if t+a <= b: t += a
    else:
        ans='No'
        break

print(ans)

Solution (Python):
import heapq
N = int(input())
q = []
for _ in range(N):
	at,bt = map(int,input().split())
	heapq.heappush(q,[bt,at])

cond = True
cnt = 0
tmp = 0
for _ in range(N):
	d,c = heapq.heappop(q)
	cnt += (d - tmp)
	cnt -= c
	if cnt < 0:
		cond = False
		break
	tmp = d

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

Solution (Python):
import heapq
N = int(input())
q = []
for _ in range(N):
	at,bt = map(int,input().split())
	heapq.heappush(q,[bt,at])

cond = True
cnt = 0
tmp = 0
for _ in range(N):
	d,c = heapq.heappop(q)
	cnt += (d - tmp)
	cnt -= c
	if cnt < 0:
		cond = False
		break
	tmp = d

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

Solution (Python):
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
AB = sorted(AB, key=lambda x: x[1])
A_sum=0
hantei = True
for i in range(N):
  A_sum += AB[i][0]
  if A_sum>AB[i][1]:
    hantei=False
    break
print('Yes' if hantei else 'No')

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

ab=sorted(ab, key=lambda x: x[1])
a_sum=0
ans='Yes'
for i in range(n):
    a_sum+=ab[i][0]
    if a_sum>ab[i][1]:
        ans='No'
        break
print(ans)

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

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

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

sum_value = 0
result = "Yes"
for val in sortV:
    sum_value += val[0]
    if sum_value > val[1]:
        result = "No"
        break

print(result)

Solution (Python):
def main():
    N = int(input())
    l = []
    for _ in range(N):
        a, b = map(int, input().split())
        l.append((a,b))
    l.sort(key=lambda x:x[1])
    s = 0
    for i, j in l:
        s += i
        if s > j:
            return('No')
    return('Yes')
print(main())

Solution (Python):

import sys










def main():
    n = int(sys.stdin.readline().rstrip())
    ab = [tuple(int(x) for x in sys.stdin.readline().split()) for _ in range(n)]
    ab.sort(key=lambda x: x[1])

    s = 0
    for i in range(n):
        s += ab[i][0]
        if s <= ab[i][1]:
            continue
        else:
            ans = 'No'
            break
    else:
        ans = 'Yes'
    
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
n = int(input())
a = np.array([[int(i) for i in input().split(" ")] for j in range(n)])
arg = np.argsort(a[:,1])
sa = a[:,0][arg]
sb = a[:,1][arg]
tm = 0
flag = 0
for i in range(len(sa)):
    tm += sa[i]
    if tm > sb[i]:
        flag = 1
        break
if flag == 1:
    print("No")
else:
    print("Yes")

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

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

print("Yes")

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

Solution (Python):
import sys
input = sys.stdin.readline

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

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

time = 0
for task in tasks:
    time += task[0]
    if time > task[1]:
        print('No')
        break
else:
    print( 'Yes' )

Solution (Python):
import sys
input = sys.stdin.readline

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

tasks.sort()
tasks = sorted( tasks, key = lambda a: a[1] )

time = 0
flg = 0
for task in tasks:
    time += task[0]
    if time > task[1]:
        print('No')
        break
else:
    print( 'Yes' )

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

tasks.sort()
tasks = sorted( tasks, key = lambda a: a[1] )

time = 0
flg = 0
for task in tasks:
    time += task[0]
    if time > task[1]:
        flg = 1
print( 'No' if flg else 'Yes' )

Solution (Python):
n = int(input())
l = sorted([[int(i) for i in input().split()] for _ in range(n)],key = lambda x : (x[1],x[0]))

time = 0
flg = True
for i in l:
    time += i[0]
    if time > i[1]:
        flg = False
        break
    
print('Yes' if flg else 'No')

Solution (Python):
N=int(input())
V=[]
a,b=0,0
for i in range(N):
  V.append(list(map(int,input().split())))
V.sort(key=lambda x: x[1])
for i in range(N):
  a=a+V[i][0]
  if a>V[i][1]:
    b=b+1
if b==0:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
AB = sorted([list(map(int, input().split())) for i in range(N)], key=lambda x: x[1]-x[0])
cur = 0
aki = 0
if sum([a for a, b in AB]) <= max([b for a, b in AB]):
    for a, b in AB:
        if cur <= b-a:
            aki += (b-a)-cur
            cur += (b-a)-cur+a
        else:
            if aki >= a:
                aki -= a
            else:
                a -= aki
                if cur + a > b:
                    print('No')
                    exit()
    print('Yes')
else:
    print('No')

Solution (Python):
import heapq
n = int(input())
tasks = []
for _ in range(n):
  a,b = list(map(int, input().split()))
  heapq.heappush(tasks, (b, a))
res_a = 0
for i in range(n):
  b,a = heapq.heappop(tasks)
  res_a += a
  if(res_a > b):
    print("No")
    exit()
print("Yes")

Solution (Python):

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

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

tmp = 0
for i in range(N):
    tmp += A[i][0]
    if tmp <= A[i][1]:
        pass
    else:
        print('No')
        exit()

print('Yes')

Solution (Python):
def solve(n: int, ab: 'list(Task)') -> bool:
    from operator import attrgetter
    ab.sort(key=attrgetter('limit'))
    cur = 0
    for ab_ in ab:
        cur += ab_.cost
        if cur > ab_.limit:
            return False
    return True


if __name__ == '__main__':
    from collections import namedtuple
    import sys

    input = sys.stdin.readline
    Task = namedtuple('Task', 'cost limit')
    n = int(input())
    ab = []
    for _ in range(n):
        cost_, limit_ = map(int, input().split())
        ab.append(Task(cost=cost_, limit=limit_))
    print('Yes' if solve(n, ab) else 'No')

Solution (Python):
n = int(input().strip())
arr = [[0] * 2] * n

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

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

t = 0
flg = True

for e in s:
    if (e[1] < t + e[0]):
        flg = False
        break

    t += e[0]

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

Solution (Python):
N = int(input())
l = list()
for n in range(N):
    l.append([int(x) for x in input().split()])
l = sorted(l, key=lambda x:x[1])
sum = [l[0][0]]
for n in range(1,N):
    sum.append(l[n][0]+sum[n-1])
c = True
for n in range(N):
    if sum[n] > l[n][1]:
        c = False
if c:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import heapq
input = sys.stdin.readline

MOD = 10 ** 9 + 7


def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    h = []

    for i in range(N):
        A, B = map(int, input().split())
        
        heapq.heappush(h, (B, A))

    days = 0
    for i in range(N):
        work = heapq.heappop(h)
        days += work[1]
        
        if days > work[0]:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
d = dict()
for i in range(n):
    w, t = map(int, input().split())
    if t in d:
        d[t] = d[t] + w
    else:
        d[t] = w
d = sorted(d.items(), key=lambda x:x[0])
now = 0
ans = True
for x in d:
    t, w = x
    now = now + w
    if now > t:
        ans = False
        break
print('Yes' if ans else 'No')

Solution (Python):
n = int(input())
d = dict()
for i in range(n):
    w, t = map(int, input().split())
    if t in d:
        d[t] = d[t] + w
    else:
        d[t] = w
d = sorted(d.items(), key=lambda x:x[0])
now = 0
ans = True
for x in d:
    t, w = x
    now = now + w
    if now > t:
        ans = False
        break
print('Yes' if ans else 'No')

Solution (Python):
import sys

n = int(input())

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

need_t = 0
for b, a in abl:
    need_t += a
    if b < need_t:
        print("No")
        sys.exit()
        
print("Yes")

Solution (Python):
import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think([[2, 4], [1, 9], [1, 8], [4, 9], [3, 12]]), 'Yes')

    def test_2(self):
        self.assertEqual(think([[334, 1000], [334, 1000], [334, 1000]]), 'No')

    def test_3(self):
        self.assertEqual(think([[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]]), 'Yes')


def solve():
    list_of_a_and_b = read()
    result = think(list_of_a_and_b)
    write(result)


def read():
    n = read_int(1)[0]
    list_of_a_and_b = []
    for i in range(n):
        list_of_a_and_b.append(read_int(2))
    return list_of_a_and_b


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(data):
    data.sort(key=lambda x: (x[1], x[0]))
    current_time = 0
    for d in data:
        if current_time + d[0] > d[1]:
            return 'No'
        current_time += d[0]
    return 'Yes'


def write(result):
    print(result)


if __name__ == '__main__':
    
    solve()

Solution (Python):
import sys

n = int(input())

dic = {}

for i in range(n):
  a, b = map(int,input().split())
  if not (b in dic.keys()):
    dic[b] =[]
    
  dic[b].append(a)
  
minute = 0
for k, arr in sorted(dic.items()):
  minute += sum(arr)
  if minute > k:
    print('No')
    sys.exit(0)
    
print('Yes')

Solution (Python):
from operator import itemgetter
import sys
n = int(input())
a = [0] * n


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

a.sort(key=itemgetter(1))
tmp = 0
for i in a:
    tmp += i[0]
    if tmp > i[1]:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):
from operator import itemgetter, attrgetter
N = int(input())
l_2d = [list(map(int, input().split())) for i in range(N)]
A, B = l_2d_t = [list(x) for x in zip(*l_2d)]

z = [[a, b] for a,b in zip(A,B)]
z.sort(key=itemgetter(1))
time = 0
possible = True
for i in range(N):
  time += z[i][0]
  if time > z[i][1]:
    possible = False

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

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

Solution (Python):
N = int(input())
al = [list([0] * 2) for _ in range(N)]

for i in range(N):
    a, b = map(int, input().split())
    al[i][0] = a
    al[i][1] = b
al.sort(key=lambda x:(x[1], x[0]))
ans = 'Yes'
t = 0
for i in range(N):
    t += al[i][0]
    if t > al[i][1]:
        ans = 'No'
        break

print(ans)

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


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
    
    while((i+n<N) and (B[i]==B[i+n])):
        n += 1
    if(n>1):
        
        
        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")

Solution (Python):
N = int(input())
a = []
for i in range(N):
    ta, tb = map(int, input().split())
    a.append([ta, tb])
a = sorted(a, key=lambda x:(x[1], x[0]), reverse=True)
deadline = a[0][1]
for i in range(N - 1):
    deadline -= a[i][0]
    deadline = min(deadline, a[i + 1][1])
    if deadline < 0:
        print('No')
        exit()
deadline -= a[N - 1][0]
if deadline < 0:
    print('No')
else:
    print('Yes')

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

List=[[0]*2 for i in range(N)]
for i in range(N):
    A,B=map(int,input().split())
    List[i][0]=A
    List[i][1]=B

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

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

Solution (Python):
n = int(input())
a = []
b = []
cnt = 0
for _ in range(n):
    a1,b1 = map(int,input().split())
    a.append(a1)
    b.append(b1)
c = sorted(zip(b,a))
for i in range(n):
    cnt += c[i][1]
    if cnt > c[i][0]:
        print('No')
        break
else:
    print('Yes')