CodeEff/ECCO huggingface dataset:
# Original solution
n=int(eval(input()))
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(key=lambda x: x[1])
t=0
for i in range(n):
  a,b=ab.pop(0)
  if t+a <= b:
    t += a
  else:
    print('No')
    break
else:
  print('Yes')

# Optimized solution
n=int(eval(input()))
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(key=lambda x: x[1])
t=0
for x in ab:
  if t+x[0] <= x[1]:
    t += x[0]
  else:
    print('No')
    break
else:
  print('Yes')
# Original solution
n = int(eval(input()))
a = []
for i in range(n):
    a.append(list(map(int, input().split())))

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

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

print('Yes')


# Optimized solution
n = int(eval(input()))

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

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

t = 0
for i in range(n):
    t += b[i][0]
    if t > b[i][1]:
        print('No')
        exit()
print('Yes')
# Original solution
def main():
    from itertools import accumulate
    n, *ab = list(map(int, open(0).read().split()))

    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))
    d, f = list(zip(*c))
    
    g = all(i <= j for i, j in zip(accumulate(d), f))
    print(('Yes' if g else 'No'))


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    from itertools import accumulate
    n, *ab = list(map(int, open(0).read().split()))
    c = list(zip(*[iter(ab)] * 2))
    c.sort(key=lambda x: (x[1], x[0]))
    d, f = list(zip(*c))
    for i, j in zip(accumulate(d), f):
        if i > j:
            print('No')
            break
    else:
        print('Yes')


if __name__ == '__main__':
    main()
# Original solution
n =  int(eval(input()))
ls = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    ls.append([b,a])
ls = sorted(ls)
t=0
for i in ls:
    t += i[1]
    if t > i[0]:
        print('No')
        exit(0)
print('Yes')

# Optimized solution
def main():
    n =  int(eval(input()))
    ls = []
    for _ in range(n):
        a, b = list(map(int, input().split()))
        ls.append([b,a])
    ls = sorted(ls)
    t=0
    for i in ls:
        t += i[1]
        if t > i[0]:
            print('No')
            exit(0)
    print('Yes')
if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))

lst = []

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

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

s = 0
for a, b in lst:
    s += a

    if s > b:
        print('No')
        exit()

print('Yes')

# Optimized solution
N = int(eval(input()))

lst = [list(map(int, input().split())) for s in range(N)]
lst = sorted(lst, key=lambda x: x[1], reverse=False)

s = 0
for a, b in lst:
    s += a

    if s > b:
        print('No')
        exit()

print('Yes')
# Original solution
n = int(eval(input()))
b = []
for i in range(n):
    x,y = list(map(int,input().split()))
    b.append([y,x])
b.sort()
ans = 'Yes'
t = 0
for i in range(n):
    t += b[i][1]
    if t>b[i][0]:
        ans='No'
print(ans)


# Optimized solution
n = int(eval(input()))
d = [list(map(int,input().split())) for i in range(n)]
d.sort(key=lambda x: x[1])
ans = 'Yes'
t = 0
for i in d:
    t += i[0]
    if t>i[1]:ans='No'
print(ans)
# Original solution
def bSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j][1] < a[j-1][1]:
                a[j], a[j-1] = a[j-1], a[j]
    return a


N = int(eval(input()))
ab = [list(map(int, input().split())) for i in range(N)]
ab = bSort(ab)
for i in range(N):
    for j in range(i, N):
        ab[j][1] -= ab[i][0]
        if ab[j][1] < 0:
            print("No")
            exit()
print("Yes")


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

print("Yes")
# Original solution
n = int(eval(input()))
a = [0] * n
b = [0] * n

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

for i in range(n):
    if max(b) < sum(a):
        print("No")
        break
    a.pop(b.index(max(b)))
    b.pop(b.index(max(b)))
else:
    print("Yes")


# Optimized solution
n = int(eval(input()))
a = [[0,0]] * n
time = 0

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

a.sort()
for i,j in a:
    time += j
    if i < time:
        print("No")
        break
else:
    print("Yes")
# Original solution
n=int(eval(input()))
a=[0]*n
b=[0]*n
for i in range(n):
  a[i],b[i]=list(map(int,input().split()))

for i in range(n):
  suma=sum(a)
  maxb=max(b)
  if suma<=maxb:
    index=b.index(maxb)
    del a[index]
    del b[index]
  else:
    print('No')
    exit()
print('Yes')


# Optimized solution
n = int(eval(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")
# Original solution
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in range(n)]

ab.sort(key=lambda i: i[1])
t = 0
for i in ab:
  t += i[0]
  if t > i[1]:
    print("No")
    exit()
print("Yes")

# Optimized solution
n = int(eval(input()))
ab = sorted([list(map(int, input().split())) for _ in range(n)], key = lambda i: i[1])

t = 0
for i in ab:
  t += i[0]
  if t > i[1]:
    print("No")
    exit()
print("Yes")
# Original solution
n = int(eval(input()))
ab = sorted([list(map(int, input().split())) for _ in range(n)], key = lambda i: i[1])

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

# Optimized solution
n = int(eval(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")
    exit()
print("Yes")
# Original solution
#import sys
#input = sys.stdin.readline
def main():
    N = int( eval(input()))
    T = [ (0,0)]*N
    for i in range(N):
        a, b = list(map( int, input().split()))
        T[i] = (b,a)
    T.sort()
    time = 0
    ans = "Yes"
    for i in range(N):
        time += T[i][1]
        if time > T[i][0]:
            ans = "No"
            break
    print(ans)
if __name__ == '__main__':
    main()


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


N = int(eval(input()))
jobs = []
for i in range(N):
    jobs.append(list(map(int, input().split())))
           
time = 0
result = "Yes"
jobs.sort(key=lambda x:x[1])

while jobs:
    job = jobs.pop(0)
    time += job[0]
    if(time > job[1]):
        result = "No"
        break

print(result)

    


# Optimized solution


N = int(eval(input()))
jobs = []
for i in range(N):
    jobs.append(list(map(int, input().split())))
           
time = 0
result = "Yes"
jobs.sort(key=lambda x:x[1])

for job in jobs:
    time += job[0]
    if(time > job[1]):
        result = "No"
        break

print(result)
# Original solution
n = int(eval(input()))
T = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    T.append((a, b))
T = sorted(T, key=lambda x: x[1])[::-1]
d = [0] * n
d[0] = T[-1][0]
for i in range(n-1):
    d[i + 1] = d[i] + T[::-1][i + 1][0]
d = d[::-1]

f = 0
for i, (a, b) in enumerate(T):
    if b < d[i]:
        f = 1
        break
if f == 0:
    print('Yes')
else:
    print('No')


# Optimized solution
n = int(eval(input()))
T = []
s = 0
for _ in range(n):
    a, b = list(map(int, input().split()))
    T.append((a, b))
    s += a
T = sorted(T, key=lambda x: x[1])[::-1]
f = 0
for i, (a, b) in enumerate(T):
    if b < s:
        f = 1
        break
    s -= a
if f == 0:
    print('Yes')
else:
    print('No')
# Original solution
# -*- coding: utf-8 -*-


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

    for ai, bi in mod_ab:
        time += ai

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

    print('Yes')


if __name__ == '__main__':
    main()


# Optimized solution
# -*- coding: utf-8 -*-


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

    for ai, bi in mod_ab:
        time += ai

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

    print('Yes')


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x:x[1])

ok = True
time = 0
for a, b in AB:
  time += a
  if time <= b: continue
  else:
    ok = False
    break
print(("Yes" if ok else "No"))

# Optimized solution
n = int(eval(input()))
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
t = 0
ok = True
for a,b in ab:
  t += a
  if t > b: ok = False
print(("Yes" if ok else "No"))
# Original solution
# 2019-11-14 20:54:46(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

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

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

if __name__ == "__main__":
    main()


# Optimized solution
import sys

n, *ab = list(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)
# Original solution
N = int(eval(input()))

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

lst.sort()
t = 0
for i in range(N):
    t += lst[i][1] #仕事に使う時間をプラス
    if t > lst[i][0]: #制限時間と比較
        print ('No')
        exit()

print ('Yes')


# Optimized solution
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(eval(input()))
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key = lambda x: x[1]) #締め切りが早い順位ソート

tmp = 0
for a, b in AB:
    if tmp + a <= b:
        tmp += a
    else:
        print ('No')
        exit()

print ('Yes')
# Original solution
n = int(eval(input()))
l = []
a = 0
b = 0

for _ in range(n):
    li = list(map(int, input().split()))
    l.append(li)
    a += li[0]
    b = max(b,li[1])
    l = sorted(l, key=lambda x: x[1])


if a > b:
    print('No')
    exit()

count = 0
for i in range(n):
    count += l[i][0]
    if count <= l[i][1]:
        continue
    else:
        print('No')
        exit()
print('Yes')
    

# Optimized solution
n = int(eval(input()))
l = []
a = 0
b = 0

for _ in range(n):
    li = list(map(int, input().split()))
    l.append(li)
    a += li[0]
    b = max(b,li[1])
    
l = sorted(l, key=lambda x: x[1])
if a > b:
    print('No')
    exit()

count = 0
for i in range(n):
    count += l[i][0]
    if count <= l[i][1]:
        continue
    else:
        print('No')
        exit()
print('Yes')
# Original solution
N=int(eval(input()))
AB=[list(map(int,input().split())) for _ in range(N)]
#print(AB)

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

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

# Optimized solution
N = int(eval(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")
# Original solution
import sys
n=int(eval(input()))
ab=[]
for i in range(n):
  AB=[int(x) for x in input().rstrip().split()]
  ab.append(AB)
ab=sorted(ab,key=lambda x :x[0])
ab=sorted(ab,key=lambda x :x[1])

time=0
for a,b in ab:
  if time+a<=b:
    time+=a
  else:
    print("No")
    sys.exit()

print("Yes")

# Optimized solution
import sys
n=int(eval(input()))
ab=[]
for i in range(n):
  AB=[int(x) for x in input().rstrip().split()]
  ab.append(AB)
# ab=sorted(ab,key=lambda x :x[0])
ab=sorted(ab,key=lambda x :x[1])

time=0
for a,b in ab:
  if time+a<=b:
    time+=a
  else:
    print("No")
    sys.exit()

print("Yes")
# Original solution
def main():
    N = int(eval(input()))
    A = []
    B = []
    AB = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        A.append(a)
        B.append(b)
        AB.append((a, b))
    if sum(A) > max(B):
        print('No')
        return
    AB = sorted(AB, key=lambda x: x[1])
    c = 0
    for a, b in AB:
        c += a
        if c > b:
            print('No')
            return
    print('Yes')


main()


# Optimized solution
def main():
    N = int(eval(input()))
    AB = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        AB.append((a, b))
    AB = sorted(AB, key=lambda x: x[1])
    c = 0
    for a, b in AB:
        c += a
        if c > b:
            print('No')
            return
    print('Yes')


main()
# Original solution
import sys
input = sys.stdin.readline

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

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

sum = 0
for cost, limit in ab:
    sum += cost
    if sum > limit:
        print('No')
        break
else:
    print('Yes')


# Optimized solution
import sys
input = sys.stdin.readline

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

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

sum = 0
for cost, limit in ab:
    sum += cost
    if sum > limit:
        print('No')
        break
else:
    print('Yes')
# Original solution
N=int(input().strip())
a=[]
for i in range(N):
    array=list(map(int,input().strip().split()))
    a.append(array)
b=sorted(a, key=lambda x:x[1])
n,t,f=0,0,0
while True:
    t+=b[n][0]
    if t>b[n][1]:
        f=1
        break
    n+=1
    if n==N:
        break
if f==1:
    print('No')
else:
    print('Yes')

# Optimized solution
n=int(eval(input()))
a,f,b=sorted([list(map(int,input().split())) for i in range(n)],key=lambda x:x[1]),1,0
for i in range(n):
    b+=a[i][0]
    if b>a[i][1]:
        f=0
print(('Yes' if f==1 else 'No'))
# Original solution
n = int(eval(input()))
l = []
lb = []
la = []
c = 0
for _ in range(n):
    a,b = list(map(int,input().split()))
    l.append([b,a])
l = sorted(l)
for i in range(0,n):
    lb.append(l[i][0])
    la.append(l[i][1])

for i in range(0,n):
    if lb[i] < sum(la[:i+1]):
        c = 1
        break
    else:
        continue
if c == 0:
    print('Yes')
else:
    print('No')

# Optimized solution
n = int(eval(input()))
l = []
c = 0
d = 0
for _ in range(n):
    a,b = list(map(int,input().split()))
    l.append([b,a])
l = sorted(l)


for i in range(0,n):
    if l[i][0] < d + l[i][1]:
        c = 1
        break
    else:
        d = d+ l[i][1]
        continue
if c == 0:
    print('Yes')
else:
    print('No')
# Original solution
from sys import stdin, exit

N = int(stdin.readline().rstrip())
work = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(N)]

work.sort(key=lambda x: x[1])
time = 0
for k in range(N):
    if time + work[0][0] > work[0][1]:
        print('No')
        exit()
    time += work.pop(0)[0]
print('Yes')


# Optimized solution
from sys import stdin, exit

N = int(stdin.readline().rstrip())
work = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(N)]

work.sort(key=lambda x: x[1])
time = 0
for k in range(N):
    if time + work[k][0] > work[k][1]:
        print('No')
        exit()
    time += work[k][0]
print('Yes')
# Original solution
def main():
    n = int(eval(input()))
    L = [list(map(int,input().split())) for _ in range(n)]
    L.sort(key = lambda x: x[1])
    now = 0
    for l in L:
        now += l[0]
        if now > l[1]:
            print('No')
            return
    print('Yes')
main()

# Optimized solution
def main():
    n = int(eval(input()))
    L = [list(map(int,input().split())) for _ in range(n)]
    L.sort(key = lambda x: x[1])
    time = 0
    for a, b in L:
        time += a
        if time > b:
            print('No')
            return
    print('Yes')
main()
# Original solution
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(eval(input())) for _ in range(n)]

n = int(eval(input()))
lines = sys.stdin.readlines()

works = [None]*n
_ = 0
for l in lines:
    works[_] = tuple(map(int, l.split(" ")))
    _ += 1

works.sort(key=lambda w:w[1], reverse=True)


time = 9999999999999999999999999
for i,w in enumerate(works):
    time = min(time,w[1]) - w[0]

print(("Yes" if time >= 0 else "No"))

# Optimized solution
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

n = int(eval(input()))
lines = sys.stdin.readlines()

works = [None]*n
_ = 0
for l in lines:
    works[_] = tuple(map(int, l.split(" ")))
    _ += 1

works.sort(key=lambda w:w[1], reverse=True)


time = 9999999999999999999999999
for i,w in enumerate(works):
    time = min(time,w[1]) - w[0]

print(("Yes" if time >= 0 else "No"))
# Original solution
def insertionsort(a,A):
    flg=0
    if len(A)>0:
        for i in range(len(A)):
            if A[i][1]==a[1]:
                if A[i][0]>a[1]:
                    A=A[:i]+[a]+A[i:]
                else:
                    A=A[:i+1]+[a]+A[i+1:]
                flg=1
                break
            elif A[i][1]>a[1]:
                A=A[:i]+[a]+A[i:]
                flg=1
                break
    if flg==0:
        A.append(a)
    return A



if __name__ == "__main__":
    N=int(eval(input()))
    work=[]

    for i in range(N):
        W=list(map(int,input().split()))
        work=insertionsort(W,work)
    
    result=work[0][0]
    i=0

    while result<=work[i][1]:
        i+=1
        if i<N:
            result+=work[i][0]
        else:
            break
    if i==N:
        print('Yes')
    else:
        print('No')

# Optimized solution
if __name__ == "__main__":
    N=int(eval(input()))
    work=[]

    for i in range(N):
        W=list(map(int,input().split()))
        work.append(W)
    
    work.sort(key=lambda x:x[1])
    result=0
    flg=0

    for i in range(N):
        result+=work[i][0]
        if result>work[i][1]:
            flg=1
            break
    
    if flg==1:
        print('No')
    else:
        print('Yes')
# Original solution
ABs = []

N = int(eval(input()))
for i in range(N):
    ABs.append(list(map(int,input().split())))

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

sum = 0
for pair in ABs:
    sum += pair[0]
    if sum > pair[1]:
        print('No')
        exit()
print('Yes')

# Optimized solution
ABs = []

N = int(eval(input()))
for i in range(N):
    ABs.append(tuple(map(int,input().split())))

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

sum = 0
for A, B in ABs:
    sum += A
    if sum > B:
        print('No')
        exit()
print('Yes')
# Original solution

N = int(eval(input()))

# (締切, 時間)
DeadlineCost = [] * N

for i in range(N):
    c, d = list(map(int, input().split()))
    DeadlineCost.append((d, c))

DeadlineCost.sort()
#print(DeadlineCost)

t = 0
for i in range(N):
    (d, c) = DeadlineCost.pop(0)

    t += c
    if t > d:
        print('No')
        exit()

print('Yes')

# Optimized solution

N = int(eval(input()))

# (締切, 時間)
DeadlineCost = [] * N

for i in range(N):
    c, d = list(map(int, input().split()))
    DeadlineCost.append((d, c))

DeadlineCost.sort(reverse=True)
#print(DeadlineCost)

t = 0
for i in range(N):
    (d, c) = DeadlineCost.pop()

    t += c
    if t > d:
        print('No')
        exit()

print('Yes')
# Original solution

N = int(eval(input()))

# (締切, 時間)
DeadlineCost = [] * N

for i in range(N):
    c, d = list(map(int, input().split()))
    # tupleじゃなくて array だとどれぐらい遅くなる？
    DeadlineCost.append([d, c])

DeadlineCost.sort(reverse=True)
#print(DeadlineCost)


t = 0
for i in range(N):
    (d, c) = DeadlineCost.pop()

    t += c
    if t > d:
        print('No')
        exit()

print('Yes')

# Optimized solution

N = int(eval(input()))

# (締切, 時間)
DeadlineCost = [] * N

for i in range(N):
    c, d = list(map(int, input().split()))
    DeadlineCost.append((d, c))

DeadlineCost.sort()
#print(DeadlineCost)


t = 0
for i in range(N):
    # .pop じゃなくて参照に変更するとどれぐらい速くなる？
    (d, c) = DeadlineCost[i]

    t += c
    if t > d:
        print('No')
        exit()

print('Yes')
# Original solution
N = int(eval(input()))

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

lst.sort()
lst.sort(key=lambda tup: tup[2])
count = 0
for ind, x in enumerate(lst):
  if count > x[0]:
    print("No")
    exit()
  count += x[1]

print("Yes")


# Optimized solution
N = int(eval(input()))

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

lst.sort(key=lambda tup: tup[2])
count = 0
for ind, x in enumerate(lst):
  if count > x[0]:
    print("No")
    exit()
  count += x[1]

print("Yes")
# Original solution
N=int(eval(input()))
D=[]
x=[]
D = [[0 for i in range(2)] for j in range(N)]#N×"2"の行列Dを作る
for i in range(0,N):
    x=input().split(" ")
    for j in range(0,2):#i行目の成分を入力
        D[i][j]=int(x[j])

D.sort(key=lambda p:p[1])#2列目の成分でソート

x=0
for i in range(0,N):
    x=x+D[i][0]#経過時間
    y=D[i][1]#締め切り時刻
    if x>y:
        n=1
        break
    else:
        z=0
        for j in range(0,N):
            z=z+D[j][0]
            if z<=D[N-1][1]:
                n=0
if n==1:
    print('No')
else:
    print('Yes')


# Optimized solution
N=int(eval(input()))
D=[]
x=[]
D = [[0 for i in range(2)] for j in range(N)]#N×"2"の行列Dを作る
for i in range(0,N):
    x=input().split(" ")
    for j in range(0,2):#i行目の成分を入力
        D[i][j]=int(x[j])

D.sort(key=lambda p:p[1])#2列目の成分でソート

x=0
for i in range(0,N):
    x=x+D[i][0]#経過時間
    y=D[i][1]#締め切り時刻
    if x>y:
        n=1
        break
    else:
        n=0
if n==1:
    print('No')
else:
    print('Yes')