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 collections
import itertools as it
import math

 

n  = int(input())

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




ba = sorted(ba)


qa = 0
for (b, a) in ba:
    qa += a

    if qa > b:
        print('No')
        break
else:
    print('Yes')

Solution (Python):


N = int(input())

AB = {} 


for i in range(N):
    a, b = map(int, input().split())
    if b in AB: AB[b].append(a)
    else: AB[b] = [a]


time = 0
for s, t in sorted(AB.items(), key=lambda x:x[0]):
    for ti in t:
        time += ti
        if time > s:
            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])
s = 0
for i in ab:
    s += i[0]
    if s > i[1]:
        print("No")
        exit()
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())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(key=lambda x: (x[1], -x[0]))
time = 0
for a, b in AB:
    time += a
    if time > b:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

n = I()
a = [LI() for _ in range(n)]
a.sort(key = lambda x: x[1])
t = 0
for i in range(n):
    t += a[i][0]
    if t > a[i][1]:
        print('No')
        break
else:
    print('Yes')

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

works = list()
for num in range(n):
    a = list(map(int, input().split()))
    works.append(a)

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

time = 0
limit = 0

for row in works:
    time += row[0]
    limit = row[1]
    if time > limit:
        print("No")
        exit()

print("Yes")

Solution (Python):

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

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

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

print('Yes')

Solution (Python):

n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda x: x[1])
a, b = [list(i) for i in zip(*ab)]
import sys
time_sum=0
limit_sum =0

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

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

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

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N)]
ab = sorted(ab, key=lambda x:x[1])
now = 0
for a, b in ab:
  if now + a <= b:
    now += a
  else:
    print('No')
    exit()
print('Yes')

Solution (Python):
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB = sorted(AB, key=lambda x:(x[0]), reverse=True)
AB = sorted(AB, key=lambda x:(x[1]))
time = 0
for ab in AB:
    time += ab[0]
    if time > ab[1]:
        time = -1
        break

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

Solution (Python):


n = int(input())

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

work.sort(key=lambda x: x[1])
for i in range(n - 1):
    work[i + 1][0] += work[i][0]

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

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

d=[]
for i in range(n):
  x,y=map(int,input().split())
  d.append([y,x])
d.sort()
time=0
flag=True
for i in range(n):
  time+=d[i][1]
  if time>d[i][0]:
    flag=False
    break
if flag==True:
  print("Yes")
else:
  print("No")

Solution (Python):
from operator import itemgetter
N = int(input())
AB = []
for _ in range(N):
    A, B = map(int, input().split())
    AB.append([A, B])
AB.sort(key=itemgetter(1))
cnt = 0
for a, b in AB:
    cnt += a
    if cnt > b:
        print("No")
        exit()
print("Yes")

Solution (Python):
n = int(input())
ab_list = [list(map(int,input().split())) 
           for nesya in range(n)]
ab_list = sorted(ab_list,key=lambda x: (x[1],x[0]))
time = 0
for ab in ab_list:
  a = ab[0]
  b = ab[1]
  time += a
  if time <= b:
    pass
  else:
    time = -1
    print('No')
    break
if time > -1:
  print('Yes')

Solution (Python):
import numpy as np

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

t = 0
for i in b_:
    t += A[i]
    if t > B[i]:
        print('No')
        exit()
print('Yes')

Solution (Python):
n = int(input())
mat = [list(map(int, input().split())) for _ in range(n)]
mat.sort(key=lambda x: x[1])
t = 0
for task in mat:
    due = task[1] - t
    if due < task[0]:
        print('No')
        exit()
    else:
        t += task[0]
print('Yes')

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

res = 0
for j, k in task:
    res += j
    if res > k:
        print("No")
        exit()
print("Yes")

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

Solution (Python):
from collections import deque
import sys

n = int(input())

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

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

d = []
d = deque(d)
num = 0
while len(ab) > 0:
	d = deque([])
	d.append(ab.pop())
	while True:
		if len(ab) == 0:
			break
		if ab[-1][1] == d[0][1]:
			d.append(ab.pop())
		else:
			break
	for i in range(len(d)):
		a,b = d.pop()
		num += a
	if num > b:
		print('No')
		sys.exit()

print('Yes')

Solution (Python):
from collections import deque
N = int(input())
A = deque()
for _ in range(N):
    a,b = list(map(int,input().split()))
    A.append([b,a])
A = list(A)
A.sort()
time = 0
for i in A:
    time += i[1]
    if time > i[0]:
        print('No')
        exit()
print('Yes')

Solution (Python):
from collections import deque
N = int(input())
A = deque()
for _ in range(N):
    a,b = list(map(int,input().split()))
    A.append([b,a])
A = list(A)
A.sort()
time = 0
for i in A:
    time += i[1]
    if time > i[0]:
        print('No')
        exit()
print('Yes')

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

works = []

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

    works.append([a,b])

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


flg = 0
for j in range(N):
    if j==0:
        if sorted_works[j][0]>sorted_works[j][1]:
            flg+=1
    else:
        sorted_works[j][0] += sorted_works[j-1][0]

        if sorted_works[j][0]>sorted_works[j][1]:
            flg+=1


if flg==0:
    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()

time=0
for item in ba:
  b=item[0]
  a=item[1]
  
  
  time+=a
  if time>b:
    print("No")
    exit()
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"
t = 0

for i in  range(len(ab)):
    t += ab[i][0]
    if t > ab[i][1]:
        ans = "No"
        break

print(ans)

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

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

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



i=0
time=0
while i<N:
    
    time+=List[i][0]
    
    if not time<=List[i][1]:
        print("No")
        quit()
    
    i+=1
    
print("Yes")

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

t = [[0]*2 for i in range(N)]

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

t.sort()



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

print("Yes")

Solution (Python):
n = int(input())
work = [None] * n
for i in range(n):
    work[i] = tuple(map(int, input().split()))
work = sorted(work, key=lambda x: x[1])
t = 0
f = True
for i, w in enumerate(work):
    t += w[0]
    if t > w[1]:
        f = False
        break
if f:
    print("Yes")
else:
    print("No")

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd

import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
AB = LIR(n)
AB.sort(key=itemgetter(1))
tmp = 0
for a, b in AB:
    if tmp + a <= b:
        tmp += a
    else:
        print("No")
        exit()
print("Yes")

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

    N = int(input())

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

    t = 0
    cond = True
    for a, b in tasks:
        t += a
        if t > b:
            cond = False
            break

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


if __name__ == '__main__':
    main()

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

Max = L[0][1]
for i, j in L:
  Max -= i + max( Max - j, 0 )
if Max >= 0:
  print('Yes')
else:
  print('No')

Solution (Python):


from operator import itemgetter

N = int(input())
AB = []
for i in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))
AB = sorted(AB, key=itemgetter(1), reverse=True)
deadline = AB[0][1]
for i in range(N):
    deadline = min(deadline, AB[i][1]) - AB[i][0]

print('Yes' if 0 <= deadline else 'No')

Solution (Python):


int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def solve():
    n = II()
    C = []
    for i in range(n):
        a, b = MI()
        C.append((a, b))
    C = sorted(C, key=lambda x:x[1])
    

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

if __name__ == '__main__':
    solve()

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

ans = 'Yes'
present_time = 0
for ab in AB:
  present_time += ab[0]
  dead_line = ab[1]
  if present_time > dead_line:
    ans = 'No'
    break

print(ans)

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

li.sort(key=lambda x:x[1])
time = 0
flag = 'Yes'

for i in li:
  time += i[0]
  if i[1]<time:
    flag = 'No'
    break

print(flag)

Solution (Python):
import sys
from operator import itemgetter
import numpy as np
input = sys.stdin.readline


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


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


def main():
    N = readint()
    ab = sorted([list(readnums()) for _ in range(N)], key=itemgetter(1))
    a = np.cumsum(np.array(list(map(lambda x: x[0], ab))))
    b = list(map(lambda x: x[1], ab))
    for A, B in zip(a, b):
        if A > B:
            print('No')
            sys.exit()

    print('Yes')


if __name__ == "__main__":
    main()

Solution (Python):
from collections import deque
import bisect
import sys
sys.setrecursionlimit(10**9)

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

    x = 0
    X.sort(key=lambda x: x[0])
    X = deque(X)
    l = len(X)
    for _ in range(l):
        b,a = X.popleft()
        
        if x + a > b:
            print("No")
            exit()

        x += a

    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])
jikoku=0
for i in range(n):
  jikoku+=ab[i][0]
  if jikoku>ab[i][1]:
    print('No')
    exit()
print('Yes')

Solution (Python):
import sys










stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

n = int(stdin.readline().rstrip())



ab = [list(map(int, stdin.readline().rstrip().split())) for _ in range(n)]
ab.sort(key=lambda x: x[1])
now = 0

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

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 ab in AB:
    a,b = ab[0], ab[1]
    time += a
    if time > b:
        ans = 'No'

print(ans)

Solution (Python):
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor



dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
ab = [readints() for _ in range(n)]

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

tmp = 0
cnt = 0
for i in range(n):

    tmp += ab2[i][0]
    if tmp <= ab2[i][1]:
        cnt += 1
if cnt == n:
    print('Yes')
    exit()
print('No')

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

Solution (Python):
import sys

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

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

M = 0
for k,v in K:
    M += k
    if M > v:
        print("No")
        exit()

print("Yes")

Solution (Python):
N = int(input())
X=[0]*N
for i in range(N):
    X[i] = list(map(int, input().split()))
X.sort(key=lambda x:x[1])
def check():
    now = 0
    for i in range(N):
        now += X[i][0]
        if now > X[i][1]:
            return 'No'
    return 'Yes'
print(check())

Solution (Python):
N = int(input())
L = []

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

count = 0
frag = 0
for i in range(N):
    count += L[i][1]
    if count > L[i][0]:
        print("No")
        frag = 1
        break
if frag == 0:
    print('Yes')

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
ab = [inpl() for _ in range(n)]
ab.sort(key=lambda x:x[1])
now = 0
for a,b in ab:
    now += a
    if now > b:
        print('No')
        break
else:
    print('Yes')

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

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

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

for i in range(N):
    t=L[i]
    a,b=t
    if now+a<=b:
        now+=a
    else:
        print("No")
        exit()

print("Yes")

Solution (Python):
N = int(input())
L = [tuple(map(int,input().split())) for i in range(N)]
X = sorted(L, key = lambda k:k[1])
cnt = 0
ans = True
for i,j in X:
    cnt += i
    if cnt > j:
        ans = False
        break
        
if ans:
    print("Yes")
else:
    print("No")

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


n=I()
lis=[LI() for i in range(n)]
lis.sort(key=lambda x:x[1])

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

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

Solution (Python):
import sys, heapq, bisect, math, fractions
from collections import deque

N = int(input())
AB = [tuple(map(int, input().split())) for _ 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())
a = [list(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x:(x[1],x[0])) 
t = 0
for s,b in a:
    t += s
    if t > b:
        print("No")
        break
else:
    print("Yes")

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

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

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


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

Solution (Python):
n = int(input())
from operator import itemgetter
t = 0
ab = [list(map(int,input().split()))for i in range(n)]
ab.sort(key = itemgetter(1))
for i in range(n):
    a = ab[i][0]
    b = ab[i][1]

    t += a
    if t > b:
        print('No')
        break
else:print("Yes")

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

jobs = []

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

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

time = 0

for i, j in jobs:
    time += i
    if time <= j:
        continue
    else:
        print('No')
        exit()
print('Yes')

Solution (Python):
from sys import stdin
def main():
    
    readline=stdin.readline
    N=int(readline())
    li=[]
    for i in range(N):
        ab=list(map(int,readline().split()))
        li.append(ab)
    
    li.sort(key=lambda x:x[1])
    t=0
    for i in range(N):
        task=li[i]
        t+=task[0]
        if t>task[1]:
            print("No")
            break
    else:
        print("Yes")
if __name__=="__main__":
    main()

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

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

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

C = zip(B, A)
C = sorted(C)
B, A = zip(*C)
ans = 1
t = 0
for i, j in zip(A, B):
    t += i
    if t <= j:
        continue
    else:
        print("No")
        ans = 0
        break
if ans:
    print("Yes")

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

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

Solution (Python):
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right


from functools import reduce
from pprint import pprint

INF = float("inf")

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

n = int(input())
ab = mylistinput(n)

ab = mysort(ab,1,False)


t = 0
for i in range(n):
    a = ab[i][0]
    b = ab[i][1]
    t += a
    if t<=b:
        pass
    else:
        print("No")
        exit()
print("Yes")
exit()

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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

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


if __name__ == '__main__':
    resolve()

Solution (Python):
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1])

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

print(ans)

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
ab = [list(map(int, readline().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')
        break
else:
    print('Yes')

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(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')

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

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

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

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

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

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

print("Yes")

Solution (Python):
N = int(input())
res = 'Yes'
A = [[0 for j in range(2)] for i in range(N)]
for i in range(N):
  A[i][0], A[i][1] = map(int, input().split(' '))
A.sort(key=lambda x: x[1])
A.append([0, 0])
total = 0
i = 0
while i < N:
  while True:
    total += A[i][0]
    if A[i][1] != A[i + 1][1]:
      break
    i += 1
  if A[i][1] < total:
    res = 'No'
    break
  i += 1
print(res)

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

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

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


ab=[[int(x) for x in input().split()]for j in range(n)]
ab.sort(key=lambda x:(x[1],x[0]))

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

Solution (Python):
import numpy as np
from itertools import accumulate

n = int(input())
aa = np.zeros(n, np.int64)
bb = np.zeros(n, np.int64)
for i in range(n):
    aa[i], bb[i] = list(map(int, input().split()))
asums = list(accumulate(aa))

cc = np.argsort(bb)
aa = [aa[c] for c in cc]
aa = np.array(list(accumulate(aa)))
bb.sort()
if (aa > bb).sum()>0:
    print('No')
else:
    print('Yes')

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

import heapq
N = int(input())
tasks = []
heapq.heapify(tasks)
broke = False
cum = 0
for i in range(N):
    A,B = (int(x) for x in input().split())
    if A > B:
        print('No')
        broke = True
        break
    else:
        heapq.heappush(tasks,(B,A))
if broke == False:
    for i in range(N):
        temp = heapq.heappop(tasks)
        cum += temp[1]
        if cum > temp[0]:
            print('No')
            broke = True
            break
    if broke == False:
        print('Yes')

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

import numpy as np
def main():
    N = int(readline())
    tasks = np.array(read().split(), np.int64).reshape((-1, 2))
    tasks = tasks[np.argsort(tasks[..., 1]), ...]
    tasks[..., 0] = np.add.accumulate(tasks[..., 0], axis=0)
    if np.all(tasks[..., 1]-tasks[..., 0]>=0):
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

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

import numpy as np
def main():
    N = int(readline())
    tasks = np.array(read().split(), np.int64).reshape((-1, 2))
    tasks = tasks[np.argsort(tasks[..., 1]), ...]
    tasks[..., 0] = np.add.accumulate(tasks[..., 0], axis=0)
    if (tasks[..., 1]-tasks[..., 0]>=0).all():
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

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

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

import numpy as np
def main():
    N = int(readline())
    tasks = np.array(read().split(), np.int64).reshape((-1, 2))
    tasks = tasks[np.argsort(tasks[..., 1]), ...]
    tasks[..., 0] = np.add.accumulate(tasks[..., 0], axis=0)
    tmp = tasks[..., 1]-tasks[..., 0]
    if np.all(tmp>=0):
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

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

from operator import itemgetter 
def main():
    N = int(readline())
    tasks = []
    for _ in range(N):
        a, b = map(int, readline().split())
        tasks.append((a, b))
    tasks.sort(key=itemgetter(1))
    time = 0
    for a, b in tasks:
        time += a
        if time > b:
            print('No')
            return  
    print('Yes')
if __name__ == '__main__':
    main()