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


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

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

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

Solution (Python):
N=int(input())
AB=list(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 not (t<=b):
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys
import numpy as np

N = int(sys.stdin.readline())
ind = np.fromstring(sys.stdin.read(), dtype='i8', sep=' ').reshape((N, 2))
a = ind[:, 0]
b = ind[:, 1]
arg = np.argsort(b)
a = a[arg]
b = b[arg]
ac = np.add.accumulate(a)
if np.all(b - ac >= 0):
    print('Yes')
else:
    print('No')

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

load=0
for cost,limit in job:
    load+=cost
    if load>limit:
        print("No")
        import sys 
        sys.exit()
print("Yes")

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

    jobs.sort()

    time = 0

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

    print('Yes')


main()

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

N = int(input())

task = [[] for _ in range(N)]
for i in range(N):
    a,b = [int(z) for z in input().split()]
    task[i] = [b,a]

task.sort()

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

print('Yes')

Solution (Python):
from operator import itemgetter


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

info = sorted(info, key = itemgetter(1))
sum1 = 0
for i in range(n):
    sum1 += info[i][0]
    if sum1 > info[i][1]:
        print("No")
        exit()
print("Yes")

Solution (Python):
from operator import itemgetter

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

AB.sort(key=itemgetter(1))

now_time = 0
flag = True
for a, b in AB:
    now_time += a
    if now_time > b:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    s = S()
    for i in range(3):
        if s[i] == s[i + 1]:
            print("Bad")
            return
    print("Good")
    return


def B():
    n, l = LI()
    lis = [l + i for i in range(n)]
    s = sum(lis)
    a = inf
    for i in lis:
        if abs(a) > abs(i):
            a = i
    print(s-a)
    return


def C():
    def gcd(a, b):
        a, b = max(a, b), min(a, b)
        while b:
            a, b = b, a % b
        return a
    def lcm(a, b):
        return a * b // gcd(a, b)
    a, b, c, d = LI()
    x = b // c - (a-1) // c
    y = b // d - (a-1) // d
    z = b // lcm(c , d) - (a-1) // lcm(c , d)
    print(b-a+1-(x+y-z))
    return


def D():
    n = II()
    ab = LIR(n)
    ab.sort(key=lambda x: x[1])
    now = 0
    for a, b in ab:
        now += a
        if now <= b:
            continue
        print("No")
        return
    print("Yes")
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    D()

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

for i in range(n):
    t = list(map(int, input().split()))
    ablist.append(t)

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

t = 0
flag = True
for i in ablist:
    t += i[0]
    if t > i[1]:
        flag = False

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

Solution (Python):
import sys
n = int(sys.stdin.readline())
ab = [list(map(int, sys.stdin.readline().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1])
now = 0
for t in ab:
    now += t[0]
    if now > t[1]:
        print("No")
        quit()
print("Yes")

Solution (Python):
n = int(input())
tasks = []
for i in range(n):
    aa,ba = map(int,input().split())
    tasks.append([aa,ba])

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

now = 0
ok = 1
for i in range(n):
    now += tasks[i][0]
    
    if now > tasks[i][1]:
        ok = 0

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

Solution (Python):
from operator import itemgetter
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
l=sorted(l,key=itemgetter(1))
f=0
ct=0
for i in range(n):
  x=l[i][1]
  ct+=l[i][0]
  if ct>x:
    f=1
    break
if f==1:
  print('No')
else:
  print('Yes')

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    N = II()
    AB = []
    for _ in range(N):
        AB.append(LI())

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

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


main()

Solution (Python):

 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
import time
import sys
from pprint import pprint
import itertools
import fractions

N = int(input())
AB = []
for _i in range(N):
    AB.append([ int(x) for x in input().split() ])
AB = sorted(AB, key=lambda x:x[1])

fail = False
now = 0
for ab in AB:
    a = ab[0]
    b = ab[1]
    now += a
    if now > b:
        fail = True
        break

if fail:
    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])
ans = 'Yes'
time = 0

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

Solution (Python):
n = int(input())
x = [list(map(int, input().split())) for _ in range(n)]
x.sort(key=lambda x: x[1])
t = 0
for a, b in x:
    t += a
    if t > b:
        print('No')
        break
else:
    print('Yes')

Solution (Python):


def Sort(sub_li): 

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

n=int(input())
l=[]
for i in range(0,n):
    p=input().rstrip().split(' ')
    D=[]
    D.append(int(p[0]))
    D.append(int(p[1]))
    l.append(D)
l=Sort(l)
t=0;
G=0;
for i in range(0,len(l)):
    t=t+int(l[i][0])
    if t<=int(l[i][1]):
        continue;
    else:
        G=1;
        break;
if G==0:
    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])

flag = True

now = 0


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

  if now > job[1]:
    flag = False

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

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

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

time = 0
prev_dd = 0
ans = 'Yes'
for t in task_sorted:
    time += t[1] - prev_dd
    prev_dd = t[1]
    time -= t[0]
    if time < 0:
        ans = 'No'
        break
print(ans)

Solution (Python):
def doit(ab):
    ab = sorted(ab, key=lambda x: (x[1], x[0]))
    s = 0
    for a, b in ab:
        s += a
        if s > b:
            return "No"
    return "Yes"

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

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

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

AB.sort()

Asum = 0
check = 0
for i in range(N):
    Asum += AB[i][1]
    if Asum > AB[i][0]:
        check = 1
        break

if check == 0:
    print('Yes')
else:
    print('No')

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])
t=0
for i in range(N):
    t+=AB[i][0]
    if t>AB[i][1]:
        print("No")
        quit()
print("Yes")

Solution (Python):
def main():
    N = int(input())
    work = {}
    for i in range(N):
        A, B = [int(n) for n in input().split()]
        if B not in work:
            work[B] = []
        work[B].append(A)
    times = list(work.keys())
    times.sort()
    cur = 0
    for t in times:
        for w in work[t]:
            cur += w
            if cur > t:
                print("No")
                return
    print("Yes")
main()

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

dat = []

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

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

now = 0
for l,t in dat:
    if now + l > t:
        print("No")
        exit(0)
    else:
        now += l
print("Yes")

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

lst = []
for _ in range(N):
    A, B = 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')

Solution (Python):
from heapq import heappop, heappush

N = int(input())
h = []
res = 'Yes'

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

t = 0
for i in range(N):
    B, A = heappop(h)
    t += A
    if t > B:
        res = 'No'

print(res)

Solution (Python):
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')
        break
else:
    print('Yes')

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n = onem()

s = []

for i in range(n):
    s.append(l())

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
INL = []
for i in range(N):
    a,b = LI()
    INL.append((b,a))
INL.sort()

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

print('Yes')

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]





N = int(input())


C = [0]*(N)

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

C.sort()
ans = "Yes"
cnt = 0
for (b, a) in C:
    cnt += a
    if cnt > b:
        ans = "No"
print(ans)

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

t = 0
ans = 'Yes'
for a_b in ab:
    t += a_b[0]
    if t > a_b[1]:
        ans = 'No'
        break

print(ans)

Solution (Python):
N = int(input())
X = sorted([list(map(int, input().split())) for _ in range(N)], key = lambda x: x[1])
a = [0] * N
a[0] = X[0][0]
for i in range(1, N):
	a[i] = a[i - 1] + X[i][0]
for j in range(N):
	if a[j] > X[j][1]:
		print("No")
		exit()
print("Yes")

Solution (Python):
from collections import deque
from itertools import accumulate
import sys
sys.setrecursionlimit(10**6)
mo=10**9+7

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])
t=0
k=0
for i in range(n):
    a,b=l[i]
    t+=a
    if t>b:
        k=1
        break
    




ans=['Yes','No']
print(ans[k])

Solution (Python):
import sys
N = int(input())
a = []
for i in range(N):
    A, B = map(int, input().split())
    a.append([A, B])
a = sorted(a, key=lambda x:x[1])
ans = 0
for x in a:
    ans += x[0]
    if ans > x[1]:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):
n = int(input())
works = [tuple(int(v) for v in input().split()) for _ in range(n)]

works = sorted(works, key=lambda w: w[1])

sum_a = 0
workable = True
for a, b in works:
    sum_a += a
    if sum_a > b:
        print('No')
        workable = False
        break

if workable:
    print('Yes')

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

A.sort(key=lambda x:x[1])
n = 0
ans = "Yes"

for a in A:
  n += a[0]
  if n > a[1]:
    ans = "No"
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
inpl = lambda: list(map(int,input().split()))
N = int(input())
AB = [ inpl() for i in range(N) ]
AB.sort(key=lambda x: x[1])
totaltime = 0
for time, deadline in AB:
    totaltime += time
    if totaltime > deadline:
        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((b, a))

ba = list(sorted(ab))


now = 0
bad = False
for b, a in ba:
    now += a
    if now <= b:
        pass
    else:
        bad = True
        break

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

Solution (Python):
N = int(input())
BA = [[0,0]for i in range(N)]
flag = True
for i in range(N):
    A,B = map(int,input().split())
    BA[i] = [B,A]
BA.sort()
time = 0
for b,a in BA:
    time += a
    if time > b:
        flag =False
print(["No","Yes"][flag])

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')
        exit()

print('Yes')

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

def f():
    now = 0
    for p, t in W:
        now += p
        if now > t:
            return False
    return True

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

Solution (Python):

N=input()

CC=[]
for _ in xrange(N):
    a,b=list(map(int,raw_input().strip().split(' ')))
    CC+=[(b,a)]

CC=sorted(CC)

pre_sum=0
bad=0
for i in xrange(len(CC)):
    b,a=CC[i]
    pre_sum+=a
    if pre_sum>b:
        bad=1

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

Solution (Python):
N = int(input())
AB = [[int(i) for i in 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')
        break
else :
    print('Yes')

Solution (Python):
import sys


fin = sys.stdin.readline
N = int(fin())
work_list = [[int(elem) for elem in fin().split()] for _ in range(N)]
assert len(work_list[0]) == 2


work_list.sort(key=lambda x: (x[1], x[0]))
cur_past_time = 0

for load, limit in work_list:
    if load + cur_past_time > limit:
        print("No")
        exit(0)
    cur_past_time += load
print("Yes")

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

Tasks.sort()
s = 0
for B,A in Tasks:
    s += A
    if B < s:
        print("No")
        exit()

print("Yes")

Solution (Python):
ab = [[int(x) for x in input().split()][::-1] for _ in range(int(input()))]
ab.sort()
ab.reverse()
d = 10000000000
for b,a in ab:
    b = min(b,d)
    d = b-a
if d < 0:
    print('No')    
else:
    print('Yes')

Solution (Python):
n=int(input())
a_b_list=[]
for i in range(n):
    c, d=map(int, input().split())
    a_b_list.append([c, d])
a_b_list.sort(key=lambda x:x[1])
time=0
flag=0
for i in range(len(a_b_list)):
    time=time+a_b_list[i][0]
    if not time<=a_b_list[i][1]:
        flag=1

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

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

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

Solution (Python):

import sys




















input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())


YES = "Yes"  
NO = "No"  

def iterate_tokens():
    for line in sys.stdin:
        for word in line.split():
            yield word


if __name__ == '__main__':

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

    
    Work = [[A[i], B[i]] for i in range(N)]
    Work.sort(key=lambda x: x[1])
    
    last = 0
    for i in range(N):
        last += Work[i][0]
        if last > Work[i][1]:
            print('No')
            break
        else:
            continue
    else:
        print('Yes')

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

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

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

D = sorted(D, key=lambda x: x[1])
pre = 0
for i in range(N):
    a, b = D[i]
    if pre + a > b:
        print('No')
        exit()
    else:
        pre += a

print('Yes')

Solution (Python):



get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


N = get()
A = getss(N)


A.sort(key=lambda a: a[1])
cur = 0
for i, j in A:
    cur += i
    if cur > j:
        print "No"
        exit()

print "Yes"

Solution (Python):
import numpy as np
n = int(input())

shigoto = np.zeros((n, 2), dtype=int)

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

sorted_shigoto = shigoto[np.argsort(shigoto[:, 1])]

mount = 0
ans = True
for now_shigoto in sorted_shigoto:
    mount += now_shigoto[0]
    if mount > now_shigoto[1]:
        ans = False
        break

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

Solution (Python):
from heapq import *

def main():
  n = int(input())
  ab = []
  for _ in range(n):
    a, b = map(int, input().split())
    ab.append((b, a))
  heapify(ab)
  total = 0
  is_done = True
  while ab:
    _ab = heappop(ab)
    if total + _ab[1] <= _ab[0]:
      total += _ab[1]
    else:
      is_done = False
  if is_done:
    print('Yes')
  else:
    print('No')


if __name__ == '__main__':
  main()

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

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

now = 0
flag = 1
for i in range(N):
    now += a[i][0]
    if now > a[i][1]:
        flag = 0
        break

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

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

out=0
A.sort(key=lambda x:x[1])
t = 0
for i in range(n):
    if t+A[i][0] > A[i][1]:
        out = 1
    else:
        t += A[i][0]
if out==1:
    print("No")
else:
    print("Yes")

Solution (Python):

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

  for c, d in values:
    cost += c

    if d < cost:
      print('No')
      return

  print('Yes')


if __name__ == '__main__':
  main()

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

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()

tasks = []
for i in range(N):
    A, B = nl()
    tasks.append([A, B])

tasks = sorted(tasks, reverse=True, key=lambda x: x[1])
t = tasks[0][1] - tasks[0][0]
for task in tasks[1:]:
    t = min(task[1], t) - task[0]

if t < 0:
    print('No')
else:
    print('Yes')

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

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

jobs = list(tuple(map(int,input().split())) for _ in range(N))



t = 0
for dt, due in sorted(jobs, key= lambda x: x[1]):
    if t + dt > due:
        print('No')
        break
    else:
        t += dt
else:
    print('Yes')

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    arr = [[]] * n
    for i in range(n):
        a, b = map(int, input().split())
        arr[i] = [a, b]
    arr.sort(key = lambda x: x[1])
    ok = 1
    s = 0
    for i in range(n):
        s += arr[i][0]
        if s > arr[i][1]:
            ok = 0
            break
    if ok:
        print("Yes")
    else:
        print("No")
    return 0

main()

Solution (Python):
n = int(input())
ar = [list(map(int, input().split())) for _ in range(n)]
ar.sort(key=lambda x: x[1])
t = 0
for a, b in ar:
    t += a
    if b < t:
        print('No')
        exit(0)
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"

n = 0
for a, b in AB:
  n += a
  if n > b:
    ans = "No"
    break

print(ans)

Solution (Python):
N = int(input())
A, B = (
    zip(*(map(int, input().split()) for _ in range(N))) if N else
    ((), ())
)

a, b = zip(*sorted(zip(A, B), key=lambda t: t[1]))

t = 0
ans = 'Yes'
for x, y in zip(a, b):
    t += x
    if t > y:
        ans = 'No'

print(ans)

Solution (Python):
N = int(input())
ab_arr = []
for _ in range(N):
    ab_arr.append(tuple([int(x) for x in input().split()]))

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

finish = True
time = 0
for a,b in ab_arr:
    time += a
    if time > b:
        finish = False

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

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


rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

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

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

time = 0
res = 0
ans = 1
for a,b in AB:
    if time < b:
        res += (b-time)
        time = b
    if res >= a:
        res -= a
    else:
        ans = 0
        break

yn(ans)

Solution (Python):

N =int(input())
ab =[[int(i)for i in input().split()]for _ in range(N)]
ab.sort(key=lambda x:x[1])
t=0
sta = True
for a,b in ab:
    t += a
    if t > b:
        sta =False
        break
if sta:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
BA = []
for _ in range(N):
    a, b = map(int, input().split())
    BA.append((b, a))
BA.sort()
t = 0
for b, a in BA:
    t += a
    if t > b:
        print("No")
        exit()
print("Yes")

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

ans = "Yes"
time = 0
for a, b in works:
    time += a
    if time > b:
        ans = "No"
        break
print(ans)

Solution (Python):
import sys
n=int(input())
task=[list(map(int,input().split())) for _ in range(n)]
task.sort(key=lambda x:x[1])
time=0
for i in range(n):
    time+=task[i][0]
    if task[i][1]<time:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op



inf = float('inf')
input = stdin.readline


def main():
    n = get_int()
    A, B = get_data(n, [int, int])
    sum = 0
    for a, b in sorted(zip(A, B), key=op.itemgetter(1)):
        sum += a
        if sum > b:
            print("No")
            return
    print("Yes")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


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


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


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

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
ab = [list(li()) for _ in range(n)]

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

cur = 0

ans = True

for ai, bi in ab:
    cur += ai
    if cur > bi:
        ans = False

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

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

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

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

temp_total = 0
for a,b in AB:
  temp_total += a
  if temp_total<=b:
    continue
  else:
    print('No')
    break
else:
  print('Yes')

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

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

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

Solution (Python):
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])
f=True
t=0
for i in range(n):
        t+=l[i][0]
        if t>l[i][1]:
                f=False
                break
print('Yes' if f else 'No')

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