Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import Counter
N,M = map(int,raw_input().split())

es = [[] for i in range(N)]
for i in range(M):
  a,b = map(int,raw_input().split())
  a,b = a-1,b-1
  es[a].append(b)
  es[b].append(a)

group = [0 for i in range(N)]
stack = [0]
while stack:
  fr = stack.pop()
  group[fr] = 1
  for to in es[fr]:
    if group[to] > 0: continue
    stack.append(to)

stack = [1]
while stack:
  fr = stack.pop()
  group[fr] = 2
  for to in es[fr]:
    if group[to] > 0: continue
    stack.append(to)

ctr = Counter(group)
a = ctr[1]
b = ctr[2]
if a > b: a,b = b,a
b += ctr[0]

ans = a*(a-1)//2 + b*(b-1)//2 - M
print(ans)

### FIXED CODE ###

from collections import deque
N,M = map(int,input().split())

es = [[] for i in range(N)]
for i in range(M):
  a,b = map(lambda x:int(x)-1,input().split())
  es[a].append(b)
  es[b].append(a)

a = b = 1
visited = [1,1] + [0]*(N-2)
q = deque([0])
while q:
  fr = q.popleft()
  for to in es[fr]:
    if visited[to]: continue
    q.append(to)
    visited[to] = 1
    a += 1

q = deque([1])
while q:
  fr = q.popleft()
  for to in es[fr]:
    if visited[to]: continue
    q.append(to)
    visited[to] = 1
    b += 1

if a > b: a,b = b,a
unused = N-a-b
b += unused

ans = a*(a-1)//2 + b*(b-1)//2 - M
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri Mar  1 01:07:09 2019

@author: yuta
"""

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

def main(nk,a):
    k = nk[1]
    a_uni = list(set(a)) #重複なし数列
    a_uni_num = [0]*len(a_uni) #各数字の重複個数
    for i in range(len(a_uni)):
        for j in range(len(a)):
            if a[j] == a_uni[i]:
                a_uni_num[i] += 1
    a_uni_num_sort = sorted(a_uni_num) #重複個数を昇順で並び替え
    red_num = len(a_uni) - k #減らす種類の数
    print(sum(a_uni_num_sort[:red_num]))

main(NK,A)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri Mar  1 01:07:09 2019

@author: yuta
"""
import collections

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

"""
TLE解法
def main(nk,a):
    k = nk[1]
    a_uni = list(set(a)) #重複なし数列
    a_uni_num = [0]*len(a_uni) #各数字の重複個数
    for i in range(len(a_uni)):
        for j in range(len(a)):
            if a[j] == a_uni[i]:
                a_uni_num[i] += 1
    a_uni_num_sort = sorted(a_uni_num) #重複個数を昇順で並び替え
    red_num = len(a_uni) - k #減らす種類の数
    print(sum(a_uni_num_sort[:red_num]))

main(NK,A)
"""
def main(nk,a):
    k = nk[1]
    values,counts = zip(*collections.Counter(a).most_common())
    print(sum(counts)-sum(counts[:k]))
main(NK,A)
### BUGGY CODE ###

import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  K = int(input())
  s = list(map(int, input().split()))
  prod = 1
  for k in range(K):
    prod = prod * s[k]
  if prod > 10 ** 18:
    print(-1)
  else:
    print(prod)

if __name__ == '__main__':
  main()

### FIXED CODE ###

import sys
import math
 
sys.setrecursionlimit(10 ** 8)
input = sys.stdin.readline
 
def main():
  K = int(input())
  s = list(map(int, input().split()))
  prod = 1
  a = 10 ** 18
  if 0 in s:
    print(0)
    sys.exit()
  for k in range(K):
    prod = prod * s[k]
    if prod > a:
      print(-1)
      sys.exit()
  
  print(prod)

if __name__ == '__main__':
  main()
### BUGGY CODE ###

import bisect

N=int(input())
L=[0]*(N-1) 
MAP=[0]*(N+1)
for i in range(N-1):
    L[i]=list(map(int,input().split()))
L1=sorted(L,key=lambda x: (x[0],x[1]))
L2=sorted(L,key=lambda x: (x[1],x[0]))
LIST=[1]


f=0
c=0
k=0
t=LIST[k]
while(len(LIST)<N):
    while(N-1>c):
        if(L1[c][0]==t):
            f=1
            if(LIST.count(L1[c][1])==0):
                LIST.append(L1[c][1])
                MAP[L1[c][1]]=(MAP[L1[c][0]]+L1[c][2])%2
        elif(f==1):
            break
        c+=1
    f=0
    c=0

    while(N-1>c):
        if(L2[c][1]==t):
            f=1
            if(LIST.count(L2[c][0])==0):
                LIST.append(L2[c][0])
                MAP[L2[c][0]]=(MAP[L2[c][1]]+L2[c][2])%2
        elif(f==1):
            break
        c+=1
    f=0
    c=0

    k+=1
    t=LIST[k]




      

for i in range(1,N+1):
    print(MAP[i])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N=int(input())
L=[0]*(N-1) 
MAP=[-1]*(N+1)
MAP[1]=0
for i in range(N-1):
    L[i]=list(map(int,input().split()))
    t=[L[i][1],L[i][0],L[i][2]]
    L.append(t)

L1=sorted(L,key=lambda x: (x[0],x[1]))
LIST=[[]for i in range(N+1)]

for i in range(len(L)):
    LIST[L1[i][0]].append([L1[i][1],L1[i][2]])

def calc(k):
    global MAP
    for i in range(len(LIST[k])):
        #print(LIST[k],len(LIST[k]))
        if(MAP[LIST[k][i][0]]==-1):
            MAP[LIST[k][i][0]]=(MAP[k]+LIST[k][i][1])%2
            #print(LIST[k][i][0],MAP[LIST[k][i][0]])
            calc(LIST[k][i][0])

calc(1)
for i in range(1,N+1):
    print(MAP[i])
### BUGGY CODE ###

import sys
n = input()
data = map(int, sys.stdin.readline().split())

ans = 1

over=False
zero=False
for num in data:
    ans*=num
    if(ans>1000000000000000000):
        over=True
    if(num == 0):
        zero=True

if ans>1000000000000000000:
    over=True

if zero:
    print("0")
elif over:
    print("-1")
else:
    print(ans)

### FIXED CODE ###

import sys
n = input()
data = list(map(int, sys.stdin.readline().split()))

ans = 1

over=False
zero=False

if 0 in data:
    zero=True

for num in data:
    ans*=num
    if(ans>1000000000000000000):
        over=True
        break

if ans>1000000000000000000:
    over=True

if zero:
    print("0")
elif over:
    print("-1")
else:
    print(ans)
### BUGGY CODE ###

K, S = [int(n) for n in input().split(' ')]

ans = 0


for X in range(K+1):
    if X > S:
        break
    for Y in range(K+1):
        if (X+Y) > S:
            break
        for Z in range(K+1):
            if (X+Y+Z) == S:
                ans += 1
            elif (X+Y+Z) > S:
                break
print(ans)


### FIXED CODE ###

K, S = [int(n) for n in input().split(' ')]

ans = 0

for x in range(0,K+1):
    for y in range(0,K+1):
        z = S - x - y
        if z >= 0 and z <= K:
            ans += 1
print(ans)
### BUGGY CODE ###

n, x = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = []
for k in range(n):
    b = []
    for i in range(n):
        d = [a[i]]
        for j in range(1,k+1):
            d.append(a[(i-j)%n])
        b.append(min(d))
    ans.append(k*x+sum(b))
print min(ans)


### FIXED CODE ###

def solve(n, x, a):
	costs = []
	cost_min = 0
	for k in range(n):
		if k == 0:
			costs = a.copy()
		else:
			for i in range(n):
				costs[i] = min(costs[i], a[(i-k)%n])
		cost_k = sum(costs) + k*x
		if k == 0:
			cost_min = cost_k
		else:
			cost_min = min(cost_min, cost_k)
			if cost_min != cost_k:
				break
		if cost_min < (k+1) *x:
			break
 
	return cost_min
n, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
print(solve(n,x,a))
### BUGGY CODE ###

import collections
data=[collections.Counter(list(input())) for i in range(int(input()))]
count=0
for i in range(len(data)):
    for m in range(i+1,len(data)):
        count+=data[i]==data[m]
print(count)


### FIXED CODE ###

import collections
N=int(input())
Slst=["".join(sorted(list(input()))) for i in range(N)]
dic={}
namelst=set()

for S in Slst:
    if S in namelst:
        dic[S]+=1
    else:
        namelst.add(S)
        dic.update({S:1})
#print(dic)

print(sum([dic[i]*(dic[i]-1)//2 for i in dic if dic[i]>=2]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

mod = 998244353

n, k = map(int, input().split())

s = []
for _ in range(k):
    l, r = map(int, input().split())
    s += list(range(l, r+1))

s = set(s)

dp = [0] * (2 * n)
dp[0] = 1

for i in range(n):
    if dp[i] == 0:
        continue
    for s_ele in s:
        dp[i+s_ele] += dp[i]

print(dp[n-1]%mod)

### FIXED CODE ###

import sys
input = sys.stdin.readline

mod = 998244353

n, k = map(int, input().split())
lr = [list(map(int, input().split())) for _ in range(k)]

dp = [0] * (n+1)
dp[1] = 1

for i in range(1, n):
    dp[i+1] += dp[i]
    for l, r in lr:
        dp[i+1] += dp[max(i-l+1, 0)] - dp[max(i-r, 0)]
        dp[i+1] %= mod

print((dp[n]-dp[n-1])%mod)
### BUGGY CODE ###

#AtCorder Begginer Contest 049 C Daydream

s = input()
s = s[::-1]

dream = "dream"[::-1]
dreamer = "dreamer"[::-1]
erase = "erase"[::-1]
eraser = "eraser"[::-1]

while len(s) > 0:
    if s.startswith(dreamer):
        s = s.replace(dreamer,"",1)
    elif s.startswith(dream):
        s = s.replace(dream,"",1)

    if s.startswith(eraser):
        s = s.replace(eraser,"",1)
    elif s.startswith(erase):
        s = s.replace(erase,"",1)

if len(s) == 0:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

#AtCorder Begginer Contest 049 C Daydream

s = input()
s = s[::-1]

dream = "dream"[::-1]
dreamer = "dreamer"[::-1]
erase = "erase"[::-1]
eraser = "eraser"[::-1]

for i in range(len(s)):
    if s.startswith(dreamer):
        s = s.replace(dreamer,"",1)
    elif s.startswith(dream):
        s = s.replace(dream,"",1)

    if s.startswith(eraser):
        s = s.replace(eraser,"",1)
    elif s.startswith(erase):
        s = s.replace(erase,"",1)

if len(s) == 0:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for _ in range(m)]
a.sort()
bc.sort(key=lambda x:-x[1])
br=0
for b,c in bc:
    for _ in range(b):
        a_end=a.pop(0)
        if a_end>=c:
            a.append(a_end)
            br=1
            break
        a.append(c)
    if br:break
print(sum(a))

### FIXED CODE ###

import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
bc=[list(map(int,input().split())) for _ in range(m)]
heapq.heapify(a)
bc.sort(key=lambda x:-x[1])
br=0
for b,c in bc:
    for _ in range(b):
        a_mn=heapq.heappop(a)
        if a_mn>=c:
            heapq.heappush(a,a_mn)
            br=1
            break
        heapq.heappush(a,c)
    if br:break
print(sum(a))
### BUGGY CODE ###

dic = {}

def comb(n,k,p):
  from math import factorial
  
  if n / 2 < k:
    k = n - k
  
  if n<0 or k<0 or n<k: 
    return 0
  if n==0 or k==0: 
    return 1
  
  a=fact_mod[n] %p
  b=fact_mod[k] %p
  c=fact_mod[n-k] %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
  if (a,b) in dic:
    return dic[(a,b)]
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    dic[(a,b)] = d*d %p
    return d*d %p
  if b%2==1:
    dic[(a,b)] = (a*power_func(a,b-1,p))%p
    return (a*power_func(a,b-1,p))%p

  
n, k = map(int, input().split())
a = sorted(list(map(int,input().split())))

fact_mod = [1]
for i in range(1,n+1):
  fact_mod.append(fact_mod[i-1] * i)

count = 0
i = n - 1
j = k - 1
k = 0
while True:
  tmp = comb(i, j, 10**9+7)
  count += tmp * a[-1-k]
  count -= tmp * a[k]
  count = count % (10 ** 9 + 7)
  if i == j:
    break
  i -= 1
  k += 1
    
print(count)

### FIXED CODE ###

# x^n % mod
def pow_k(x, n, mod):
  if n == 0:
    return 1

  K = 1
  while n > 1:
    if n % 2 != 0:
      K = (x * K) % mod
        
    x = (x * x) % mod

    n //= 2

  return (x * K) % mod

def main():
  MOD = 10 ** 9 + 7
  n,k = map(int,input().split())
  a = sorted(list(map(int,input().split())))
  
  g_k = 1
  for i in range(1,k):
    g_k *= i
    g_k %= MOD
    
  gyakugen = pow_k(g_k,MOD-2,MOD)
  array = [0] * (n+1)
  array[k-1] = g_k
  
  for i in range(k, n+1):
    array[i] = array[i-1] * i * pow_k(i-k+1,MOD-2,MOD)
    array[i] %= MOD
    
  ans = 0
  for i in range(n):
    if i-k+1 >= 0:        
      ans += array[i] * gyakugen * a[i]
      
    if n-i-k >= 0:
      ans -= array[n-i-1] * gyakugen * a[i]
      
    ans %= MOD
      
  print(ans)

main()
### BUGGY CODE ###

h,w,d=map(int,input().split())
dict={}

for i in range(1,h+1):
  lst=list(map(int,input().split()))
  for j in range(w):
    dict.setdefault(lst[j],(i,j+1))

dist=[0]*(h*w-d)

for i in range(h*w-d):
  dist[i]+=abs(dict[i+d+1][0]-dict[i+1][0])+abs(dict[i+d+1][1]-dict[i+1][1])


ans=0

q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    while True:
      if l==r:
        break
      ans+=dist[l-1]
      l+=d

    
    print(ans)

### FIXED CODE ###

h,w,d=map(int,input().split())
dict={}

for i in range(1,h+1):
  lst=list(map(int,input().split()))
  for j in range(w):
    dict.setdefault(lst[j],(i,j+1))

cost=[0]*(h*w)

for i in range(d,h*w):
  cost[i]=cost[i-d]+abs(dict[i-d+1][0]-dict[i+1][0])+abs(dict[i-d+1][1]-dict[i+1][1])


ans=0

q=int(input())
for i in range(q):
    ans=0
    l,r=map(int,input().split())
    print(cost[r-1]-cost[l-1])
### BUGGY CODE ###

import math
n = int(input())
k = int(math.sqrt(n))
for i in range(k,n+1):
  if n%i == 0:
    a = i
    break
s = len(str(a))
print(s)

### FIXED CODE ###

import math
n = int(input())
k = int(math.sqrt(n))
for i in range(k+2,0,-1):
  if n%i == 0:
    a = n//i
    break
s = len(str(a))
print(s)
### BUGGY CODE ###

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

MOD = 998244353

dp = [[0] * (S + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S + 1):
        dp[i + 1][j] += 2 * dp[i][j]
        #dp[i + 1][j] %= MOD
        if j + A[i] <= S:
            dp[i + 1][j + A[i]] += dp[i][j]
            #dp[i + 1][j + A[i]] %= MOD

print(dp[N][S] % MOD)


### FIXED CODE ###

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

MOD = 998244353

dp = [[0] * (S + 1) for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    for j in range(S + 1):
        dp[i + 1][j] += 2 * dp[i][j]
        dp[i + 1][j] %= MOD
        if j + A[i] <= S:
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= MOD

print(dp[N][S])
### BUGGY CODE ###

from collections import deque


H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
maze = [input() for _ in range(H)]

INF = 10 ** 12
path = [[INF] * W for _ in range(H)]

walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))
    for dx, dy in warp:
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.appendleft((nx, ny, s + 1))

ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)


### FIXED CODE ###

from collections import deque


def solve(H, W, Ch, Cw, Dh, Dw, maze):
    # 後の条件分岐を簡略化するためワープしても迷路外に出ないように壁で囲む
    walled_maze = ['##{}##'.format(row) for row in maze]
    walled_maze.insert(0, '##{}##'.format('#' * W))
    walled_maze.insert(0, '##{}##'.format('#' * W))
    walled_maze.append('##{}##'.format('#' * W))
    walled_maze.append('##{}##'.format('#' * W))

    INF = 10 ** 12
    path = [[INF] * (W + 4) for _ in range(H + 4)]
    walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
    warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

    yet = deque()
    yet.append((Ch + 2, Cw + 2, 0))    # 囲った壁の分だけプラス
    path[Ch + 2][Cw + 2] = 0
    done = deque()

    while yet:
        y, x, s = yet.popleft()
        done.append((y, x, s))
        for dy, dx in walk:
            ny = y + dy
            nx = x + dx
            if walled_maze[ny][nx] == '.' and path[ny][nx] > s:
                path[ny][nx] = s
                yet.append((ny, nx, s))
        if len(yet) == 0:
            while done:
                y, x, s = done.popleft()
                for dy, dx in warp:
                    ny = y + dy
                    nx = x + dx
                    if walled_maze[ny][nx] == '.' and path[ny][nx] > s + 1:
                        path[ny][nx] = s + 1
                        yet.append((ny, nx, s + 1))
    ans = path[Dh + 2][Dw + 2] if path[Dh + 2][Dw + 2] < INF else -1
    print(ans)


if __name__ == '__main__':
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    maze = [input() for _ in range(H)]
    solve(H, W, Ch, Cw, Dh, Dw, maze)
### BUGGY CODE ###

n = int(input())
s = input()

ans = 0
for i in range(1000):
    p = str(i).zfill(3)
    p_index = 0
    for j in range(n):
        if p[p_index] == s[j]:
            p_index += 1
        if p_index == 3:
            break
    if p_index == 3:
        ans += 1

print(ans)


### FIXED CODE ###

n = int(input())
s = input()

ans = 0
# 000 ～　999 がsから作成できるか確認していく
for i in range(1000):
    p = str(i).zfill(3)

    s_index_100 = s.find(p[2])
    if s_index_100 == -1:
        continue

    s_index_10 = s.find(p[1], s_index_100+1)
    if s_index_10 == -1:
        continue

    s_index_1 = s.find(p[0], s_index_10+1)
    if s_index_1 == -1:
        continue
    ans += 1

print(ans)
### BUGGY CODE ###

S = input()
Q = int(input())
for i in range(Q):
    tmp = input()
    if tmp[0] == '1':
        S = S[::-1]
    else:
        tmpt, tmpf, tmpc = tmp.split(' ')
        if tmpf == '1':
            S = tmpc + S
        else:
            S = S + tmpc
print(S)

### FIXED CODE ###

S = input()
Q = int(input())
reverseFlag = False
forwardList = []
backwardList = []
for i in range(Q):
    tmp = input()
    if tmp[0] == '1':
        reverseFlag = not reverseFlag
    else:
        tmpt, tmpf, tmpc = tmp.split(' ')
        if tmpf == '1' and reverseFlag == False or tmpf == '2' and reverseFlag == True:
            forwardList.append(tmpc) 
        else:
            backwardList.append(tmpc)

if reverseFlag == True:
    S = ''.join(reversed(backwardList)) + S[::-1] + ''.join(forwardList)
else:
    S = ''.join(reversed(forwardList)) + S + ''.join(backwardList)
print(S)
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    g = [1]
    for i in range(len(A)-1):
        prev_p = g[-1]
        g.append(A[prev_p-1])
        
    if K <= N - 1:
        print(g[K])
    else:
        prev_ = g[-1]
        new_g = []
        while True:
            if new_g[:len(new_g)//2] == new_g[len(new_g)//2:] and len(new_g) > 0:
                break
            new_g.append(A[prev_-1])
            prev_ = new_g[-1]
        new_g = new_g[:len(new_g)//2]
        
        K_ = (K - N) % len(new_g)
        print(new_g[K_])
        
 
 
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    prev_p = 1
    g = []
    seen = [0]*N
    i = 0
    while True:
        if seen[prev_p-1]:
            break
        seen[prev_p-1] = i
        g.append(A[prev_p-1])
        prev_p = g[-1]
        i += 1
    g_periodic = g[seen[prev_p-1]:]  
    g_before = g[:seen[prev_p-1]]

    if K <= len(g_before):
        print(g_before[K-1])
    else:
        K_new = (K - len(g_before)) % len(g_periodic)
        print(g_periodic[K_new-1])
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import numpy as np
n, h =[int(i) for i in input().split()]
ab = np.empty((n,2),dtype=int)
for i in range(n):
    ab[i,:] = np.array([int(i) for i in input().split()])
np.sort(ab[:,0])
b = ab[:,1]
sort_b_idx = np.argsort(b)
sort_b =ab[sort_b_idx,1]
max_a = np.max(ab[:,0])
b_sum = np.sum(b[b>max_a])
if b_sum > h:
    for i in range(1,n+1):
        if np.sum(sort_b[-i:]) > h:
            ret = i
            break
else:
    ret = len(b[b>max_a])
    ret += np.ceil((h -b_sum)/max_a)
print(str(int(ret)))

### FIXED CODE ###

import numpy as np
n, h =[int(i) for i in input().split()]
a = np.empty(n)
b = np.empty(n)
for i in range(n):
    a[i], b[i] = [int(i) for i in input().split()]
sort_b = np.sort(b)
max_a = np.max(a)
b_big = sort_b[sort_b>max_a]
b_sum = np.sum(b_big)
if b_sum >= h:
    ret = np.sum(b_big[::-1].cumsum() <h) + 1 
else:
    ret = b_big.shape[0]
    ret += np.ceil((h -b_sum)/max_a)
print(int(ret))
### BUGGY CODE ###

#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP
import numpy as np
L = int(input())
A = [int(input()) for i in range(L)]

DP = np.zeros(5, dtype = int)

def cost(a):
    if a:
        return np.array([a,a%2,(a+1)%2,a%2,a])
    else:
        return np.array([0,2,1,2,0])

for i in range(L):
    n  = np.array([np.min(DP[:i+1]) for i in range(5)])
    DP = n + cost(A[i])

print(np.min(DP))

### FIXED CODE ###

#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP

L = int(input())
A = [int(input()) for i in range(L)]

DP = [[float("inf") for i in range(5)] for j in range(L+1)]
for i in range(5):
    DP[0][i] = 0

def cost(s, i, A):
    if s == 0 or s == 4:
        return A[i]
    elif s == 1 or s == 3:
        if A[i] > 0:
            if A[i]%2 == 0:
                return 0
            else:
                return 1
        else:
            return 2
    else:
        if A[i]%2 == 1:
            return 0
        else:
            return 1

for i in range(L):
    for j in range(5):
        for k in range(j,5):
            DP[i+1][k] = min(DP[i+1][k], DP[i][j]+ cost(k, i, A))



print(min(DP[L]))
### BUGGY CODE ###

n = int(input())
a = sorted(list(map(int, input().split())))

import math
def comb(n,r):
  return math.factorial(n) / (math.factorial(r) * math.factorial(n-r))
  
mid_dis = [abs(a[n-1] / 2 - a[i]) for i in range(n-1)]
arg_max_i = [i for i in range(n-1) if mid_dis[i] == min(mid_dis)][0]

print(a[n-1], a[arg_max_i])


### FIXED CODE ###

n = int(input())
a = sorted(list(map(int, input().split())))

import bisect

arg_max_i = bisect.bisect_left(a, a[n-1] // 2)

if abs(a[n-1] / 2 - a[arg_max_i]) > abs(a[n-1] / 2 - a[arg_max_i-1]):
  arg_max_i -= 1
if arg_max_i == n-1:
  arg_max_i -= 1

print(a[n-1], a[arg_max_i])
### BUGGY CODE ###

#!/usr/bin/env python3
def main():
    from itertools import combinations

    def prime_factorization_turple(n: int):
        """
        入力された整数nを素因数分解し，タプルを要素とするリストで返却
        Parameters
        ----------
        n : int
            素因数分解したい整数
        Returns
        -------
        prime_factorization_lst : lst
            [(素因数,累乗)]の形で素因数が列挙された素因数分解結果
        """
        fct = set()     # prime factor
        b, e = 2, 0  # base factor
        while b * b <= n:
            while n % b == 0:
                n //= b
                e += 1
            if e > 0:
                fct.add(b)
            b += 1
            e = 0
        if n > 1:
            fct.add(n)
        return fct

    _ = int(input())
    A = sorted([int(x) for x in input().split()])

    # Aの素因数分解
    fac_A = [prime_factorization_turple(a) for a in A]

    # pairwiseの判定
    pairwise_coprime = True
    for a, b in combinations(fac_A, 2):
        for i in a:
            if i in b:
                pairwise_coprime = False
                break
        if pairwise_coprime is False:
            break

    # setwise
    setwise_coprime = True
    for b in fac_A[0]:
        cnt = 0
        for a in A:
            if a % b == 0:
                cnt += 1
        if cnt == len(A):
            setwise_coprime = False
            break

    if pairwise_coprime:
        print('pairwise coprime')
    elif setwise_coprime:
        print('setwise coprime')
    else:
        print('not coprime')


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
def main():
    from math import gcd

    N = int(input())
    A = []
    INF = 10 ** 6 + 5
    frequency = [0] * INF
    for a in [int(x) for x in input().split()]:
        A.append(a)
        frequency[a] += 1
    
    pairwise = True
    for i in range(2, INF):
        cnt = 0
        for j in range(i, INF, i):
            cnt += frequency[j]
        if cnt > 1:
            pairwise = False
    if pairwise:
        print("pairwise coprime")
        return

    g = 0
    for i in range(N):
        g = gcd(g, A[i])
        if g == 1:
            print('setwise coprime')
            return
    
    print('not coprime')


if __name__ == '__main__':
    main()