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-----
5
2 4
1 9
1 8
4 9
3 12

-----Sample Output-----
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.

Difficulty: interview

Starter code:

Solutions:
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, ABs):
    ABs.sort(key=lambda x: x[1])
    time = 0
    ans = 'Yes'
    for A, B in ABs:
        time += A
        if time > B:
            ans = 'No'
            break
    print(ans)


def __starting_point():
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    ABs = [[int(i) for i in input().split()] for _ in range(N)]
    # Bs = [int(i) for i in input().split()]
    solve(N, ABs)

__starting_point()

import sys

# D - Megalomania
N = int(input())
jobs = []

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

# 締め切り時刻の順にソート
jobs.sort(key=lambda x:x[1])

time = 0

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

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

print('Yes')

import sys
input = sys.stdin.readline
def main():
   N = int(input())
   T = [list(map(int, input().split())) for i in range(N)] 
   S = [[b, a] for a,b in T]
   U = sorted(S)
   time = 0
   for b, a  in U:
        time += a
        if time > b:
           print('No')
           return
   print('Yes')

def __starting_point():
    main()
__starting_point()

#!/usr/bin/env python3
N, *AB = list(map(int, open(0).read().split()))
AB_sorted = sorted(zip(AB[0::2], AB[1::2]), key=lambda x: x[1])
current = 0
for a, b in AB_sorted:
    current += a
    if current > b:
        print("No")
        return
print("Yes")


import heapq

def solve():
    N = int(input())
    que = []
    for i in range(N):
        a, b = list(map(int, input().split()))
        heapq.heappush(que, (-b, a))
    now = 10 ** 10
    while que:
        b, a = heapq.heappop(que)
        b = -b
        if now > b:
            now = b
        now -= a
        if now < 0:
            return False
    return True

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


def main():
    N = int(input())
    A = []
    for _ in range(N):
        a, b = map(int, input().split())
        A.append(tuple([b,a]))
    A.sort()
    total = 0
    for a, b in A:
        total+=b
        if a < total:
            print('No')
            return
    print('Yes')
main()

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

time_sum = 0
for i in range(n):
    time, limit = al_s[i][0], al_s[i][1]
    time_sum += time
    if limit < time_sum:
        print('No')
        return
else:
    print('Yes')


import numpy as np

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

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

A = [x[0] for x in AB_sort]
B = [x[1] for x in AB_sort]

A_cum = np.array(A).cumsum()

for i in range(N):
    if A_cum[i] > B[i]:
        print('No')
        return

print('Yes')


def main():
    n = int(input())
    ab_lst = [list(map(int, input().split())) for _ in range(n)]

    ba_lst = [0] * n
    for i in range(n):
        a = ab_lst[i][0]
        b = ab_lst[i][1]
        ba = [b, a]
        ba_lst[i] = ba
    ba_lst.sort()

    lst = []
    b = ba_lst[0][0]
    a = ba_lst[0][1]
    for i in range(n):
        b_tmp = ba_lst[i][0]
        a_tmp = ba_lst[i][1]

        if b == b_tmp:
            if i != 0:
                a += a_tmp
            if i == n - 1:
                lst.append([b, a])

        else:
            lst.append([b, a])
            b = b_tmp
            a = a_tmp

    if len(lst) > 1:
        if ba_lst[-1][0] != ba_lst[-2][0]:
            lst.append([ba_lst[-1][0], ba_lst[-1][1]])


    accumulate = 0
    flag = True
    for i in range(len(lst)):
        accumulate += lst[i][1]
        if accumulate > lst[i][0]:
            flag = False
            break

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


def __starting_point():
    main()
__starting_point()

N=int(input())
BA=[]
for _ in range(N):
    A,B=list(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")
        break;
else:
    print("Yes")


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

N=int(input())
l=[]
for _ in range(N):
    ab=list(map(int,input().split()))
    l.append(ab)
l.sort(key=lambda x:x[1])
time=0
flag=True
for i in range(N):
    time+=l[i][0]
    if time>l[i][1]:
        flag=False
        break
if flag==True:
    print('Yes')
else:
    print('No')

from operator import itemgetter
n = int(input())

l = []

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

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


# print(l)

tmp = 0
f = 1
for i,j in l:
  tmp += i
  if tmp > j:
    f = 0

def Y(a,t = 0):
  if a==t : print('YES')
  else : print('NO')
def y(a, t =0):
  if a==t : print('Yes')
  else : print('No')

y(f,1)

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

AB.sort(key=lambda x:x[1])
total=0
for i in range(N):
    total+=AB[i][0]
    if total<=AB[i][1]:
        continue
    else:
        print('No')
        return

print('Yes')

n = int(input())
x = [[0, 0]]
for _ in range(n):
    a, b = map(int, input().split())
    x.append([b, a])
x.sort()
for i in range(1, n + 1):
    x[i][1] += x[i - 1][1]
    if x[i][0] < x[i][1]:
        print("No")
        return
print("Yes")

import numpy as np
n=int(input())
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=map(int,input().split())

flag=True
sum=0
sorted_index=np.argsort(b)
for i in sorted_index:
  sum+=a[i]
  if sum>b[i]:
    flag=False
    break
    
if flag:
  print('Yes')
else:
  print('No')

import itertools
n = int(input())
work_lst = []

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

work_lst.sort(key=lambda x: x[1])
work_acc = [i[0] for i in work_lst]
work_acc = itertools.accumulate(work_acc)
work_dead = [i[1] for i in work_lst]
for x, dead in zip(work_acc, work_dead):
    if x > dead:
        print("No")
        break
else:
    print("Yes")

c=D=0
for b,a in sorted([tuple(map(int,input().split()))[::-1] for _ in range(int(input()))]):
 c+=a
 if b<c:D=1
print('No' if D else 'Yes')

n = int(input())
x = [list(map(int, input().split())) for i in range(n)]
y = []
y = sorted(x, key = lambda x:x[1])
a = 0
for i in y:
    a += i[0]
    if a > i[1]:
        print("No")
        return
print("Yes")


Row = int(input())
List = []
for i in range (Row):
  List.append(list(map(int, input().split())))
List = sorted(List, key=lambda x: x[1])  #[1]に注目してソート
res = 0
flag = True
for i in range(Row):
  res += List[i][0]
  if res > List[i][1]:
    flag = False
    break
if flag:
  print("Yes")
else:
  print("No")

import numpy
N = int(input())
task = numpy.array([list(map(int, input().split())) for _ in range(N)])
task = task[numpy.argsort(task[:, 1])]

ans = 'Yes'

time = 0
for j in task:
    time += j[0]
    if time > j[1]:
        ans = 'No'
        break

print(ans)

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

c=0
D=[]
for a,b in A:
 c+=a
 D.append(c<=b)
print('Yes' if all(D) else 'No')

c=D=0
for b,a in sorted([tuple(map(int,input().split()))[::-1] for _ in range(int(input()))]):
 c+=a
 D|=b<c
print('No' if D else 'Yes')

from operator import *
N = int(input())
AB = [list(map(int,input().split())) for n in range(N)]
AB = sorted(AB,key=itemgetter(1))
ans = "Yes"
T = 0

for a,b in AB:
  T+=a
  if b<T:
    ans = "No"

print(ans)

# -*- coding: utf-8 -*-
"""
Created on Wed Sep 16 12:27:12 2020

@author: liang
"""

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

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

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

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

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

n = ni()
ab = [na() for _ in range(n)]
ab.sort(key=itemgetter(1, 0))
now = 0
ans = 'Yes'
for i in range(n):
    a, b = ab[i]
    now += a
    if now > b:
        ans = 'No'
        break
print(ans)

n = int(input())
t = 0
ab = [list(map(int, input().split())) for i in range(n)]
abt = sorted(ab, key= lambda x:x[1])
for i in range(n):
  t += abt[i][0]
  if t > abt[i][1]:
    print('No')
    return
print('Yes')


import numpy as np
N = int(input())
A_list =[0]*N
B_list =[0]*N
for i in range(N):
    A_list[i],B_list[i] = list(map(int,input().split()))
x = np.argsort(B_list)
A_list = np.array(A_list)[x]
B_list = np.array(B_list)[x]
ans = 0
for i,j in zip(A_list,B_list):
    ans +=i
    if(ans<=j):
        pass
    else:
        print('No')
        return
print('Yes')


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

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

N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[1])
S=0
T=True
for i in range(N):
    S+=A[i][0]
    if A[i][1]<S:
        T=False
if T==True:
    print("Yes")
else:
    print("No")

time=0
n=int(input())
todo=[]*n

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

todo.sort()
d=True

for i in range(n):
  time += todo[i][1]
  if todo[i][0]<time:
    d=False
    break

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

import operator

N = int(input())
work = sorted([tuple(map(int, input().split())) for _ in range(N)], key=operator.itemgetter(1), reverse=True)

t = work[0][1]

for i in range(N):
    if t > work[i][1]:
        t = work[i][1]
    t -= work[i][0]

print(['No', 'Yes'][t >= 0])

n = int(input())
ab = []
now = 0
for i in range(n):
    _a, _b = map(int, input().split())
    ab.append([_a, _b])

ab.sort(key=lambda x: x[1])
for a, b in ab:
    now += a
    if now>b:
        print('No')
        return
print('Yes')

N = int(input())

limit2time = []

for i in range(N):
    time, limit = map(int, input().split())

    limit2time.append((limit, time))

limit2time  = sorted(limit2time, key=lambda x: x[0])

# print(limit2time)
cur = 0
for item in limit2time:
    # print(item)
    key, time = item
    if cur + time > key:
        print("No")
        break
    cur += time
else:
    print("Yes")

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:
  t += ab[0]
  if t > ab[1]:
    print("No")
    break
else:
  print("Yes")

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

N = int(input())
tasks = []
time = 0
ans = "Yes"
for _ in range(N):
  A, B = map(int, input().split())
  tasks.append((B, A))
tasks.sort()
for b, a in tasks:
  time += a
  if b < time:
    ans = "No"
    break
print(ans)

n=int(input())
a=[]
b=[]
for _ in range(n):
    c=list(map(int,input().split()))
    a.append(c[0])
    b.append(c[1])
d=list(zip(b,a))
d.sort()
#print(d)

time=0
for i in range(n):
    time+=d[i][1]
    if d[i][0]<time:
        print("No")
        return
print("Yes")


n = int(input())
ab = []
for _ in range(n):
    ab.append(tuple(map(int,input().split())))

ab = sorted(ab,key=lambda x:x[1])
ans = True
t = 0
for i in range(n):
    t += ab[i][0]
    if t>ab[i][1]:
        ans = False
print("Yes" if ans==True else "No")

n = int(input())
t = []
for i in range(n):
  a, b = map(int, input().split())
  t.append([b, a])
t.sort()
p = 0
ans = 'Yes'
for i in range(n):
  p += t[i][1]
  if p > t[i][0]:
    ans = 'No'
    break
print(ans)

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

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

time = 0

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

print("Yes")

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

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

cnt = 0
for i in range(n):
    cnt += l[i][0]
    if cnt > l[i][1]:
        print("No")
        return

print("Yes")

N = int(input())

work = [[] for i in range(N)]

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

work.sort()
total = 0
for i in range(N):
    total += work[i][1]
    if total > work[i][0]:
        print('No')
        return
print('Yes')

import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())


n = inint()

wt = []

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

wt = sorted(wt, reverse=True, key=lambda x: x[1])[::-1]

t = 0

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

print("Yes")

from operator import itemgetter
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab, key = itemgetter(1))
for i in range(n):
  if ab[i][0] > ab[i][1]:
    print("No")
    return
  if i != n-1:
    ab[i+1][0] += ab[i][0]
  else:
    print("Yes")

import numpy as np

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

ab = np.array(ab)
ab = ab[ab[:, 1].argsort()]

total_time = 0
flag = 0
for _a, _b in zip(ab[:,0], ab[:, 1]):
    total_time += _a
    if total_time > _b:
        flag = 1
        break

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


n = int(input())
task = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x: x[1])

t = 0
for a, b in task:
    t += a
    if t > b:
        print('No')
        return
print('Yes')

def main():
    N = int(input())
    works = []
    for i in range(N):
        A, B = list(map(int, input().split()))
        works.append((A, B))
    
    works.sort(key=lambda x: x[1])

    time = 0
    for i in range(N):
        a, b = works[i]
        time += a
        if time > b:
            print('No')
            return
    print('Yes')

def __starting_point():
    main()

__starting_point()

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	D
# CreatedDate:  2020-09-03 21:15:23 +0900
# LastModified: 2020-09-03 21:29:19 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n = int(input())
    S = []
    for _ in range(n):
        S.append(list(map(int, input().split())))
    S.sort(key=lambda x:x[1])
    current_time = 0
    for s in S:
        current_time += s[0]
        if current_time <= s[1]:
            pass
        else:
            print('No')
            return
    print('Yes')


def __starting_point():
    main()

__starting_point()

N=int(input())
P=[]
for i in range(N):
    a,b=map(int,input().split())
    P.append([b,a])
P=sorted(P)
time=0
for i in range(N):
    time+=P[i][1]
    if time>P[i][0]:
        print('No')
        return
print('Yes')

N=int(input())
li=[]
ans="Yes"
t=0
for i in range(N):
    A,B=list(map(int,input().split()))
    li.append([B,A])
li.sort()

for j in range(N):
    t+=li[j][1]
    if t<=li[j][0]:
        pass
    else:
        ans="No"
        
print(ans)


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

tasks = sorted(tasks, key=lambda x: x[1])
time = 0
for task in tasks:
    time += task[0]
    if time > task[1]:
        print("No")
        return
print("Yes")

n = int(input())
works = {}
for _ in range(n):
    a, b = list(map(int, input().split()))
    if b not in works:
        works.setdefault(b, [a])
    else:
        works[b].append(a)
works = sorted(list(works.items()), key=lambda x: x[0])
total = 0
for key, value in works:
    total += sum(value)
    if total > key:
        print('No')
        break
else:
    print('Yes')


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

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

time=0

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

N = int(input())
jobs = [0]*N
for i in range(N):
    a, b = list(map(int, input().split()))
    jobs[i] = (a, b)

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

now = 0
jobIndex = 0
for i in range(N):
    if now + jobs[i][0] > jobs[i][1]:
        print("No")
        return
    now += jobs[i][0]

print("Yes")


N = int(input())
Dic = dict()
for i in range(N):
    A,B = list(map(int,input().split()))
    if B not in Dic:
        Dic[B] = A
    else:
        Dic[B] += A
Deadlines = sorted(Dic)
Time = 0
for Deadline in Deadlines:
    if Time+Dic[Deadline] <= Deadline:
        Time += Dic[Deadline]
    else:
        Ans = 'No'
try:
    if Ans =='No':
        print(Ans)
except:
    print('Yes')


import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x: x[1])

    ans = 'Yes'
    t = 0
    limit = 0
    for A, B in AB:
        limit = B
        t += A
        if t > limit:
            ans = 'No'
            break

    print(ans)

def __starting_point():
    resolve()

__starting_point()

def main():
	N = int(input())
	tasks = []
	for i in range(N):
		A, B = [int(x) for x in input().split(" ")]
		tasks.append({
			"time" : A,
			"deadline" : B
		})
	tasks.sort(key=lambda task: task["deadline"])
	tot = 0
	in_time = "Yes"
	for i in range(len(tasks)):
		t = tasks[i]["time"]
		d = tasks[i]["deadline"]
		tot += t
		if tot > d:
			in_time = "No"
			break
	print(in_time)

main()

N=int(input())
a=list()
for _ in range(N):
  A,B=list(map(int,input().split()))
  a.append((B,A))
a.sort()
t=0
for i in range(N):
  t+=a[i][1]
  if t>a[i][0]:
    print("No")
    return
print("Yes")


N = int(input())
tasks = []
for i in range(N):
    A, B = [int(x) for x in input().split()]
    tasks.append([B, A])
tasks.sort()

ok = True
S = 0
for i in range(N):
    B, A = tasks[i][0], tasks[i][1]
    S += A
    if S > B:
        ok = False
        break

if ok == True:
    print("Yes")
else:
    print("No")

N=int(input())

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

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

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

N=int(input())
task=[[]]*N
for i in range(N):task[i]=list(map(int,input().split()))
task.sort(key=lambda x: x[1])
t=0
for i in range(N):
    t+=task[i][0]
    if task[i][1]<t:
        print('No')
        return
print('Yes')

N = int(input())

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

sorted_AB = sorted(AB, key=lambda x:(x[1], -x[0]))
worked = 0
for ab in sorted_AB:
  worked += ab[0]
  if worked > ab[1]:
    print('No')
    return

print('Yes')


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

l.sort(key=lambda l:l[1])

t = 0

for i in l:
    t += i[0]
    if(t > i[1]):
        print("No")
        return
print("Yes")

import sys

n=int(input())
ba=[[0]*2 for i in range(n)]
for i in range(n):
    ai,bi=map(int,input().split())
    ba[i]=[bi,ai]
    
ba.sort() 

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

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

A=sorted(A, key=lambda x: x[1])
c=0
D=[]
for a,b in A:
 c+=a
 D.append(c<=b)
print('Yes' if all(D) else 'No')

N=int(input())
li_=[]
for i in range(N):
  A,B=list(map(int,input().split()))
  li_.append((B,A))
li_.sort()
time=0
for i in range(N):
  time+=li_[i][1]
  if time>li_[i][0]:
    print("No")
    return
print("Yes")


n = int(input())
task = []
for i in range(n):
    a,b = map(int,input().split())
    task.append([b,a])
sorted_task = sorted(task)
#print(sorted_task)
isOK = True
ans = 0
for i in range(n):
    ans += sorted_task[i][1]
    #print(sorted_task[i][0],ans)
    if ans > sorted_task[i][0]:
        isOK = False
        break
if isOK:
    print('Yes')
else:
    print('No')

import sys

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

sum = 0

for i in range(n):
  sum += work[i][0]
  if sum > work[i][1]:
      print('No')
      return

print('Yes')

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

t=0
for time,limit in work:
  t+=time
  if t>limit:
    print('No')
    return
print('Yes')


def __starting_point():
    N = int(input())
    tasks = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        tasks.append((b, a))
    tasks.sort()
    t = 0
    for b, a in tasks:
        if t + a > b:
            break
        t += a
    else:
        print("Yes")
        return
    print("No")

__starting_point()

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

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

time = 0
for ai, bi in inputs:
    time += ai
    if time > bi:
        print('No')
        break
    
if time <= bi:
    print('Yes')

N = int(input())
AB = [tuple(map(int,input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])
cnt = 0
for a,b in AB:
    cnt += a
    if cnt > b:
        print("No")
        return
print("Yes")

import heapq

def solve():
    N = int(input())
    que = []
    for i in range(N):
        a, b = list(map(int, input().split()))
        heapq.heappush(que, (b, a))
    now = 0
    while que:
        b, a = heapq.heappop(que)
        now += a
        if now > b:
            return False
    return True

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


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

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key = lambda x: x[1])
time = 0
ans = "Yes"
for i in range(n):
    time += ab[i][0]
    if time <= ab[i][1]:
        continue
    else:
        ans = "No"
        break
print(ans)


# AtCoder Beginner Contest 131
# D - Megalomania

import numpy as np


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

ls.sort(key= lambda x:x[1])
# print(ls)

time=0

for i in range (N):
    time+=ls[i][0]
    if ls[i][1] < time:
        print("No")
        return
    else:
        pass

print("Yes")

n = int(input())
task_time = {}
task_limit = {}
for i in range(1,n+1):
    a,b = list(map(int,input().split()))
    task_time[i] = a
    task_limit[i] = b

task_limit_sorted = sorted(list(task_limit.items()), key=lambda x:x[1])

time = 0
for i in task_limit_sorted:
    time += task_time[i[0]]
    if task_limit[i[0]] < time:
        print ("No")
        exit ()

print ("Yes")


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

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

n = 0
d = 0
f = 0
for i in range(N):
    n += t[i][0]
    if n > t[i][1]:
        f = 1
        break

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

import sys

input = sys.stdin.readline
al = [list(map(int, input().split())) for _ in range(int(input()))]
al = sorted(al, key=lambda x: x[1])
s = 0
for i, j in al:
    s += i
    if s > j:
        print("No")
        break
else:
    print("Yes")

import numpy as np
N = int(input())
AB = ['']*N
for i in range(N):
  AB[i] = list(map(int, input().split()))
#AB = np.array(AB)

AB = sorted(AB, key=lambda x: x[1])
#print(AB)
total = 0
flag = 1
for i in range(N):
  total += AB[i][0]
  if total > AB[i][1]:
    flag = 0
    break
if flag == 1:
  print('Yes')
else:
  print('No')

import pprint
n = int(input())
a = [[0]*2 for i in range(n)]
memo = 0 
ahozon = 0
for i in range(n):
  a[i][0],a[i][1]=map(int,input().split())
a.sort(key=lambda x: x[1])
for j in range(n):
  if(memo<=1):
    if(a[j][1]-a[j][0]-ahozon>=0):
      ahozon+=a[j][0]
    else:
      memo +=1
if(memo>=1):
  print("No")
else:
  print("Yes")

# 52 D - Megalomania
N = int(input())
work = []
for _ in range(N):
    a,b = map(int,input().split())
    work.append((a,b))

# 締め切りが早い順にソート
work = sorted(work,key = lambda x:x[1],reverse = False)

result = 'Yes'
t = 0
for i,j in work:
    t += i
    if t>j:
        result = 'No'
        break
print(result)

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]:
    continue
  else:
    print('No')
    return
print('Yes')

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

c=0
D=1
for a,b in A:
 c+=a
 if b<c:D=0

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

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:
  t += ab[0]
  if t > ab[1]:
    print("No")
    break
else:
  print("Yes")

c=0
D=1
for b,a in sorted([tuple(map(int,input().split()))[::-1] for _ in range(int(input()))]):
 c+=a
 if b<c:D=0

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

from itertools import accumulate
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])
a, b = zip(*ab)
a = list(a)
b = list(b)
a = list(accumulate(a))
for i, j in zip(a, b):
    if i > j:
        print('No')
        break
else:
    print('Yes')

import sys
n=int(input())
l=[]

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

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

c=0
for i in range(n):
    c+=l[i][0]
    if c>l[i][1]:
        print('No')
        return
    else:
        continue

print('Yes')

N = int(input())

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

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

hours = 0

ans = "Yes"
for pair in a:
    hours += pair[0]
    deadline = pair[1]


    if hours > deadline:
        ans = "No"
        break

print(ans)

import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readlines

def main():

    lines = input()
    n = int(lines[0].strip())

    E = [list(map(int, lines[i].split())) for i in range(1, n+1)]
    E = sorted(E, key=lambda x: x[1])

    cur_t = 0

    for i in range(n):
        cur_t += E[i][0]
        if cur_t > E[i][1]:
            print('No')
            return

    print('Yes')

main()

c=0
D=1
for a,b in sorted([tuple(map(int,input().split())) for _ in range(int(input()))], key=lambda x:x[1]):
 c+=a
 if b<c:D=0

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

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

W = sorted(W,key =lambda x:(x[1],x[0]))
now = 0
for w in W:
  #print(now,w[0])
  if now +w[0] > w[1]:
    print("No")
    return
  now+=w[0]
print("Yes")

N = int(input())

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

check = True
sum_A = 0
for j in range(N):
  sum_A += BA[j][1]
  if sum_A > BA[j][0]:
    check = False
    break
    
print("Yes" if check else "No")

def main():
    point = 0
    ab = []
    for i in range(int(input())):
        t = list(map(int, input().split()))
        ab.append(t)
    ab.sort(key=lambda x: x[1])
    for i in range(len(ab)):
        point += ab[i][0]
        # print(point, ab[i])
        if point > ab[i][1]:
            print("No")
            return
    print("Yes")


def __starting_point():
    main()

__starting_point()

import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return list(map(int, input().split()))
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    n = i_input()
    l = [i_list() for i in range(n)]
    l = sorted(l, key= lambda x: x[1])

    trial = 0
    for i,k in l:
        trial += i
        if trial > k:
            print("No")
            return
    print("Yes")


def __starting_point():
    main()

__starting_point()

def main():
    n = int(input())
    adic = dict()
    bdic = dict()

    for i in range(n):
        a, b = map(int, input().split())
        adic[i+1] = a
        bdic[i+1] = b
    
    bdic2 = sorted(bdic.items(),key = lambda x:x[1])
    time = 0

    for dic in bdic2:
        shigoto = dic[0]
        time += adic[shigoto]
        if time > dic[1]:
            print("No")
            return
    
    print('Yes')





def __starting_point():
    main()
__starting_point()

n,t=int(input()),0
AB=[list(map(int,input().split())) for _ in range(n)]
AB.sort(key=lambda X: X[1])

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