CodeEff/ECCO huggingface dataset:
# Original solution
A = list(map(int, input().split()))
B = []
counter = 0
ans = 0
for X in A:
    B.append(X % 2)
    if X % 2:
        counter += 1
if counter == 1:
    ans += 1
    for i in range(3):
        if not B[i]:
            A[i] += 1

if counter == 2:
    ans += 1
    for i in range(3):
        if B[i]:
            A[i] += 1

for X in A:
    ans += (max(A)-X)//2

print(ans)

# Optimized solution
A = list(map(int, input().split()))
if (max(A)-sum(A)) % 2:
    print(((3 * (max(A) + 1) - sum(A)) // 2))
else:
    print(((3 * max(A) - sum(A)) // 2))
# Original solution
#a,b,c, = map(int,input().split())

a = list(map(int,input().split()))
a.sort(reverse=True)

cnt = 0
while True:
	if a[0] == a[1] == a[2]:
		break
	elif a[0] == a[1] > a[2]:
		if (a[0] - a[2])%2 == 0:
			cnt += (a[0] - a[2])//2
			a[2] = a[0]
		else:
			cnt += (a[0]+1 - a[2])//2
			cnt += 1
			a[0] += 1
			a[1] += 1
			a[2] = a[0]
	elif a[0] > a[1] > a[2]:
		a[1] += 1
		a[2] += 1
		cnt += 1

print(cnt)


# Optimized solution
#和を求める解法
a,b,c = list(map(int,input().split(" ")))
sum = a+b+c
max = max(a,b,c)
if (sum - max)%2 == 0:
    print((int((max*3 - sum)/2)))
else:
    print((int(((max+1)*3 - sum)/2)))
# Original solution
# encoding: utf-8
ABC = sorted(list(map(int, input().split())))

diff0 = ABC[-1] - ABC[0]
diff1 = ABC[-1] - ABC[1]

# +2 only
if diff0 % 2 == diff1 % 2 == 0: ans = (diff0 + diff1) // 2
# +1 (ABC[0], ABC[1]) once and +2
elif diff0 % 2 == diff1 % 2 == 1: ans = (diff0 + diff1) // 2
# +1 (ABC[{0, 1}], ABC[2]) once and +2)
else: ans = 1 + (diff0 + diff1 + 2) // 2

print(ans)

# Optimized solution
# encoding: utf-8
ABC = sorted(map(int, input().split()))

if (ABC[2] - ABC[0]) % 2 == (ABC[2] - ABC[1]) % 2:
    print(((2 * ABC[2] - ABC[1] - ABC[0]) // 2))
else:
    print((1 + (2 * ABC[2] - ABC[1] - ABC[0] + 1) // 2))
# Original solution
a = list(map(int, input().split()))
s, m, b = sorted(a)
cnt = 0
while not b == m == s:
    m_s = m - s
    b_m = b - m
    if m_s % 2 == 0 and m < b and m_s != 0:
        cnt += m_s // 2
        s += m_s
    elif m_s % 2 == 1 and m < b:
        cnt += 1
        s += 1
        b += 1
    elif m_s == 0 and m < b:
        cnt += b_m
        break
print(cnt)

# Optimized solution
a = list(map(int, input().split()))
s, m, b = sorted(a)
cnt = 0
m_s = m - s
cnt += b - m
cnt += m_s // 2

if m_s % 2 == 1:
    cnt += 2
print(cnt)
# Original solution
def slove():
    import sys
    import bisect
    import collections
    import fractions
    import heapq
    input = sys.stdin.readline
    a, b, c = list(map(int, input().rstrip('\n').split()))
    cnt = 0
    while True:
        a, b, c = sorted([a, b, c])
        if abs(a - c) >= 2:
            a += 2
            cnt += 1
        else:
            if a == b == c:
                print(cnt)
                exit()
            if a == b:
                a += 1
                b += 1
                cnt += 1
            elif b == c:
                b += 1
                c += 1
                cnt += 1
            elif a == c:
                a += 1
                c += 1
                cnt += 1


if __name__ == '__main__':
    slove()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, readline().split()))
    sn = sum([a, b, c])
    mn = max(a, b, c)
    for i in range(mn * 3, 10 ** 10, 3):
        if (i - sn) % 2 == 0:
            print(((i - sn) // 2))
            exit()


if __name__ == '__main__':
    solve()
# Original solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, readline().split()))
    sn = sum([a, b, c])
    mn = max(a, b, c)
    for i in range(mn * 3, 10 ** 10, 3):
        if (i - sn) % 2 == 0:
            print(((i - sn) // 2))
            exit()


if __name__ == '__main__':
    solve()


# Optimized solution
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    a, b, c = list(map(int, readline().split()))
    dif = max([a, b, c]) * 3 - (a + b + c)
    print((dif // 2 if dif % 2 == 0 else (dif + 3) // 2))


if __name__ == '__main__':
    solve()
# Original solution
A,B,C=list(map(int, input().split()))
L=sorted([A,B,C])
ans=(L[2]-L[1]+L[2]-L[0])//2+((L[2]-L[1]+L[2]-L[0])%2)*2
print(ans)

# Optimized solution
from math import ceil
A,B,C=list(map(int, input().split()))
L=sorted([A,B,C])
n1=L[0]
n2=L[1]
n3=L[2]

fir=ceil((n2-n1)/2)
if n1+2*fir!=n2:
    sec=1
else:
    sec=0

ans=n3+sec-(n1+2*fir)+fir+sec
print(ans)
#print(fir, sec)
#6+1-(4)
# Original solution
ABC = list(map(int, input().split()))

tmp = 0
def calc(ABC, tmp):
        max_num = max(ABC)
        abs_list = [abs(max_num-i) for i in ABC]
        if all(i % 2 == 0 for i in abs_list):
                return int(sum(abs_list) / 2) + tmp
        else:
                cnt = 0
                for i, v in enumerate(abs_list):
                        if v % 2 == 0:
                                continue
                        else:
                                ABC[i] += 1
                                cnt += 1
                if cnt <= 1:
                        for i, v in enumerate(ABC):
                                if max_num == v:
                                        ABC[i] += 1
                                        break
                return calc(ABC, tmp+1)


                        

print((calc(ABC, 0)))


# Optimized solution
ABC = list(map(int, input().split()))
max_num = max(ABC)
abs_list = [abs(max_num-i) for i in ABC]
if sum(abs_list) % 2 == 0:
        res = int(sum(abs_list) / 2)
else:
        res = int((sum(abs_list)) / 2) + 2

print(res)
# Original solution
a = sorted(map(int, input().split()))
b, c = a[2] - a[1], a[2] - a[0]

あ = b // 2 + c // 2
ばいく = b % 2 + c % 2
if ばいく == 1:
    あ += 2
elif ばいく == 2:
    あ += 1
print(あ)


# Optimized solution
a, b, c = sorted(map(int, input().split()))
print(((c - a) // 2 + (c - b) // 2 + (((c - a) % 2 + (c - b) % 2) ^ 3) % 3))
# Original solution
state = list(map(int,input().strip().split(' ')))
states = [state]
flag=True
counterlist=[]
counterlist.append(0)

def procedure1(s,c):
    #case1
    states.append([s[0]+1, s[1]+1, s[2]])
    counterlist.append(c+1)
    
    #case2
    states.append([s[0]+1, s[1], s[2]+1])
    counterlist.append(c+1)
    
    #case3
    states.append([s[0], s[1]+1, s[2]+1])
    counterlist.append(c+1)
    
def procedure2(s,c):
    #case1
    states.append([s[0]+2, s[1], s[2]])
    counterlist.append(c+1)
    
    #case2
    states.append([s[0], s[1]+2, s[2]])
    counterlist.append(c+1)
    
    #case3
    states.append([s[0], s[1], s[2]+2])
    counterlist.append(c+1)

while flag:
    s = states.pop(0) 
    c = counterlist.pop(0)
    if s[0]==s[1] and s[1]==s[2]:
        flag=False
        print(c)

    procedure1(s,c)
    procedure2(s,c)

# Optimized solution
states = list(map(int,input().strip().split(' ')))
sortedlist = sorted(states)

diff0 = (sortedlist[2]-sortedlist[0])//2
diff1 = (sortedlist[2]-sortedlist[1])//2

newlist = [sortedlist[0]+2*diff0, sortedlist[1]+2*diff1, sortedlist[2]]

def patternMatch(s):
    if 1==2*s[2]-s[1]-s[0]:
        return 2
    elif 2==2*s[2]-s[1]-s[0]:
        return 1
    elif 0==2*s[2]-s[1]-s[0]:
        return 0

print((patternMatch(newlist)+diff0+diff1))
# Original solution
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return list(map(type,input().split()))
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    A=list(pin())
    A.sort()
    a=0
    if A[0]%2!=A[1]%2:
        A[1]+=1
        A[2]+=1
        a+=1
    a+=(A[2]*2-A[0]-A[1])//2
    print(a)
    
#%%submit!
resolve()

# Optimized solution
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return list(map(type,input().split()))
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    A=list(pin())
    A.sort()
    ans=0
    x,y,z=A
    if (y-x)%2:
        y+=1
        z+=1
        ans+=1
    ans+=(y-x)//2
    x=y
    ans+=z-x
    print(ans)
    
            
#%%submit!
resolve()
# Original solution
def main():
    A,B,C = list(map(int, input().split()))

    f(A,B,C)


def f(A,B,C):
    """
    A: 545, 565, 666 ans=2
    B: 445,      555 ans=1
    C: 123, 233, A pattern ans=3
    D: 135, 245, 355, 555 ans=3
    E: 235, 345, 455, A pattern ans=4
    """
    A, B, C = sorted([A, B, C])
    ans = 0
    if B != C:
        ans += C - B
        B = C
        A += ans
    
    diff = B - A
    ans += diff // 2
    if diff % 2 != 0:
        # A+2,BC+1
        ans += 2

    print(ans)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    A, B, C = list(map(int, input().split()))

    #f(A, B, C)
    editorial(A, B, C)


def editorial(A, B, C):
    """
    fより、最終値をxとするとx={max, max + 1}
    操作回数: [3x - (A+B+C)] / 2
    1回の操作で2増えるので
        差分/2が回数となる
        3x mod 2 == abc mod 2

    3max mod 2 == abc mod 2
        true: 上記の通りのあまりの一致
        false: x=max+1より、全体では3max+3より奇数増えるので一致しない
    """
    abc = [A, B, C]
    m = max(abc)
    m3 = m * 3
    s = sum(abc)

    if m3 % 2 == s % 2:
        ans = (m3 - s) // 2
    else:
        ans = (m3 + 3 - s) // 2

    print(ans)


def f(A, B, C):
    """
    A: 545, 565, 666 ans=2
    B: 445,      555 ans=1
    C: 123, 233, A pattern ans=3
    D: 135, 245, 355, 555 ans=3
    E: 235, 345, 455, A pattern ans=4
    """
    A, B, C = sorted([A, B, C])
    ans = 0
    if B != C:
        ans += C - B
        B = C
        A += ans

    diff = B - A
    ans += diff // 2
    if diff % 2 != 0:
        # A+2,BC+1
        ans += 2

    print(ans)


if __name__ == '__main__':
    main()
# Original solution
a=list(map(int,input().split()))
a=sorted(a)
cnt=0
if a[0]==a[1] and a[1]==a[2]:
	print((0))
elif a[0]==a[1]:
	while True:
		a[0]+=1
		a[1]+=1
		cnt+=1
		if a[0]==a[2]:
			print(cnt)
			break
elif a[1]==a[2]:
	while True:
		a[0]+=2
		cnt+=1
		if a[0]==a[2]:
			print(cnt)
			break
		elif a[0]>a[2]:
			print((cnt+1))
			break
else:
	while True:
		a[0]+=1
		a[1]+=1
		cnt+=1
		if a[2]==a[1]:
			break
	while True:
		a[0]+=2
		cnt+=1
		if a[0]==a[2]:
			print(cnt)
			break
		elif a[0]>a[2]:
			print((cnt+1))
			break

# Optimized solution
a=list(map(int,input().split()))
a.sort()
b=a[2]-a[1]
c=a[2]-a[0]
if (b+c)%2==0:
	print(((b+c)//2))
else:
	print((((b+c)//2)+2))
# Original solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = list(map(int, readline().split()))

    A.sort()

    ans = (A[2] - A[0]) // 2 + (A[2] - A[1]) // 2
    A[0] += (A[2] - A[0]) // 2 * 2
    A[1] += (A[2] - A[1]) // 2 * 2

    if A[0] == A[1]:
        if A[0] < A[2]:
            ans += 1
    else:
        ans += 2

    print(ans)
    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A = list(map(int, readline().split()))

    Asum = sum(A)
    Amax = max(A)

    if Asum % 2 == 3 * Amax % 2:
        ans = (3 * Amax - Asum) // 2
    else:
        ans = (3 * (Amax + 1) - Asum) // 2

    print(ans)
    return


if __name__ == '__main__':
    main()
# Original solution
A, B, C = list(map(int, input().split()))

M = max(A, B, C)

if M % 2 == (A + B + C) % 2:
    X = M
else:
    X = M + 1

ans = (3 * X - (A + B + C)) // 2
print(ans)


# Optimized solution
ABC = list(map(int, input().split()))

sm = sum(ABC)
mx = max(ABC)

if (mx * 3) % 2 == sm % 2:
    ans = (mx * 3 - sm) // 2
else:
    ans = ((mx + 1) * 3 - sm) // 2

print(ans)
# Original solution
from sys import stdin
import math

li = list(map(int,stdin.readline().rstrip().split()))

li.sort(reverse = True)

point = 0
su = sum(li)%2
sai = li[0]%2

if sum(li) == 1:
    print((1))
    exit()

else:
    if su != sai:
        li[0] += 1
        point += 1
    point += (li[0]*2-li[1]-li[2])//2

print(point)

# Optimized solution
li = list(map(int,input().split()))
li.sort()

lin = li[:]

if sum(li)%2 != 3*li[2]%2:
    lin[2] += 1

print(((lin[2]*3-sum(li))//2))
# Original solution
def main():
    nums = list(map(int, input().split()))

    # res = 0

    # while len(set(nums)) != 1:
    #     maxIdx = nums.index(max(nums))
    #     minIdx = nums.index(min(nums))

    #     if nums[maxIdx] - nums[minIdx] >= 2:
    #         nums[minIdx] += 2
    #         res += 1
    #     else:
    #         nums[minIdx] += 1
    #         nums[nums.index(min(nums))] += 1

    #         res += 1
    
    # print(res)
    M = max(nums)
    diff = 3 * M - sum(nums)

    print((diff) // 2) if diff%2 == 0 else print((3*M+3-sum(nums))//2)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    nums = list(map(int, input().split()))

    M = max(nums)
    diff = 3 * M - sum(nums)

    print((diff) // 2) if diff%2 == 0 else print((3*M+3-sum(nums))//2)

if __name__ == '__main__':
    main()
# Original solution
a,b,c,d,e=list(map(int,input().split()))
print((60*c+d-(60*a+b)-e))

# Optimized solution
x1,y1,x2,y2,t=list(map(int,input().split()))
print(((x2-x1)*60+(y2-y1)-t))
# Original solution
h1, m1, h2, m2, k = list(map(int,input().split()))
print(((60 * h2 + m2) - (60 * h1 + m1) - k))

# Optimized solution

h1,m1,h2,m2,k = list(map(int,input().split()))

a = 60*(h2-h1)
b = m2-m1
##起きている合計時間
c = a+b
##勉強開始時間の最遅時間
d = c-k
print(d)
# Original solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


H1,M1,H2,M2,K = MI()
print((max(0,60*H2+M2-60*H1-M1-K)))


# Optimized solution
# NOMURA プログラミングコンテスト 2020-A

import sys
def MI(): return list(map(int,sys.stdin.readline().rstrip().split()))


H1,M1,H2,M2,K = MI()
print((max(0,60*H2+M2-60*H1-M1-K)))
# Original solution
time = list(map(int, input().split()))
h1,m1 = time[0],time[1]
h2,m2 = time[2],time[3]
k = time[4]
ans = 0
full = (h2*60+m2) - (h1*60+m1)
while full - k !=0:
    full-=k
    ans+=k
print(ans)


# Optimized solution
h1,m1,h2,m2,k = list(map(int, input().split()))
h = h2 -h1
m = m2 - m1
print((h*60+m-k))
# Original solution
a, b, c, d, k = list(map(int, input().split()));

x = 60*a + b
y = 60*c + d

if y>x:
    print((y-x-k));
else:
    print((1440+y-x-k));

# Optimized solution
a, b, c, d, k = list(map(int, input().split()));

x = 60*a + b
y = 60*c + d

print((y-x-k));
# Original solution
h1, m1, h2, m2, k = list(map(int, input().split()))
h = h2-h1
m = m2-m1
a = h*60
m += a
b = k
if k != m:
    while k+b != m:
        if k+b == m:
            k = 0
            break
        k += b
else:
    k = 0
print(k)



# Optimized solution
h1, m1, h2, m2, k = list(map(int, input().split()))
print((60*(h2-h1) + m2-m1-k))
# Original solution
A = list(map(int, input().split()))

h = (A[2]-A[0])*60+A[3]-A[1]-A[4]
print(h)

# Optimized solution
A = list(map(int, input().split()))

print(((A[2]*60+A[3])-(A[0]*60+A[1])-A[4]))
# Original solution
h1, m1, h2, m2, k = list(map(int, input().split()))
t = 0

if h1 == h2:
    t = m2 - m1
else:
    if m2 >= m1:
        t = (h2 - h1) * 60 + m2 - m1
    else:
        t = (h2 - h1 -1) * 60 + m2 +60 - m1
print((t - k))

# Optimized solution
h1, m1, h2, m2, k = list(map(int, input().split()))
print((60 * (h2 - h1) + m2 - m1 -k))
# Original solution
a = list(map(int, input().split()))
kishou = a[0] * 60 + a[1]
shuusin = a[2] * 60 + a[3]
print((shuusin - kishou - a[4]))

# Optimized solution
a = list(map(int, input().split()))
b = (a[2] * 60 + a[3]) - (a[0] * 60 + a[1])
print((b - a[4]))
# Original solution
import datetime as D
while 1:
  a,b,c,d,e,f=x=list(map(int,input().split(" ")))
  if min(x)<0: break
  print((D.date(d,e,f)-D.date(a,b,c)).days)

# Optimized solution
import datetime as D
while 1:
  a,b,c,d,e,f=x=list(map(int,input().split(" ")))
  if any([i<0 for i in x]): break
  print((D.date(d,e,f)-D.date(a,b,c)).days)
# Original solution
from operator import itemgetter
from itertools import accumulate
 
n = int(eval(input()))
a = sorted(tuple(map(int, reversed(input().split()))) for _ in range(n))
c, d = (list(map(itemgetter(i), a)) for i in (0, 1))
print(('YNeos'[any(x < y for x, y in zip(c, accumulate(d)))::2]))                    


# Optimized solution
from operator import itemgetter
from itertools import accumulate
 
n = int(eval(input()))
a = sorted((tuple(map(int, input().split())) for _ in range(n)),
           key=itemgetter(1))
c, d = (list(map(itemgetter(i), a)) for i in (0, 1))
print(('YNeos'[any(x > y for x, y in zip(accumulate(c), d))::2]))
# Original solution
n = int(eval(input()))

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

key = 0
ans = True
for i in range(n):
  if key + work[i][1]> work[i][0]:
    ans = False
    break
  key += work[i][1]

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

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

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

jobs.sort()

ans = True
sub = 0
for i in range(n):
  b, a = jobs[i][0], jobs[i][1]
  sub += a
  if sub > b:
    ans = False
    break

print(("Yes" if ans else "No"))
# Original solution
def main():
    N = int(eval(input()))
    A = []
    B = []
    for _ in range(N):
        a, b = list(map(int, input().split(" ")))
        A.append(a)
        B.append(b)
    tasks = [[0] for _ in range(max(B) + 1)]
    for i in range(N):
        tasks[B[i]].append(A[i])
    time = 0
    flag = True
    for i, task in enumerate(tasks):
        if i == 0:
            continue
        time += sum(task)
        if time > i:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

# Optimized solution
def main():
    N = int(eval(input()))
    flag = True
    tascs = []
    for _ in range(N):
        a, b = list(map(int, input().split(" ")))
        tmp = [a, b]
        tascs.append(tuple(tmp))
    tascs.sort(key=lambda x: x[1])
    passed_time = 0
    for tasc in tascs:
        passed_time += tasc[0]
        if passed_time > tasc[1]:
            flag = False
            break
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
# Original solution
# ABC131D - Megalomania
from operator import itemgetter as gt


def main():
    N, *AB = list(map(int, open(0).read().split()))
    cur, TD = 0, sorted([(i, j) for i, j in zip(*[iter(AB)] * 2)], key=gt(1))
    for task, deadline in TD:  # check all tasks greedily
        cur += task
        if cur > deadline:  # fail to finish a task within its deadline
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()


# Optimized solution
from operator import itemgetter


def solve(string):
    n, *ab = list(map(int, open(0).read().split()))
    ab = sorted(zip(*[iter(ab)] * 2), key=itemgetter(1))
    past = 0
    for a, b in ab:
        past += a
        if past > b:
            return "No"
    return "Yes"


if __name__ == '__main__':
    print((solve("")))
# Original solution
N=int(eval(input()))
L=[list(map(int,input().split())) for _ in range(N)]
s=0
p=True
L=sorted(L,key=lambda x: x[1])
for l in L:
    s+=l[0]
    if l[1]>=s:
        continue
    else:
        p=False
        break
print(("Yes" if p else "No"))


# Optimized solution
N=int(eval(input()))
L=[list(map(int,input().split())) for _ in range(N)]
L.sort(key=lambda x:x[1])
t=0
p=True
for l in L:
  t+=l[0]
  if t > l[1]:
    p=False
    break
print(("Yes" if p else "No"))
# Original solution
n = int(eval(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')


# Optimized solution
n = int(eval(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')
# Original solution
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(eval(input()))
BA = [[] for i in range(N)]
for i in range(N):
    a,b = LI()
    BA[i] = (b,a)

BA.sort()
part_A = [0 for i in range(N)]
for i in range(N):
    B,A = BA[i]
    part_A[i] = A + part_A[i-1]

for i in range(N):
    B,A = BA[i]
    if B - part_A[i] < 0:
        print("No")
        break
else:
    print("Yes")


# Optimized solution
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(eval(input()))
BA = [[] for i in range(N)]
for i in range(N):
    a,b = LI()
    BA[i] = (b,a)

BA.sort()

tmp  = 0
for i in range(N):
    b,a = BA[i]
    tmp += a
    if b - tmp < 0:
        print("No")
        break
else:
    print("Yes")
# Original solution
# ABC131D - Megalomania
import sys
input = sys.stdin.readline

def main():
    n = int(eval(input()))
    arr = sorted(
        [tuple(map(int, input().rstrip().split())) for _ in range(n)], key=lambda x: x[1]
    )
    tasks = 0
    for i, j in arr:
        tasks += i
        if tasks > j:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()

# Optimized solution
# ABC131D - Megalomania
import sys
input = sys.stdin.readline

def main():
    N = int(eval(input()))
    A = sorted(
        [tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[1]
    )
    tasks = 0
    for task, deadline in A:
        tasks += task
        if tasks > deadline:
            print("No")
            break
    else:
        print("Yes")


if __name__ == "__main__":
    main()
# Original solution
# ABC131D - Megalomania
from itertools import accumulate
from operator import itemgetter as gt


def main():
    N, *AB = list(map(int, open(0).read().split()))
    T, D = list(zip(*sorted([(i, j) for i, j in zip(*[iter(AB)] * 2)], key=gt(1))))
    T = list(accumulate(T))
    flg = all(t <= d for t, d in zip(T, D))  # all tasks finish within each deadline?
    print(("Yes" if flg else "No"))


if __name__ == "__main__":
    main()

# Optimized solution
# ABC131D - Megalomania
from operator import itemgetter as gt


def main():
    N, *AB = list(map(int, open(0).read().split()))
    cur, TD = 0, sorted([(i, j) for i, j in zip(*[iter(AB)] * 2)], key=gt(1))
    for task, deadline in TD:  # check all tasks greedily
        cur += task
        if cur > deadline:  # fail to finish a task within its deadline
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()
# Original solution
from operator import itemgetter
N = int(eval(input()))
A = [None] * N
for i in range(N):
  A[i] = list(map(int,input().split()))

s = sorted(A, key=itemgetter(0),reverse=True)
t = sorted(s, key=itemgetter(1))

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

# Optimized solution
from operator import itemgetter
N = int(eval(input()))
A = [None] * N
for i in range(N):
  A[i] = list(map(int,input().split()))

#s = sorted(A, key=itemgetter(0),reverse=True)
t = sorted(A, key=itemgetter(1))

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