Problem:
 Score: 400 points    Problem Statement  Kizahashi, who was appointed as the administrator of ABC at National Problem Workshop in the Kingdom of AtCoder, got too excited and took on too many jobs.  Let the current time be time 0 . Kizahashi has N jobs numbered 1 to N .  It takes A_i units of time for Kizahashi to complete Job i . The deadline for Job i is time B_i , and he must complete the job before or at this time.  Kizahashi cannot work on two or more jobs simultaneously, but when he completes a job, he can start working on another immediately.  Can Kizahashi complete all the jobs in time? If he can, print Yes ; if he cannot, print No .      Constraints   All values in input are integers.  1 \leq N \leq 2 \times 10^5  1 \leq A_i, B_i \leq 10^9 (1 \leq i \leq N)         Input  Input is given from Standard Input in the following format:  N  A_1  B_1  .  .  .  A_N  B_N       Output  If Kizahashi can complete all the jobs in time, print Yes ; if he cannot, print No .        Sample Input 1 5
2 4
1 9
1 8
4 9
3 12      Sample Output 1 Yes  He can complete all the jobs in time by, for example, doing them in the following order:   Do Job 2 from time 0 to 1 .  Do Job 1 from time 1 to 3 .  Do Job 4 from time 3 to 7 .  Do Job 3 from time 7 to 8 .  Do Job 5 from time 8 to 11 .   Note that it is fine to complete Job 3 exactly at the deadline, time 8 .       Sample Input 2 3
334 1000
334 1000
334 1000      Sample Output 2 No  He cannot complete all the jobs in time, no matter what order he does them in.       Sample Input 3 30
384 8895
1725 9791
170 1024
4 11105
2 6
578 1815
702 3352
143 5141
1420 6980
24 1602
849 999
76 7586
85 5570
444 4991
719 11090
470 10708
1137 4547
455 9003
110 9901
15 8578
368 3692
104 1286
3 4
366 12143
7 6649
610 2374
152 7324
4 7042
292 11386
334 5720      Sample Output 3 Yes

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

Solution (Python):
N = int(input())
dic = {}
time = 0
flag = 0

for _ in range(N):
    a, b = map(int, input().split())
    if b in dic:
        dic[b] += a
    else:
        dic[b] = a

deadlines = sorted(dic.keys())

for dead in deadlines:
    time += dic[dead]
    if time > dead:
        flag += 1

if flag:
    print('No')
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])
time = 0

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

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

C = []
for _ in range(N):
    a, b = map(int, input().split())
    C.append((a, b))
C = list(sorted(C, key=lambda x: x[1]))

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

Solution (Python):
n = int(input())
s = [list(map(int,input().split())) for _ in range(n)]
s.sort(key=lambda x:(x[1],x[1]-x[0]))
time = 0
ans = 1
for v in s:
  time += v[0]
  if time > v[1]:
    ans = 0
print('Yes' if ans else 'No')

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

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


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

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

now_index = 0
now_time = 0
while now_index < N:
    deadline = ABs[now_index][1]
    now_time += ABs[now_index][0]
    additional_task = 0
    for i in range(now_index+1, N):
        if ABs[i][1] != deadline:
            break
        else:
            now_time += ABs[i][0]
            additional_task+=1
    now_index += 1
    now_index += additional_task
    if now_time > deadline:
        print("No")
        break
else:
    print("Yes")

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

Solution (Python):
N=int(input())
ba=[list(map(int,input().split()))[::-1]for _ in range(N)]
ba.sort()
 
time=0
ans='Yes'
for b,a in ba:
    time+=a
    if time>b:
        ans='No'
print(ans)

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
W = []
for i in range(N):
	a, b = rl()
	W.append((b, a))
W.sort()

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

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

time=0
ans='Yes'
for b,a in ba:
    time+=a
    if time>b:
        ans='No'
print(ans)

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

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

Solution (Python):
n = int(input())
A = [0]*n
B = [0]*n
dica = {}
dicb = {}
for i in range(n):
    A[i],B[i] = map(int,input().split())
    dica[i] = A[i]
    dicb[i] = B[i]

dicb = sorted(dicb.items(), key = lambda x:x[1])

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

print('Yes')

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd





def solve():
    n = int(input())
    d = []
    for _ in range(n):
        f, s = [int(x) for x in input().split()]
        d.append((s, f))
    d.sort()
    cur = 0
    for b, a in d:
        cur += a
        if cur > b:
            print("No")
            return
    print("Yes")


t = 1

for case in range(1,t+1):
    ans = solve()


"""



"""

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

tasks = []

for _ in range(N):
    a, b = map(int, input().split(' '))
    tasks.append((b, a))

tasks.sort()

t = 0
for b, a in tasks:
    t += a
    if t > b:
        print('No')
        break
else:
    print('Yes')

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

sort_AB = sorted(AB, key= lambda x: x[1])
ans = 'Yes'
tmp = 0

for i in range(N):
    tmp += sort_AB[i][0]
    if tmp > sort_AB[i][1]:
        ans = 'No'
        break
        
print(ans)

Solution (Python):
def resolve():
    '''
    code here
    '''
    N = int(input())
    task = [[int(item) for item in input().split()] for _ in range(N)]

    task.sort(key=lambda x:x[1] ,reverse=True)


    res = task[0][1]
    for time, lim in task:
        if res > lim:
            res = lim
            
        res -= time

    print('Yes') if res >= 0 else print('No')

if __name__ == "__main__":
    resolve()

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

def main(n,ab):
    ab.sort(key=lambda x:x[1], reverse=True)
    t=ab[0][1]
    for i in range(n):
        if ab[i][1]<t:
            t=ab[i][1]
        t=t-ab[i][0]
    if t>=0:
        return 'Yes'
    else:
        return 'No'

if __name__=='__main__':
    n,ab=readinput()
    ans=main(n,ab)
    print(ans)

Solution (Python):
def main():
    n = int(input())
    lim = {}
    for i in range(n):
        a,b = map(int,input().split())
        if b not in lim.keys():
            lim[b] = [a]
        else:
            lim[b].append(a)
    time = 0
    for k in sorted(lim.keys()):
        time += sum(lim[k])
        if time<=k:
            continue
        else:
            print('No')
            return
    print('Yes')

if __name__ == "__main__":
    main()

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

ba.sort()
time = 0
for b, a in ba:
    time += a
    if b < time:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys

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

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

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

Solution (Python):







__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


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

  AB = sorted(AB, key=lambda x: x[1])
  time = 0
  for a, b in AB:
    time += a
    if time > b:
      print('No')
      return
  print('Yes')


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

Solution (Python):

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

n=int(input())
AB=[input_array() for _ in range(n)]

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

ans=0
flag=True
for i in sort_AB:
	ans+=i[0]
	if ans > i[1]:
		flag=False
		break

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations,product

from heapq import heapify,heappop,heappush


from functools import reduce,lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    N = int(input())
    
    
    
    S = list(tuple(map(int, input().split())) for i in range(N)) 

    S.sort(key=itemgetter(1))
    cur=0
    for a,b in S:
        cur+=a
        if b<cur:
            print('No')
            return
        
        

    print('Yes')




if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()

n = readInt()
ab = [readInts() for i in range(n)]
ab.sort(key=lambda x:x[1])
now = 0
for i in ab:
  now+=i[0]
  if now<=i[1]:
    pass
  else:
    print("No")
    exit()

print("Yes")

Solution (Python):
n = int(input())
ablist = [tuple(map(int, input().split())) for _ in range(n)]
ablist.sort(key=lambda x: x[1])

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

Solution (Python):
N=int(input())
d=[]
for _ in range(N):
    d.append(list(map(int,input().split())))
d.sort(key=lambda x:x[1])
sum_d=[0]*N
sum_d[0]=d[0][0]
for i in range(N-1):
    sum_d[i+1]=sum_d[i]+d[i+1][0]

for i in range(N):
    if sum_d[i]>d[i][1]:
        print('No')
        exit()
print('Yes')

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

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

Work.sort(key=lambda x: x[1])
now = 0
for a, b in Work:
    now += a
    if b < now:
        print('No')
        exit()
print('Yes')

Solution (Python):
N=int(input())
Z=[]
for i in range(N):
    Z.append(list(map(int,input().split())))
ct=sorted(Z, key=lambda x:x[1])
ans=0
flag=True
for k in ct:
    ans+=k[0]
    if ans<=k[1]:
        continue
    else:
        flag=False
        break
print('Yes' if flag==True else 'No')

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

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

task.sort()
ans = "Yes"
for i in range(n):
    t += task[i][1]
    if task[i][0] < t:
        ans = "No"
        break

print(ans)

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

cnt = 0
flag = True
for l in li:
  cnt += l[0]
  if cnt > l[1]:
    flag = False
    break
    
if flag:
  print('Yes')
else:
  print('No')

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

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

ab.sort()

time = 0

for b, a in ab:
    time += a
    if b < time:
        print('No')
        exit()
    
print('Yes')

Solution (Python):
N=int(input())
A=[]
B=[]
for n in range(N):
    a,b=map(int,input().strip().split())
    A.append(a)
    B.append((b,n))

B=sorted(B)

sumA=0
fin=True
for n in range(N):
    tmp=B[n][1]
    sumA+=A[tmp]
    if sumA>B[n][0]:
        fin=False
        break

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

Solution (Python):


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


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

print('Yes')

Solution (Python):
import sys
N = int(input())
a, b = [], []
ans = 0

for i in range(N):
    a0, b0 = map(int, input().split())
    a.append(a0)
    b.append(b0)
b, a = zip(*sorted(zip(b, a)))
for i, j in zip(a, b):
    ans += i
    if ans > j:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):

from collections import defaultdict
d=set()
a=defaultdict(list)
n = int(input())
for i in range(n):
    h,m=list(map(int,input().split()))
    a[m].append(h)
    d.add(m)
t=0
r=0

for i in sorted(d):
    for j in a[i]:
        t+=j
    if t>i:
        r=1
        break
if r==1:
    print('No')
else:
    print('Yes')

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

Solution (Python):
def main():
    n =  int(input())
    ls = []
    for _ in range(n):
        a, b = map(int, input().split())
        ls.append([b,a])
    ls.sort()
    t=0
    for i in ls:
        t += i[1]
        if t > i[0]:
            print('No')
            exit(0)
    print('Yes')
if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n =  int(input())
    ls = []
    for _ in range(n):
        a, b = 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()

Solution (Python):
n =  int(input())
ls = []
for _ in range(n):
    a, b = 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')

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    jobs = []
    for i in range(n):
        a,b = map(int,ipt().split())
        jobs.append((b,a))
    jobs.sort()
    t = 0
    for bi,ai in jobs:
        t += ai
        if bi < t:
            print("No")
            exit()

    print("Yes")
    return None

if __name__ == '__main__':
    main()

Solution (Python):
from operator import itemgetter

n = int(input())
ab = [[int(i) for i in input().split()] for _ in range(n)]

ab.sort()
ab.sort(key=itemgetter(1))
t = 0
for a, b in ab:
    t += a
    if t > b:
        print('No')
        break
else:
    print('Yes')

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

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

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

print('Yes')

Solution (Python):
N=int(input())
AB=[list(map(int,input().split())) for i in range(N)]
AB.sort(key=lambda x:x[1])
time=0
for A,B in AB:
    time+=A
    if time>B:
        print("No")
        break
else:
    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])
time=0
for i in range(N):
    time+=AB[i][0]
    if time>AB[i][1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
from operator import itemgetter
n = int(input())
lst = [0] * n
for i in range(n):
  lst[i] = tuple(map(int, input().split()))
lst.sort(key=itemgetter(1))
t = 0
for i in range(n):
  t += lst[i][0]
  if t > lst[i][1]:
    print('No')
    exit()
print('Yes')

Solution (Python):
from operator import itemgetter
n = int(input())
lst = [0] * n
for i in range(n):
  lst[i] = tuple(map(int, input().split()))
lst.sort(key=itemgetter(1))
t = 0
for i in range(n):
  t += lst[i][0]
  if t > lst[i][1]:
    print('No')
    exit()
print('Yes')

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

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

for ab in AB:
    sum_t += ab[0]
    if sum_t > ab[1]:
        print("No")
        exit()

print("Yes")

Solution (Python):
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
a = [LIST() for i in range(n)]
a.sort(key=lambda x:x[1])
time = 0
for i in range(n):
        time += a[i][0]
        if(time>a[i][1]):
                print("No")
                exit()
print("Yes")

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

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

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())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab, key=lambda x:(x[1], x[0]))

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())
ab = [list(map(int,input().split())) for i in range(n)]
ab = sorted(ab, key=lambda x:(x[1], x[0]))

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

abl.sort()
curr = 0
for b,a in abl:
    curr += a
    if curr > b:
        print('No')
        break
else:
    print('Yes')

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

ab = sorted(ab, key=lambda x:(x[1], -x[0]))
count = 0
for i in range(n):
    count += ab[i][0]
    if count > ab[i][1]:
        print("No")
        break
else:
    print("Yes")

Solution (Python):

import datetime
from decimal import Decimal, ROUND_DOWN
import heapq
from fractions import gcd
from functools import reduce
from collections import deque

import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)







n = int(input())








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

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


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

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

Solution (Python):
n = int(input())
data = []

for i in range(n):
    a, b = map(int, input().split())
    data.append([a, b])
data = sorted(data, key = lambda x: x[1])
time = 0
ans = "Yes"
for i in range(n):
    if time + data[i][0] > data[i][1]:
        ans = "No"
    time += data[i][0]
print(ans)

Solution (Python):
def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]
    a.sort(key=lambda x: x[1], reverse=True)
    lim = float("inf")
    for p, q in a:
        if q < lim:
            lim = q
        lim -= p
    if 0 <= lim:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
import numpy as np
n = int(input())
g = []
for _ in range(n):
  a, b = map(int, input().split())
  g.append([a,b])
g = np.array(g)
g = g[np.argsort(g[:, 1])]
a = 0
for i,j in g:
  a+=i
  if a>j:
    print('No')
    exit(0)
print('Yes')

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

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    a_b = []
    for _ in range(n):
        a_b.append(LI())
    a_b.sort(key=lambda x: x[1])
    t = 0
    for d in a_b:
        t += d[0]
        if t > d[1]:
            print("No")
            sys.exit()
    print("Yes")

if __name__ == '__main__':
    main()

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

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

t=0

for a,b in ab:
    t+=a

    if t>b:
        print('No')
        exit(0)

print('Yes')

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
L = []
for i in range(N):
    A,B = I()
    L.append([B,A])
L.sort()
cnt = 0
for i in range(N):
    cnt += L[i][1]
    if cnt > L[i][0]:
        print('No')
        exit()
print('Yes')

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

X.sort(key=lambda x: x[1])
t = 0
ans = "No"
for a, b in X:
    if t + a > b:
        break
    t += a
else:
    ans = "Yes"
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
l = []
for i in range(n):
    a,b = map(int,input().split())
    l.append((b,a))
l.sort()
t = 0
for i in range(n):
    t += l[i][1]
    if t > l[i][0]:
        print('No')
        exit()
print('Yes')

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

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

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

time=0
work=0
count=0

for i in range(N):
    time=brr[i][1]
    work+=brr[i][0]
    if work<=time:
        count+=1
if count==N:
    print("Yes")
else:
    print("No")

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

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

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

max_B = max(B)
sum_A = sum(A)

if (sum_A > max_B):
    print('No')
    exit()
else:
    count = 0
    for i in range(N):
        count += L[i][0]

        if (count > L[i][1]):
            print('No')
            exit()
        else:
            continue

    print('Yes')

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

Solution (Python):
N = int(input())
AB = list()
for _ in range(N):
    ab = list(map(int, input().split()))
    ab.reverse()
    AB.append(ab)
AB.sort()


at = 0
flag = False

for i in range(N):
    bt = AB[i][0]
    at += AB[i][1]
    
    if at > bt:
        flag = True
        break

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

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



time = 0
for t in task:
    limit, required = t
    if time + required > limit:
        print('No')
        break
    time += required
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])
total_time = 0

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

    if total_time > ab[i][1]:
        print('No')
        exit()

print('Yes')

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

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

print('Yes')

Solution (Python):
N = int(input())
C = []
for i in range(N):
  A, B = map(int, input().split())
  C.append([B, A])
C.sort()
a = 0
ans = 'Yes'
for i in range(N):
  if a + C[i][1] <= C[i][0]:
    a += C[i][1]
  else:
    ans = 'No'
    break
print(ans)

Solution (Python):
N = int(input())
lst = []
for i in range(N):
    A,B = map(int,input().split())
    lst.append([B,A])
    
if N == 1:
    print("Yes" if B - A >= 0 else "No")
    exit()
    
lst.sort()  
left = lst[0][0] - lst[0][1]

for i in range(1,N):
    left = left + (lst[i][0] - lst[i-1][0])
    left -= lst[i][1]
    if left < 0:
        print("No")
        exit()
print("Yes")

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

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

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

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

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

main()

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = i()
time = []

for i in range(S):
    a = l()
    a.reverse()
    time.append(a)

time.sort()

pl = 0

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

print("Yes")

Solution (Python):
import sys





import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = ri()
li=[rl() for _ in range(n)]
li.sort(key=lambda x: x[1])
sum_=0
for i in range(n):
    sum_+=li[i][0]
    if sum_>li[i][1]:
        print("No")
        sys.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()    

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

Solution (Python):
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
l=[]
for i in range(n):
    l.append(lmp())
l=sorted(l,key=lambda x:x[1])
t=0
for i in range(n):
    t+=l[i][0]
    if t>l[i][1]:
        print("No")
        exit()
print("Yes")

Solution (Python):
n=int(input())
list=[list(map(int,input().split())) for _ in range(n)]
list1=sorted(list, key=lambda x:x[1])
t=0
for i in range(n):
  t+=list1[i][0]
  if not t<=list1[i][1]:
    print("No")
    break
else:
  print("Yes")

Solution (Python):
def myfunc(e):
  return e[1]
nb = int(input())
liste=[]
for loop in range(nb):
  liste += [[int(x) for x in input().split()]]
liste.sort(key=myfunc)
def mm():
  somme = 0
  for loop in range(len(liste)):
    somme += liste[loop][0]
    if somme>liste[loop][1]:
      return "No"
  return "Yes"
print(mm())

Solution (Python):
N = int(input())
C = {}

for i in range(N):
  a, b = map(int,input().split())
  if b in C.keys():
    C[b] += a
  else:
    C[b] = a
    
time = 0
D = sorted(C.items())

for i in range(len(D)):
  time += D[i][1]
  if time > D[i][0]:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
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])
sum = 0
for a,b in AB:
    sum += a
    if sum > b:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys
n=int(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[1])

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

print("Yes")

Solution (Python):
import sys
n=int(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")