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):
from collections import Counter
from operator import itemgetter
import math
N = int(input())
work_list = [[int(i) for i in input().split()] for i in range(N)]
new_worklist=sorted(work_list, key=itemgetter(1))
now_time = 0
for i in range (N):
	now_time += new_worklist[i][0]
	if now_time > new_worklist[i][1]:
		print("No")
		break
	if i == N-1:
		print("Yes")

Solution (Python):
from collections import defaultdict

N = int(input())
jobs = defaultdict(int)
for i in range(N):
    Ai, Bi = map(int, input().split())
    jobs[Bi] += Ai

acu = 0
able = True
for Bi in sorted(jobs.keys()):
    acu += jobs[Bi]
    if acu > Bi:
        able = False
        break

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

Solution (Python):

def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

n = int(input())
jobs = []

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

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


flag = False
now_limit = 0
past = 0
for i in range(n):
    now_limit = jobs[i][1]
    past += jobs[i][0]
    if past > now_limit:
        flag = True
        break

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

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

Solution (Python):
N = int(input())
Task = []
now = 0
is_clear = 0
for i in range(N):
  a, b = map(int, input().split())
  Task.append((b, a))

Task.sort()

for i in range(N):
  now += Task[i][1]
  if now > Task[i][0]:
    is_clear = 1
    break
if is_clear == 1:
  print("No")
else:
  print("Yes")

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

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

cur = 0
flag = True
for a, b in L:
    cur += a
    if cur > b:
        flag = False
        break

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

Solution (Python):
import sys

fin = sys.stdin.readline
n = int(fin())
ab = [tuple(map(int, fin().split())) for i in range(n)]

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

cum = []
for i in range(n):
    if cum:
        cum.append(cum[-1] + ab[i][0])
    else:
        cum = [ab[i][0]]

for i in range(n):
    if cum[i] > ab[i][1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
def solve():
  N = int(input())
  AB = [[int(i) for i in input().split()] for i in range(N)]
  AB.sort(key=lambda e: e[1])
  time = 0
  for ab in AB:
    a, b = ab
    time += a
    if time > b: return 'No'

  return 'Yes'

print(solve())

Solution (Python):
def foo():
    N = input()
    data = [map(int, raw_input().split()) for _ in range(N)]
    data.sort(key=lambda x: (x[1], x[0]))

    total = 0
    for a, b in data:
        total += a
        if total > b:
            return "No"
    return "Yes"

print foo()

Solution (Python):

from __future__ import division, print_function

import os
import sys
from collections import defaultdict
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    n = int(input())

    d = defaultdict(int)
    for _ in range(n):
        a, b = map(int, input().split())
        d[b] += a

    s = sorted(d.items(), key=lambda x: x[0])
    pf = 0

    for b, a in s:
        pf += a
        if pf > b:
            print("No")
            return

    print("Yes")




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

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

ab = [0]*N

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


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


sum0 = 0
ans = 'Yes'
for i in range(N):
    sum0 += ab[i][0]
    if sum0 > ab[i][1]:
        ans = 'No'
        break

print(ans)

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

    C = sorted(zip(A, B), key=lambda x: x[1])

    cumsum = 0
    for n in range(N):
        cumsum += C[n][0]
        if cumsum > C[n][1]:
            print('No')
            return
    print('Yes')


main()

Solution (Python):
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    ab_list = [tuple(map(int, input().split())) for _ in range(n)]
    ab_list.sort(key=lambda x: x[1])
    time_elapsed = 0
    is_ok = True
    for ab in ab_list:
        time_elapsed = time_elapsed + ab[0]
        if time_elapsed > ab[1]:
            is_ok = False
            break
    if is_ok:
        print("Yes")
    else:
        print("No")

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

Solution (Python):
from operator import itemgetter

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

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

Solution (Python):
n = int(input())
flag = True
a = [[0] * 2 for i in range(n)]
for i in range(n):
    c, b = map(int, input().split())
    a[i][0], a[i][1] = c, b

a = sorted(a, key=lambda x:x[1])
time = 0
for w, lim in a:
    time += w
    if(time > lim):
        flag = False
        break

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

Solution (Python):
def main():
    n = int(input())
    L = []

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

    L.sort()
    sum = 0
    for l in L:
        sum += l[1]
        if sum > l[0]:
            print("No")
            return

    print("Yes")

main()

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

sorted_works = sorted(works, key=lambda x: (x[1], x[0]))

atime = 0
for time, dead in sorted_works:
  atime += time
  if atime > dead:
    print("No")
    break
else:
  print("Yes")

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

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

ab

total_time = 0
for i in range(n):
    total_time += ab[i][0]

flag = True
time = total_time
for i in range(n):
    _ab = ab.pop(-1)

    if time > _ab[1]:
        flag = False
    time -= _ab[0]

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], reverse=True)
limit = ab[0][1] - ab[0][0]
for a, b in ab[1:]:
    limit = min(limit, b) - a
    if limit < 0:
        print("No")
        break
else:
    if limit < 0:
        print("No")
    else:
        print("Yes")

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

BA.sort()

can = True
cum = 0
for ba in BA:
    cum += ba[1]
    if cum > ba[0]:
        can = False
        break

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

Solution (Python):



def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    lt = []
    for _ in range(n):
        a, b = rli()
        lt.append((b, a))
    t = 0
    lt.sort()
    for b, a in lt:
        t += a
        if t > b:
            print("No")
            return
    print("Yes")


if __name__ == '__main__':
    main()

Solution (Python):
import heapq

n = int(input())
q = []
for i in range(n):
  a, b = map(int, input().split())
  heapq.heappush(q, [b, a])

t = 0
for i in range(n):
  b, a = heapq.heappop(q)
  t += a
  if t > b:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
import queue


def megalomania(N: int, tasks: list)->bool:
    que = queue.PriorityQueue()

    for a, b in tasks:
        que.put((b, a))

    time = 0
    while not que.empty():
        b, a = que.get()
        time += a
        if time > b:
            return False

    return True


if __name__ == "__main__":
    N = int(input())
    tasks = [tuple(int(s) for s in input().split()) for _ in range(N)]

    yes = megalomania(N, tasks)
    print('Yes' if yes else 'No')

Solution (Python):
import sys


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

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

ans = 'No'
time = 0
for i, (Ai, Bi) in enumerate(AB):
    time += Ai
    if time > Bi: break
else:
    ans = 'Yes'

print(ans)

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

task = []

for n in range(N):
    a,b = map(int,input().split())
    task.append((b,a))

task.sort()

T = 0

for i in range(N):
    b = task[i][0]
    a = task[i][1]

    T+= a
    if T>b:
        print("No")
        exit()

print("Yes")

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

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

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

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

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

print("Yes")

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

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

AB = sorted(AB, 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())
BA = []
for _ in range(N):
    a, b = map(int, input().split())
    BA.append((b, a))

t = 0
clear = True
for b, a in sorted(BA):
    t += a
    if t > b:
        clear = False
        break

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

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 permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

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()
AB = [LIST() for _ in range(N)]

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

sum_time = 0
for A, B in AB:
	sum_time += A
	if sum_time <= B:  
		continue
	else:
		print("No")
		break
else:
	print("Yes")

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()
loo = []

for i in range(n):
    a,b = na()
    loo.append([b,a])

loo = sorted(loo)

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

print('Yes')

Solution (Python):
N = int(input())
works = [tuple(map(int, input().split())) for i in range(N)]
works.sort(key=lambda x:x[1])

now = 0
ans = "Yes"
for i in range(N):
    now += works[i][0]
    if(works[i][1]<now):
        ans = "No"
        break

print(ans)

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

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

lim = 0
ok = True
for i in range(N):
    lim += task[i][0]
    if lim > task[i][1]:
        ok = False
        break
    if not ok:
        break
if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
n = getN()

works = []
for i in range(n):
    works.append(getList())

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

ans = "Yes"
tmp = 0
for w in works:
    tmp += w[0]
    
    if tmp > w[1]:
        ans = "No"

print(ans)

Solution (Python):
n=int(input())
a=[list(map(int,input().split()))[::-1]for _ in range(n)]
a.sort()
t=0
for i,j in a:
  t+=j
  if i<t:print("No");exit()
print("Yes")

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

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

AB = sorted(AB, 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):
import sys
input = sys.stdin.readline
n=int(input())
T=[]
append=T.append
for i in range(n):
  a,b=map(int,input().split())
  append([a,b])
T.sort(key=lambda x:x[1])
chk=True
t=0
for i in range(n):
  a,b=T[i]
  t+=a
  if t>b:
    chk=False
print("Yes" if chk==True else "No")

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())


from operator import itemgetter
N = ii()
ABs = sorted([tuple(mi()) for _ in range(N)], key=itemgetter(1))

timesum = 0
for a, b in ABs:
  timesum += a
  if timesum>b:
    print('No')
    exit()

print('Yes')

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

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

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

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

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

l=sorted(l,key=lambda x:x[1])
t=0
ans='Yes'
for i in range(n):
    if t+l[i][0]<=l[i][1]:
        t+=l[i][0]
    else:
        ans='No'
print(ans)

Solution (Python):

import sys
INF = float("inf")


def yes():
    print("Yes")  


def no():
    print("No")  


def solve(N: int, A: "List[int]", B: "List[int]"):
    data = list(sorted(zip(B, A)))
    curr = 0
    for i in range(N):
        b, a = data[i]
        curr += a
        if curr > b:
            no()
            return
    yes()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    A = [int()] * (N)  
    B = [int()] * (N)  
    for i in range(N):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, A, B)


if __name__ == '__main__':
    main()

Solution (Python):
import bisect
from operator import itemgetter
import math
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
ab = [IL() for i in range(N)]

ab.sort(key=itemgetter(1))

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

Solution (Python):
def getlist():
	return list(map(int, input().split()))

L = []

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

L = sorted(L)

judge = "Yes"
s = 0
for i in range(N):
	s += L[i][1]
	if L[i][0] < s:
		judge = "No"
		break

print(judge)

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

now = 0
comp = True
for a,b in ab_list:
    now += a
    if now > b:
        comp = False
        break

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

Solution (Python):
n = int(input())
L = []
i = 0
while i < n:
    a,b = map(int,input().split(' '))
    L.append((b,a))
    i += 1
L.sort()
sum_a = 0
f = 0
for l0 in L:
    sum_a += l0[1]
    if l0[0] < sum_a:
        f = 1
        break
if f == 1:
    print('No')
else:
    print('Yes')

Solution (Python):
N = int(input())
taskList = []
for x in range(N):
    ABtuple = tuple(map(int, input().split()))
    taskList.append(ABtuple)

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

Judge = True
time = 0

for x in taskList:
    time += x[0]
    if time > x[1]:
        Judge = False
        break

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

Solution (Python):
import numpy as np
n = int(input())
aa = []
bb = []
for k in range(n):
    a, b = list(map(int, input().split()))
    aa.append(a)
    bb.append(b)





aa = np.array(aa)
bb = np.array(bb)

must_start = bb - aa

s = np.argsort(bb)

must_start = must_start[s]
must_end = bb[s]
aa = aa[s]
ruikei_end = np.cumsum(aa)
must_end  >= ruikei_end

if (must_end  >= ruikei_end).all() == True:
    print("Yes")
else:
    print("No")

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, AB):
    AB.sort(key=lambda x: x[1])
    c = 0
    for a, b in AB:
        if c + a <= b:
            c += a
        else:
            return 'No'
    
    return 'Yes'


def main():
    N = read_int()
    AB = [read_int_n() for _ in range(N)]
    print(slv(N, AB))


if __name__ == '__main__':
    main()

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

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

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

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

n = int(input())

task_list = []

for i in range(n):
    a, b = [ int(v) for v in input().split() ]
    task_list.append([b,a])
task_list = sorted(task_list)

s = 0
for i in range(n):
    s += task_list[i][1]
    task_list[i][1] = s

task_list = [ i[0] >= i[1] for i in task_list ]

if all(task_list):
    ans = "Yes"
else:
    ans = "No"
    
print(ans)

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

BA.sort()

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

print('Yes')

Solution (Python):
n = int(input())
task = [[int(x) for x in input().split()] for i in range(n)]
task.sort(key=lambda x:x[1])
check = True;time = 0
for i in range(n):
    t,f = task[i]
    time += t
    if time <= f:continue
    else:check = False;break
if check:
    print('Yes')
else:
    print('No')

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

X.sort(key=lambda x: (x[1], x[0]))
cnt = 0
for a, b in X:
    if cnt + a <= b:
        cnt += a
    else:
        print('No')
        break
else:
    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 = 'Yes'
s = 0
for i in range(N):
    A,B = AB[i]
    s += A
    if s > B:
        ans = 'No'
print(ans)

Solution (Python):
def check(A, B, raw):
    now = 0
    for i in raw:
        now += A[i]
        if now > B[i]:
            print('No')
            return
    print('Yes')
    return


N = int(input())
A, B = {}, {}
for i in range(N):
    A[i], B[i] = map(int, input().split())
raw = []
for k, v in sorted(B.items(), key=lambda x: x[1]):
    raw.append(k)

check(A, B, raw)

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

total = 0
for a, b in arr:
  total += a
  if b < total:
    print('No')
    exit()
print('Yes')

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

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

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


time = ab_array[0][1]

for ab in ab_array:
    time = min(ab[1],time)
    time -= ab[0]
    if time < 0:
        print("No")
        exit()
else:
    print("Yes")

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

Solution (Python):
from operator import itemgetter

N = int(input())

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

e.sort(key=itemgetter(2))

bl = True
cur = 0
for t, a, b in e:
    if cur <= t:
        cur += a
    else:
        bl = False
        break
print('Yes' if bl else 'No')

Solution (Python):
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations

from itertools import accumulate
from bisect import bisect_left, bisect_right





def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")



N = i_inpl()
L = []

for _ in range(N):
    ab = l_inpl()
    L.append(ab)

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

t = 0
flag = True
for a, b in L:
    t += a
    if t > b:
        flag = False

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

Solution (Python):
n=int(input())
ab=[]
for i in range(n):
    ab.append(list(map(int,input().split())))
ab.sort(key=lambda x:x[1])
l=[]
tmp=0
for i in range(n):
    tmp+=ab[i][0]
    l.append(tmp)

f=False
for i in range(n):
    if l[i]>ab[i][1]:
        f=True

print("YNeos"[f::2])

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

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

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


calc = 0

ans = "Yes"

for i in range(len(L)) :
    a,b = L[i]
    calc += a
    if calc > b :
        ans = "No"
        break
print(ans)

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

inputs = [[int(elm) for elm in input().split(" ")] for i in range(N)]
inputs = sorted(inputs, key=lambda x: x[::-1])



out = "Yes"
tmp = 0
for A, B in inputs:
    tmp += A
    if tmp > B:
        out = "No"
        break

print(out)

Solution (Python):
n = int(input())
ab = [0] * n
for i in range(n):
  ab[i] = [int(j) for j in input().split()]
ab.sort(key=lambda x: x[1])
t = 0
for i in ab:
    t += i[0]
    if t > i[1]:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
lis = []
for i in range(N):
    a,b = Is()
    lis.append([b,a])
lis = sorted(lis)
t = 0
for e in lis:
    t += e[1]
    if e[0] < t:
        print("No")
        exit()
print("Yes")

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from fractions import gcd
from functools import lru_cache, reduce

import numpy as np
from operator import itemgetter

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")


N = int(sys.stdin.readline())
AB = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
AB.sort(key=itemgetter(1))

A, B = zip(*AB)
A = np.array(A).cumsum()
B = np.array(B)

if all(A <= B):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
jobs = sorted([list(map(int, input().split())) for _ in range(N)],
              key=lambda x: x[1])
time = 0
for j in jobs:
    time += j[0]
    if time > j[1]:
        print('No')
        break
else:
    print('Yes')

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

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

t = 0
canDone = True
for _ab in ab:
    t += _ab[0]
    if t > _ab[1]:
        canDone = False
        break
if canDone:
    print("Yes")
else:
    print("No")

Solution (Python):

N=int(input())
a = []
for i in range(N):
    l = tuple(map(int,input().split()))
    a.append(l)
a = sorted(a, key= lambda x: (x[1],x[0]) )
sm = 0
f = True
for aa in a:
    x,y = aa
    sm += x
    if sm > y:
        f = False
        break

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

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

Solution (Python):
n=int(input())
arr=[]
for i in range(n):
    a,b = map(int, input().split())
    arr.append([a,b,i])
arr=sorted(arr, key=lambda x: x[0], reverse=True)
arr=sorted(arr, key=lambda x: x[1])


task=0
ti=0
flag=0
for i in arr:
    task+=i[0]
    ti=i[1]
    
    if task > ti:
        flag=1
        break

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

Solution (Python):

import sys
input = sys.stdin.readline
n = int(input())
ab = []
for _ in range(n):
    a,b = map(int, input().split())
    ab.append((a,b))

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

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

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

works_rev = []
for loop in range(N):
    a, b = list(map(int, input().split()))
    works_rev.append((b, a))

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