peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n,*a=map(int,open(0).read().split())
ans=1000
for i,j in zip(a,a[1:]):
    if i<j:
        ans+=ans//i*abs(i-j)
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
inf = 10**17
mod = 10**9+7

a, b, k = map(int, input().split())

x = y = 0
if a < k: x = 0
elif k < a:
    print(a - k, b)
    exit(0)
else: x = k - a

k -= a
if b < k: y = 0
else: y = b - k

print(x, y)
# Judge status: Accepted
n,C,T=map(int,input().split())
t=[int(input()) for i in range(n)]
t.sort()
res=t[0]+T
cnt=1
ans=0
for i in range(1,n):
  if t[i]<=res and cnt<C:
    cnt+=1
  elif t[i]>res or cnt==C:
    ans+=1
    res=t[i]+T
    cnt=1
print(ans+1)
# Judge status: Wrong Answer
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
K = 60

bit_nums = [0 for _ in range(K)]
ans = 0
mod = 10 ** 9 + 7

for i in range(K):
    bit_nums[i] = np.sum(A >> i & 1)
    
ans = 0
for i in range(K):
    ans += (2 ** i) * (bit_nums[i] * (N - bit_nums[i]))
    ans %= mod

print(ans)
# Judge status: Wrong Answer
a,b,t = map(int,input().split())
ans = t//a*5
print(ans)
# Judge status: Accepted
a, b = map(int, input().split())

if a > b:
  K = a+b
else:
  K = b+a

if K % 2 == 0:
  print(K//2)
else:
  print('IMPOSSIBLE')
# Judge status: Accepted
N = int(input())
nums = list(map(int, input().split()))
nodes = []
currentLeaf = 1
fail = False
#check from top
for i in range(N + 1):
	nodes.append(currentLeaf)
	currentLeaf = (currentLeaf-nums[i])*2
	if (currentLeaf < 0):
		fail = True
		break 
if (fail):
	print(-1)
else:
  #check from bottom
  currentLeaf = 0
  totalNode = 0
  for i in reversed(range(N+1)):
      currentLeaf += nums[i]
      currentLeaf = min(currentLeaf, nodes[i])
      totalNode += currentLeaf

  if (fail):
      print(-1) 
  else:
      print(totalNode)
# Judge status: Accepted
N,L=map(int,input().split())
taste=list(range(L,N+L))
 
taste2=[]
for i in range(N):
    taste2.append((taste[i])**2)
 
X=0
for i in range(N):
    if taste2[i]==min(taste2):
        X+=taste[i]
        
print(sum(taste)-X)
# Judge status: Accepted
from math import gcd
n = int(input())
t = list([int(input()) for _ in range(n)])
x = 1
for i in t:
    x = x*i//gcd(x,i)
print(x)
# Judge status: Accepted
N = int(input())
R_L = []
for n in range(N):
    S,P = input().split()
    R_L.append([S,int(P)])

R_L2 = R_L.copy()
R_L2.sort( key=lambda x:(x[0],-x[1]))
for r in R_L2:
    print(R_L.index(r)+1)
# Judge status: Accepted
A = set(list(input()))
if len(A) == 2 and("S" in A and "N" in A ):
    print("Yes")
elif  len(A) == 2 and ("W" in A and "E" in A):
    print("Yes")
elif len(A) == 4:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a=int(input())
b=int(input())
print(6-(a+b))
# Judge status: Wrong Answer
n=int(input())

ans=[]
while n!=0:
    r=n%2
    ans.append(r)
    n=int((n-r)/(-2))

ans.reverse()

for i in ans:
    print(i,end='')
# Judge status: Accepted
S = [int(i) for i in input()]
K = int(input())

if sum(S)==len(S):
    print(1)
else:
    for i in range(len(S)):
        if S[i]!=1:
            print(S[i])
            break
        elif S[i]==1 and K-1<=i:
            print(1)
            break
# Judge status: Accepted
n, k = map(int, input().split())
P = list(map(int, input().split()))

P_ac = [sum(P[:k])]
for i in range(n-k):
    P_ac.append(P_ac[-1]-P[i]+P[i+k])

print((max(P_ac)+k)/2)
# Judge status: Accepted
N, M = map(int, input().split())

print(abs((N-2)*(M-2)))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
ans = [0] * N
for i in range(N-1):
    ans[A[i]-1] += 1

for i in range(N):
    print(ans[i])
# Judge status: Wrong Answer
N = int(input())
now = 1
sum = 0
for i in sorted(list(map(int,input().split()))):
    if(now == i):
        sum += 1
    else:
        for j in range(i - now -1):
            print(0)
        print(sum)
        sum = 1
        now = i
else:
    print(sum)
while(now < N):
    print(0)
    now += 1
# Judge status: Accepted
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [_b-_a for _a, _b in zip(a, b)]
x, y = 0, 0
for _c in c:
    if _c > 0:
        x += _c//2
    else:
        y -= _c
if x >= y:
    print('Yes')
else:
    print('No')
# Judge status: Accepted

def main2():
    import heapq
    n,k = map(int,input().split(" "))
    q = []
    for i in range(n):
        a,b = map(int,input().split(" "))
        heapq.heappush(q,(a,b))
    
    while k>0:
        a,b = heapq.heappop(q)
        k-=b
    
    print(a)
main2()
# Judge status: Accepted
s = input()
l = len(s)
dp = [[0, 0] for _ in range(l + 1)]
dp[1][0] = 1
for i in range(2, l + 1):
    if s[i - 1] != s[i - 2]:
        dp[i][0] = dp[i - 1][0] + 1
    dp[i][0] = max(dp[i][0], dp[i - 1][1] + 1)
    dp[i][1] = dp[i - 2][0] + 1
print(max(dp[-1]))
# Judge status: Accepted
import math

A,B,C,D = map(int,input().split())

#C,Dの最小公倍数
E = C*D//math.gcd(C,D)
def num_mult(fro,to,mult):
    goal = to//mult
    if fro % mult == 0:
        start = fro // mult
    else:
        start = fro // mult + 1
    
    return goal - start + 1

ans = B-A+1
#Cの倍数
ans -= num_mult(A,B,C)
#Dの倍数
ans -= num_mult(A,B,D)
#C,Dの公倍数
ans += num_mult(A,B,E)

print(ans)
# Judge status: Accepted
t = input()

s = list(t)

for i in range(len(s)):
    if s[i] == '?':
        if i > 0 and s[i - 1] == 'P':
            s[i] = 'D'
        elif i < len(s) - 1 and s[i + 1] == 'D':
            s[i] = 'P'
        else:
            s[i] = 'D'

print(''.join(s))
# Judge status: Accepted
import math
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
ans = r * g * b
for i in range(n-2):
  for j in range(i+1,math.ceil((i+n)/2)):
    if s[i] != s[j] and s[j] != s[j*2-i] and s[j*2-i] != s[i]:
      ans -= 1
print(ans)
# Judge status: Wrong Answer
A=int(input())
B=int(input())
ans=[1,2,3]
ans.remove(A)
ans.remove(B)
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
k = int(input())

for _ in range(k):
    if b <= a:
        b*=2
    elif c <= b:
        c*=2

if c > b > a:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
# coding: utf-8

num = int(input())
if num < 10:
    print(num)
elif num < 100:
    print(9)
elif num < 1000:
    print(10 + int(num % 100))
elif num < 10000:
    print(10 + 999)
elif num < 100000:
    print(9 + 1000 + num % 1000)
elif num == 100000:
    print(90909)
# Judge status: Accepted
s = {c:list(input()) for c in "abc"}
x = "a"
while s[x]:
    x = s[x].pop(0)
print(x.upper())
# Judge status: Wrong Answer
n,d = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(xarray[i]-xarray[j])%1!=0:
      ans+=1
print(ans)
# Judge status: Wrong Answer
K,A,B=map(int,input().split())
bis=1
if K==1:
  bis+=1
elif A>=B-1 or K-A+1<=0:
  bis+=K
else:
  if int((K-(A-1)))%2==0:
    bis=int(A+(B-A)*(K-(A-1))/2)
  else:
    bis=A+(B-A)*int((K-(A-1))//2)+1
print(bis)
# Judge status: Accepted
s = input()
ans = []
for i in range(len(s)-2):
    ans.append(abs(int(s[i:i+3])-753))
print(min(ans))
# Judge status: Accepted
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(n)]
ab.sort()

ans = 0
for a, b in ab:
    buy = [m, b][0 <= m-b]
    m -= buy
    ans += a*buy
print(ans)
# Judge status: Accepted
col = input().split()
num = list(map(int, input().split()))
col2 = input()

if col[0] == col2:
  print(num[0] - 1, num[1])
elif col[1] == col2:
  print(num[0], num[1] - 1)
# Judge status: Accepted
n,m=map(int,input().split())
flag=list(1 for _ in range(n+1))
count=list(0 for _ in range(n+1))
ans=0
for i in range(m):
    x=int(input())
    flag[x]=0

if n==1:
    ans=1
else:
    if flag[1]==1:
        count[1]=1
    if flag[2]==1:
        count[2]=count[1]+1
    for i in range(3,n+1):
        if flag[i]==1:
            count[i]=count[i-1]+count[i-2]
            
    ans=count[n]
print(ans%(10**9+7))
# Judge status: Accepted
n, m = map(int, input().split())

num = [0] * n

for x in range(0, m):
    a, b = map(int, input().split())
    num[a-1] += 1
    num[b-1] += 1

for x in range(0, n):
    print(num[x])
# Judge status: Accepted
n = int(input())

t = 10 ** 9 + 7

ans = 1
for i in range(1, n + 1):
    ans *= i
    ans %= t

print(ans)
# Judge status: Wrong Answer
a,b,k = map(int,input().split())
if a >= k:
    print(str(a - k) + " " + str(b))
else:
    print("0" + " " + str(b - k + a))
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
x = int(input())

cnt = 0

for h in range(0,c):
  for i in range(0,b):
    for j in range(0,a):
      if (x == ((500 * j) + (100 * i) + (50 * h))):
      	cnt = cnt +1

  print(cnt)
# Judge status: Accepted

n,m,K=map(int,input().split());print("YNeos"[all(k*m-K+l*n-k*l*2for k in range(n+1)for l in range(m+1))::2])
# Judge status: Wrong Answer
n=int(input())
temp=str(input())
templ=list(temp)
tempb=templ[len(templ)-1]
w=[0]*n
w[0]=temp
for i in range(0,n-1):
  temp=str(input())
  templ=list(temp)
  if temp in w or tempb!=templ[len(templ)-1]:
    print("No")
    break
else:
  print("Yes")
# Judge status: Accepted
h,a=map(int,input().split())
print(-(-h//a))
# Judge status: Accepted
# -*- coding: utf-8 -*-
import sys
import copy

def int2char(x):
    return chr(ord('a')+x)


N = int(input())
dp = ['a']
for i in range(N-1):
    nxt = []
    for s in dp:
        sets = set()
        for t in s:
            sets.add(t)
        for i in range(len(list(sets))+1):
            nxt.append(s+int2char(i))
    dp = copy.copy(nxt)

for s in dp:
    print(s)
# Judge status: Accepted
x, y =map(int, input().split())
if y % 2 == 1:
    print("No")
else:
    y = y / 2
    if  y > x*2 or y < x :
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
MOD = 10**9+7

n,a,b = map(int,input().split())

Sn = pow(2,n,MOD) - 1
if a > b:
    a,b = b,a
Xa, Xb = 1,1
Ya, Yb = 1,1
for i in range(b):
    if i < a:
        Xa = ( Xa * (n-i) ) % MOD
        Ya = ( Ya * pow((a-i),MOD-2, MOD)) % MOD
    Xb = ( Xb * (n-i) ) % MOD
    Yb = ( Yb * pow((b-i),MOD-2, MOD)) % MOD

ans = Sn - Xa*Ya % MOD - Xb*Yb % MOD
while ans < 0:
    ans += MOD
    
print(ans)
# Judge status: Wrong Answer
N = int(input())
an = list(map(int, input().split()))
four = 0
odd = 0
for a in an:
    if a % 2 == 1:
        odd += 1
    elif a % 4 == 0:
        four += 1
print('Yes' if 2*odd-2 <= four or N//2 == four and -(-N//2) == odd else 'No')
# Judge status: Wrong Answer
n = int(input())
a = n % 10
if (a == 3):
  print("bon")
elif (a == 2 or 4 or 5 or 7 or 9 ) :
  print("hon")
else:
  print("pon")
# Judge status: Wrong Answer
n , k = map(int,input().split())
ans = []
ans.append(n%k)
n = n//k
while n >= k:
    ans.append(n%k)
    n = n//k
ans.append(n)

print(len(ans))
# Judge status: Accepted
a,b,n = list(map(int,input().split()))
if n<b:
    x=n
    print(int(a*x/b)-a*int(x/b))
else:
    x=b-1
    print(int(a*x/b)-a*int(x/b))
# Judge status: Accepted
A = sum([list(map(int,input().split()))for _ in range(3)],[])
N = int(input())
b = [int(input()) for _ in range(N)]

f=sum(1<<i for i in range(9)if A[i]in b)
print('Yes'if[v for v in[7,56,73,84,146,273,292,448]if f&v==v]else'No')
# Judge status: Accepted
S = input()
mini = 1000
for i in range(len(S)-2):
    X = int(S[i] + S[i+1] + S[i+2])
    mini = min(abs(X-753), mini)
print(mini)
# Judge status: Accepted
N,A,B=map(int,input().split())
p=10**9+7
def f(n,x):
    a,b=1,1
    for i in range(1,x+1):
        a=a*n%p
        b=b*i%p
        n-=1
    return a*pow(b,p-2,p)
print((pow(2,N,p)-1-f(N,A)-f(N,B))%p)
# Judge status: Accepted
_ = input()
a = [int(x) for x in input().split()]

p = set()
q = 0
for i in a:
    if i < 3200:
        p.add(i//400)
    else:
        q += 1
else:
    lenp = len(p)
    print(max(lenp, 1), lenp + q)
# Judge status: Accepted
# https://atcoder.jp/contests/abc138/tasks/abc138_a

a = int(input())
s = input()
res = s if a >= 3200 else 'red'
print(res)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
for i in range(n-1, -1, -1):
    count = 0
    for j in range(i, n, i+1):
        count += ans[j]
    if count % 2 != a[i]:
        ans[i] = 1

if sum(ans) == 0:
    print(0)
    exit()

print(sum(ans))
for i in range(n):
    if ans[i] != 0:
        print(ans[i], end=" ")
# Judge status: Accepted
import math

K = int(input())

ans = 0
for i in range(1, K+1):
    for j in range(1, K+1):
        x = math.gcd(i, j)
        for k in range(1, K+1):
            ans += math.gcd(x, k)

print(ans)
# Judge status: Wrong Answer
a, b, x = map(int, input().split())
if x >= a and x < a+b:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n,k,s=map(int,input().split())
a=[s]*k+[10**10]*(n-k)
print(*a)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i] = a[a[i]-1]

print(b)
# Judge status: Wrong Answer
N, M = map(int, input().split())

# 偶偶　奇奇

if N != 0 and M != 0:
    ans = int(N * (N - 1) / 2) + int(M * (M - 1) / 2)
elif N == 0:
    ans = M * (M - 1)
elif M == 0:
    ans = N * (N - 1)
print(int(ans))
# Judge status: Wrong Answer
a,b,c = sorted(map(int,input().split()))
d=str(b)+str(c)
print(a+int(d))
# Judge status: Accepted
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
r=Counter([min(x//400,8) for x in a])
l=len(list(iter(r)))
if r[8]==0:
  print(l,l)
else:
  print(max(l-1,1),l-1+r[8])
# Judge status: Accepted
from itertools import combinations

n = int(input())
l = list(map(int, input().split()))

combi = combinations(l, 3)

ans = 0
for a, b, c in combi:
    if a != b and b != c and c != a:
        if a + b > c and b + c > a and c + a > b:
            ans += 1

print(ans)
# Judge status: Accepted
n = int(input())
a_l=[]
for i in range(n):
    a_l.append(int(input()))

record = set()
pos = 1
count = 0

while True:
    count += 1
    pos = a_l[pos-1]
    if pos == 2:
        print(count)
        break
    elif pos in record:
        print(-1)
        break
    record.add(pos)
# Judge status: Accepted
x, y = map(int, input().split())
ans = 0
while x <= y:
    x *= 2
    ans += 1
print(ans)
# Judge status: Wrong Answer
a = input().split()
for i in range(0,5):
  if (i + 1) == int(a[i]):
    continue
  else:
    print(a[i])
# Judge status: Accepted
L,M,N = map(int,input().split())
print("bust" if L+M+N >= 22 else "win")
# Judge status: Wrong Answer
s1=input()
s2=input()
flag=0
x=s1[::-1]
if x==s1:
    flag=1
if flag==0:
    print("NO")
else:
    print("YES")
# Judge status: Wrong Answer
from fractions import gcd

n=int(input())
A=list(map(int,input().split()))
DP=[[0,0] for _ in range(n)]
DP[0][0]=A[0]
DP[-1][1]=A[-1]

for i in range(1,n-1):
    left,right=i,n-i-1
    DP[left][0]=gcd(DP[left-1][0],A[i])
    DP[right][1]=gcd(DP[right+1][1],A[i])

ans=max(DP[1][1],DP[-2][0])
for i in range(1,n-1):
    ans=max(ans,gcd(DP[i-1][0],DP[i+1][1]))
print(ans)
# Judge status: Accepted
n =int(input())
A = list(map(int,input().split()))

B = [0]*n

for i in range(n)[::-1]:
  tmp = 0
  j = i+1
  
  while j<=n:    
    tmp += B[j-1]
    j += i+1
    
  if tmp%2 != A[i]:    
    B[i] = 1

print(sum(B))
print(*[i+1 for i in range(n) if B[i]])
# Judge status: Wrong Answer
a,b,c,x,y = map(int,input().split())

ans = 0

if a + b >= c * 2:
    ans = c * 2 * min(x,y)
    if min(a,b) >= c * 2:
        ans += (max(x,y) - min(x,y)) * (c * 2)
    else:
        ans += min((max(x,y) - min(x,y)) * a,(max(x,y) - min(x,y)) * b) 
else:
    ans = a * x + b * y

print(ans)
# Judge status: Accepted
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]
E = [0] * 26
for i in range(D):
    ans = -1
    max_v = -float("inf")
    for j in range(26):
        tmp = S[i][j] - (C[j] * (i-E[j]))
        if tmp > max_v:
            ans = j + 1
            max_v = tmp
    E[ans-1] = i
    print(ans)
# Judge status: Accepted
K = int(input())
S = input()

len_S = len(S)

if len_S <= K:
    print(S)
else:
    print(S[:K] + '...')
# Judge status: Accepted
n = int(input())
A = sorted(list(map(int,input().split())))
for i in range(n):
    if A[i]*2>A[-1]:
        ind = i
        break
ind -= 1
a = A[ind]
b = A[-1]-A[ind+1]
if a>=b:
    print(A[-1],a)
else:
    print(A[-1],A[ind+1])
# Judge status: Accepted
n, t = map(int, input().split())

for x in range(n+1):
    for y in range(n+1 -x):
        z = n - x - y
        if z < 0:
            z = 0
        if x*10000 + y*5000 + z*1000 == t:
            print(x, y , z)
            exit()

print("-1 -1 -1")
# Judge status: Wrong Answer
n,k=map(int,input().split())
if n%k==0:
  print(0)
else:
  print(n//k-n%k)
# Judge status: Accepted
c=[list(map(int,input().split())) for _ in range(3)]
a_a=set()
a_b=set()
a_c=set()

for i in range(3):
    a_a.add(c[i][0]-c[i][1])
    a_b.add(c[i][1]-c[i][2])
    a_c.add(c[i][2]-c[i][0])
if len(a_a)==1 and len(a_b)==1 and len(a_c)==1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


sx,sy,tx,ty = map(int, input().split())
wx = tx-sx
wy = ty-sy
ans = "U"*wy + "R"*wx + "D"*wy + "L"*wx + ("L"*1 + "U"*(wy+1) + "R"*(wx+1) + "D"*1) + ("R"*1 + "D"*(wy+1) + "L"*(wx+1) + "U"*1)
print(ans)
# Judge status: Wrong Answer
o = input()
e = input()
if len(o) == len(e):
  for i in range(len(o)):
    print(o[i]+e[i],end='')
else:
  for i in range(len(e)):
    print(o[i]+e[i],end='')
  print(e[-1])
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
import math
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
xlist = []
wa = sum(a)
for i in a:
  xlist.append((k+n)*i/wa)

xlist_int = []
for i in xlist:
  j = int(i)
  if j == 0:
    j = 1
  xlist_int.append(j)

amari = n+k-sum(xlist_int)
xlist_hi = [xlist_int[i]/xlist[i] for i in range(n)]
xlist_hi.sort()
ans = math.ceil(wa/(k+n)/xlist_hi[amari])


print(ans)
# Judge status: Wrong Answer
x = int(input())
q, r = divmod(x, 100)
if q < r//5:
  print(0)
else:
  print(1)
# Judge status: Accepted
A,B,X = map(int,input().split())
s = "YES"
if A > X or A+B < X:
  s = "NO"
print(s)
# Judge status: Wrong Answer
def calc(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


def main():
    s = int(input())
    ans = [s]
    while True:
        tmp = calc(ans[-1])
        ans.append(tmp)
        if ans.index(tmp) != len(ans)-1:
            print(len(ans))
            break
# Judge status: Wrong Answer
A,B = (float(x) for x in input().split())
ans = A * B
print(int(ans))
# Judge status: Accepted
n =  int(input())
d = [list(map(int,input().split())) for i in range(n)]
cnt = 0

for i in range(n):
    if d[i][0] == d[i][1]:
        cnt += 1
        if cnt == 3:
            print('Yes')
            break
    else:
        cnt = 0
else:
    print('No')
# Judge status: Accepted
S = input()
Q = int(input())
T1 = 0
S_left = ''
S_right = ''
for _ in range(Q):
  a = list(map(str,input().split()))
  if a[0] == '1':
    T1 += 1
  elif a[0] == '2':
    if ((a[1]=='1')and(T1%2==0)) or ((a[1]=='2')and(T1%2!=0)):
      S_left = a[2]+S_left
    else:
      S_right = S_right+a[2]
S = S_left+S+S_right
if T1 % 2 == 0:
  print(S)
else:
  print(S[::-1])
# Judge status: Wrong Answer
n, l = map(int, input().split())
taste = [l+i for i in range(n)]
ans = [abs(i) for i in taste]

del ans[ans.index(min(ans))]
print(sum(ans))
# Judge status: Accepted
import math
import collections
import fractions
import itertools

def solve():
    n = int(input())
    s = [input() for i in range(n)]
    print(len(set(s)))
    return 0

if __name__ == '__main__':
    solve()
# Judge status: Accepted
A,B = map(int,input().split())
s = list(map(int,input().split()))
if sum(s) <= A:
  print(A-sum(s))
else:
  print("-1")
# Judge status: Accepted
# -*- coding: utf-8 -*-

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

for i in range(N-K):
  if A[i] < A[i+K]:
    print('Yes')
  else:
    print('No')
# Judge status: Accepted
X, Y = map(int, input().split())

if 0 <= X < Y or X < Y <= 0:
    print(Y-X)
elif 0 < Y < X or Y < X < 0:
    print(2+X-Y)
elif X < 0 < Y or Y < 0 < X:
    print(1+abs(X+Y))

if X == 0 and Y < 0:
    print(abs(Y)+1)
elif Y == 0 and X > 0:
    print(abs(X)+1)
# Judge status: Accepted
N=input()
if N[-1]=="3":
  print("bon")
elif N[-1]=="0" or N[-1]=="1" or N[-1]=="6" or N[-1]=="8":
  print("pon")
else:
  print("hon")
# Judge status: Accepted
Q, H, S, D = map(int, input().split())
N = int(input())
S = min(min(Q * 2, H) * 2, S)
D = min(S * 2, D)
print(N//2*D + N%2*S)
# Judge status: Wrong Answer
N, M= map(float, input().split())
if N > round(M/2):
	print(round(M/2))
else:
	c=N+(M-N*2)//4
	print(c)
# Judge status: Wrong Answer
n,k = map(int,input().split())
print(n%k)
# Judge status: Accepted
N, M = map(int, input().split())

if M%N == 0:
	print(M//N)
	exit()

A = []
for i in range (1, M//N+1):
	if M%i == 0:
		A.append(i)

print(A[-1])
# Judge status: Accepted
s = input()
t = input()

s = sorted(s)
s = str(''.join(s))
t = sorted(t, reverse=True)
t = str(''.join(t))

if s < t:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
A, B = map(int, input().split())
print(A + B if A + B < 24 else (A + B) - 24)
# Judge status: Accepted
a,b,c = map(int,input().split())

if a*c<b:
  print(c)
else:
  print(int(b/a))
# Judge status: Accepted
n, m = map(int, input().split())

stair = [1]*(n+1)
for i in range(m):
    a = int(input())
    stair[a] = 0

for i in range(2, n+1):
    stair[i] *= (stair[i-1] + stair[i-2])

print(stair[n]%(10**9+7))
# Judge status: Accepted
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
ca = Counter(A)
ca = sorted(ca.items(), key=lambda x:-x[0])
cnt = 0
m = []
for k, v in ca:
  if 3 >= v >= 2:
    cnt += 1
    m += [k]
  elif v >= 4:
    cnt += 2
    m += [k, k]
  if cnt >= 2:
    break

if len(m) <= 1:
  print(0)
  exit()
print(m[0]*m[1])
# Judge status: Wrong Answer
a=int(input())
f=0
for i in range(1,10):
  if a==0:
    print("No")
    break
  elif a%i==0:
    f=1
if f==1:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = input()
ans=int(N[-1])    
if(ans==3):
  	print("bon")
elif(ans==0 or ans==1 or ans==6 or ans==8):
    print("pon")
else:
    print("hon")
# Judge status: Accepted
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

n = int(input())
ans = 0
for i in range(1,n+1):
  if i % 2 == 1 and len(make_divisors(i)) == 8:
    ans += 1
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
print(min(a+b,a+c,b+a,b+c,c+a,c+b))
# Judge status: Accepted
s = input()
if 1 <= int(s[0:2]) <= 12:
  if 1 <= int(s[2:4]) <= 12:
    print("AMBIGUOUS")
  else:
    print("MMYY")
else:
  if 1 <= int(s[2:4]) <= 12:
    print("YYMM")
  else:
    print("NA")
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))
# print(n)
# print(A)

B = [0]*n
for i in range(n):
    B[i] = A[i] - (i+1)
# print('B',B)
b = sum(B)
bmin = sum(B)
# print('sumB',b)
b //= n
# print('b',b)
# print('bmin',bmin)

ans1 = 0
ans2 = 0
ans3 = 0
for i in range(n):
    ans1 += abs( B[i] - b )
    ans2 += abs( B[i] - (b-1) )
    ans3 += abs( B[i] - (b+1) )


print(min([ans1, ans2, ans3]))
# print(ans1)
# Judge status: Wrong Answer
n = int(input())

N = n + 1
totalcount = 0

for i in range(1,N):
  a = str(i)
  a_first = a[0]
  a_end = a[len(str(i)) - 1]
  for j in range(1,N):
    b = str(j)
    b_first = b[0]
    b_end = b[len(str(j)) - 1]
    if a_first == b_end and a_end == b_first:
      totalcount += 1
      print(a,j)
print(totalcount)
# Judge status: Accepted
n=int(input())
now=[0,0,0]#t,x,y
f=True
for i in range(n):
    t,x,y=map(int,input().split())
    k=abs(x-now[1])+abs(y-now[2])
    l=abs(t-now[0])
    if not(k<=l and abs(k-l)%2==0):
        f=False
    now=[t,x,y]
print("Yes" if f else "No")