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):
def main():
    n = int(input())
    ab = []
    for _ in range(n):
        ab.append(tuple(map(int, input().split())))
    sorted_ab = sorted(ab, key=lambda x: x[1])
    now = 0
    for a, b in sorted_ab:
        now += a
        if now > b:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
s = []
c = 0
for _ in range(n):
    a, b = map(int, input().split())
    s.append([b, a])
s.sort()
for i in range(n):
    c += s[i][1]
    if c > s[i][0]:
        c = -1
        break
if c != -1:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
n=int(input())
ab = []
for _ in range(n):
    a, b = (int(x) for x in input().split())
    ab.append([a, b])
ab = sorted(ab, key=lambda x: x[1])

limit = 0

for i, j in ab:
    limit += i
    if j < limit:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n = ni()
ab = nan(n)
d = [(ab[i][1], ab[i][0], ab[i][1] - ab[i][0]) for i in range(n)]
d.sort()

ok = True
c = 0
for i in range(n):
    b, a, p = d[i]
    if p < c:
        ok = False
        break
    c += a

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

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


AB.sort(key=lambda x: x[1])
t = 0
for a, b in AB:
    t += a
    if t <= b:
        continue
    else:
        print("No")
        exit(0)
print("Yes")

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    AB=LLIN(N)
    AB.sort(key=lambda x: x[1])

    now = 0    
    for a,b in AB:
        now += a
        if now > b:
            print("No")
            return
    print("Yes")
if __name__ == '__main__':
    main()

Solution (Python):
N=int(input())
A=[]
for i in range (N):
	A.append(list(map(int,input().split())))
C=sorted(A,key=lambda A: A[1])
tmp=0
count=0
for i in range (N):
  tmp+=C[i][0]
  if tmp<=C[i][1]:
    count+=1
  else:
    print("No")
    break
if count==N:
  print("Yes")

Solution (Python):
from collections import OrderedDict
if __name__ == "__main__":
    n = int(input())
    job = dict()
    for i in range(n):
        tmp = list(map(int, input().split()))
        if tmp[1] in job:
            job[tmp[1]].append(tmp[0])
        else:
            job[tmp[1]] = [tmp[0]]

    sch = sorted(job)

    time = 0
    for j in sch:
        time += sum(job[j])
        if time <= j:
            continue
        else:
            print('No')
            exit()

    print('Yes')

Solution (Python):
from operator import itemgetter
n = int(input())
jobs = [tuple(map(int, input().split())) for _ in range(n)]
jobs = sorted(jobs, key=itemgetter(1))
total = 0
for a, b in jobs:
    total += a
    if total > b:
        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

can = False

for a, b in ab:
    t += a
    if t > b:
        break
else:
    can = True

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

Solution (Python):
import sys
from collections import defaultdict
from operator import itemgetter
input = sys.stdin.readline

N = int(input())
d = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    d[b] += a
task = list(d.items())
task.sort()

now = 0
ans = "Yes"
for limit, time in task:
    now += time
    if now > limit:
        ans = "No"
        break

print(ans)

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


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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = []
for _ in range(N):
  l, r = map(int, input().split())
  a.append((l, r))
a.sort(key = lambda x: x[1])
p = 0
for i in range(N):
  if p <= a[i][1] - a[i][0]: p += a[i][0]
  else:
    print("No")
    exit(0)
print("Yes")

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

now = cant = 0
for a, b in ab:
    now += a
    if now>b: cant = True
print("YNeos"[cant::2])

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

time = 0
flag = False
for i in range(N):
    time += AB[i][0]
    if time <= AB[i][1]:
        continue
    else:
        flag = True
        break

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

Solution (Python):
import sys
stdin = sys.stdin
from itertools import accumulate

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

n = ni()
ab = list()
for _ in range(n):
    ab.append(na())

ab.sort(key=lambda x:x[1])
time = 0
for ai, bi in ab:
    time += ai
    if time > bi:
        print("No")
        quit()
print("Yes")

Solution (Python):
N = int(input())
L = [[int(l) for l in input().split()] for _ in range(N)]

from operator import itemgetter
L.sort(key=itemgetter(1))
time = 0
ans = "Yes"
for i in range(N):
    time += L[i][0]
    if time > L[i][1]:
        ans = "No"
        break
print(ans)

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

Solution (Python):
import sys
from operator import itemgetter

def solve():
    input = sys.stdin.readline
    N = int(input())
    W = [[int(w) for w in input().split()] for _ in range(N)]
    W.sort()
    W.sort(key = itemgetter(1))
    time = 0
    for i, w in enumerate(W):
        if time + w[0] > w[1]:
            print("No")
            break
        else:
            time += w[0]
    else: print("Yes")

    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
def main():
    N = int(input())
    AB = [[int(i) for i in input().split()] for j in range(N)]
    AB.sort(key=lambda p: p[1])
    time = 0
    for a, b in AB:
        time += a
        if time > b:
            return print("No")
    print("Yes")


if __name__ == '__main__':
    main()

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

N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda k: k[1])
t = 0

for Ai, Bi in AB:
    t += Ai
    
    if t>Bi:
        print('No')
        exit()

print('Yes')

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
task = [LIST() for _ in range(N)]
task = sorted(task, key=lambda x: (x[1], x[0]))
task = [list(x) for x in zip(*task)]

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

print("Yes")

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
task = [LIST() for _ in range(N)]
task = sorted(task, key=lambda x: x[1])
task = [list(x) for x in zip(*task)]

c = 0
for i in range(N - 1):
    if task[1][i] == task[1][i + 1]:
        c += 1
    else:
        if c != 0:
            task[0][i - c:i+1] = sorted(task[0][i - c:i+1])
            c = 0

now_time = 0
for i in range(N):
    now_time += task[0][i]
    if now_time > task[1][i]:
        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])

ans=True
now=0
for i in range(n):
    now+=ab[i][0]
    if now>ab[i][1]:
        ans=False
        break

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

Solution (Python):
n = int(input())
lis = []
for i in range(n):
    lis.append(list(map(int, input().split())))
lis = sorted(lis, key=lambda x:x[1])
ans = 'Yes'
cnt = 0
for i in range(n):
    cnt += lis[i][0]
    if lis[i][1] < cnt:
        ans = 'No'
print(ans)

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
import queue
import copy






N = int(input())
AB=[]
A = []
B = []
C = []

for i in range(N):
  AB.append(str(input()).split())
  A.append(int(AB[i][0]))
  B.append(int(AB[i][1]))
  C.append([B[i]-A[i], A[i], B[i]])

C = sorted(C, key = lambda x: (x[2], x[0]))
unko = 1
time = 0



for i in range(N):
  if(C[i][2]-time-C[i][1]<0):
    print("No")
    unko = 0
    break
  else:
    time += C[i][1]

if(unko==1):
  print("Yes")

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

A = [0]*N
B = [0]*N

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


indexes = [i for i in range(N)]
sorted_indexes = sorted(indexes, key=lambda i: B[i])

sorted_A = [A[i] for i in sorted_indexes]
sorted_B = [B[i] for i in sorted_indexes]

total = 0
for i in range(N):
    total += sorted_A[i]
    if total <= sorted_B[i]:
        continue
    else:
        print('No')
        exit()
print('Yes')

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

print(ans)

Solution (Python):
"""brute force
import itertools


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

for pattern in itertools.permutations([i for i in range(n)]):
    t = 0
    flag = True
    for i in pattern:
        t += jobs[i][0]
        if t > jobs[i][1]:
            flag = False
    if flag:
        print("Yes")
        exit()
print("No")
"""
import heapq

n = int(input())
jobs = [list(map(int, input().split()[::-1])) for _ in range(n)]

heapq.heapify(jobs)
t = 0
for i in range(len(jobs)):
    deadline, job_t = heapq.heappop(jobs)
    t += job_t
    if t > deadline:
        print("No")
        exit()
print("Yes")

Solution (Python):
n=int(input())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  l.append([b,a])
l.sort()
tmp=0
for i in range(n):
  tmp+=l[i][1]
  if tmp>l[i][0]:
    print('No')
    break
  if i==n-1:
    print('Yes')

Solution (Python):
import sys
def input():
    return sys.stdin.readline()[:-1]
from operator import itemgetter
N=int(input())
s=[tuple(map(int, input().split())) for i in range(N)]
s.sort(key=itemgetter(1))
t=0
for i in s:
    t+=i[0]
    if t>i[1]:
        print("No")
        break
else:
    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 = sorted(a, key=itemgetter(1))
work = 0
for i in range(N):
    work = work + a[i][0]
    if work > a[i][1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
n = int(input())
ary = []
for i in range(n):
	a, b = map(int, input().split())
	ary.append([a,b])
ary.sort(key=lambda x:x[1])
s = 0
for i in ary:
	s += i[0]
	if s <= i[1]:
		continue
	else:
		print ("No")
		exit()
print ("Yes")

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

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

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    AB=LLIN(N)
    AB.sort(key=lambda x: x[1])

    now = 0    
    for a,b in AB:
        now += a
        if now > b:
            print("No")
            return
    print("Yes")
if __name__ == '__main__':
    main()

Solution (Python):
import sys

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

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

time = 0

for task in tasks:
    time += task[0]

    if time > task[1]:
        print("No")
        sys.exit()

print("Yes")

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

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

tota = 0
ans = 'Yes'
for i in range(n):
    tota += AB[i][0]
    if tota > AB[i][1]:
        ans = 'No'
print(ans)

Solution (Python):
import sys

n, *ab = map(int, sys.stdin.read().split())
ab = sorted(zip(*[iter(ab)] * 2), key=lambda x: x[1])

def main():
    t = 0
    for a, b in ab:
        t += a
        if t > b:
            return 'No'
    return 'Yes'

if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):
import numpy as np

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
sorted_ab = sorted(ab, key=lambda x: x[1])
arr = np.array(sorted_ab)
if np.any((arr[:, 1] - np.cumsum(arr[:, 0])) < 0):
  print('No')
else:
  print('Yes')

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

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

for i,j in l:
    if c+i <= j:
        c += i
    else:
        print("No")
        break
else:
    print("Yes")

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

Solution (Python):
N = int(input())
works = []
for i in range(N):
    works.append(list(map(int, input().split())))
works = sorted(works, key=lambda x: (x[1], x[0]))
time = 0
isFail = False
for i in range(N):
    time += works[i][0]
    if time > works[i][1]:
        isFail = True
        break
print("YNeos"[isFail::2])

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

ab_li.sort(key=lambda x: x[1])
ab = []
a = 0
b = 0
h = 0
now = 0

for i in range(n):
    ab = ab_li[i]
    a = ab[0]
    b = ab[1]
    if b != h:
        h = b
    now += a
    if h < now:
        print("No")
        exit(0)

print("Yes")

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

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

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

count = 1
ans = 1
init = ab[0][0]
if ab[0][0] > ab[0][1]:
    ans = 0
for i in range(1, n):
    if init <= ab[i][1]:
        init += ab[i][0]
        count += 1
        if init > ab[i][1]:
            ans = 0
            break
if ans == 0:
    print("No")
else:
    if count == n:
        print("Yes")
    else:
        print("No")

Solution (Python):
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(key=lambda ab: -ab[1])
deadline = AB[0][1]
for a, b in AB:
  if b < deadline:
    deadline = b
  deadline -= a
if deadline < 0:
  print('No')
else:
  print('Yes')

Solution (Python):
from operator import itemgetter

n = int(input())
ab = sorted([list(map(int, input().split())) for _ in range(n)], key=itemgetter(1))

t = 0
for i, j in ab:
    t += i
    if t <= j:
        ans = "Yes"
    else:
        ans = "No"
        break

print(ans)

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

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

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

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

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


def main():
    AB = []
    n = int(input())
    for i in range(n):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB = sorted(AB, key=lambda x: (x[1], -x[0]))
    time = 0
    for span, dead in AB:
        time += span
        if time > dead:
            print('No')
            return
    print('Yes')
    return


if __name__ == "__main__":
    main()

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


def main():
    AB = []
    n = int(input())
    for i in range(n):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB = sorted(AB, key=lambda x: (x[1], -x[0]))
    time = 0
    for span, dead in AB:
        time += span
        if time > dead:
            print('No')
            return
    print('Yes')
    return


if __name__ == "__main__":
    main()

Solution (Python):

from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) 
A = [int(input()) for _ in range(N)] 
lst = [list(map(int,input().split())) for i in range(M)] 
"""

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

lst = sorted(AB, key=lambda x: x[1], reverse=True)
deadline = lst[0][1]

for i in range(N):
  if lst[i][1] < deadline:
    deadline = lst[i][1] - lst[i][0]
  else:
    deadline = deadline - lst[i][0]
  if deadline < 0:
    print('No')
    exit()
else:
    print('Yes')

Solution (Python):
import sys
import heapq

ans = 'Yes'
N = int(input())

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

d.sort(key=lambda x:x[1])
T = 0
for i in range(N):
    T += d[i][0]
    if T > d[i][1]:
        ans = 'No'
        break

print(ans)

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

def main():
    N = int(input())
    X = [list(map(int,input().split())) for _ in range(N)]
    X.sort(key = lambda x:x[1])
    time = 0

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

        if time > X[i][1]:
            print('No')
            return

    print('Yes')

if __name__ == "__main__":
	main()

Solution (Python):
n=int(input())
ab=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[1])
time=0
for a,b in ab:
  if time+a<=b:
    time+=a
  else:
    print('No')
    exit()
print('Yes')

Solution (Python):
import sys

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

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

print("Yes")

Solution (Python):
import sys
n = int(input())
ab = []
for i in range(n):
    a,b = map(int,input().split())
    ab.append([a,b])
ab = sorted(ab,key=lambda x:x[1])
limit = 0
for i in range(n):
    limit += ab[i][0]
    if limit > ab[i][1]:
        print("No")
        sys.exit()

print("Yes")

Solution (Python):
n = int(input())
ba = [0 for _ in range(n)]
for i in range(n):
    ba[i] = list(map(int, input().split()))[::-1]
ba_sort = sorted(ba)
t = 0
for i in range(n):
    t += ba_sort[i][1]
    if t > ba_sort[i][0]:
        print('No')
        exit(0)
print("Yes")

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

    now = 0
    for t, deadline in tasks:
        now += t
        if deadline < now:
            print("No")
            return

    print("Yes")

main()

Solution (Python):
N, *D = map(int, open(0).read().split())
D = list(zip(*[iter(D)]*2))
D = sorted(D, key=lambda x:x[1])
t = 0
f = True
for d in D:
  if t + d[0] <= d[1]:
    t += d[0]
  else:
    f = False
    break
print('Yes' if f else 'No')

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

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

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n = ii()
arr=llint(n)
arr.sort(key=lambda x: x[1])
cnt=0
chk=True
for i,j in arr:
    if cnt + i <=j:
        cnt +=i
    else:
        chk=False
if chk:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
l_2d = []
for i in range(N):
  l_2d.append(list(map(int,input().split())))
l_2d.sort(key=lambda x: x[1], reverse=False)
A=0
ANS='Yes'
for l in l_2d:
  A += l[0]
  if l[1] < A:
    ANS = 'No'
    break
print(ANS)

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

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

Solution (Python):
N = input()
A = [0]*N
B = [0]*N
for i in range(N):
  A[i], B[i] = map(int, raw_input().split())

AB = zip(B, A)
AB.sort()
x = 10**9
for b, a in AB[::-1]:
  x = min(x, b)-a
print "Yes" if x>=0 else "No"

Solution (Python):
N = int(input())
task = []
for _ in range(N):
    A,B = map(int,input().split())
    task.append([A,B])
task.sort(key=lambda task:task[1])

time = 0
ans = "Yes"
for i in range(N):
    A = task[i][0]; B = task[i][1]
    if time + A <= B:
        time += A
    else:
        ans = "No"
        break

print(ans)

Solution (Python):
import heapq
DEADLINE = 0
REQTIME = 1

ans = "Yes"

N = int(input())
min_heap = []
for i in range(N):
    job = [int(x) for x in input().split()]
    job = tuple((job[1], job[0]))
    heapq.heappush(min_heap, job) 

t = 0 
for _ in range(N): 
    job = heapq.heappop(min_heap)
    t += job[REQTIME]
    if t > job[DEADLINE]:
        ans = "No"
        break

print(ans)

Solution (Python):
n = int(input())
ba_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')

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

Solution (Python):
import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
AB = []
for s in inputs[1:]:
    a, b = map(int, s.split())
    AB.append((a, b))
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):
N = int(input())
tasks = []
for i in range(N):
    D = list(map(int,input().split()))
    tasks.append(D)
tasks.sort(key=lambda x:x[1])
time = 0
total = 0
for i in range(N):
    total += tasks[i][0]
    if total>tasks[i][1]:
        print('No')
        break
else:
    print('Yes')

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

now=0
for job in S:
    now+=job[0]

    if now > job[1]:
        print("No")
        exit()

print("Yes")

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

jobs.sort(key=lambda j: j[1])
curr_jour = 0

can = True
for j in jobs:
    curr_jour += j[0]
    if curr_jour > j[1]:
        can = False
        break

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

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

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

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

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

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

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

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

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

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

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

sum_a = 0
for a, b in AB:
  sum_a += a
  if sum_a > b:
    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])

sum_a = 0
for a, b in AB:
  sum_a += a
  if sum_a > b:
    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])
t=0
for ab in AB:
  a=ab[0]
  b=ab[1]
  t+=a
  if b<t:
    print("No");exit()
print("Yes")