Harryxun/stf_run huggingface dataset:
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def city_saver(a, b):
    monster = 0
    for i in range(len(b)):
        monster += min(a[i], b[i])
        if(a[i]<b[i]):
            monster += min(b[i]-a[i], a[i+1])
            a[i+1] -= min(b[i]-a[i], a[i+1])
    return monster

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    city_saver(a, b)

if __name__ == "__main__":
    try:
    main()


### FIXED CODE ###

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

def city_saver(a, b):
    monster = 0
    for i in range(len(b)):
        monster += min(a[i], b[i])
        if(a[i]<b[i]):
            monster += min(b[i]-a[i], a[i+1])
            a[i+1] -= min(b[i]-a[i], a[i+1])
    return monster

def main():
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    print(city_saver(a, b))

if __name__ == "__main__":
    main()
h,w=map(int,input().split())
mass=[]
f=0
for i in range(h):
    mass.append(input().split())
for i in range(h-1):
    if f==0:
        for j in range(w-1):
            if mass[i][j]=="#" and mass[i][j]!=mass[i][j+1] and mass[i][j]!=mass[i+1][j]:
                print(i,j)
                f=1
                break
if f==0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

h,w=map(int,input().split())
mass=[]
f=0
frame=[["."]*(w+2) for i in range(h+2)]
for i in range(h):
    mass.append(list(input()))
for i in range(h):
    for j in range(w):
        frame[i+1][j+1]=mass[i][j]
for i in range(1,h):
    if f==0:
        for j in range(1,w):
            if frame[i][j]=="#" and frame[i][j]!=frame[i][j+1] and frame[i][j]!=frame[i+1][j] and frame[i][j]!=frame[i][j-1] and frame[i][j]!=frame[i-1][j]:
                    f=1
                    break
if f==0:
    print("Yes")
else:
    print("No")
import numpy as np
import itertools
 
H, W, K = list(map(int, input().split())) 
c = [list(input()) for i in range(H)]
 
c.replace("." , "0")
c.replace("#" , "1")
 
C_arr = np.array(c)
 
In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertolls.product([0,1] , repeat=W)))
 
ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])
    
    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)
    
    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()
    
    if ICO.count(1) == k:
      ans += 1
      
print(ans)

### FIXED CODE ###

H, W, K = list(map(int, input().split()))
 
c = [list(input()) for i in range(H)]
 
cnt = 0
for i in range(2**H):
    for j in range(2**W):
        cnt_black = 0
        for k in range(H):
            if (i >> k) & 1:
                continue
            for l in range(W):
                if (j >> l) & 1:
                    continue
                if c[k][l] == '#':
                    cnt_black += 1
        if cnt_black == K:
            cnt += 1
 
print(cnt)
s=input()
S=''
moji=len(s)
for i in range(moji)
    S+='x'
print(S)

### FIXED CODE ###

s=input()
print('x'*len(s))
# -*- coding: utf-8 -*-
import sys

S = input()
re = len(list(filter( lambda x: x == 'C', a[2:-1])))
if re == 1:
    print('AC')
else:
    print('WA')

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

S = input()
if S[0] != 'A':
    print('WA')
    sys.exit(0)
for l in S:
    if l in list('BDEFGHIJKLMNOPQRSTUVWXYZ'):
        print('WA')
        sys.exit(0)

re = len(list(filter( lambda x: x == 'C', S[2:-1])))
if re == 1:
    print('AC')
else:
    print('WA')
L,R=map(int,input().split())
M=[]
for i in range(L,R):
    for j in range(i+1,R+1):
        M.append((i%2019)*(j%2019))
print(min(M))

### FIXED CODE ###

import math
N,D=map(int,input().split())
X=[]
cnt=0
def distance(x,y):
    d2=[]
    for k in range(D):
        d2.append((X[x][k]-X[y][k])**2)
    return math.sqrt(sum(d2))
for i in range(N):
    X.append(list(map(int,input().split())))
for j in range(N-1):
        for l in range(j+1,N,):
            if float.is_integer(distance(j,l)):
                cnt+=1 
print(cnt)
n = int(input())
m = int(input())

result = 0

if n != 0: 
  result += n*(n-1)/2

if m != 0:
  result += m*(m-1)/2

print(result)

### FIXED CODE ###

n, m = map(int, input().split())
 
result = 0
 
if n != 0: 
  result += n*(n-1)/2
 
if m != 0:
  result += m*(m-1)/2
 
print(int(result))
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happiness = 0

for i in range(0, N, i++):
  if(A[N-1]==A[N]-1):
    happiness += (B[A[N]]+C[N-1])
  else:
    happiness += B[A[N]]

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]
happiness = 0

for i in range(0, N, 1):
  if i > 0:
    if A[i-1] == (A[i]-1):
      happiness += (B[A[i]-1]+C[A[i]-2])
    else:
      happiness += B[A[i]-1]
  else:
    happiness += B[A[i]-1]
print(happiness)
s = list(map(str, input().split()))
ctn = 0
for i in range(3):
  if s[i] == 'o':
    ctn += 1
print(700 + 100 * ctn)
         

### FIXED CODE ###

s = input()
print(700 + 100 * s.count('o'))
N = int(input())
F = [int("".join(input().split()), 1) for i in range(N)]
P = [list(map(int, (input().split()))) for i in range(N)]

ans = float('-inf')
for bit in range(1,1024):
    sum_p = 0
    for shop in range(N):
        time = bin(F[shop] & bit).count('1')
        sum_p += P[shop][time]

    ans = max(sum_p, ans)
print(ans)


### FIXED CODE ###

N = int(input())
F = [int("".join(input().split()), 2) for i in range(N)]
P = [list(map(int, (input().split()))) for i in range(N)]

ans = float('-inf')
for bit in range(1,1024):
    sum_p = 0
    for shop in range(N):
        time = bin(F[shop] & bit).count('1')
        sum_p += P[shop][time]

    ans = max(sum_p, ans)
print(ans)
import sys
input = sys.stdin.readline

mod = 998244353

A, B, C, D = map(int, input().split())
dp = [[0]*(D+1) for _ in range(C+1)]
dp2 = [[0]*(D+1) for _ in range(C+1)]


for w in range(B-1, D+1):
    dp[A][w] = 0
    dp2[A][w] = pow(A, (D-B), mod)

for c in range(A+1, C+1):
    invc = pow(c-1, mod-2, mod)
    t = pow(c*invc, D-B-1, mod)
    kakeru = pow(invc*c, mod-2, mod)
    dp[c][B] = pow(B,c-A,mod) * pow(c, D-B, mod) % mod
    dp2[c][B] = dp[c][B]
    for d in range(B+1, D+1):
        dp[c][d] = (dp2[c-1][d-1] + dp[c-1][d]*d ) * t % mod
        t = t * kakeru % mod
        dp2[c][d] = (dp2[c][d-1] + dp[c][d]) % mod

print(dp2[C][D])

### FIXED CODE ###

import sys
input = sys.stdin.readline

mod = 998244353


NN = 10**4 # 使うデータによって変える

inv = [0]
for i in range(1, NN):
    inv.append(pow(i, mod-2, mod))

def main():
    A, B, C, D = map(int, input().split())
    dp = [[0]*(D+1) for _ in range(C+1)]
    dp2 = [[0]*(D+1) for _ in range(C+1)]


    for w in range(B-1, D+1):
        dp[A][w] = 0
        dp2[A][w] = pow(A, (D-B), mod)


    for c in range(A+1, C+1):
        if D - B - 1 >= 0:
            t = pow(c*inv[c-1] % mod, D-B-1, mod)
        kakeru = (c-1)*inv[c] % mod
        dp[c][B] = pow(B,c-A,mod) * pow(c, D-B, mod) % mod
        dp2[c][B] = dp[c][B]
        for d in range(B+1, D+1):
            dp[c][d] = (dp2[c-1][d-1] + dp[c-1][d]*d % mod ) * t % mod
            t = t * kakeru % mod
            dp2[c][d] = (dp2[c][d-1] + dp[c][d]) % mod

    print(dp2[C][D])


if __name__ == "__main__":
    main()
n = int(input())
ans = 0
flg = False

for i in range(10)[1:]:
  ans = n/i
  r = n%i
  if(ans<10 and r ==0):
    flg = True
    break
if(flg):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

ams = 0
a,b = map(int, input().split())
if (a >=10 or b >= 10):
  ans = -1
else:
  ans = a*b
print(ans)
import sys
sys.setrecursionlimit(10**9)
N,M = map(int, input().split())
LRD = [ [int(j) for j in input().split()] for _ in range(M)]

data = [-1] * (N+1)
rank = [0]  * (N+1)
diff_weight = [0] * (N+1)

def root(x):
    if data[x] == x:
        return x
    else:
        r = root(x)
        diff_weight[x] += diff_weight[ data[x] ]
        data[x] = r
        return r

def weight(x):
    _ = root(x)
    return diff_weight[x]


def diff(x,y):
    return weight(y) - weight(x)

def merge(x,y,w):
    w  += weight(x); w -= weight(y)
    x = root(x)
    y = root(y)
    if x == y: return False
    if rank[x] < rank[y]: x,y = y,x; w = -w
    if rank[x] == rank[y]: rank[x] += 1
    data[y] = x
    diff_weight[y] = w
    return True

def issame(x,y):
    return root(x) == root(y)

for i in range(M):
    L,R,D = LRD[i]
    if not issame(L,R):
        merge(L,R,D)
    else:
        if weight(L,R) != D:
            print("No")
            exit(0)
            
print("Yes")

    
    


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
N,M = map(int, input().split())
input = sys.stdin.readline
LRD = [ [int(j) for j in input().split()] for _ in range(M)]

data = [x for x in range(N+1)]
rank = [0]  * (N+1)
diff_weight = [0] * (N+1)

def root(x):
    if data[x] == x:
        return x
    else:
        r = root( data[x] )
        diff_weight[x] += diff_weight[ data[x] ]
        data[x] = r
        return r

def weight(x):
    # _ = root(x)
    return diff_weight[x]


def diff(x,y):
    return weight(y) - weight(x)

def merge(x,y,w):
    w  += weight(x); w -= weight(y)
    x = root(x)
    y = root(y)
    if x == y: return False
    if rank[x] < rank[y]: x,y = y,x; w = -w
    if rank[x] == rank[y]: rank[x] += 1
    data[y] = x
    diff_weight[y] = w
    return True

def issame(x,y):
    return root(x) == root(y)

for i in range(M):
    L,R,D = LRD[i]
    # print(L,R,D)
    if not issame(L,R):
        _  = merge(L,R,D)
    else:
        if diff(L,R) != D:
            print("No")
            exit(0)
            
print("Yes")
a,b,c,d=map(int,input().split())
print(((a-c)**2+(b-d)**2)**0.5)

### FIXED CODE ###

a,b,c,d=map(float,input().split())
print(abs(complex(c-a,d-b)))
n=list(map(int, input().strip().split()))

lis1=[]
for i in range(0,len(n)):
    for a in range(0,len(n)):
        if n[i]!=n[a]:
            z=(int(n[a])+int(n[i]))
            lis1.append(str(z))
             
print(int(min(lis1)))



### FIXED CODE ###

try:
    n=list(map(int, input().strip().split()))
    lis1=[]
    for i in range(0,len(n)):
        for a in range(0,len(n)):
            if a!=i:
                z=(int(n[a])+int(n[i]))
                lis1.append(z)
            
    minscore='9999999999'
    for i in range(0,len(lis1)):
        if float(minscore)>float(lis1[i]):
            minscore=lis1[i]
    
    print(minscore)
    
except:
    print('')
N=int(input())
def kore(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
s=kore(N)
s.lower()
print(s)

### FIXED CODE ###

N=int(input())
def kore(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return kore(num//26-1)+chr(90)
    else:
        return kore(num//26)+chr(64+num%26)
s=kore(N)
s=s.lower()
print(s)
N = int(input())
a = 0
for i in input():
    if(i == R):
        a += 1
print("Yes" if N/2 < a else "No")

### FIXED CODE ###

n = int(input())
a = input()
cnt = 0
for i in a:
  cnt += (i == "R")
print("YNeos"[(cnt <= n // 2)::2])
from collections import defaultdict
N, W = map(int, input().split())
dd = defaultdict(int)
dd[0] = 0
for i in range(N):
    w, v = map(int, input().split())
    ddOld = dd.copy()
    for dk, dv in ddOld.items():
        dd[dk+w] = max(ddOld[dk+w], ddOld[dk]+v)
ans = 0
for dk, dv in dd.items():
    if dk <= W:
        ans = max(ans, dv)
print(ans)


### FIXED CODE ###

from collections import defaultdict
N, W = map(int, input().split())
dd = defaultdict(int)
dd[0] = 0
for i in range(N):
    w, v = map(int, input().split())
    ddOld = dd.copy()
    ddOld2 = dd.copy()
    for dk, dv in ddOld.items():
        dd[dk+w] = max(ddOld2[dk+w], dv+v)
ans = 0
for dk, dv in dd.items():
    if dk <= W:
        ans = max(ans, dv)
print(ans)
n = "#."
m = ".#"

while 1:
   H, W = map(int, raw_input().split())

   if H == 0 and W == 0:
      break
   if W%2 ==0:
      for i in range(0, H, 2):
         M[i] = n*(w/2)
      for i in range(1, H, 2):
         M[i] = m*(W/2)
   elif W%2 == 1:
      for i in range(0, H, 2):
         M[i] = n*(w/2)+n(0)
      for i in range(1, H, 2):
         M[i] = m*(W/2)+m(0)

   for i in range(H):
      print M[i]

### FIXED CODE ###

while 1:
   H, W = map(int, raw_input().split())
           
   if H == 0 and W == 0:
      break
   for i in range(H):
      if i%2 == 0:
         if W%2 == 0:
            print "#."*(W/2)
         elif W%2 == 1:
            print "#."*(W/2)+"#"
      elif i%2 == 1:
         if W%2 == 0:
            print ".#"*(W/2)
         elif W%2 == 1:
            print ".#"*(W/2)+"."
   print ""
# -*- coding: utf-8 -*-
"""
Created on Sun May 31 18:36:13 2020

@author: NEC-PCuser
"""
n = int(input())
l = list(map(int, input().split()))
dic_gusu = {}
dic_kisu = {}

for i in range(0, n):
    if (i % 2 == 0):
        if (l[i] in dic_gusu):
            dic_gusu[l[i]] += 1
        else:
            dic_gusu[l[i]] = 1
    if (i % 2 == 1):
        if (l[i] in dic_kisu):
            dic_kisu[l[i]] += 1
        else:
            dic_kisu[l[i]] = 1
dic_kisu = sorted(dic_kisu.items(), key = lambda x : x[1])
dic_gusu = sorted(dic_gusu.items(), key = lambda x : x[1])

count = 0
if (len(dic_kisu) == 1 and len(dic_gusu) == 1 and dic_kisu[len(dic_kisu) - 1][0] == dic_gusu[len(dic_gusu) - 1][0]):
    count = n // 2
elif (dic_kisu[len(dic_kisu) - 1][0] != dic_gusu[len(dic_gusu) - 1][0]):
    for i in range(0, len(dic_kisu) - 1):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_gusu) - 1):
        count += dic_kisu[i][1]
else:
    for i in range(0, len(dic_kisu)):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_kisu)):
        count += dic_kisu[i][1]
    count_tmp = count
    count_ans = count_tmp - dic_kisu[len(dic_kisu) - 1][1] - dic_kisu[len(dic_gusu) - 2][1] 
    count_ans2 = count_tmp  - dic_kisu[len(dic_kisu) - 2][1] - dic_kisu[len(dic_gusu) - 1][1]
    count = min([count_ans, count_ans2])     
        
print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sun May 31 18:36:13 2020

@author: NEC-PCuser
"""
n = int(input())
l = list(map(int, input().split()))
dic_gusu = {}
dic_kisu = {}

for i in range(0, n):
    if (i % 2 == 0):
        if (l[i] in dic_gusu):
            dic_gusu[l[i]] += 1
        else:
            dic_gusu[l[i]] = 1
    if (i % 2 == 1):
        if (l[i] in dic_kisu):
            dic_kisu[l[i]] += 1
        else:
            dic_kisu[l[i]] = 1
dic_kisu = sorted(dic_kisu.items(), key = lambda x : x[1])
dic_gusu = sorted(dic_gusu.items(), key = lambda x : x[1])

count = 0
if (len(dic_kisu) == 1 and len(dic_gusu) == 1 and dic_kisu[len(dic_kisu) - 1][0] == dic_gusu[len(dic_gusu) - 1][0]):
    count = n // 2
elif (dic_kisu[len(dic_kisu) - 1][0] != dic_gusu[len(dic_gusu) - 1][0]):
    for i in range(0, len(dic_kisu) - 1):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_gusu) - 1):
        count += dic_gusu[i][1]
else:
    for i in range(0, len(dic_kisu)):
        count += dic_kisu[i][1]
    for i in range(0, len(dic_gusu)):
        count += dic_gusu[i][1]
    count_tmp = count
    count_ans = count_tmp - dic_kisu[len(dic_kisu) - 1][1] - dic_gusu[len(dic_gusu) - 2][1] 
    count_ans2 = count_tmp  - dic_kisu[len(dic_kisu) - 2][1] - dic_gusu[len(dic_gusu) - 1][1]
    count = min([count_ans, count_ans2])    
        
print(count)
a,b,c = map(int,input(.split()))
print(a*B/2)


### FIXED CODE ###

a,b,c = map(int,input().split())
print(a*b//2)
a, b =[int(x) for x in input().split()]

import numpy as np
import sys
n=a*b

A = np.array(a)
B = np.array(b)
if np.gcd(A, B) == 1:
  print(n)
  sys.exit()

elif a > b:
  for i in range(a, n+1):
    if (i % a == 0)and(i % b == 0):
      print(i)
      sys.exit()
else:
  for i in range(b, n+1):
    if (i % a == 0)and(i % b == 0):
      print(i)
      sys.exit()

### FIXED CODE ###

a, b = [int(x) for x in input().split()]
# a = [int(input()) for _ in range(m)]
# a = [int(x) for x in input().split()]

from fractions import gcd



print((a*b)//gcd(a, b))
s = 3
arr =[]
for _ in range(s):
        arr.append(list(map(int, input().rstrip().split())))
#print(arr)
 
check = [[0,0,0],[0,0,0],[0,0,0]]
#print(check)
 
#check データ
N = int(input())
#print(N)
 
for i in range(N):
    data = int(input())
    for k in range(3):
        for j in range(3):
            if data == arr[j][k]:
                check[j][k]= 1
#print(check)
 
#chek ビンゴ
answer = "No"
for k in range(3):
    if check[k][0] == 1 and check[k][1]== 1 and check[k][2] == 1:
        answer = "Yes"
 
for j in range(3):
    if check[0][j] == 1 and check[1][j] == 1 and check[2][j] == 1:
        answer = "Yes"
 
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
    answer = "Yes"
 
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
    answer = "Yes"
 
 
print(answer)
s = 3
arr =[]
for _ in range(s):
        arr.append(list(map(int, input().rstrip().split())))
print(arr)

check = [[0,0,0],[0,0,0],[0,0,0]]
#print(check)

#check データ
N = int(input())
#print(N)

for i in range(N):
    data = int(input())
    for k in range(3):
        for j in range(3):
            if data == arr[j][k]:
                check[j][k]= 1
#print(check)

#chek ビンゴ
answer = "No"
for k in range(3):
    if check[k][0] == 1 and check[k][1]== 1 and check[k][2] == 1:
        answer = "Yes"

for j in range(3):
    if check[0][j] == 1 and check[1][j] == 1 and check[2][j] == 1:
        answer = "Yes"

if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
    answer = "Yes"

if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
    answer = "Yes"


print(answer)
提出情報

### FIXED CODE ###

s = 3
arr =[]
for _ in range(s):
        arr.append(list(map(int, input().rstrip().split())))
#print(arr)
 
check = [[0,0,0],[0,0,0],[0,0,0]]
#print(check)
 
#check データ
N = int(input())
#print(N)
 
for i in range(N):
    data = int(input())
    for k in range(3):
        for j in range(3):
            if data == arr[j][k]:
                check[j][k]= 1
#print(check)
 
#chek ビンゴ
answer = "No"
for k in range(3):
    if check[k][0] == 1 and check[k][1]== 1 and check[k][2] == 1:
        answer = "Yes"
 
for j in range(3):
    if check[0][j] == 1 and check[1][j] == 1 and check[2][j] == 1:
        answer = "Yes"
 
if check[0][0] == 1 and check[1][1] == 1 and check[2][2] == 1:
    answer = "Yes"
 
if check[0][2] == 1 and check[1][1] == 1 and check[2][0] == 1:
    answer = "Yes"
 
 
print(answer)
n = int(input())
a = list(map(int, input().split()))

l = []
d = dict()
for v in a:
    if v not in d:
        d[v] = 1
    else:
        d[v] += 1
        
    if d[v] == 2:
        l.append(v)

l.sort()
print(l[-1] * l[-2])

### FIXED CODE ###

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

l = []
d = dict()
for v in a:
    if v not in d:
        d[v] = 1
    else:
        d[v] += 1
        
    if d[v] == 2 or d[v] == 4:
        l.append(v)

if len(l) < 2:
    print(0)
else:
    l.sort()
    print(l[-1] * l[-2])
n = int(input())
a = [int(input()) for _ in range(6)]

print(4+(n-1)//min(a)+1)

### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a = IR(5)
    k = II()
    if max(a) - min(a) > k:
        print(":(")
    else:
        print("Yay!")
    return

#B
def B():
    a = IR(5)
    b = a[0]
    ans = 0
    for a_ in a:
        if a_ % 10 != 0:
            if b % 10> a_ % 10:
                b = a_
    flg = 0
    for a_ in a:
        if a_ != b or flg:
            ans += math.ceil(a_ / 10) * 10
        else:
            ans += b
            flg = 1
    print(ans)
            
    
    return

#C
def C():
    n = II()
    ai = IR(5)
    print(math.ceil(n / min(ai)) + 4)
        
        
    return

#D
def D():
    x, y, z, k = LI()
    a = LI()
    a.sort(reverse = True)
    b = LI()
    b.sort(reverse = True)
    c = LI()
    c.sort(reverse=True)
    ans = [0, 0, 0]
    print(a[ans[0]]+b[ans[1]]+c[ans[2]])
    for _ in range(k-1):
        ansa = a[ans[0] - 1] + b[ans[1]] + c[ans[2]]
        ansb = a[ans[0]] + b[ans[1] - 1] + c[ans[2]]
        ansc = a[ans[0]] + b[ans[1]] + c[ans[2] - 1]
        if ansa > ansb:
            if ansa > ansc:
                ans = [ans[0] - 1, ans[1], ans[2]]
            else:
                ans = [ans[0], ans[1], ans[2] - 1]
        else:
            if ansb > ansc:
                ans = [ans[0], ans[1] - 1, ans[2]]
            else:
                ans = [ans[0], ans[1], ans[2] - 1]

        print(a[ans[0]]+b[ans[1]]+c[ans[2]])
                    

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()
n = int(input())
a = sorted(list(map(int, input().split())))[::-1]
l = []
for i in range(n-1):
    if a[i] == a[i+1] and a[i] not in l:
        l.append(a[i])
        
print(l[0]*l[1])

### FIXED CODE ###

from collections import Counter
n=int(input())
a=Counter(list(map(int,input().split())))
b=[0,0]
for i in a:
    if a[i] > 1:b.append(i)
    if a[i] > 3:b.append(i)
b.sort()
print(b[-1]*b[-2])
A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)
print(A)

N = int(input())
b = [int(input()) for i in range(N)]
print(b)

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

if A[1][1] == 0:
  if A[0][0]==A[2][2]==0 or A[0][2]==A[2][0]==0:
    print("Yes")
  else:
    print("No")
elif A[1][1] != 0:
  if sum(A[0])==0 or sum(A[2])==0 or sum(A[:][0])==0 or sum(A[:][2]==0):
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

A = []
for i in range(3):
  a = input().split()
  a = [int(num) for num in a]
  A.append(a)

N = int(input())
b = [int(input()) for i in range(N)]

for i in range(3):
  for j in range(3):
    if b.count(A[i][j]) != 0:
      A[i][j] = 0
    else:
      continue

def Agetraw(j):
    Ans = [int(A[i][j]) for i in range(3)]
    return(Ans)

if (sum(A[0])==0 or sum(A[1])==0 or sum(A[2])==0 
    or sum(Agetraw(0))==0 or sum(Agetraw(1))==0 or sum(Agetraw(2))==0 
    or A[0][0]+A[1][1]+A[2][2]==0 or A[0][2]+A[1][1]+A[2][0]==0):
  print("Yes")
else:
  print("No")
def f(myC, chrs, s, lst):
    for c in chrs:
        if(myC + c) in s:
            lst += [myC + c]
            f(myC + c, chrs, s, lst)
            
if __name__ == '__main__':
    s = input()
    k = int(input())

    chrs = sorted(list(set(s)))
    lst = []
    f('', chrs, s, lst)
    ##print(lst)
    print(lst[k - 1])

### FIXED CODE ###

def f(myC, s, chrs, lst, k):
    if len(lst) == k:
        print(lst[k - 1])
        exit()
    else:
        for c in chrs:
            buf = myC + c
            if buf in s:
                lst += [buf]
                ##print(lst)
                f(buf, s, chrs, lst, k)

if __name__ == '__main__':
    s = input()
    k = int(input())

    chrs = sorted(list(set(s)))
    lst = f('', s, chrs, list(), k)