peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
H, N = map(int, input().split())
inf = 1 << 32
dp = [inf] * (H + 1)
dp[0] = 0
for i in range(N):
    a,b = map(int, input().split())
    for j in range(H+1):
        dp[min(H,j + a)] = min(dp[min(H,j + a)], dp[j] + b)
print(dp[H])
# Judge status: Wrong Answer
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*M
C=[0]*M
for i in range(M):
    B[i],C[i]=map(int,input().split())

for i in range(M):
    A.sort()
    for j in range(B[i]):
        if A[j] < C[i]:
            A[j]=C[i]
            print(i,j)
        else:
            break
        if j==N-1:
            break
print(sum(A))
# Judge status: Accepted
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]
hl.sort()

h_min = min(hl[i+k-1] - hl[i] for i in range(n-k+1))
print(h_min)
# Judge status: Wrong Answer
N,M=map(int,input().split())
ans=1
for i in range(1,int(M**0.5)+1):
    if M%i==0 and M//N>=i:
        ans=max(ans,i)
print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())
judge = ""
if a == b:
    judge = "Draw"
elif a == 1:
    judge = "Alice"
elif b == 1:
    judge = "Bob"
if a < b:
    judge = "Bob"
elif a > b:
    judge = "Alice"
else:
    judge = "Draw"

print(judge)
# Judge status: Accepted
a = int(input())
b = int(a / 2)
c = int((a + 1) / 2)

if a % 2 == 0:
    print(b)
else:
    print(c)
# Judge status: Accepted
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
x = a[-1]
N = a[-1]//2

a = a[:-1]
y = bisect.bisect_left(a,N)
if len(a) <= y: ans = a[y-1]
else:
    ans = a[y]
    if 0 < y and abs(N-ans) > abs(N-a[y-1]): ans = a[y-1]
    if y < len(a)-1 and abs(N-ans) > abs(N-a[y+1]): ans = a[y+1]
print(x,ans)
# Judge status: Accepted
k,s=[int(i) for i in input().split()]

count=0
for x in range(k+1):
    for y in range(k+1):
        if 0<=s-(x+y)<=k:
            count+=1
               
                
print(count)
# Judge status: Accepted

n=list(input())

if (n[0]==n[1]==n[2]) or (n[1]==n[2]==n[3]) or (n[0]==n[1]==n[2]==n[3]):print('Yes')
else:print('No')
# Judge status: Accepted
N, K = map(int, input().split())
A = [int(x) for x in input().split()]

when = [-1 for _ in range(N+1)]
new = 1
i = 0

while when[new] == -1:
    when[new] = i
    new = A[new - 1]
    i += 1

line = when[new]
roop = i - when[new]

if K > line:
    K = (K - line) % roop
    for j in range(N+1):
        when[j] -= line
    
for j in range(N+1):
    if when[j] == K:
        print(j)
        break
# Judge status: Wrong Answer
s = input()
if s == "ABC":
  print("ADC")
else:
  print("ABC")
# Judge status: Accepted
import numpy

N = int(input())
A = list(map(int, input().split()))
res = numpy.cumsum(A)

if res[-1] % 2 == 0:
  L = res[-1]//2
  ans = [abs(r - L) for r in res]
  print(2*min(ans))
else:
  L1 = res[-1]//2
  L2 = L1 + 1
  ans = [min(abs(r - L1),abs(r-L2)) for r in res]
  print(2*min(ans)+1)
# Judge status: Wrong Answer
S = list(map(str, input()))
S[3]='8'
print(S)
# Judge status: Wrong Answer
l, r = map(int, input().split())

l %= 2019
r %= 2019

if l >= r:
    print(0)
    exit()

ans = 2018

for i in range(l, r):
    for j in range(i+1, r+1):
        ans = min(ans, (i*j)%2019)

print(ans)
# Judge status: Accepted
from fractions import gcd

n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7

lcm = 1
for i in range(n):
  lcm = lcm * a[i] // gcd(lcm, a[i])
lcm %= mod

sum_b = 0
for i in range(n):
  sum_b = (sum_b + lcm * pow(a[i], mod - 2, mod)) % mod
print(sum_b)
# Judge status: Accepted
p, q, r = map(int, input().split())
print(min(p+q, q+r, p+r))
# Judge status: Accepted
N=int(input())
for i in range(N,1000):
    if i in [111,222,333,444,555,666,777,888,999]:
        print(i)
        break
# Judge status: Accepted
from math import sqrt, ceil
S = int(input())

"""
|x1y2 - x2y1| = S

"""

x1 = ceil(sqrt(S))
x2 = x1*x1 - S
print(0,0,x1,1,x2,x1)
# Judge status: Accepted
import math
A, B, H, M = map(int, input().split())
Hno = 30 * H + 0.5 * M
Mno = 6 * M
 
angle = Hno - Mno
if angle < 0:
    angle *= -1
 
cos = math.cos(math.radians(angle))
x = A ** 2 + B ** 2 - (2 * A * B * cos)
print(math.sqrt(x))
# Judge status: Accepted
a,b,c=input()
if a=='7' or b=='7' or c=='7':
  print("Yes")
else:
  print('No')
# Judge status: Wrong Answer
N=list(input())
print(N)
if N[0]=='9' or N[1]=='9':
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import collections

N, K = map(int, input().split())
cntA = sorted(collections.Counter(list(map(int, input().split()))).items(), key=lambda x: x[1])

ans = 0
for i in range(max(0, len(cntA) - K)):
    ans += cntA[i][1]
print(ans)
# Judge status: Accepted
def is_prime(a):
    if a == 2:
        return True
    for i in range(2, int(a**0.5)+2):
        if a%i == 0:
            return False
    return True

X = int(input())

for i in range(X, 100004):
    if is_prime(i):
        print(i)
        break
# Judge status: Accepted
a = [int(input())]
flg = False
while flg == False:
    now = a[-1] 

    if a[-1] % 2 == 0:
        new = int(a[-1] / 2)
    else:
        new = int(a[-1] * 3 + 1)

    if new in a:
        flg = True
    else:
        a.append(new)
print(len(a)+1)
# Judge status: Wrong Answer
def get_c(p):
    c = 1
    while 1:
        if pow(2, c) >= p:
            return c
        c += 1


# input
N, K = map(int, input().split())

# check
prob = [1 / N] * N
for p, n in zip(range(1, N + 1), prob):
    c = get_c(K - p)
    n *= 0.5 ** c

print(sum(prob))
# Judge status: Accepted
import itertools

n = input()
l = list(map(int, input().split()))
ls = sorted(set(l))
ans = 0
for p in itertools.combinations(ls, 3):
    if p[0] + p[1] > p[2]:
      ans += l.count(p[0]) * l.count(p[1]) * l.count(p[2])
print(ans)
# Judge status: Accepted
s = input()

ks = "keyence"

if s.startswith(ks) or s.endswith(ks):
  print("YES")
  exit(0)
  
for i in range(1, len(ks)):
  k1 = ks[:i]
  k2 = ks[i:len(ks)]
  if s.startswith(k1) and s.endswith(k2):
    print("YES")
    exit(0)

print("NO")
# Judge status: Wrong Answer
a,b,c,k = map(int, input().split())

if a==b==c:
  print(0)
  exit()
  
itr = k//3
amari = k%3

if itr > 100:
  print("Unfair")
  exit()
  
a *= pow(2,itr)
b *= pow(2,itr)
c *= pow(2,itr)

for i in range(amari):
  newa=b+c
  newb=a+c
  newc=b+c
  a,b,c = newa,newb,newc

if abs(a-b) > 10**18:
  print("Unfair")
else:
  print(a-b)
# Judge status: Accepted
a,b,c=list(map(int,input().split()))
for n in range(101):
    if (a*n) % b ==c:
        print("YES")
        exit()
print("NO")
# Judge status: Wrong Answer
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left #bisect_left(list, value)
#from fractions import gcd
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
def pri(x): print('\n'.join(map(str, x)))

N = int(input())

if N>999:
    print('ABC')
else:
    print('ABD')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
s = 0
P = (A[0:N])
Q = A
for i in range(N-1):
    if Q[i] < Q[i+1]:
        Q[i+1] = Q[i]
for i in range(N):
    if P[i] == Q[i]:
        s += 1
print(s)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
ans = 0

if n == 0 and A[0] == 1:
    print(1)
    exit()
if n == 0 and A[0] != 1:
    print(-1)
    exit()
if n != 0 and A[0] == 1:
    print(-1)
    exit()


start = 1
way = sum(A)

for i in range(1,n+1):
    start *= 2

    if start < A[i]:
        print(-1)
        exit()
    if start > way:
        start = way

    ans += start
    #print(start, start-A[i])
    start -= A[i]
    way -= A[i]
#print()
print(ans+1)
# Judge status: Accepted
n,k = map(int,input().split())
R,S,P = map(int,input().split())
points = {'r':P,'s':R,'p':S}
l = list(input())
com = ['']*n
ans = 0
for i,j in enumerate(l):
  p = points[j]
  com[i] = j
  if (i-k>=0) and com[i] == com[i-k]:
    com[i] = ''
    p = 0
  ans += p
print(ans)
# Judge status: Accepted
a = int(input())
als = [0]*(10**6+2)
for i in range(0,10**6+2):
    als[a] = 1
    if a%2 == 0:
        a = a//2
    else:
        a = 3*a+1
    if als[a] == 1:
        print(i+2)
        exit()
# Judge status: Accepted
N = int(input())

if 1 <= N <= 999:
    print("ABC")
elif 1000 <= N <= 1998:
    print("ABD")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
M = 1000
stock = 0
for i in range(1, N):
  # print(M)
  if A[i-1] < A[i]:
    stock = M // A[i-1]
    M -= stock * A[i-1]
  elif A[i-1] > A[i]:
    M += stock * A[i-1]
    stock = 0
M += stock * A[-1]
print(M)
# Judge status: Wrong Answer
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
import decimal

def main():
    numbers=[]
    n = int(input())
    t,a = map(int,input().split())
    numbers=list(map(int,input().split()))
    dp=[]
    hensu=decimal.Decimal('0.006')
    for number in numbers:
        tmp=t-number*hensu
        dp.append(a-tmp)
    print(dp)
    print(dp.index(min(dp))+1)

if __name__=="__main__":
    main()
# Judge status: Accepted
import math
from functools import reduce
K=int(input())
a=0
def gcd(*numbers):
    return reduce(math.gcd,numbers)
#def gcd_list(numbers):
 #   return reduce(math.gcd,numbers)
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            a+=gcd(i,j,k)
print(a)
# Judge status: Wrong Answer
N = int(input())
A = [int(a)-i-1 for i,a in enumerate(input().split(),1)]
A.sort()
b = int(sum(A)/len(A))
c = 10**9
for j in range(b-10, b+11):
    k = sum(map(lambda x:abs(x-j), A))
    c = min(c,k)
print(c)
# Judge status: Accepted
S=input()

a=int(S[:2])
b=int(S[2:])

if(1<=a<=12 and 1<=b<=12):
  print("AMBIGUOUS")
elif(1<=a<=12):
  print("MMYY")
elif(1<=b<=12):
  print("YYMM")
else:
  print("NA")
# Judge status: Accepted
#129_A
a=sorted(list(map(int,input().split())))
print(sum(a)-max(a))
# Judge status: Accepted
x,y=list(map(int, input().split()))
if x%3==0 or y%3==0 or (x+y)%3==0:
	print('Possible')
else:
	print('Impossible')
# Judge status: Wrong Answer
n, k = map(int, input().split())
n_sum = 0

def min_cnt(n, k):
  res = 2
  cnt = 1
  while k > res:
    cnt += 1
    res *= 2*n
  return cnt

if n < k:
  for i in range(n):
    num = k/2 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
else:
  for i in range(k - 1):
    num = k//2 + 1 - (i + 1)
    n_sum += (1/n) * ((1/2) ** num)
  n_sum += (n - k + 1) / n

print(n_sum)
print(5//2)
# Judge status: Accepted
X = [int(input()) for _ in range(4)]
ans = 0
for i in range(X[0] + 1):
    for j in range(X[1] + 1):
        for k in range(X[2] + 1):
            if 500 * i + 100 * j + 50 * k == X[3]:
                ans += 1
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

ans = 1
mm = 0
i = 0
while(i<N-2):
    if (A[i]-A[i+1])*(A[i+1]-A[i+2])<0:
        ans += 1
        i+=1
    i+=1
    
print(ans)
# Judge status: Accepted
d = list(map(int, input().split()))

d.sort()

print(d[0] + d[1])
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a = [a[i] - (i + 1) for i in range(len(a))]
a.sort()

median = a[len(a) // 2]
cnt = 0
for i in range(len(a)):
    cnt += abs(a[i] - median)

print(cnt)
# Judge status: Accepted
n = int(input())
A = list(map(int,input().split()))
b = ""
inv = 1
import collections
b = collections.deque()
for i in range(n):
    a = A[i]
    if inv ==1:
        b.append(a)
    else:
        b.appendleft(a)
    inv *=-1
if inv ==1:
    print(*b)
else:
    print(*reversed(b))
# Judge status: Accepted
from collections import Counter
INF = 114514191981036436433-4
n = int(input())
s = input()

b = Counter(s)
ans = b["."]

cur = b["."]

for i in range(n):
    if s[i] == "#":
        cur += 1
    else:
        cur -= 1
        
    ans = min(ans,cur)
    
print(ans)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
print(max(a*c,b*d,a*d,b*d))
# Judge status: Accepted
n = int(input())
m = 10**9 + 7

L = [-1 for _ in range(n+10)]
L[0] = 0
L[1] = 0
L[2] = 1
L[3] = 1
L[4] = 1
def f(m):
    if m <= 5:
        return L[m-1]
    a = 1
    for i in range(3, m-2):
        if L[i-1] == -1:
            L[i-1] = f(i)
        a += L[i-1]
    return a

print(f(n) % m)
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    h, w = map(int, input().split())
    if h == 1 or w == 1:
        ans = 1
    elif h % 2 == 0:
        ans = (h // 2) * w
    elif w % 2 == 0:
        ans = (w // 2) * h
    else:
        ans = h * (w // 2) + (h // 2) + 1
    print("%d" % ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import math
x,y = map(int, input().rstrip().split(' '))
# n = int(math.log2(y/x))
# print(n+1)

for i in range(100):
  a = x*(2**i)
  if(a<=y):
    continue
  else:
    print(i)
    break
# Judge status: Wrong Answer
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())
  
a,b=input2()

if a>=13:
	print(b)
elif a>=6 and a<=12:
	print(b/2)
else:
	print(0)
# Judge status: Wrong Answer
from functools import reduce
from fractions import gcd
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
x = reduce(gcd,T)
sum=1
if x ==1:
    for i in set(T):
        sum*=i
    print(sum)
else:
    print(max(T))
# Judge status: Accepted
def main():
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline
    from heapq import heappush, heappop

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

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

    ans = 0
    heap = []
    for a in range(M):
        for b in AB[a]:
            heappush(heap, b)
        if heap:
            ans -= heappop(heap)
    
    print(ans)

main()
# Judge status: Accepted
a = [int(input()) for i in range(6)]
if a[4]-a[0]<=a[5]: print("Yay!")
else: print(":(")
# Judge status: Wrong Answer
import math
import sys
import collections
import bisect
readline = sys.stdin.readline


def main():
    keyence = "keyence"
    s = readline().rstrip()
    lenS = len(s)
    for i in range(1, 7):
        if s.count(keyence[0:i]) > 0:
            idx = s.index(keyence[0:i]) + i + 1
            if s[idx-1:lenS].count(keyence[i:7]) > 0:
                print("YES")
                return
    print("NO")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import sys
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input()) 
c = collections.Counter(S)
a = c.most_common()
s = c.most_common()[0][1]
ans = []
for i in a:
    if i[1] == s:
        print(i[0])
        sys.stdout.flush
# Judge status: Accepted
import sys
from collections import Counter

S = sys.stdin.readline().strip()
counter = Counter(S)
counter = sorted(counter.items(), key=lambda x: x[1])
# print(counter)

if len(counter) == 1:
    if counter[0][1] == 1:
        print("YES")
    else:
        print("NO")
elif len(counter) == 2:
    if counter[0][1] == 1 and counter[1][1] == 1:
        print("YES")
    else:
        print("NO")
else:
    if counter[0][1] + 1 < counter[2][1]:
        print("NO")
    else:
        print("YES")
# Judge status: Accepted
#B - Count Balls
N, A,B= map(int, input().split())

a = N % (A+B)
b = N // (A+B)
if a <= A:
    print(b*A+a)
else:
    print(b*A+A)
# Judge status: Accepted
import datetime

S = datetime.date(*map(int, input().split('/')))
x = datetime.date(2019, 4, 30)

print('Heisei' if S <= x else 'TBD')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
ans = 0
l = [0]*(3*10**5+10)
for i in range(1,len(A)):
  x = i-A[i]
  if x<0:
    continue
  else:
    l[x]+=1
if A[0]<=2*10**5:
  ans+=l[A[0]]
for i in range(1,N):
  x = i+A[i]
  if x<0:
    continue
  if x>2*10**5:
    continue
  
  l[i-A[i]]-=1
  ans+=l[x]
  
print(ans)
# Judge status: Accepted
# 幅優先探索
from collections import deque

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

links = [[] for _ in range(N + 1)]
for a, b in AB:
    links[a].append(b)
    links[b].append(a)

result = [-1] * (N + 1)
q = deque([1])
while q:
    i = q.popleft()
    for j in links[i]:
        if result[j] == -1:
            result[j] = i
            q.append(j)
print('Yes')
print('\n'.join(str(i) for i in result[2:]))
# Judge status: Accepted
n,m = map(int, input().split())
A = list(map(int, input().split()))

s = 0
for i in range(n):
  if A[i] >= sum(A)/(4*m):
    s += 1
  else:
    pass
  
if s >= m:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n, tl = [int(x) for x in input().split()]

c_init = 10 * 4
ans = c_init
for _ in range(n):
    c, t = [int(x) for x in input().split()]
    if (t <= tl) and (c < ans):
        ans = c
if ans == c_init:
    ans = "TLE"
print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

n, k, q = [int(w) for w in input().split()]


score = [0] * n

for i in range(q):
    a = int(input())
    score[a - 1] += 1
    

for s in score:
    cond = k - q + a > 0
    print("Yes" if cond else "No")
# Judge status: Wrong Answer
S = input()
T = input()

min_count = len(T)
for i in range(len(S) - len(T)):

    count = 0
    for x in range(len(T)):
        if S[i+x] != T[x]:
            count += 1

    if count < min_count:
        min_count = count

print(min_count)
# Judge status: Accepted
n,a,b = map(int,input().split())
s = input()
ans = ["0"]*n
acnt = 0
bcnt = 0
for i in range(n):
  if s[i] == "a":
    if acnt < a+b:
      acnt += 1
      ans[i] = "Yes"
    else:
      ans[i] = "No"
  elif s[i] == "b":
    bcnt += 1
    if acnt < a+b and bcnt <= b:
      acnt += 1
      ans[i] = "Yes"
    else:
      ans[i] = "No"
  else:
    ans[i] = "No"
print(*ans,sep='\n')
# Judge status: Wrong Answer
S='ABC'
if S=='ABC':
    print('ARC')
else:
    print('ABC')
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
print('YES' if len(a) == len(set(a)) else 'NO')
# Judge status: Accepted
n = int(input())
c = 0
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        c += 1
    else:
        c = 0
    if c >= 3:
        print("Yes")
        break
else:
    print("No")
# Judge status: Accepted
a = [int(x) for x in input().split()]
a.sort()
print(a[0] + a[1])
# Judge status: Accepted
N, M = map(int, input().split())
if N == 1 and M == 1:
    print(1)
elif N==1 or M==1:
    print(M*N-2)
else:
    print((M-2)*(N-2))
# Judge status: Accepted
k,n = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
dmax = 0
for i in range(1,n):
  if a[i]-a[i-1]>dmax:
    dmax = a[i]-a[i-1]
if k-a[-1]+a[0] > dmax:
  dmax = k-a[-1]+a[0]
print(k-dmax)
# Judge status: Accepted
a, b, c = sorted(map(int, input().split()))

diff1 = c - b
a += diff1
diff2 = c - a
if diff2 % 2 == 0:
    diff2 //= 2
else:
    diff2 += 1
    diff2 //= 2
    diff2 += 1

print(diff1 + diff2)
# Judge status: Wrong Answer
n = int(input())
list_A1 = list(map(int, input().split()))
list_A2= list(map(int, input().split()))
ans = 0
for i in range(1, n):
    k = sum(list_A1[:i]) + sum(list_A2[i:]) + list_A1[i]
    ans = max(ans, k)

if n == 1:
    ans = list_A1[0] + list_A2[0]

print(ans)
# Judge status: Wrong Answer
n,*v=3,10,10,10
v.sort()
print(sum(v[i]<<i+(i==0)for i in range(n))/2**n)
# Judge status: Accepted
X,Y = list(map(int,input().split()))

MAXN = 2*(10**6)+10
p = 10**9+7
f = [1]
for i in range(MAXN):
    f.append(f[-1] * (i+1) % p)
def nCr(n, r, mod=p):
    return f[n] * pow(f[r], mod-2, mod) * pow(f[n-r], mod-2, mod) % mod


Z = (X+Y)//3
if Z*3!=X+Y:
    print(0)
else:
    P,Q = X-Z, Y-Z
    if P<0 or Q<0:
        print(0)
    else:
        print(nCr(Z,P))
# Judge status: Accepted
a,b,c=map(int, input().split())
if a+b>=c:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a,b = input().split()

print(a*int(b) if a<b else b*int(a))
# Judge status: Wrong Answer
x, y = map(int, input().split())
if x <= y: print(y-x)
elif x < 0 and y < 0:
    print(abs(y-x)+2)
else:
    print(abs(-y - x) + 1)
# Judge status: Accepted
N = int(input())
m = 10000000
def judge_1(t):
  c = 0
  while t>0:
    c += t%6
    t = t//6  
  return c
def judge_2(t):
  c = 0
  while t>0:
    c += t%9
    t = t//9  
  return c
for i in range(N+1):
  m = min(m, judge_1(i)+judge_2(N-i))
print(m)
# Judge status: Accepted
N,x = map(int,input().split())
a = sorted(list(map(int,input().split())))
s = [sum(a[:i+1]) for i in range(N)]

if s[-1] == x:
  print(N)
  exit()
else:
  for i in range(N-1):
    if s[i] > x:
      print(i)
      exit()
      
  print(N-1)
# Judge status: Accepted
A, B = input().split()
A = int(A)
B = int(B[0]+B[2:])
C = A*B
D = str(C)[:-2]
if D == "":
    D = 0
else:
    D = int(D)
print(D)
# Judge status: Accepted
f_inf = float('inf')
N, K = map(int, input().split(' '))
h = list(map(int, input().split(' ')))
h.append(f_inf)
h.append(f_inf)
dp = [f_inf for _ in range(N + 100)]
dp[0] = 0
for i in range(N - 1):
  for j in range(1, K + 1):
    if i + j > N - 1:
      break
    dp[i+j] = min(dp[i] + abs(h[i+j] - h[i]), dp[i+j])
print(dp[N-1])
# Judge status: Wrong Answer
import re
N=int(input())
s=input()
s=re.sub(r"^\.+","",s)
s=re.sub(r"#$","",s)
print(min(s.count("."),s.count("#")))
# Judge status: Accepted
s = input()

s = s.replace('hi', '')
#print(s)
if s == '':
  print('Yes')
  exit()
print('No')
# Judge status: Accepted
import sys
input=lambda: sys.stdin.readline().rstrip()
D = int(input())
C = [int(i) for i in input().split()]
S = [[int(i) for i in input().split()] for _ in range(D)]


for i in range(D):
    print(1)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

tmp_s = {i for i in range(A, A+K)}
tmp_l = {i for i in range(B+1-K, B+1)}

ans = list(tmp_s.union(tmp_l))
ans.sort()

print(*ans, sep="\n")
# Judge status: Wrong Answer
N=int(input())
S=input()
stack= []
ans=""

for i in range(N):
  if S[i]=="(":
    stack.append(S[i])
  else:
    if len(stack)>0:
      ans = stack.pop()+ ans + ")"
    else:
      ans = "(" + ans + ")"

nokori=len(stack)
ans += nokori * "(" + nokori * ")"

print(ans)
# Judge status: Accepted
a=input()
if len(set(a))==3:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N=int(input())
S=set()
for i in range(N):
    S.add(str(input()))

print(len(S))
# Judge status: Accepted
a, b, c = map(int, input().split())
if b - a == c - b:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
N = input()
a = int(N[-1])
if a==2 or a==4 or a==5 or a==7 or a==9:
    print("hon")
elif a==0 or a==1 or a==6 or a==8:
    print("pon")
else:
    print("bon")
# Judge status: Wrong Answer
W, H, N = map(int,input().split())
p = 0
q = W
r = 0
s = H
for i in range(N):
    x, y, a = map(int,input().split())
    if a == 1:
        if x > p:
            p = x
    if a == 2:
        if x < q:
            q = x
    if a == 3:
        if y > r:
            r = y
    if a == 4:
        if y < s:
            s = y
ans = (q-p)*(s-r)
if ans < 0:
    ans = 0
print(ans)
# Judge status: Accepted
import math
a,b = map(int,input().split())
num = a + b
if num < 0:
  num = -num
if num % 2 == 0:
  print(math.floor(num/2))
else:
  print("IMPOSSIBLE")
# Judge status: Accepted
import heapq
from collections import deque

x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = sorted(list(map(lambda x:int(x),input().split())),reverse=True)

p = sorted(p)[a - x:a]
q = sorted(q)[b - y:b]
p+=q
p.sort()

for i in range(min(len(r),len(p))):
    p[i] = max(p[i],r[i])
print(sum(p))
# Judge status: Wrong Answer
a,b=map(int,input().split())
if (a==1):
  a=14
if (b==1):
  b=14
if (a>b):
    print('Alice')
elif (b>a):
    print('Bob')
else:
    print('draw')
# Judge status: Accepted
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()
ans = 0
for i in b:
  x = bisect.bisect_left(a, i)
  y = bisect.bisect_right(c, i)
  ans = ans + (x * (n-y))
print(ans)
# Judge status: Accepted
# coding: utf-8
a,b,c,d=map(int,input().split())
if abs(a-b)<=d and abs(b-c)<=d:
    print('Yes')
else:
    if abs(a-c)<=d:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
H = int(input())
W = int(input())
N = int(input())
# print(H, W, N)

if H < W:
    H, W = W, H

n = 0
cnt = 0
while n < N:
    n += H
    cnt += 1

print(cnt)