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



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

def cmp(a,b):
    if a == "" or b == "":
        if len(a) > len(b):
            return False
        elif len(a) < len(b):
            return True
    else:
        if int(a) >= int(b):
            return False
        else:
            return True

dp = [""] * (N+10)
l = [0,2,5,5,4,5,6,3,7,6]

for i in range(N+1):
    for s in A:
        if dp[i] == "" and i!=0:
            continue
        ss = dp[i] + s
        if cmp(dp[i + l[int(s)]] , ss):
            dp[i + l[int(s)]] = ss
            

print(dp[N])


                





### FIXED CODE ###

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

dp = [-1 for i in range(N+10)]
l = [0,2,5,5,4,5,6,3,7,6]
dp[0] = 0
for i in range(N-1):
    for s in A:
        if dp[i] == -1 and i!=0:
            continue
        if dp[i + l[s]] < dp[i]*10+s:
            dp[i + l[s]] = dp[i]*10+s
print(dp[N])
### BUGGY CODE ###

N, K = input().split()
N = int(N)
K = int(K)
scores = [int(s) for s in input().split()]
sums = []
for i in range (K-1, N):
    c = 1
    j = i
    while (j>i-K):
        c *= scores[j]
        j -= 1
    sums.append(c)

for i in range(N-K):
    if sums[i] < sums[i+1]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N, K = input().split()
N = int(N)
K = int(K)
scores = [int(s) for s in input().split()]
sums = []
k = K-1
for i in range(k,N-1):
    if(scores[i-k] < scores[i+1]):
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

def resolve():
    a, b = map(int, input().split())
    d = []
    for i in range(2, min(a, b) + 1):
        if a % i == 0 and b % i == 0:
            if any([i % di == 0 for di in d]):
                continue
            d.append(i)
    print(len(d) + 1)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    a, b = map(int, input().split())
    div_a = set(prime_factorize(a))
    div_b = set(prime_factorize(b))
    print(len(div_a & div_b) + 1)
    # print(div_a)
    # print(div_b)


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

# D - String Formation

S = input()
Q = int(input())

for _ in range(Q):
    T = [t for t in input().split()]
    t = int(T[0])
    if t == 1:
        S = S[::-1]
    if t == 2:
        f, c = int(T[1]), T[2]
        if f == 1:
            S = c + S
        if f == 2:
            S = S + c

print(S)


### FIXED CODE ###

# D - String Formation

from collections import deque

S = deque([s for s in input()])
Q = int(input())
rev = False

for _ in range(Q):
    T = [t for t in input().split()]
    t = int(T[0])
    if t == 1:
        rev = not rev
    if t == 2:
        f, c = int(T[1]), T[2]
        if f == 1:
            if rev:
                S.append(c)
            else:
                S.appendleft(c)
        if f == 2:
            if rev:
                S.appendleft(c)
            else:
                S.append(c)

S = ''.join(list(S))
print(S if not rev else S[::-1])
### BUGGY CODE ###

import itertools
n,m,q=(int(i) for i in input().split())
l=[]
r=[i+1 for i in range(m)]
g=itertools.combinations_with_replacement(r,n)
point=0
def checker(x,l):
  p=0
  for i in range(len(l)):
    a,b,c,d=(l[i][j] for j in range(4))
    if x[b]-x[a]==c:
      p+=d
  return p
def mini(x):
  m=0
  for i in range(len(x)):
    if x[i]!=None:
      if x[i]<m:
        m=x[i]
  return m
def maxe(x):
  m=0
  for i in range(len(x)):
    if x[i]!=None:
      if x[i]>m:
        m=x[i]
  return m
for i in range(q):
  a,b,c,d=(int(i) for i in input().split())
  a-=1
  b-=1
  l.append([a,b,c,d])
l.sort(key=lambda x:x[3])
for i in g:
  p=checker(i,l)
  if p>point:
    point=p
print(point)

### FIXED CODE ###

import itertools
n,m,q=(int(i) for i in input().split())
l=[]
r=[i+1 for i in range(m)]
point=0
def checker(x,l):
  p=0
  for i in range(len(l)):
    if x[l[i][1]]-x[l[i][0]]==l[i][2]:
      p+=l[i][3]
  return p
for i in range(q):
  a,b,c,d=(int(i) for i in input().split())
  a-=1
  b-=1
  l.append([a,b,c,d])
for i in itertools.combinations_with_replacement(r,n):
  p=checker(i,l)
  if p>point:
    point=p
print(point)
### BUGGY CODE ###

from itertools import combinations
n=int(input())
s=input()
ans=0
set_s=len({i for i in s})
for i in range(1,set_s+1):
    koho=tuple(combinations((j for j in s),i))
    ex=tuple([j for j in koho if len(j)==len(tuple(set(j)))])
    ans+=len(ex)
print(ans%(10**9+7))

### FIXED CODE ###

from collections import Counter
n=int(input())
s=input()
cnt=Counter(s)
ans=1
for i in cnt.values():
    ans*=i+1
print((ans-1)%(10**9+7))
### BUGGY CODE ###

import itertools
n = int(input())
a = list(map(int,input().split()))
v = itertools.combinations(a,2)
for item in v:
    if item[0] == item[1]:
        print('NO')
        exit()
print('YES')

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
if len(a) == len(set(a)):
    print('YES')
else:
    print('NO')
### BUGGY CODE ###

N, M = map(int, input().split())
a_list = tuple(map(int, input().split()))
b_list = tuple(map(int, input().split()))
mod = 10 ** 9 + 7

a_list = sorted(a_list, reverse=True)
b_list = sorted(b_list, reverse=True)
a_list.append(-1)
b_list.append(-1)
ans = 1
a_i = 0
b_i = 0
for i in range(N*M, 0, -1):
    if i == a_list[a_i] and i == b_list[b_i]:
        a_i += 1
        b_i += 1
    elif i == a_list[a_i]:
        a_i += 1
        ans *= b_i
    elif i == b_list[b_i]:
        b_i += 1
        ans *= a_i
    else:
        ans *= (a_i*b_i - (N * M - i))
print(ans % mod)



### FIXED CODE ###

N, M = map(int, input().split())
a_list = tuple(map(int, input().split()))
b_list = tuple(map(int, input().split()))
mod = 10 ** 9 + 7

a_list = sorted(a_list, reverse=True)
b_list = sorted(b_list, reverse=True)
a_list.append(-1)
b_list.append(-1)
ans = 1
a_i = 0
b_i = 0
for i in range(N*M, 0, -1):
    if i == a_list[a_i] and i == b_list[b_i]:
        a_i += 1
        b_i += 1
    elif i == a_list[a_i]:
        a_i += 1
        ans *= b_i
        ans %= mod
    elif i == b_list[b_i]:
        b_i += 1
        ans *= a_i
        ans %= mod
    else:
        ans *= (a_i*b_i - (N * M - i))
        ans %= mod
print(ans % mod)
### BUGGY CODE ###

from collections import deque
from itertools import product
h, w = map(int, input().split())
si, sj = map(lambda x: int(x)-1, input().split())
gi, gj = map(lambda x: int(x)-1, input().split())
fld = ''.join([input()for _ in range(h)])
INF = 10**18


def to_v(i, j):
    return i*w+j


n = h*w
start = to_v(si, sj)
goal = to_v(gi, gj)


def generate_v2(v):
    i, j = divmod(v, w)
    it = [-2, -1, 0, 1, 2]
    for di, dj in product(it, repeat=2):
        x, y = i+di, j+dj
        if x < 0 or h <= x or y < 0 or w <= y:
            continue
        if (di, dj) in [(-1, 0), (1, 0), (0, -1), (0, 1), (0, 0)]:
            d = 0
        else:
            d = 1
        yield d, x*w+y


def bfs(init_v):
    next_v = deque([init_v])
    INF = 10**18
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        v = next_v.popleft()
        for d, v2 in generate_v2(v):
            if fld[v2] == '#':
                continue
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            if d:
                next_v.append(v2)
            else:
                next_v.appendleft(v2)
    return dist


ans = bfs(start)[goal]
print(-1 if ans == INF else ans)


### FIXED CODE ###

import heapq
from itertools import product
h, w = map(int, input().split())
si, sj = map(lambda x: int(x)-1, input().split())
gi, gj = map(lambda x: int(x)-1, input().split())
fld = ''.join([input()for _ in range(h)])
INF = 10**18


def to_v(i, j):
    return i*w+j


n = h*w
start = to_v(si, sj)
goal = to_v(gi, gj)


def generate_v2(v):
    i, j = divmod(v, w)
    it = [-2, -1, 0, 1, 2]
    for di, dj in product(it, repeat=2):
        x, y = i+di, j+dj
        if x < 0 or h <= x or y < 0 or w <= y:
            continue
        if (di, dj) in [(-1, 0), (1, 0), (0, -1), (0, 1), (0, 0)]:
            d = 0
        else:
            d = 1
        yield d, x*w+y


def dijkstra(init_v):
    next_v = [(0, init_v)]
    dist = [INF]*n
    dist[init_v] = 0
    while next_v:
        d, v = heapq.heappop(next_v)
        if dist[v] < d:
            continue
        for d, v2 in generate_v2(v):
            if fld[v2] == '#':
                continue
            if dist[v2] <= dist[v]+d:
                continue
            dist[v2] = dist[v]+d
            heapq.heappush(next_v, (dist[v2], v2))
    return dist


ans = dijkstra(start)[goal]
print(-1 if ans == INF else ans)
### BUGGY CODE ###

N = int(input())
sum = 0

while N >= 10:
  sum += N%10
  N = N//10

sum += N

if sum%9 == 0:
  print("Yes")
else:
  print("No")
  

### FIXED CODE ###

N = list(input())
num = list(map(int,N))

sum = sum(num)

if sum%9 == 0:
  print("Yes")
else:
  print("No")
### BUGGY CODE ###

n = int(input())
l = []
l[:] = map(int,input().split())
l.sort()

c = 0
for i in range(0,n-2):
    for j in range(i+1, n-1):
        ab = l[i]+l[j]
        for k in range(j+1, n):
            if(ab>l[k]):
                c+=1
            else:
                break
print(c)


### FIXED CODE ###

from bisect import bisect_right

n = int(input())
l = list(map(int,input().split()))
l.sort() # 昇順にソート

count = 0
for i in range(0,n-2):
    a = l[i]
    for j in range(i+1, n-1):
        ab = a+l[j]
        # bisect_left(a, x): x を a に挿入できる点を返す
        # cの最大値は a+b-1
        k = bisect_right(l, ab-1, j+1, n)
        count += k-(j+1)
print(count)
### BUGGY CODE ###

from collections import defaultdict, deque
from itertools import permutations
inf = float('inf')

def min_dis_dfs(graph, start_node, end_node):
  stack = deque()
  stack.append([start_node,0])
  done = []
  min_dis = inf
  
  while len(stack) > 0:
    prv_node, prv_dis = stack.pop()
    #print('#'*20)
    #print("prv_node:{}, prv_dis:{}".format(prv_node, prv_dis))
    for node, dis in graph[prv_node]:
      if node not in done:
        if node == end_node and min_dis > prv_dis + dis:min_dis=prv_dis + dis
        else:
          done.append(node)
          stack.append([node,prv_dis + dis])
      #print('node:{}, min_dis:{}, dis:{}'.format(node, min_dis, dis))
  return min_dis
  
n,m,r =map(int,input().split())
rlist = [int(r)-1 for r in input().split()]
graph = defaultdict(list)

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

ans = inf
for r_case in permutations(rlist, r):
  dis = 0
  for i in range(r-1):
    dis += min_dis_dfs(graph, r_case[i], r_case[i+1])
  if ans > dis:ans = dis
print(ans)

### FIXED CODE ###

import sys, copy
from itertools import permutations

def wf(d):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        d[i][j] = min(d[i][j],d[i][k]+d[k][j])
  return d

N,M,R = map(int,input().split())
Rs = list(map(int,input().split()))

d = [[float('inf') for i in range(N)] for i in range(N)]
for _ in range(M):
  a,b,c = map(int,sys.stdin.readline().split())
  d[a-1][b-1] = c
  d[b-1][a-1] = c

for i in range(N):
  d[i][i] = 0

wf(d)

ans = float('inf')
for prm in permutations(Rs, R):
  ans = min(ans, sum([d[prm[i-1]-1][prm[i]-1] for i in range(1,R)]))
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
N = int(input())
ans=1
for i in range(1,N+1):
    ans *= i
print(ans%(10**9+7))

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    ans=1
    for i in range(1,N+1):
        ans = ans%(10**9+7) * i%(10**9+7)
        
    print(ans%(10**9+7))

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

n=int(input())
listn=list(map(int,input().split()))
count=0
for i in range(n):
	flag=True
	for j in range(0,i+1):
		if(listn[i]>listn[j]):
			flag=False
	if(flag==True):
		count+=1
print(count)



### FIXED CODE ###

n=int(input())
listn=list(map(int,input().split()))
count=0
min1=listn[0]
for i in range(0,n):
	if(listn[i]>min1):
		pass
	else:
		min1=listn[i]
		count+=1
print(count)
### BUGGY CODE ###

N,K,Q=map(int,input().split())
ans=[K for i in range(N)]
for i in range(Q):
  A=int(input())
  ans[A-1]=ans[A-1]+1
  ans=list(map(lambda x:x-1,ans))
for i in range(N):
  if ans[i]>0:
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

N,K,Q=map(int,input().split())
ans=[K for i in range(N)]
ans=list(map(lambda x:x-Q,ans))
for i in range(Q):
  A=int(input())
  ans[A-1]=ans[A-1]+1
for i in range(N):
  if ans[i]>0:
    print('Yes')
  else:
    print('No')
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split(" ")))
list = [a.index(x)+1 for x in range(1, n+1)]
print(*list)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split(" ")))
dic = {}
i = 0
for a_s in a:
    dic.setdefault(i, a_s)
    i += 1
for k, v in sorted(dic.items(), key=lambda x: x[1]):
    print(k + 1)
### BUGGY CODE ###

N = int(input())
staff = list(map(int, input().split()))
i=1
while i<N:
    count = sum(x==i for x in staff)
    print(count)
    i += 1
print(0)

### FIXED CODE ###

import numpy as np

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

boss=[0]*N

for x in A:
    boss[x-1] += 1
for i in boss:
    print(i)
### BUGGY CODE ###

N = int(input())
L = [int(x) for x in input().split()]

import bisect
L = sorted(L)
ans = 0
for i in range(1, N - 1):
    for j in reversed(range(i + 1, N)):
        k = bisect.bisect_right(L[0:i], L[j] - L[i])
        ans += i - k
print(ans)

### FIXED CODE ###

N = int(input())
L = [int(x) for x in input().split()]

import bisect
L = sorted(L)
ans = 0
for i in range(N - 2):
    for j in reversed(range(i + 1, N - 1)):
        k = bisect.bisect_left(L, L[i] + L[j], j)
        ans += k - j - 1
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())

books = [[] for _ in range(N + 1)]
years = []

for i in range(M):
    P, Y = map(int, input().split())
    years.append((P, Y))

for p, y in years:
    books[p].append(y)

for i in range(N + 1):
    books[i].sort()

for p, y in years:
    ind = books[p].index(y) + 1
    s = ''
    s += '{:06d}'.format(p)
    s += '{:06d}'.format(ind)
    print(s)


### FIXED CODE ###

from collections import defaultdict

N, M = map(int, input().split())

years = []
for i in range(M):
    P, Y = map(int, input().split())
    years.append((P, Y))

d = defaultdict(int)
b = dict()
for p, y in sorted(years, key=lambda x: x[1]):
    d[p] += 1
    b[y] = '{:06d}{:06d}'.format(p, d[p])

for p, y in years:
    print(b[y])
### BUGGY CODE ###

#coding:utf-8
n, m = map(int, input().split())
A = list(map(int, input().split()))
for i in range(m):
    b, c = map(int, input().split())
    cnt = 0
    A.sort()
    for j in range(b):
        if A[j] < c:
            cnt += 1
        else:
            break
    A[:cnt] = [c] * cnt
print(sum(A))


### FIXED CODE ###

# coding: utf-8
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
heapq.heapify(A)
minus = 0
l = []
for i in range(M):
    b, c = map(int, input().split())
    l.append([b, c])
l.sort(key=lambda x: x[1], reverse=True)
A.sort(reverse=False)
idx = 0
i = 0
ans = 0
while i < N and idx < M:
    if l[idx][0] == 0:
        idx += 1
    if idx >= M:
        ans += A[i]
        i += 1
        continue
    if A[i] < l[idx][1]:
        ans += l[idx][1]
        l[idx][0] -= 1
        i += 1
    else:
        ans += A[i]
        i += 1
    # print("ans =", ans)
for j in range(i, N):
    ans += A[j]
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [-10000 for i in range(N)]
for i in range(N):
    if (N-i)%2 != 0:#from front
        index = (N-i)//2
        B[index] = A[i]
    else:# from backward
        index = N - (N-i)//2
        B[index] = A[i]
ans = ''
for e in B:
    ans += str(e)+' '
print(ans[:-1])

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
B = [-10000 for i in range(N)]
for i in range(N):
    if (N-i)%2 != 0:#from front
        index = (N-i)//2
        B[index] = A[i]
    else:# from backward
        index = N - (N-i)//2
        B[index] = A[i]
ans = ''
for e in B:
    ans += str(e)+' '
print(ans[:-1])
### BUGGY CODE ###

'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,len(s)+1):
    ans=[]
    for j in range(len(s)-i+1):
      ans.append(s[j:j+i])
    d=sorted(d+sorted(list(set(ans))))
  print(d[K-1])
  return 
main()

### FIXED CODE ###

'''
Created on 2020/08/26

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  s=pin()[:-1]
  K=int(pin())
  d=[]
  for i in range(1,K+1):
    for j in range(len(s)-i+1):
      d.append(s[j:j+i])
  ans=sorted(list(set(d)))
  print(ans[K-1])
  return
main()

#解説AC
### BUGGY CODE ###

import math
k=int(input())
k+=1
d=0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      d+=math.gcd(math.gcd(i,j),l)
      
print(d)


### FIXED CODE ###

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)
### BUGGY CODE ###

import sys

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import fractions
from functools import reduce
from functools import lru_cache

@lru_cache(maxsize=None)
def calc_gcd(a, b):
    return fractions.gcd(a, b)

def gcd_list(numbers):
    return reduce(calc_gcd, numbers)

print( max([gcd_list(A_li[:i]+A_li[i+1:]) for i in range(len(A_li))]) )


### FIXED CODE ###

import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())

N = II()
A_li = LI()

import fractions
from functools import reduce
from functools import lru_cache

@lru_cache(maxsize=None)
def calc_gcd(a, b):
    return fractions.gcd(a, b)

def gcd_list(numbers):
    if len(numbers) == 0: return None
    elif len(numbers) == 1: return numbers[0]
    else: return reduce(calc_gcd, numbers)

left_gcd = [None,A_li[0]]
prev_gcd = A_li[0]
for i in range(1,N-1):
    prev_gcd = calc_gcd(prev_gcd, A_li[i])
    left_gcd.append(prev_gcd)

right_gcd = [None, A_li[N-1]]
prev_gcd = A_li[N-1]
for i in range(1,N-1):
    prev_gcd = calc_gcd(prev_gcd, A_li[N-1-i])
    right_gcd.append(prev_gcd)
right_gcd.reverse()

print(max([right_gcd[0]]+[calc_gcd(left_gcd[i], right_gcd[i]) for i in range(1,len(A_li)-1)]+[left_gcd[N-1]]))
### BUGGY CODE ###

def readinput():
    n=int(input())
    l=list(map(int,input().split()))
    return n,l

def main(n,a):
    MOD=10**9+7
    hist=[0]*61
    bs=[]
    for i in range(n):
        # s=list(reversed(bin(a[i])[2:]))
        # for j in range(len(s)):
        #     if s[j]=='1':
        #         hist[j]+=1
        # bs.append(s)

        s=bin(a[i])[2:]
        bs.append(s)
        for j in range(len(s)):
            if s[j]=='1':
                hist[len(s)-j-1]+=1
        # j=0
        # ai=a[i]
        # while ai>0:
        #     if ai&1==1:
        #         hist[j]+=1
        #     ai = ai >> 1
        #     j+=1


    #print(bs)
    #print(hist)
    sum=0
    for i in range(n-1):
        s=bs[i]
        b=1
        for j in range(len(s)):
            if s[len(s)-1-j]=='0':
                sum=(sum+hist[j]*b)%MOD
            else:
                sum=(sum+( n-i-hist[j] )*b)%MOD
                hist[j]-=1
            b*=2
        for j in range(len(s),61):
            sum=(sum+hist[j]*b)%MOD
            b*=2
    # b=1
    # for j in range(61):
    #     sum=(sum+( hist[j]*(n-hist[j])*b )%MOD )%MOD
    #     b*=2

    return sum

if __name__=='__main__':
    n,l=readinput()
    ans=main(n,l)
    print(ans)


### FIXED CODE ###

def readinput():
    n=int(input())
    l=list(map(int,input().split()))
    return n,l

def main(n,a):
    MOD=10**9+7
    hist=[0]*61
    bs=[]
    for i in range(n):
        # s=list(reversed(bin(a[i])[2:]))
        # for j in range(len(s)):
        #     if s[j]=='1':
        #         hist[j]+=1
        # bs.append(s)
        s=bin(a[i])[2:]
        for j in range(len(s)):
            if s[j]=='1':
                hist[len(s)-j-1]+=1

    #print(bs)
    #print(hist)
    sum=0
    # for i in range(n-1):
    #     s=bs[i]
    #     b=1
    #     for j in range(len(s)):
    #         if s[j]=='0':
    #             sum=(sum+hist[j]*b)%MOD
    #         else:
    #             sum=(sum+( n-i-hist[j] )*b)%MOD
    #             hist[j]-=1
    #         b*=2
    #     for j in range(len(s),61):
    #         sum=(sum+hist[j]*b)%MOD
    #         b*=2
    b=1
    for j in range(61):
        sum=(sum+( hist[j]*(n-hist[j])*b )%MOD )%MOD
        b*=2

    return sum

if __name__=='__main__':
    n,l=readinput()
    ans=main(n,l)
    print(ans)
### BUGGY CODE ###

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



sho=1
dai=max(a)
for jfdlas in range(100):
    now=(sho+dai)//2
    gokei=0
    for i in range(n):
        gokei+=(a[i]-1)//now
        #print(gokei)
    if(gokei<=k):
        dai=now
    else:
        sho=now
    #print(now,gokei,sho,dai)


print(dai)
#gokei=0
#for i in range(n):
#    gokei+=(a[i]-1)//
#if(gokei>k):
#    print(sho)
#else:
#    print(dai)

### FIXED CODE ###

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



sho=1
dai=max(a)
for jfdlas in range(100):
    now=(sho+dai)//2
    gokei=0
    for i in range(n):
        gokei+=(a[i]-1)//now
        #print(gokei)
        if(gokei>k):
            sho=now
            continue
    if(gokei<=k):
        dai=now
    else:
        sho=now
    #print(now,gokei,sho,dai)


print(dai)
#gokei=0
#for i in range(n):
#    gokei+=(a[i]-1)//
#if(gokei>k):
#    print(sho)
#else:
#    print(dai)
### BUGGY CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
import collections
D=collections.defaultdict(int)
r,c,k=map(int,input().split())
for _ in range(k):
	ri,ci,v=map(int,input().split())
	ri-=1
	ci-=1
	D[ri*10**5+ci]=v

DP0=[[0]*(c+1) for i in range(r+1)]
DP1=[[0]*(c+1) for i in range(r+1)]
DP2=[[0]*(c+1) for i in range(r+1)]
DP3=[[0]*(c+1) for i in range(r+1)]
for i in range(r+1):
	for j in range(c+1):
		v=D[i*10**5+j]
		if v!=0:
			DP1[i][j]=max(DP0[i-1][j],DP1[i-1][j],DP2[i-1][j],DP3[i-1][j])+v

		DP0[i][j]=max(DP0[i][j],DP0[i-1][j],DP1[i-1][j],DP2[i-1][j],DP3[i-1][j])
		if v!=0:
			DP1[i][j]=max(DP1[i][j],DP0[i-1][j]+v,DP1[i-1][j]+v,DP2[i-1][j]+v,DP3[i-1][j]+v)
		DP0[i][j]=max(DP0[i][j],DP0[i][j-1])
		DP1[i][j]=max(DP1[i][j],DP1[i][j-1])
		DP2[i][j]=max(DP2[i][j],DP2[i][j-1])
		DP3[i][j]=max(DP3[i][j],DP3[i][j-1])
		if v!=0:
			DP1[i][j]=max(DP1[i][j],DP0[i][j-1]+v)
			DP2[i][j]=max(DP2[i][j],DP1[i][j-1]+v)
			DP3[i][j]=max(DP3[i][j],DP2[i][j-1]+v)
		
ans=max(DP0[r-1][c-1],DP1[r-1][c-1],DP2[r-1][c-1],DP3[r-1][c-1])
print(ans)



### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()

r,c,k=map(int,input().split())
D=[[0]*c for _ in range(r)] 
for _ in range(k):
	ri,ci,v=map(int,input().split())
	ri-=1
	ci-=1
	D[ri][ci]=v

DP0=[[0]*(c+1) for i in range(r+1)]
DP1=[[0]*(c+1) for i in range(r+1)]
DP2=[[0]*(c+1) for i in range(r+1)]
DP3=[[0]*(c+1) for i in range(r+1)]
for i in range(r):
	for j in range(c):
		v=D[i][j]
		if v!=0:
			DP1[i][j]=max(DP0[i-1][j],DP1[i-1][j],DP2[i-1][j],DP3[i-1][j])+v

		DP0[i][j]=max(DP0[i][j],DP0[i-1][j],DP1[i-1][j],DP2[i-1][j],DP3[i-1][j])
		if v!=0:
			DP1[i][j]=max(DP1[i][j],DP0[i-1][j]+v,DP1[i-1][j]+v,DP2[i-1][j]+v,DP3[i-1][j]+v)
		DP0[i][j]=max(DP0[i][j],DP0[i][j-1])
		DP1[i][j]=max(DP1[i][j],DP1[i][j-1])
		DP2[i][j]=max(DP2[i][j],DP2[i][j-1])
		DP3[i][j]=max(DP3[i][j],DP3[i][j-1])
		if v!=0:
			DP1[i][j]=max(DP1[i][j],DP0[i][j-1]+v)
			DP2[i][j]=max(DP2[i][j],DP1[i][j-1]+v)
			DP3[i][j]=max(DP3[i][j],DP2[i][j-1]+v)
		
ans=max(DP0[r-1][c-1],DP1[r-1][c-1],DP2[r-1][c-1],DP3[r-1][c-1])
print(ans)