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):
class Megalomania:
    def __init__(self):
        N = int(input())
        self.T = []
        for i in range(N):
            self.T.append([int(n) for n in input().split()])

    def main(self):
        sum_time = 0

        for task in sorted(self.T, key=lambda x: x[1]):
            sum_time += task[0]
            if sum_time > task[1]:
                print("No")
                return

        print("Yes")


megalomania = Megalomania()
megalomania.main()

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

time = [0] * N

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



time.sort(key=lambda A : A[1])

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

Solution (Python):
import heapq

N = int(input())
tasks = []

fin = 0
for _ in range(N):
    A, B = map(int, input().split())
    fin = max(fin, B)
    heapq.heappush(tasks, (-B, A, B))

now = fin

while len(tasks)>0:
    _, time, deadline = heapq.heappop(tasks)
    now = min(deadline, now)
    now -= time

if now >= 0:
    print("Yes")
else:
    print("No")

Solution (Python):


import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
        tokens = lines[0].split(" ")
        n = int(tokens[0])
        for i in range(n):
            lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
        tokens = lines[0].split(" ")
        n = int(tokens[0])

    ab_list = []
    for i in range(1, n+1):
        tokens = lines[i].split(" ")
        a = int(tokens[0])
        b = int(tokens[1])
        ab_list.append((a, b))

    return (n, ab_list)


def solve(n, ab_list):


    ab_list.sort(key = lambda e: e[1])

    sum = 0
    result = "Yes"
    for i in range(n):
        e = ab_list[i]
        sum = sum + e[0]
        if sum > e[1]:
            result = "No"
            break

    return result


def main():
    

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()

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

Solution (Python):

if __name__=='__main__':
    N = int(input())
    AB = []
    worktime = 0
    answer = 'Yes'
    for i in range(N):
        a,b= map(int,input().split())
        AB.append((a,b))
    AB.sort(key=lambda x:x[1])
    for i in range(N):
        worktime +=AB[i][0]
        if worktime > AB[i][1]:
            answer = 'No'
            break
    print(answer)

Solution (Python):
import sys
N = int(input())
li = [None] * N
for i in range(N):
  li[i] = list(map(int,input().split()))
li = sorted(li, key = lambda x:x[1])

t = 0
for l in li:
  t += l[0]
  if t > l[1]:
    print("No")
    sys.exit()
print("Yes")

Solution (Python):
from sys import stdin
import numpy as np
N = int(stdin.readline().rstrip())
ab = [[None] * 2] * N
work = np.array(ab)

for i in range(N):
    input = stdin.readline().split()
    work[i][0], work[i][1] = int(input[0]), int(input[1])


work_sort_b = work[np.argsort(work[:,1])]


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

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

time = 0
ans = 'Yes'
for v in sls:
    time += v[0]
    if time > v[1]:
        ans = 'No'
print(ans)

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

for i in range(n):
  Sum += S[i][0]
  if Sum > S[i][1]:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
import sys
from collections import deque
stdin = sys.stdin

def ii(): return int(stdin.readline())
def li(): return map(int, stdin.readline().split())
N = ii()
infos = [ tuple(li()) for i in range(N) ]
infos.sort(key=lambda x:x[1])
def do(infos):
    works = deque()
    time = 0
    used = 0
    for t, e in infos:
        time += t
        works.append( (t, e) )
        while works and time >= works[0][1]:
            deadline = works[-1][1]
            lt, le = works.popleft()
            if deadline < time:
                return "No"

    return "Yes"
print(do(infos))

Solution (Python):
N = int(input())
works = []
for i in range(0, N):
	works.append(list(map(int, input().split())))
works.sort(key = lambda v: v[1])
now = 0
for i in range(0, N):
	now += works[i][0]
	if works[i][1] < now:
		print('No')
		break
	if i == N-1:
		print('Yes')

Solution (Python):
from operator import itemgetter
n=int(input())
l = []
for i in range(n):
	l.append(list(map(int,input().split())))
l.sort(key=itemgetter(1))
t=0
for pair in l:
	t+=pair[0]
	if(t>pair[1]):
		print("No")
		exit()
print("Yes")

Solution (Python):
n = int(input())
ab_ls = []
for i in range(n):
    ab_ls.append(list(map(int, input().split())))
ab_ls.sort(key=lambda x:x[1])
hoge = 0
result = True
for i in ab_ls:
    hoge = hoge + i[0]
    if hoge > i[1]:
        result = False
if result:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
AB = sorted([[int(_) for _ in input().split()] for _ in range(N)],
            key=lambda xs: xs[1])
t = 0
for ab in AB:
    t += ab[0]
    if t > ab[1]:
        print('No')
        exit()
print('Yes')

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


listC = []
while True:     
  try:         
    
    
    
    listC.append(list(map(int,input().split())))
  except:         
    break; 





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

time = 0
ans = "Yes"
for i in range(N):
  time += listC[i][0]
  if time <= listC[i][1]:
    continue
  else:
    ans = "No"
    break
print(ans)

Solution (Python):
N = int(input())
AB = []
for i in range(N):
    A, B = map(int, input().split())
    AB.append([A,B])
AB_list = AB
AB_list.sort(key=lambda x:x[0])
AB_list.sort(key=lambda x:x[1])
flag = True
task = 0
for i in range(N):
    task += AB_list[i][0]
    if task>AB_list[i][1]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
job = {}
for i in range(0, N):
    a, b = map(int, input().split())
    if b not in job:
        job[b] = []
    job[b].append(a)


job_sorted = sorted(job.items(), key=lambda x: x[0])


time = 0
for value in job_sorted:
    
    deadline = value[0]
    require = value[1]
    require.sort()
    for i in range(0, len(require)):
        time += require[i]
        
        if time > deadline:
            print('No')
            exit()
print('Yes')

Solution (Python):
l=int(input())
a=[]
for i in range(l):
  m,n=(int(i) for i in input().split())
  a.append([n,m])
a.sort()
r="Yes"
s=0
for i in range(l):
  s=s+a[i][1]
  if s>a[i][0]:
    r="No"
    break
print(r)

Solution (Python):
n = int(input())
a = sorted([tuple(map(int, input().split())) for _ in range(n)], key=lambda x: (x[1], -x[0]))
total = 0
for time, deadline in a:
    total += time
    if total > deadline:
        print('No')
        exit()
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])
check=0
sum=0
for i in range(N):
    sum+=a[i][0]
    if sum>a[i][1]:
        check+=1
if check>0:
    print("No")
else:
    print("Yes")

Solution (Python):
n = int(input())
tasks = [[int(x) for x in input().split()] for _ in range(n)]
tasks_sorted = sorted(tasks, key=lambda x:x[1])
task = 0
ret = "Yes"
for i in range(len(tasks_sorted)):
    task += tasks_sorted[i][0]
    if task > tasks_sorted[i][1]:
        ret = "No"
        break
print(ret)

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

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


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


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

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

tasks = []

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

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

worked = 0
for i in range(n):
    a, b = by_due[i]
    worked += a
    if worked > b:
        print('No')
        break
else:
    print('Yes')

Solution (Python):

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

Solution (Python):
n = int(input())
nums = []
time = 0
check = True
for i in range(n):
    a,b = map(int,input().split())
    nums.append((a,b))
nums.sort(key=lambda x:x[1])
for n in nums:
    time+=n[0]
    if time>n[1]:
        check = False
if check==True:
    print("Yes")
else:
    print("No")

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

Solution (Python):
from operator import itemgetter
from itertools import accumulate
import numpy as np
N = int(input())
work = []
for i in range(N):
  a, b = map(int, input().split())
  work.append([a, b])

work = sorted(work, key=itemgetter(1,0))
work = np.array(work)

ans = "Yes"
for idx, time in enumerate(list(accumulate(work[:,0]))):
  if time > work[idx,1]:
    ans = "No"
    break

print(ans)

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

maps = [map(int, input().split(' ')) for _ in range(0, num_task)]
tasks = [(b, a) for a, b in maps]
tasks.sort()


current_time = 0

for deadline, time_needed in tasks:
    end_time = current_time + time_needed

    if end_time > deadline:
        print("No")
        break

    current_time = end_time

else:
    print("Yes")

Solution (Python):
import fractions


inp = int(input())

task = []
for e in range(inp):
    task.append([int(i) for i in input().split()])

so = sorted(task,key=lambda x:x[1])
ti = 0

for dd in so:
    ti = dd[0] + ti
    if ti <= dd[1]:
        pass
    else:
        print('No')
        exit()

print('Yes')

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

f = 0
sum = 0
for i in range(n):
    sum += li[i][1]
    if li[i][0] < sum:
        f = 1

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

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

tsum = 0
out = 0
for i in range(n):
  tsum += lst[i][0]
  if tsum > lst[i][1]:
    out = 1
    break
if out == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
T = []
for i in range(N):
    a,b = map(int,input().split())
    T.append({'A':a, 'B':b})
T = sorted(T, key=lambda x: x['B'])

ans = 'Yes'
t = 0
for task in T:
    t += task['A']
    if t > task['B']:
        ans = 'No'

print(ans)

Solution (Python):
N = list(map(int, input().split()))
N=N[0]
d={}
def dad(d,a,b):
    if a not in d:
        d[a]=[]
    d[a].append(b)

for x in range(N):
    A,B = list(map(int, input().split()))
    dad(d,B,A)

time=0
flag=0
for item in sorted(d.items()):
    for x in item[1]:
        time+=x
    if not time<=item[0]:
        flag=-1
        break
if flag==0:
    print("Yes")
else:
    print("No")

Solution (Python):

N=int(input())

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

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

time=0
flag=0
for i,j in AB:
    time+=i
    if time>j:
        flag=1
        break
if flag==1:
    print("No")
else:
    print("Yes")

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

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

ans = 0
for x in l:
    ans += x[0]
    if ans > x[1]:
        print('No')
        exit()
print('Yes')

Solution (Python):
import sys

input = sys.stdin.readline
N = int(input())
AB = [tuple(map(int, input().strip().split(' '))) for i in range(N)]
AB.sort(key=lambda x: x[1])
count = 0
for a, b in AB:
    count += a
    if count > b:
        print('No')
        sys.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])

time = 0

for a,b in AB:
    time += a
    if time <= b:
        pass
    else:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
n = int(input())
job = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    inputs = [int(s) for s in input().split()]
    job[i][0] = inputs[1]
    job[i][1] = inputs[0]

sortedJob = sorted(job)
times = 0
breaked = False
for i in range(n):
    times += sortedJob[i][1]
    if times > sortedJob[i][0]:
        breaked = True
        break

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

Solution (Python):
N = int(input())
job = []
for i in range(N):
    A,B = map(int,input().split())
    job.append([B,A])
job = sorted(job)
time = 0
flag = 0
for i in job:
    time += i[1]
    if i[0] < time:
        print('No')
        flag = 1
        break
        
if flag == 0:
    print('Yes')

Solution (Python):
import numpy as np

n = int(input())

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

sum_t = np.cumsum(ab_np[:, 0])


if any(ab_np[:,1]-sum_t < 0):
    print('No')
else:
    print('Yes')

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


A_B = []
for i in range(N):
    a, b = map(int, input().split())
    A_B.append([a,b])
C = sorted(A_B, key=lambda x:x[1])
sum = 0
import sys
for i in range(N):
    sum += C[i][0]
    if sum > C[i][1]:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
N = int(input())
L = [list(map(int, input().split())) for _ in range(N)]
X = {}
for a, b in L:
    if b not in X:
        X[b] = []
    X[b].append(a)
now = 0
for b, Y in sorted(X.items(), key=lambda x: x[0]):
    for a in Y:
        now += a
        if b < now:
            print("No")
            exit()
print("Yes")

Solution (Python):
n=int(input())
work=[]
for i in range(n):
    a,b=map(int,input().split())
    work.append((b,a))
work.sort()
a_sum=0
import sys
for i in work:
    b=i[0]
    a_sum=a_sum+i[1]
    if b<a_sum:
        print('No')
        sys.exit()
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[0])
ab.sort(key=lambda x:x[1])
cur = 0
ans = True
for i in range(N):
    cur += ab[i][0]
    if cur > ab[i][1]:
        ans = False
        break
print("Yes" if ans else "No")

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

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

Solution (Python):
def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    C = zip(A, B)
    C = sorted(C, key=lambda x: x[1])
    A, B = zip(*C)
    t = 0
    ok = True
    for i in range(N):
        t += A[i]
        if t > B[i]:
            ok = False
            break

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


if __name__ == "__main__":
    main()

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

Solution (Python):
N=int(input())
AB=[[0 for i in range(2)] for j in range(N)]
for i in range(N):
    AB[i][0],AB[i][1]=map(int, input().split())
AB=sorted(AB, 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())
AB=[]


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

for i in range(N-1):
    AB[i+1][1]+=AB[i][1]

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

Solution (Python):
from sys import stdin
N = int(stdin.readline().rstrip())
data = []
for _ in range(N):
    data.append([int(x) for x in stdin.readline().rstrip().split()])
data = sorted(data,key=lambda x:x[1])
stack_labor = 0
flag = True
for i in data:
    stack_labor += i[0]
    if stack_labor > i[1]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
from operator import itemgetter
n = int(input())
ab = [input().split() for i in range(n)]
ab = [[int(ab[i][0]),int(ab[i][1])] for i in range(n)]
ab.sort(key=itemgetter(1))
flg = 0
t = 0
for i in range(n):
  t += ab[i][0]
  if t > ab[i][1]:
    flg = 1
    break
if flg == 0:
  print('Yes')
else:
  print('No')

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

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

dic = {}

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

cum = 0    
flag = True
dic_sort = sorted(dic.items(), key=lambda x:x[0])

for bb,aa in dic_sort:
    cum += aa
    if bb < cum:
        flag = False
        break

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

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

ans = "Yes"
c = 0
for i, v in enumerate(ba):
    b, a = v
    c += a
    if c > b:
        ans = "No"
        break
print(ans)

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

BA = []

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

BA.sort()

a = 0

flg = False
for ba in BA:
    b = ba[0]
    a += ba[1]
    if b < a:
        flg = True
        break

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

Solution (Python):
import numpy as np

N = int(input())
tasks = np.empty(shape=(N,2), dtype=np.int64)
for i in range(N):
    a, b = map(int, input().split())
    tasks[i,0] = a
    tasks[i,1] = b
tasks = tasks[np.argsort(tasks[:,1])]

progress = 0
deadline = False
for i in range(N):
    progress += tasks[i,0]
    if progress > tasks[i,1]:
        deadline = True
        break

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

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

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


total = 0
can = True
for (need, limit) in W:

    total += need
    if total > limit:
        can = False
        break
if can:
    print('Yes')
else:
    print('No')

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

flag = True
now = 0
li = sorted(li)

for a, b, c in li:
    now += b
    if now > c:
        print("No")
        flag = False
        break
        
if flag:
    print("Yes")

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

sa = sorted(a, key=lambda x:x[1])
suma = 0
flag = True
for i in range(N):
  suma += sa[i][0]
  if suma > sa[i][1]:
    flag = False
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import defaultdict
N = int(input())
dic = defaultdict(int)

m = 0
B = set()
for i in range(N):
    a,b = map(int,input().split())
    dic[b] += a
    B.add(b)
    if m < b: m = b
B = sorted(B)

flag = True
sub = 0
for b in B:
    sub += dic[b]
    if b-sub < 0:
        flag = False
        break

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

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

AB = sorted(AB, key=lambda x: x[1])
sa = 0
sb = 0
flag = True
for a, b in AB:
    sa += a
    sb = b
    if sa > sb:
        flag = False
        break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):


N = int(input())

task_list = [[0, 0]] * N

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

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

goodjob = True
time = 0
for (a_i, b_i) in sorted_list:
    time += a_i
    if time > b_i:
        goodjob = False
        break

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

Solution (Python):
N = int(input())
d = {}
for i in range(N):
    A, B = map(int, input().split())
    if d.get(B) is None:
        d[B] = [A]
    else:
        d[B].append(A)

ans = 1
works = 0

for k in sorted(d):
    if works + sum(d[k]) > k:
        ans = 0
        break
    works += sum(d[k])
if ans:
    print("Yes")
else:
    print("No")

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

w = [[0 for i in range(2)]for i in range(n)]

ans = "Yes"
total = 0
for i in range(n):
    a,b = map(int, input().split())
    w[i][0] = b
    w[i][1] = -a

w.sort()

for i in range(n):
    total += -1*w[i][1]
    
    if total > w[i][0]:
        ans = "No"
        break

print(ans)

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, A: "List[int]", B: "List[int]"):
    ab = [[A[i],B[i]] for i in range(N)]

    t = 0
    ab = sorted(ab, key=lambda x:x[1])
    for i in range(N):
        t += ab[i][0]
        if(t > ab[i][1]):
            print(NO)
            exit()
        
    print(YES)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    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))
    solve(N, A, B)

if __name__ == '__main__':
    main()

Solution (Python):
from operator import itemgetter
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N)]
flag = True
AB.sort(key = itemgetter(1))
now = 0
for a, b in AB:
    now += a
    if now > b:
        flag = False

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(N: int, A: "List[int]", B: "List[int]"):

    L2 = [(b,b-a,a,b) for a,b in zip(A,B) ]
    L2.sort()

    t = 0
    for l in L2:
        if t > l[1]:
            print(NO)
            return
        t += l[2]

    print(YES)



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    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))
    solve(N, A, B)

if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
import sys

n = int(input())



a = []
b = []

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

a = np.array(a)
b = np.array(b)

sortIndex = np.argsort(b)

a = a[sortIndex]
b = b[sortIndex]

sum = 0
for i in range(n):
    sum += a[i]
    if sum > b[i]:
        print('No')
        sys.exit()

print('Yes')

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

inputlist = sorted(inputlist)

time = 0
ans = 0
for j in range(N):
    time += inputlist[j][1]
    if time > inputlist[j][0]:
        ans = 1

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

Solution (Python):
n = int(input())
sortsecond = lambda val : val[1]
a = []
time = 0
[a.append(list(map(int,input().split()))) for i in range(n)]
b = sorted(a, key=sortsecond)
for o,i in b:
    if time + o <= i:
        time+=o
    else :
        print("No")
        break
else:
    print("Yes")

Solution (Python):
import numpy as np
import itertools
n = int(input())
ab = np.array([[int(i) for i in input().split()] for i in range(n)])
ab = ab[ab[:, 1].argsort(), :]

reqtime = list(itertools.accumulate(ab[:, 0]))
dead = ab[:, 1].tolist()
ans = 'Yes'
for d, r in zip(dead, reqtime):
    if d<r:
        ans  = 'No'
        break
print(ans)

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

l = []
for i in range(N):
    A, B = map(int, input().split())
    l.append((B, A))
l.sort()
    
ans = 0
t = 0
for i in range(N):
    if (t + l[i][1] <= l[i][0]):
        ans += 1
        t += l[i][1]

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

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

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

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

sum = 0
for k,i in enumerate(sorted_lsts):
  sum += i[0]
  if (sum > i[1]):
    print('No')
    break
  if (k == len(sorted_lsts) - 1):
    print('Yes')

Solution (Python):
from functools import cmp_to_key


def cmp(a, b):
    if a[1] == b[1]:
        return 0
    return -1 if a[1] < b[1] else 1

def main():
    N = int(input())
    T = []
    for _ in range(N):
        a, b = map(int, input().split())
        T.append([a, b])
    T2 = sorted(T, key=cmp_to_key(cmp))

    now = 0
    possible = 'Yes'
    for i in range(len(T2)):
        t = T2[i]
        deadline = t[1]
        now += t[0]
        if now > deadline:
            possible = 'No'
            break
    
    print(possible)
    

main()

Solution (Python):


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

now = 0

f = 0
for i in range(n):
    now += ab[i][0]
    if now > ab[i][1]:
        f = 1
        break

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

Solution (Python):
N = int(input())
task = [tuple(map(int, input().split())) for _ in range(N)]
task.sort(key=lambda x:x[1])
done_task = 0
flag = 0
for i in range(N):
  done_task += task[i][0]
  if done_task <= task[i][1]:
    continue
  else:
    flag = 1
    break

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

Solution (Python):
import numpy as np

N=int(input())
A = np.zeros(N)
B = np.zeros(N)
for i in range(N):
    A[i], B[i] = map(int, input().split())
idx = np.argsort(B)
A = A[idx]
B = B[idx]

A = np.cumsum(A)

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

print('Yes')

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

now = 0
for k in range(N):
    if now+G[k][0] > G[k][1]:
        print("No")
        exit(0)
    else:
        now += G[k][0]
print("Yes")

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

ima = 0
gou = 0
for i, j in l:
    ima += i
    if ima > j:
        print("No")
        break
else:
    print("Yes")

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

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

tasks.sort(key=lambda x: x[2])

now = 0
for task in tasks:
	now += task[0]
	if now > task[1]:
		print("No")
		break 
else:
	print("Yes")

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

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


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


t=0
for ab in ABs:
    t+=ab[0]
    if t>ab[1]:
        print('No')
        sys.exit()

print('Yes')

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

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

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

count = 0
flag = 0
for a, b in AB_lis_sorted:
  count += a
  flag += 1
  if count > b:
    print("No")
    break
  if flag == N:
    print("Yes")
    break

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

sum_task=0
for i in range(n):
    sum_task+=info[i][0]
    if sum_task>info[i][1]:
        print("No")
        break
    else:
        if i==n-1:
            print("Yes")

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

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

    time = 0
    count = 0
    for i in range(N):
        flag = True
        a, b = AB[i]
        if time + a <= b:
            time += a
            count += 1
            flag = False
        if flag:
            break

    if count == N:
        print('Yes')
    else:
        print('No')    

if __name__ == "__main__":
    main()

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

for i in range(N):
    tmp_a, tmp_b = input().split(' ')
    tmp_array = [int(tmp_b), int(tmp_a)]
    answer.append(tmp_array)

answer.sort()

now_time = 0

for item in answer:
    now_time += item[1]
    if now_time > item[0]:
        print('No')
        break
else:
    print('Yes')