Harryxun/stf_run huggingface dataset:
H, N = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())
INF = 10**10


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

for b in range(1, INF):
    for i in range(1, N+1):
        if b - B[i-1] > 0:
            dp[i][b] = max(dp[i][b - B[i-1]] + A[i-1], dp[i - 1][b])
        else:
            dp[i][b] = max(dp[i-1], A[i-1])
    if dp[-1][b] >= H:
        print(b)
        break

### FIXED CODE ###

H, N = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

dp = [[10**10] * (H + 1) for _ in range(N+1)]

for i in range(1, N+1):
    for h in range(1, H+1):
        if h - A[i-1] <= 0:
            dp[i][h] = min(dp[i-1][h], B[i-1])
        else:
            dp[i][h] = min(dp[i-1][h], dp[i][h-A[i-1]] + B[i-1])

print(dp[-1][-1])
a=list(map(int, input().split()))
l=[a[0]]
def d(a,b):
    if a<b:
        if min(l)!=b-a:
            l.append(b-a)
            d(b-a,a)
        else:
            print(b-a)
            exit()
    elif b<a:
        if min(l)!=a-b:
            l.append(a-b)
            d(a-b,b)
        else:
            print(a-b)
            exit()
    else:
        print(0)
        exit()
d(a[0],a[1])

### FIXED CODE ###

a=list(map(int, input().split()))
def d(a,b):
    _1=a%b
    _2=b-(a%b)
    if _1<_2:
        print(_1)
    else:
        print(_2)
d(a[0],a[1])
k = int(input())
x = int(input())
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(int(l))

### FIXED CODE ###

k,x = map(int,input().split())	
li = [str(x-k+1+i) for i in range(2*k-1)]
l = ' '.join(li)
print(l)
"""
python3 main.py < input.txt
"""
import math
import itertools as it
import heapq


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

if len(A) == 2:
        print(max(A[0][1], A[1][1]))
        exit(0)

maxX=-1
for i, ai in enumerate(A):
        x=10**20
        l=list(A)
        l0, l1=(l[1][1], l[2][1]) if i == 0 else (l[0][1], l[2][1]) if i == 1 else (l[0][1], l[1][1]) 

        x=math.gcd(l0, l1)
        for (j, lj) in l[(3 if i <= 2 else 2):]:
                if i != j:
                        x=math.gcd(x, lj)
        maxX=max(x, maxX)
print(maxX)

### FIXED CODE ###

"""
python3 main.py < input.txt
"""
import math
import itertools as it
import heapq

def gcd(a, b):
        return a if b == 0 else gcd(b, a%b)
N=int(input())
A=list(map(int, input().split()))

L=[A[0]]
for i in range(1, N):
        L.append(gcd(L[-1], A[i]))
R=[A[-1]]
for i in reversed(range(N-1)):
        R.append(gcd(R[-1], A[i]))
R.reverse()

m=max(R[1], L[-2])
for i in range(1, N-1):
        m=max(m, gcd(L[i-1], R[i+1]))
print(m)
N = int(input())
count = 0
for a in range(1,N+1):
  for b in range(a,N/a+1):
    count += 1
print(count)

### FIXED CODE ###

N = int(input())
count = 0
for a in range(1,N+1):
  for b in range(a,N//a+1):
    if a * b < N:
      if a == b:
        count += 1
      else:
        count += 2
print(count)
i = 0
while(n = (int)raw_input()):
  i = i + 1;
  print 'Case',i+':',n

### FIXED CODE ###

n = input()
i = 1
while n != 0:
  print "Case %d: %d" % (i, n)
  n = input()
  i += 1;
# -*- coding: utf-8 -*-

import numpy as np

r = float( input() )

area = r * r * np.pi
circle = 2 * r * np.pi

print(format(area, '.10f'), format(circle, '.10f'))

### FIXED CODE ###

# -*- coding: utf-8 -*-

import math

r = float( input() )

area = r * r * math.pi
circle = 2 * r * math.pi

print(format(area, '.10f'), format(circle, '.10f'))
X = int(input())

if X >= 0 and X <= 10 ** 9:
    while True:
        if X >= 500:
            C = X // 500
            X = X - (500 * C)
        elif X >= 5:
            D = X // 5
            X = X - (5 * D)
        else:
            break

total = (1000 * C) + (5 * D)

print(total)

### FIXED CODE ###

X = int(input())

C = 0
P = 0
D = 0
L = 0
total = 0

if X >= 0 and X <= 10 ** 9:
    while True:
        if X >= 500:
            C = X // 500
            P = 500 * C
            X = X - P
        elif X >= 5:
            D = X // 5
            L = 5 * D
            X = X - L
        else:
            break
man = 1000 * C
t   = 5 * D

total = man + t

print(total)
n = int(input())
l = list(map(int, input().split()))
 
ans = 0
for i in range(1, n - 1):
  if l[i - 1] < l[i] and l[i] < l[i + 1]:
    ans += 1
  elif l[i + 1] < l[i] and l[i] < l[i - 1]:
 	ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split()))
 
ans = 0
for i in range(1, n - 1):
  if l[i - 1] < l[i] and l[i] < l[i + 1]:
    ans += 1
  elif l[i + 1] < l[i] and l[i] < l[i - 1]:
    ans += 1
print(ans)
import math
n,k = map(int, input().split())
end=min(n-k+1,k)
ans=1
for i in range(1,end+1):
    ans=math.factorial(n-k+1)*math.factorial(k-1)//(math.factorial(i)*math.factorial(n-k+1-i)*math.factorial(i-1)*math.factorial(k-i))
    print(ans%(10**9+7))
    if end=n-k+1:
        for _ in range(end+1,k+1)
        print(0)

### FIXED CODE ###

import math
n,k = map(int, input().split())
end=min(n-k+1,k)
ans=1
for i in range(1,end+1):
    ans=math.factorial(n-k+1)*math.factorial(k-1)//(math.factorial(i)*math.factorial(n-k+1-i)*math.factorial(i-1)*math.factorial(k-i))
    print(ans%(10**9+7))
if end==n-k+1:
    for _ in range(end+1,k+1):
        print("0")
N, X = map(lambda x: int(x), input().split())
L = map(lambda x: int(x), input().split())
D = 0
count = 0
for i, l in enumerate(L):
if D <= X:
    count += 1
D += int(l)
print(count)

### FIXED CODE ###

N, X = map(int, input().split())
L = map(int, input().split())
D = 0
count = 1
for i, l in enumerate(L):
  D += l
  if D <= X:
      count += 1
print(count)
x,k,d = map(int,input().split())
x = abs(x)
if x//d > k:
  print(x-k*d)
elif (k-x//d)%2 == 0:
  print(x%d)
else:
  print(d-x%d)

### FIXED CODE ###

s = input()
#print(s[0])
if s[0]==s[1]==s[2]=="R":
    print(3)
elif s[0]=="R" and s[1]=="R":
    print(2)
elif s[1]=="R" and s[2]=="R":
    print(2)
elif s[0]=="R":
    print(1)
elif s[1]=="R":
    print(1)
elif s[2]=="R":
    print(1)
else:
    print(0)
N=int(input())
city=[]
for i in range(N):
    x,y=map(int,input().split())
    city.append((i,x,y))
city.sort(key=lambda x:x[1])
data=[]
for i in range(N-1):
    data.append((city[i][0],city[i+1][0],city[i+1][1]-city[i][1]))
city.sort(key=lambda y:y[2])
for i in range(N-1):
    data.append((city[i][0],city[i+1][0],city[i+1][2]-city[i][2]))
data.sort(key=lambda d:d[2])
idx=[-1]*N
def find(idx,x):
    if idx[x]<0:
        return x
    elif idx[x]>=0:
        idx[x]=find(idx,idx[x])
        return idx[x]
ans=0
for q in range(len(data)):
    i,j,d=data[q]
    iidx=find(idx,i)
    jidx=find(idx,j)
    if iidx==jidx:
        continue
    elif idx[iidx]>=idx[jidx]:
        idx[iidx]+=idx[jidx]
        idx[jidx]=iidx
        ans+=d
    elif idx[iidx]<idx[jidx]:
        idx[jidx]+=idx[iidx]
        idx[iidx]=jidx
        ans+=d
print(ans)

### FIXED CODE ###

N=int(input())
city=[]
for i in range(N):
    x,y=map(int,input().split())
    city.append((i,x,y))

data=[]
city.sort(key=lambda x:x[1])
for i in range(N-1):
    data.append((city[i][0],city[i+1][0],city[i+1][1]-city[i][1]))
city.sort(key=lambda y:y[2])
for i in range(N-1):
    data.append((city[i][0],city[i+1][0],city[i+1][2]-city[i][2]))
data.sort(key=lambda d:d[2])

idx=[-1]*N
def find(idx,x):
    if idx[x]<0:
        return x
    elif idx[x]>=0:
        idx[x]=find(idx,idx[x])
        return idx[x]

ans=0
for q in range(len(data)):
    i,j,d=data[q]
    iidx=find(idx,i)
    jidx=find(idx,j)
    if iidx==jidx:
        continue
    elif idx[iidx]<=idx[jidx]:
        idx[iidx]+=idx[jidx]
        idx[jidx]=iidx
        ans+=d
    elif idx[iidx]>idx[jidx]:
        idx[jidx]+=idx[iidx]
        idx[iidx]=jidx
        ans+=d
print(ans)
n = input()
N = int(n)
P = []
counter = 0
input_string = input()
P = input_string.split()

for i in range(int(N)):
    for j in range(N):
        if N == int(P[i]):
            counter = counter + 1
            if N != 1:
                N = N - 1
                break
            else: 
                break
        elif N < int(P[i]):
            break
        else:
            if N != 1:
                N = N - 1   

print(counter + 1)





### FIXED CODE ###

n = input()
N = int(n)
P = []
counter = 0
input_string = input()
P = input_string.split()

for i in range(int(N)):
    for j in range(N):
        if N == int(P[i]):
            counter = counter + 1
            if N != 1:
                N = N - 1
                break
            else: 
                break
        elif N < int(P[i]):
            break
        else:
            if N != 1:
                N = N - 1   

print(counter)
import numpy as np
N = int(input())
for i in range(1, N+1):
    count = 0
    for j in range(1, int(np.sqrt(i))+2):
        for k in range(j, int(np.sqrt(i))+2):
            for l in range(k, int(np.sqrt(i))+2):
                n = j*j + k*k + l*l + j*k + k*l + l*j
                #print(i, j, k, l)
                if n == i:
                    if j == k == l:
                        count += 1
                    elif j==k or k==l or l==j:
                        count += 3
                    else:
                        count += 6
    print(count)

### FIXED CODE ###

L, R, d = map(int, input().split())
count_1 = (R - L) // d 
count_2 = 0
if L % d == 0 or R % d == 0:
    count_2 += 1
ans = count_1 + count_2
print(ans)
s = tuple(map(int,input().split('/')))
t = tuple(2019,4,30)
print("Heisei" if s <= t else "TBD")

### FIXED CODE ###

y,m,d = input().split('/')
print("Heisei" if int(y+m+d) <= 20190430 else "TBD")
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
A = inpl()
A.sort()
BC = []
for _ in range(M):
    BC.append(inpl())
BC.sort(key=lambda x: -x[1])

S = 0
j = 0
b = -1
for i in range(N):
  b += 1
  if b >= BC[j][0]
    j += 1
    b = 0
  if j >= M:
    S += A[i]
    break
  if BC[j][1] > A[i]:
    S += BC[j][1]
  else:
    S += A[i]
    break
S += sum(A[i+1:])
print(S)

### FIXED CODE ###

inpl = lambda: list(map(int,input().split()))
N, M = inpl()
A = inpl()
A.sort()
BC = []
for _ in range(M):
    BC.append(inpl())
BC.sort(key=lambda x: -x[1])
t = 0
S = 0
for B,C in BC:
    f = t
    t = f + B
    if t > N:
        t = N
    if f >= N:
        break
    if C >= A[t-1]:
        S += (t-f)*C
    else:
        for i in range(f,t):
            if C >= A[i]:
                S += C
            else:
                t = i
                break
        break
if t < N:
    S += sum(A[t:])
print(S)
import numpy as np

def count_ABC_num(D, thr):
    return len([_ for _ in D if _ < thr])


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

D = np.sort(np.array(D))
cent_index = int(len(D)/2)

print(len([threshold for threshold in range(D[cent_index - 1], D[cent_index + 1] + 1) if count_ABC_num(D, threshold) == cent_index]))

### FIXED CODE ###


def count_ABC_num(D, thr):
    return len([_ for _ in D if _ < thr])

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

D.sort()
cent_index = int(len(D)/2)

print(D[cent_index] - D[cent_index - 1])
a, b, k = int(i) for i in input().split()
takahashi = a - k
aoki = b + takahashi if takahashi < 0 else b
print(f"{max(takahashi, 0)} {max(aoki, 0)}")


### FIXED CODE ###

s, t = input().split()
print(t+s)
inport math
n=int(input())
print(math.ceil(n/2))

### FIXED CODE ###

import math
n=int(input())
print(math.ceil(n/2))
K = int(input())

odd = [0 for i in range(1, K + 1) if i % 2 == 1]
even = [0 for i in range(1, K + 1) if i % 2 == 0]

print(len(odd) * len(event))


### FIXED CODE ###

K = int(input())

odd = [0 for i in range(1, K + 1) if i % 2 == 1]
even = [0 for i in range(1, K + 1) if i % 2 == 0]

print(len(odd) * len(even))
if (n := int(input())) > 0:
  for _ in range(n):
    input()

### FIXED CODE ###

class Counter(dict):
  def __missing__(self, i):
    return 0

n = int(input())

s = Counter()

for _ in range(n):
  i = input()
  s[i] += 1

s = list(sorted(s.items(), key=lambda x: -x[1]))
m = s[0][1]

ans = []
for key, value in s:
  if value == m:
    ans.append(key)
  else:
    break

ans.sort()

print('\n'.join(ans))
def main():
    n = input()

    l = len(n)

    nines = "9" * (l - 1)
    num = int(nines)

    for i in range(1, 10):
        tmp = str(i) + nines
        if int(tmp) <= int(n):
            num = tmp

    ans = sum(map(int, num))
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    n = input()

    l = len(n)

    nines = "0" + "9" * (l - 1)
    nines = int(nines)

    num = nines
    for i in range(1, 10):
        tmp = i * 10 ** (l - 1) + nines
        if tmp <= int(n):
            num = tmp

    ans = sum(map(int, str(num)))
    print(ans)


if __name__ == "__main__":
    main()
n, a, b = map(int, input().split())
s = input()

all = list(s)
count = 0
count_b = 0
for i in all:
    if i == 'a':
        if count <= a + b:
            print('yes')
            count += 1
        else:
            print('no')
    if i == 'b':
        if count <= a + b and count_b <= b
            print('yes')
            count += 1
            count_b += 1
        else:
            print('no')
    else:
        print('no')

### FIXED CODE ###

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

all = list(s)
count = 0
count_b = 0
for i in all:
    if i == 'a':
        if count < a + b:
            print('Yes')
            count += 1
        else:
            print('No')
    elif i == 'b':
        if (count < a + b) and (count_b < b):
            print('Yes')
            count += 1
            count_b += 1
        else:
            print('No')
    else:
        print('No')
a = input().int()
s = input() 

if a>=3200:print s 
else: print "red"

### FIXED CODE ###

a = int(input())
s = input() 

if a>=3200:print (s) 
else: print ("red")
import random

def name():
    S = input("S:")
    
    if len(S) > 20:
        return name()
    
    if len(S) < 3:
        return name()
    
    if s.isupper() == True:
        return name()
    
    if s.isalpha() == False:
        return name()
    
    else:
        l = list(S)
        x = random.randint(0, len(s) - 3)
        y = l[x]
        z = l.index(y)
        print(y + l[z+1] + l[z+2])
                
name()

### FIXED CODE ###

import random

def name(x):
    if len(x) > 20:
        return name()
    if len(x) < 3:
        return name()
    if x.isupper() == True:
        return name()
    if x.isalpha() == False:
        return name()
    else:
        l = list(x)
        w = random.randint(0, len(x) - 3)
        y = l[w]
        z = l.index(y)
        print(y + l[z+1] + l[z+2])
        
S=input()
name(S)
a, b, k = map(int, input().split())
arr = list(range(a, b+1))
for i in sorted(set(arr[:k]) | set(arr[-k:])):
    print(i)

### FIXED CODE ###

a, b, k = map(int, input().split())
arr = range(a, b+1)
for i in sorted(set(arr[:k]) | set(arr[-k:])):
    print(i)
input_lines = input().split()
N = int(input_lines[0])
M = int(input_lines[1])
S = input()
T = input()

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

def lcm(a, b):
  return a*b/gcd(a, b)

L = int(lcm(N,M))
x = 1
count = 0
if N >= M:
    big = N
    small = M
else:
    big = M
    small = N
    
while True:
    k = L*x
    flag = 1
    left = 0
    right = big - 1
    for j in range(small):
        while left <= right:
            mid = (left+right)/2
            if((mid-1)*k/big+1 == (j-1)*k/small+1):
                if(S[mid-1] != T[j-1]):
                    flag = 0
                    count += 1
                    break
            elif((mid-1)*k/big+1 > (j-1)*k/small+1):
                right = mid - 1
            else:
                left = mid + 1
    if(flag == 1):
        print(k)
        break
    if(count == 2):
        print(-1)
        break
    x += 1


### FIXED CODE ###

input_lines = input().split()
N = int(input_lines[0])
M = int(input_lines[1])
S = input()
T = input()

def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

def lcm(a, b):
  return a*b/gcd(a, b)

L = int(lcm(N,M))
x = 1
count = 0
while True:
    k = L*x
    flag = 1
    starti = 0
    startj = 0
    for i in range(starti, N):
        for j in range(startj, M):
            hoge = i*k/N+1
            fuga = j*k/M+1
            if(hoge < fuga):
                startj = j - 1
                break
            elif(hoge == fuga):
                if(S[i] != T[j]):
                    flag = 0
                    count += 1
                    break
        if(flag == 0):
            break
    if(flag == 1):
        print(k)
        break
    if(count == 2):
        print(-1)
        break
    x += 1
M = 10**9+7
N = int(input())
S = list(input())
s = []

#0ならW、1ならB
s_append = s.append
for i in range(2*N):
    if S[i] == "B":
        s_append(1)
    else:
        s_append(0)

#端が0なら0を返す
if s[0] == 0 or s[2*N-1] == 0:
    print(0)
    exit()

ans = 0
lis = [0] #0なら左、1なら右
#全て0にする
lis_append = lis.append
for j in range(1,2*N):
    j1 = lis[j-1]
    if s[j-1] != s[j]:
        lis_append(j1)
    elif j1 == 0:
        lis_append(1)
    else:
        lis_append(0)

#左と右の数が違ったら0を返す
if lis.count(0) != lis.count(1):
    print(0)
    exit()

#"右"が選べる"左"の選択肢を掛けていく
cnt = 1
ans = 1
for k in range(1,2*N):
    if lis[k] == 0:
        cnt += 1
    else:
        ans *= cnt
        cnt -= 1

#N!をかける
for l in range(1,N+1):
    ans *= l
    ans %= M
print(ans)

### FIXED CODE ###

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

ans = 0

if D <= 21:
    ans = 0
else:
    for d_ in range(22,D+1):
        d = list(map(int, str(d_)))
        if int(d[0])<2 or int(d[1])<2:
            continue
        for m in range(1,M+1):
            if d[0] * d[1] == m:
                ans += 1
print(ans)
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))

ans = lcm_list(T)
print(ans)

### FIXED CODE ###

from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

N = int(input())
T = []
for _ in range(N):
    T.append(int(input()))

ans = lcm(*T)
print(ans)
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a, b, c, d, e]
li_2 = []
d = 10
count = 0
adr = 0
for i in li:
    li_2.append(i % 10)
for i in li_2:
    if i < d and i != 0:
        d = i
        ans = adr
    adr += 1
if d == 10:
    d = 0
for i in range(5):
    if i != ans and li_2[i] != 0:
        count += (li[i] - li_2[i] + 10)
    elif i != ans and li_2[i] == 0:
        count += li[i]
count += li[ans]
print(count)


### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
li = [a, b, c, d, e]
li_2 = []
d = 10
count = 0
adr = 0
for i in li:
    li_2.append(i % 10)
for i in li_2:
    if i < d and i != 0:
        d = i
        ans = adr
    adr += 1
if d == 10:
    d = 0
    ans = 0
for i in range(5):
    if i != ans and li_2[i] != 0:
        count += (li[i] - li_2[i] + 10)
    elif i != ans and li_2[i] == 0:
        count += li[i]
count += li[ans]
print(count)
def main():
    s = input()
    t = input()
    ans = 100000000
    for i in range(0,len(s)-len(t)):
        cnt = 0
        for sub_s,sub_t in zip(s[i:len(t)+i],t):
            if sub_s != sub_t:
                cnt += 1
        if cnt < ans:
            ans = cnt
    print(cnt)
    

if __name__ == "__main__":
    main()

### FIXED CODE ###

s = input()
t = input()

stri = []
mincount = 1e9
for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if(s[i+j] != t[j]):
            count+= 1
    mincount = min(mincount,count) 
print(mincount)
height=list(map(int,input().strip().split()) )
lst=[1]*h

for i in range(m):
    a,b=map(int,input().strip().split())
    if height[a-1]>height[b-1]:
        lst[a-1]=1
        lst[b-1]=0
    elif height[a-1]<height[b-1]:
        lst[b-1]=1
        lst[a-1]=0
    else:
        lst[b - 1] = 0
        lst[a - 1] = 0
print(lst.count(1))

### FIXED CODE ###

h, m =map(int,input().strip().split())

height=list(map(int,input().strip().split()) )
lst=[1]*h

for i in range(m):
    a,b=map(int,input().strip().split())
    if height[a-1]>height[b-1]:
        lst[b-1]=0
    elif height[a-1]<height[b-1]:
        lst[a-1]=0
    else:
        lst[b - 1] = 0
        lst[a - 1] = 0

print(lst.count(1))
N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[-1] * FIELD_SIZE for n in range(FIELD_SIZE)]
under_flag = True

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):
            if h[n] != 0:
                under_flag = False

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if H[cx][cy] == -1:
                H[cx][cy] = ch
            elif under_flag and H[cx][cy] <= ch:
                H[cx][cy] = ch
            elif H[cx][cy] == ch:
                H[cx][cy] = ch
            else:
                H[cx][cy] = None

for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] is not None:
            print(cx, cy, H[cx][cy])


### FIXED CODE ###

#!/usr/bin/env python

N = int(input())

FIELD_SIZE = 101

x = []
y = []
h = []
for n in range(N):
    inputs = input().split()
    x.append(int(inputs[0]))
    y.append(int(inputs[1]))
    h.append(int(inputs[2]))

H = [[0] * FIELD_SIZE for n in range(FIELD_SIZE)]
determined_flag = False

for n in range(N):
    for cx in range(FIELD_SIZE):
        for cy in range(FIELD_SIZE):

            ch = h[n] + abs(x[n] - cx) + abs(y[n] - cy)
            if n == 0:
                H[cx][cy] = ch

            elif determined_flag:
                if h[n] != 0:
                    if ch == H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0
                else:
                    if ch >= H[cx][cy]:
                        pass
                    else:
                        H[cx][cy] = 0

            else:
                if h[n] != 0:
                    if ch <= H[cx][cy]:
                        H[cx][cy] = ch
                    else:
                        H[cx][cy] = 0
                else:
                    H[cx][cy] = min(H[cx][cy], ch)
    if h[n] != 0:
        determined_flag = True


for cx in range(FIELD_SIZE):
    for cy in range(FIELD_SIZE):
        if H[cx][cy] >= 1:
            print(cx, cy, H[cx][cy])
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
ls = []
for _ in range(5):
    ls.append(int(input()))
if N <= min(ls):
    print(5)
else:
    mint = min(ls)
    ans = 5 + min//N +1
    print(ans)

### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import math

N = int(input())
ls = []
for _ in range(5):
    ls.append(int(input()))

if N <= min(ls):
    print(5)
else:
    mint = min(ls)
    ans = 4 + math.ceil(N/mint) 
    print(ans)
n,k = list(map(int, input().split()))
v = list(map(int, input().split()))

dp=[[[-1 for i in range(k+1)] for j in range(n+1)] for l in range(n+1)]

def f(a, b, d):
    if d == 0: return 0
    if a == b and d > 1 and v[a] > 0: return v[a]
    if dp[a][b][d] != -1: return dp[a][b][d]
    maxi = max(v[a] + f(a+1, b, d - 1), v[b] + f(a, b - 1, d - 1))
    if v[a] < 0 and d > 1:
        maxi = max(maxi, f(a + 1, b, d - 2))
    if v[b] < 0 and d > 1:
        maxi = max(maxi, f(a, b - 1, d - 2))
    maxi = max(maxi, 0)
    dp[a][b][d]=maxi
    return maxi


print(f(0, n-1, k))

### FIXED CODE ###

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

dp=[[[-1 for i in range(k+1)] for j in range(n+1)] for l in range(n+1)]

def f(a, b, d):
    if d == 0: return 0
    if a == b and d > 1 and v[a] > 0: return v[a]
    if a == b and d > 1 and v[a] <= 0: return 0
    if dp[a][b][d] != -1: return dp[a][b][d]
    maxi = max(v[a] + f(a+1, b, d - 1), v[b] + f(a, b - 1, d - 1))
    if v[a] < 0 and d > 1:
        maxi = max(maxi, f(a + 1, b, d - 2))
    if v[b] < 0 and d > 1:
        maxi = max(maxi, f(a, b - 1, d - 2))
    maxi = max(maxi, 0)
    dp[a][b][d]=maxi
    return maxi


print(f(0, n-1, k))