peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n, money = map(int, input().split())
ans = [-1, -1, -1]
flag = False

money = money // 1000

for i_1 in range(n+1):
  for j_5 in range(n - i_1 + 1):
    if (money - i_1 - j_5 * 5) == 10 * (n - i_1 - j_5):
      flag = True
      ans = [i_1, j_5, n - i_1 - j_5]
      
  if flag:
    break

print(ans[2], ans[1], ans[0])
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1, N+1, 2):
    d = 0
    for k in range(1, i+1):
        if i % k == 0:
            d += 1
    if d == 8:
        ans += 1
print(ans)
# Judge status: Accepted
a = int(input())

def Rec(a):
  if a == 1: 
    return 1
  return 1 + Rec(a//2)*2

print(Rec(a))
# Judge status: Accepted
input();a=list(map(int,input().split()));d={}
for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1
d={i:j for i,j in d.items() if j>1}
if len(d)<2:
  print(0)
else:
  d=sorted(d.items(),key=lambda x:(-x[0],-x[1]))
  print(d[0][0]*d[1][0] if d[0][1]<4 else d[0][0]*d[0][0])
# Judge status: Accepted
s = input()
ans = 0
for i in range(len(s)//2):
    if s[i] != s[-1-i]:
        ans += 1
print(ans)
# Judge status: Accepted
s=input()
l=[0]*(len(s)+1)

for i in range(len(s)):
  if s[i]=='<':
    l[i+1]=l[i]+1
    
for i in range(len(s)-1,-1,-1):
  if s[i]=='>':
    l[i]=max(l[i],l[i+1]+1)
print(sum(l))
# Judge status: Wrong Answer
N = int(input())

P = 1

for i in range(2,N+1):
    P = P*i
    P = P % (100000007)

print(P)
# Judge status: Accepted
n,m = map(int,input().split())
if n >= 3 and m >= 3:
    ans = (n-2) * (m-2)
elif n >= 3 and m==1:
    ans = n-2
elif m >= 3 and n==1:
    ans = m-2
elif n==1 and m==1:
    ans = 1
else:
    ans = 0
print(ans)
# Judge status: Accepted
n = int(input())
precount = 0
if n==1:
    ans = 1
for i in range(1, n+1):
    tmp = i
    flag = 1
    count = 0
    while flag :
        flag = 0
        if i%2 == 0:
            i = i//2
            flag = 1
            count += 1
    if precount < count :
        precount = count
        ans = tmp
        
    
            

print(ans)
# Judge status: Accepted
import heapq
from math import ceil
n,m = map(int,input().split())
A = list(map(int,input().split()))
hq = list(map(lambda x:-1*x ,A))
heapq.heapify(hq)

for i in range(m):
    a = heapq.heappop(hq)
    a = ceil(a/2)
    heapq.heappush(hq,a)
print(-1*sum(hq))
# Judge status: Accepted
x,a,b=map(int,input().split())
if abs(x-a)<abs(x-b):
  print("A")
else:
  print("B")
# Judge status: Accepted
s = input().replace('><','> <').split()
ans = 0
#print(list(s))
for st in s:
    lt = st.count('<')
    gt = len(st) - lt
    if lt > gt:
        gt -= 1
    else:
        lt -= 1
    ans += (lt*lt+lt)//2 + (gt*gt+gt)//2
print(ans)
# Judge status: Wrong Answer
x = input()

if x==0:
  print(1)
else:
  print(0)
# Judge status: Wrong Answer
O = input()
E = input()
print("".join(o + e for o, e in zip(O, E)))
# Judge status: Accepted
n = int(input())
lst = [0] * 10**6
for x in range(1, 101):
  for y in range(1, 101):
    for z in range(1, 101):
      t = (x**2 + y**2 + z**2 + (x+y+z)**2) // 2
      lst[t] += 1
for i in range(1, n+1):
  print(lst[i])
# Judge status: Accepted
def main():
    N = int(input())
    for i in range(N, 1000):
        s = str(i)
        if s[0] == s[1] and s[1] == s[2]:
            print(i)
            break
main()
# Judge status: Wrong Answer
import sys
inputs = sys.stdin.readlines()
n, m = map(int, inputs[0].split())
P, S = [], []
for s in inputs[1:]:
    x, y = s.split()
    P.append(int(x)-1)
    S.append(y)

num_ac = num_wa = 0
acs = [0]*n
for p, s in zip(P, S):
    if acs[p]:
        continue
    if s == 'WA':
        num_wa += 1
    else:
        acs[p] = 1
        num_ac += 1
        
print(*[num_ac, num_wa])
# Judge status: Accepted
d,t,s = map(int,input().split())
print("Yes" if d <= t*s else "No")
# Judge status: Wrong Answer
line = input()
num = (int)(line.split(" ")[0])
limit = (int)(line.split(" ")[1])

x = 0
count = 0
line = input()
for i in range(num):
  if x > limit:
    break
  x += (int)(line.split(" ")[i])
  count += 1
print(count)
# Judge status: Accepted
N,R=map(int,input().split())
if N<10:
  print(R+100*(10-N))
else:
  print(R)
# Judge status: Accepted
a, b, c, d, e, k = [int(input()) for _ in range(6)]
if e-a > k:
    print(':(')
else:
    print('Yay!')
# Judge status: Accepted
x,a,b = map(int,input().split())
if abs(a-x)>abs(b-x):
    print("B")
else:
    print("A")
# Judge status: Accepted
n = int(input())
s = input()
cnt = 0
W, E = [], []
w, e = 0, 0
for i in range(n):
    W.append(w); E.append(e)
    if s[i] == 'W':
        w += 1
    if s[-i-1] == 'E':
        e += 1
print(min([w+e for (w, e) in zip(W, E[::-1])]))
# Judge status: Accepted
n = int(input())

MOD = 1000000007

def mod(n):         
  return n % MOD

def modpow(a, n):   #mod(a**n)を高速で求める
    res = 1  
    digit = len(str(bin(n))) - 2
    for i in range(digit):
      if (n >> i) & 1:
        res *= mod(a)
        res = mod(res)
      a = mod(a**2)
    return mod(res)
  
ans = modpow(10, n)
ans -= 2*modpow(9, n)
ans += modpow(8, n)
print(mod(ans))
# Judge status: Wrong Answer
import statistics
N = int(input())
A = list(map(int, input().split()))

cnt = 1
for i in range(N):
    A[i] = A[i] - cnt
    cnt += 1
A.sort(reverse=True)
medA = statistics.median(A)

ans = 0
cnt = 1
for j in range(N):
    ans += abs(A[j] - medA)
    cnt += 1

print(ans)
# Judge status: Accepted
n,m=map(int,input().split())
print('Yes' if n==m else 'No')
# Judge status: Accepted
N, D = map(int, input().split())
X = [0]*N
for i in range(0, N):
    X[i] = list(map(int, input().split()))
s = 0
for i in range(0, N):
    for j in range(i, N):
        t = 0
        for k in range(0, D):
            t = t+(X[i][k]-X[j][k])**2
        for l in range(1, t+1):
            if l**2 == t:
                s = s+1
                break
print (s)
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
d=[]
for i in range(k+1):
    d.append(1)
for i in range(1,100):
    if a%i==0 and b%i==0:
        d.append(i)

print(d[-1*k])
# Judge status: Accepted
N = int(input())
que= [[]for i in range(2)]
for i in range(N):
    x,y = map(int,input().split())
    que[0].append(x-y)
    que[1].append(x+y)
que[0].sort()
que[1].sort()
ans = max(que[0][-1]-que[0][0],que[1][-1]-que[1][0])
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    S = input().rstrip()
    C = Counter(S)
    n = C['N']
    s = C['S']
    w = C['W']
    e = C['E']
    if (n != 0 and s != 0) or (n == 0 and s == 0):
        if (w != 0 and e != 0) or (w == 0 and e == 0):
            print('Yes')
        else:
            print('No')
    else:
        print('No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
k = int(input())
kkk = [0] * k
kkk[0] = 7 % k
ans = -1
for i in range(1, k):
    kkk[i] = (kkk[i - 1] * 10 + 7) % k
for j in range(k):
    if kkk[j] == 0:
        ans = j + 1
        break
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
dic={}
doll=0
for i in range(n):
  a,b=map(int,input().split())
  dic[a]=b
  
con=sorted(dic.items())

for k,v in con:
  if v<m:
    doll+=k*v
    m-=v
  else:
    doll+=k*m
    print(doll)
    exit()
# Judge status: Wrong Answer
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
lists = [list(map(int,input().split())) for i in range(m)]
a.sort()
b.sort()
Min = min(a) + min(b)
for x,y,c in lists:
    x -= 1
    y -= 1
    Min = min(Min,a[x] + b[y] - c)
print(Min)
# Judge status: Accepted
from collections import Counter
n = int(input())
count_list = []
for i in range(n):
    s = input()
    c = sorted(Counter(s).items(), key = lambda x:x[0])
    tmp = ""
    for j in range(len(c)):
        tmp += c[j][0]
        tmp += str(c[j][1])
    count_list.append(tmp)

c = Counter(count_list)
ans = 0
for i in c.values():
    if i >= 2:
        ans += i * (i - 1) // 2

print(ans)
# Judge status: Wrong Answer
N , K = map(int, input().split())
p = list(map(int, input().split()))
Etop = 0
E = 0
q = []
for j in p:
    q.append((j+1) / 2)

print(q)

for i in range(N-K+1):
    E = 0
    for n in range(K):
        E += q[n+i]
    if E > Etop:
        Etop = E
print(Etop)
# Judge status: Accepted
s=input()
n=len(s)
x=(n-1)//2
i=0
while i<x:
  if s[i]!=s[n-1-i] or s[i]!=s[x-1-i]:
    print('No')
    break 
  i=i+1
else:
  print('Yes')
# Judge status: Accepted
n, m = map(int, input().split())
ab = list(map(int, input().split()) for i in range(n))
cd = list(list(map(int, input().split())) for i in range(m))

for a, b in ab:
    md = 1001001001
    res = 0
    for i in range(m):
        tmp = abs(a - cd[i][0]) + abs(b - cd[i][1])
        if tmp < md:
            md = tmp
            res = i + 1
    print(res)
# Judge status: Wrong Answer
C = input()
if C == "z":
  pass
else:
  print(C)
# Judge status: Accepted
A,B,C,D = map(int,input().split())

while A > 0 or C > 0:
    C = C-B
    if C <= 0:
        print('Yes')
        break
    A = A-D
    if A <= 0:
        print('No')
        break
# Judge status: Accepted
n = int(input())
arr = [int(i) for i in input().split()]

left = [0]*n
xor = arr[0]
for i in range(1, n):
  left[i] = xor
  xor ^= arr[i]

right = [0]*n
xor = arr[n-1]
for i in range(n-2, -1, -1):
  right[i] = xor
  xor ^= arr[i]

for i in range(n):
  arr[i] = left[i] ^ right[i]

print(*arr)
# Judge status: Accepted
s = list(input())
ew = []
sn = []
for i in s:
    if i == "E" or i == "W":
        ew.append(i)
    else:
        sn.append(i)
if len(set(ew)) == 1 or len(set(sn)) == 1:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
N,K=map(int,input().split())
H=list(map(int,input().split()))
cost =200000
DP=[0]*(N+10)
DP[0]=0
DP[1]=abs(H[1]-H[0])
for i in range(2,N):
  cost=200000
  for k in range(max(i-K,0),i):
    cost=min(cost,(abs(H[i]-H[k])+DP[k]))
  DP[i]=cost
print(DP[N-1])
# Judge status: Accepted
import itertools
N = int(input())

if N == 0:
    print(0)
    exit()
ans = []
while N !=0:
    ans.append(N%2)
    N = -(N-N%2)//2
ans.reverse()
print("".join(list(map(str,ans))))
# Judge status: Accepted
N = int(input())

A = list(map(int, input().split()))

res = 10 ** 9

for a in A:
    t = 0
    while a % 2 == 0:
        t += 1
        a //= 2

    res = min(res, t)

print(res)
# Judge status: Accepted
N = int(input())

query = [list(map(int, input().split())) for _ in range(2)]
ans = []
for i in range(N):
    ans.append(sum(query[0][:i+1])+sum(query[1][i:]))
print(max(ans))
# Judge status: Accepted
n = int(input())
mod = 10**9+7
ans = pow(10,n,mod)-pow(9,n,mod)*2+pow(8,n,mod)
print(ans%mod)
# Judge status: Wrong Answer
import itertools
s = input()
if s =="ABC":
	print("ARC")
else:
	print("ARC")
# Judge status: Accepted
n,l=map(int,input().split())
s=[""]*n
for i in range(n):
  s[i]=input()
  
s=sorted(s)
ans=""
for i in range(n):
  ans=ans+s[i]
  
print(ans)
# Judge status: Accepted
n,x=map(int,input().split())
l=list(map(int,input().split()))
b=0
cnt=0
for i in l:
  b+=i
  cnt+=1
  if b>x:
    print(cnt)
    exit()
print(n+1)
# Judge status: Accepted
from itertools import combinations

n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0

for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
    
print(count)
# Judge status: Accepted
S = input()
T = input()
cnt = 0
for i in range(0,len(S)):
    if S[i]!=T[i]:
        cnt += 1
print(cnt)
# Judge status: Wrong Answer
def cal():
  a = str(input())
  n = a + a**2 + a**3
  print(n)
# Judge status: Accepted
a,b,k=map(int,input().split())

cnt=0

for i in range(100,0,-1):
	if a%i==0 and b%i==0:
		cnt+=1
	if cnt==k:
		print(i)
		break
# Judge status: Wrong Answer
S = list(input())
for i in range(2):
    if S[i] == S[i+1]:
        print("Bad")
        exit()
print("Good")
# Judge status: Accepted
#abc058 b
O=input()
E=input()
ans=""

for i in range(len(E)):
    ans+=O[i]+E[i]
if len(O)!=len(E):
    ans+=O[-1]
print(ans)
# Judge status: Accepted
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
c=Counter(a)
l4,l2=[],[]
for k,v in c.items():
    if v>=4:l4.append(k)
    if v>=2:l2.append(k)
l4.sort(reverse=True)
l2.sort(reverse=True)
if len(l4)<=2:l4+=[0,0]
if len(l2)<=2:l2+=[0,0]
print(max(l4[0]*l4[1],l4[0]*l2[0],l2[0]*l2[1]))
# Judge status: Wrong Answer
N = int(input())

nx = 0
ny = 0
nt = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    k = abs(nx-x)+abs(ny-y)
    if k > t:
        print("No")
        break
    if (k-t)%2 != 0:
        print("No")
        break
    nx = x
    ny = y
    nt = t
else:
    print("Yes")
# Judge status: Accepted
from math import ceil
h, a = map(int, input().split())
print(ceil(h/a))
# Judge status: Accepted
import math
n = int(input())
lst = list(map(int, input().split()))

res = 0
lst2 = [0]*n
for i in range(n):
  lst2[i] = lst[i] - i
lst2.sort()

p = lst2[n//2]
q = lst2[n//2-1]
ps = qs = 0
for i in range(n):
  ps += abs(lst[i] - (p+i))
  qs += abs(lst[i] - (q+i))
print(min(ps, qs))
# Judge status: Accepted
s = input()
w = ["R","RR","RRR"]
ans = 0

for i in range(3):
    if w[i] in s:
        ans = i + 1
        
print(ans)
# Judge status: Wrong Answer
def product(n, r):
    S = max(r, 1)
    while n > r:
        S *= n
        n -= 1
    return S
def C(n,r):
    return(product(n,r)//product(n-r,1))
X, Y = map(int, input().split())
k = (X + Y) % 3
if k != 0:
    print(0)
else:
    k = (X + Y) // 3
    l = abs(X-2*k)
    print(C(k,l)%(10**9+7))
# Judge status: Accepted
X = int(input())

if 400 <= X < 600:
  print('8')
elif 600<= X < 800:
  print('7')
elif 600 <= X < 1000:
  print('6')
elif 800 <= X < 1200:
  print('5')
elif 1000 <= X < 1400:
  print('4')
elif 1200 <= X < 1600:
  print('3')
elif 1400 <= X < 1800:
  print('2')
elif 1800 <= X < 2000:
  print('1')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
xor = A[0]
for i in range(1, len(A)):
    xor = xor^A[i]
ans = []
for ai in A:
    ans += [xor^ai]
print(' '.join(list(map(str, ans))))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
BOX = [None for i in range(N)]
ANS_LIST = []
for i in range(N-1,-1,-1):
    loop = N//(i+1)
    cnt = 0
    for j in range(loop):
        if BOX[(i+1)*(j+1)-1]!=None:
            cnt+=BOX[(i+1)*(j+1)-1]
    BOX[i]=(cnt-A[i])%2

for i in range(N):
    if BOX[i]==1:
        ANS_LIST.append(i+1)

print(sum(BOX))
print(*ANS_LIST)
# Judge status: Accepted
K,N=map(int,input().split())
A=list(map(int,input().split()))
A+=[K+A[0]]
B=[A[i+1]-A[i] for i in range(N)]
print(K-max(B))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
MAX = 10**6+1

is_divided = [0]*MAX 
is_appeared = [0]*MAX

for i in range(n):
  if not is_divided[a[i]]:
    if not is_appeared[a[i]]:
      is_appeared[a[i]] = 1
      k = a[i]*2
      while k < MAX:
        is_divided[k] = 1
        k += a[i]
    else:
      is_divided[a[i]] = 1
      
ans = 0      
for i in range(n):
  if not is_divided[a[i]]:
    ans += 1
print(ans)
# Judge status: Accepted
#素因数分解
def prime_factor(n):
        ass = []
        for i in range(2,int(n ** 0.5) + 1):
            while n % i == 0:
                ass.append(i)
                n = n // i
        if n != 1:
            ass.append(n)
        return ass

a,b=map(int,input().split())
a=list(set(prime_factor(a)))
b=list(set(prime_factor(b)))

arr=[i for i in a if i in b]
print(len(arr)+1)
# Judge status: Wrong Answer
S=list(map(int,input().split()))

sx=S[0]
sy=S[1]
tx=S[2]
ty=S[3]
answer=[]
for i in range(ty-sy):
    answer.append("U")
for i in range(tx-sx):
    answer.append("R")
for i in range(ty-sy):
    answer.append("D")
for i in range(tx-sx):
    answer.append("L")
answer.append("D")
for i in range(tx-sx+1):
    answer.append("R")
for i in range(ty-sy+2):
    answer.append("U")
for i in range(tx-sx+1):
    answer.append("L")
for i in range(tx-sx+2):
    answer.append("D")
answer.append("R")
for s in answer:
    print(s,end="")
# Judge status: Wrong Answer
a,b,k=map(int,input().split())
d=[]
for i in range(1,b+1):
    if a%i==0 and b%i==0:
        d.append(i)

print(d[k-1])
# Judge status: Accepted
x=int(input())
print (0 if x==1 else 1)
# Judge status: Wrong Answer
n,m=[int(i) for i in input().split()]

print(max(0,(n-2)*(m-2)))
# Judge status: Accepted
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n,m,x,y=INTM()
    xs=LIST()
    xs.append(x)
    ys=LIST()
    ys.append(y)
    #print(xs,ys)
    if max(xs)>=min(ys):
        print('War')
    else:
        print('No War')
    
    
if __name__ == '__main__':
    do()
# Judge status: Wrong Answer


import collections


def solve():

    S = list(input())
    K = int(input())

    for i in range(K):
        if S[i] != 1:
            print(S[i])
            exit()
    print(1)


if __name__ == "__main__":
    solve()
# Judge status: Accepted
D,N = map(int,input().split())
if N == 100:
  N += 1
print(N*(100**D))
# Judge status: Wrong Answer
n = int(input())
s = input()
#文字ごとの累積和を取っておく
acc_char = [0 for i in range(26)]
ans = 0
for i in range(n):
    #今回の数字は使うの確定
    char = s[i]
    plus = 1
    for j in range(len(acc_char)):
        if (ord(char) - ord('a')) != j:
            plus *= acc_char[j] + 1
    ans += plus
    acc_char[ord(char) - ord('a')] += 1
print(ans)
# Judge status: Wrong Answer
import sys

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))

a.sort()
a.pop(0)
print(sum(a))
# Judge status: Accepted
l = list(map(int, input().split()))

if l[0] % 2 == 0 or l[1] % 2 == 0 or l[2] % 2 == 0:
  print(0)
else:
  ans = 1
  max_idx = l.index(max(l))
  for i in range(3):
    if i != max_idx:
      ans *= l[i]
  print(ans)
# Judge status: Accepted
tmp = input().split(" ")
A = int(tmp[0])
B = int(tmp[1])

if A <= 9 and B <= 9:
  print(A * B)
else:
  print("-1")
# Judge status: Accepted
n,a,b=map(int,input().split())
s=input()
ans=list('No'for _ in range(n))
c=a+b
countY=0
countb=0
for i in range(n):
    if countY<c:
        if s[i]=='a':
            ans[i]='Yes'
            countY+=1
        if s[i]=='b' and countb<b:
            ans[i]='Yes'
            countY+=1
            countb+=1
            
print(*ans,sep='\n')
# Judge status: Wrong Answer
import sys

N , X = map(int,input().split())
L = list(map(int,input().split()))

D = 0

for i in range(0,N):
    D += L[0]
    if D > X :
        print(i)
        sys.exit()

print(N)
# Judge status: Accepted
n = input()
n = n[::-1] + '0'
inf = 10 ** 9
dp = [[inf for _ in range(2)] for _ in range(len(n) + 1)]
dp[0][0] = 0
dp[0][1] = 2
for i in range(len(n)):
        n_i = int(n[i])
        dp[i + 1][0] = min(dp[i][0] + n_i, dp[i][1] + n_i)
        dp[i + 1][1] = min(dp[i][0] + 11 - n_i, dp[i][1] + 9 - n_i)
print(min(dp[-1][0], dp[-1][1]))
# Judge status: Wrong Answer
a,b = map(int,input().split(' '))
if a == b:
    print("yes")
else:
    print("no")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

if 0 in A:
    ans = 0
else:
    ans = 1
    for Ai in A:
        ans *= Ai
        if ans > 10 ** 18:
            ans = -1
            break
print(ans)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
S = input()
passed = 0
foreigner = 0
for s in S:
  if s == "c":
    print("No")
  elif s == "a":
    if passed < A + B:
      print("Yes")
      passed += 1
    else:
      print("No")
  elif s == "b":
    if passed < A + B and foreigner <= B:
      print("Yes")
      passed += 1
      foreigner += 1
    else:
      print("No")
# Judge status: Wrong Answer
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    A = list(map(int, input().split()))
    count = 0
    for i in range(1, N):
        diff = A[i - 1] - A[i]
        if diff < 0:
            count += abs(diff)
    print(count)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n = int(input())
ab = [list(map(int,input().split())) for _ in range(n)]

ab =sorted(ab, key = lambda x:x[1])
ans = 0
for i in ab:
    ans+=i[0]
    if ans > i[1]:
        print(ans, i[0], i[1])
        print("No")
        exit()
print("Yes")
# Judge status: Wrong Answer
n = int(input())
candi = []
for i in range(2,int(n/2+1)):
  j = n - i
  candi.append([i,j])

#candi = [[2, 13], [3, 12], [4, 11], [5, 10], [6, 9], [7, 8]]

ans = 0
for a,b in candi:
  count = 0
  a = str(a)
  b = str(b)
  for i in a:
    count += int(i)
  for i in b:
    count += int(i)
  if ans == 0 :
    ans = count
  ans = min(ans,count)

print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
from itertools import accumulate
s=list(accumulate(a))
a_sum=sum(a)
ans=10**18
if n==2:
  print(abs(a[0]-a[1]))
  exit(0)
for i in range(1,n-1):
  x=s[i]
  y=a_sum-x
  ans=min(ans,abs(x-y))
print(ans)
# Judge status: Accepted
s=input().split()
i=int(s[0])
j=int(s[1])
k=int(s[2])
a=[]
for l in range(k):
  if i+l<=j:
    a.append(str(i+l))
  else:
    break
b=int(a[-1])
if b>=j-k and b<j:
  for l in range(1,j-b+1):
    if b+l<=j:
      a.append(str(b+l))
elif b<j-k:
  for l in range(k-1,-1,-1):
    if j-l<=j:
      a.append(str(j-l))
print(*a)
# Judge status: Wrong Answer
n = int(input())
xor_arr = list(map(int, input().split()))
xor_of_xor = 0
for elm in xor_arr:
    xor_of_xor = xor_of_xor ^ elm
scarf_val = [xor_of_xor ^ elm for elm in xor_arr]

print(scarf_val)
# Judge status: Accepted
N, M = map(int, input().split())
odd_l = 1
odd_r = M
even_l = M + 1
even_r = 2 * M + 1
i = 0
while i < M:
    print(even_l, even_r)
    i += 1
    if i == M:
        break
    print(odd_l, odd_r)
    i += 1
    odd_l += 1
    odd_r -= 1
    even_l += 1
    even_r -= 1
# Judge status: Wrong Answer
import copy

N,K=map(int,input().split())
A=list(map(int,input().split()))
i=A[0]

for _ in range(N+K%N-1):
    i=A[i-1]
print(i)
# Judge status: Wrong Answer
import itertools

# 各種変数の取り込み
num = int(input())
a   = tuple(map(int, input().split()))
b   = tuple(map(int, input().split()))

l = range(1, num + 1)
p = list(itertools.permutations(l))

ans = p.index(b) - p.index(a)
print(ans)
# Judge status: Wrong Answer
AB,BC,CA=map(int,input().split())
print(AB*BC/2)
# Judge status: Wrong Answer
alpha = input()
a_code = ord('a')
z_code = ord('z')
alpha_code = ord(alpha)
if alpha_code >= a_code and alpha_code < z_code:
	next_alpha_code = alpha_code + 1
	next_alpha = chr(next_alpha_code)
	print(alpha + 'の次は' + next_alpha + 'です。')
# Judge status: Accepted
N=int(input())
for i in range(1,10):
    for j in range(1,10):
        if i*j==N:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")
# Judge status: Accepted
N = int(input())
cnt = 0
tmp = 0
for _ in range(N):
    a = int(input())
    if a == 0:
        cnt += tmp//2
        tmp = 0
    else:
        tmp += a

cnt += tmp//2

print(cnt)
# Judge status: Accepted
a,b,c,d=map(int,input().split())
if b<c or a>d:
    print(0)
else:
    print(min(b-c,d-a,b-a,d-c))
# Judge status: Wrong Answer
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

add_a=[]
for i in range(n-1):
    add_a.append(max(a[i]+a[i+1]-x,0))

ans=0
for i in range(n-1):
    ans+=add_a[i]
    if i!=n-2:
        add_a[i+1]=max(0,add_a[i+1]-add_a[i])
    add_a[i]=0

print(ans)
# Judge status: Accepted
N, M = input().strip().split(" ")

array = []
array.append(N*int(M))
array.append(M*int(N))

ans = sorted(array)

print(ans[0])
# Judge status: Accepted
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
print(math.ceil((N-1)/(K-1)))
# Judge status: Accepted
p,q,r = map(int,input().split())
ans = p+q+r-max(p,q,r)
print(ans)
# Judge status: Wrong Answer
n = int(input())
l = sorted(list(map(int,input().split())))
ans = 0
for ai in range(n):
  for bi in range(ai+1,n):
    ng,ok = bi,n
    while ok-ng>1:
      mid = (ng+ok)//2
      if l[mid]<l[ai]+l[bi]:
        ok = mid
      else:
        ng = mid
    ans += n-ng-1
print(ans)