Harryxun/stf_run huggingface dataset:
s_len = len(s)
ref = [0] * s_len

for i in range(1, s_len + 1):
    ref[-i] = int(s[-i]) * pow(10, i, MOD) % MOD

for i in range(1, s_len):
    ref[-i - 1] += ref[-i]
    ref[-i - 1] %= MOD

ref_cnt = Counter(ref)
ans = sum(ref_cnt.values()) - len(ref_cnt)


for i in ref_cnt.values():
    ans += (i - 1) * (i - 2) // 2

if 0 in ref:
    ans += ref_cnt[0]

print(ans)

### FIXED CODE ###

from collections import Counter
s = input()
MOD = 2019

s_len = len(s)
ref = [0] * s_len

for i in range(1, s_len + 1):
    ref[-i] = int(s[-i]) * pow(10, i, MOD) % MOD

for i in range(1, s_len):
    ref[-i - 1] += ref[-i]
    ref[-i - 1] %= MOD

ref_cnt = Counter(ref)
ans = sum(ref_cnt.values()) - len(ref_cnt)


for i in ref_cnt.values():
    ans += (i - 1) * (i - 2) // 2

if 0 in ref:
    ans += ref_cnt[0]

print(ans)
n = int(input())
for i in range(n):
    d[i] = int(input())
ans = len(set(d))
print(ans)


### FIXED CODE ###

n = int(input())
d = []
for i in range(n):
    d.append(int(input()))
ans = len(set(d))
print(ans)
# cook your dish here
def f(x):
    if x == 1:
        return 2
    if x == 2:
        return 5
    if x == 3:
        return 5
    if x == 4:
        return 4
    if x == 5:
        return 5
    if x == 6:
        return 6
    if x == 7:
        return 3
    if x == 8:
        return 7
    if x == 9:
        return 6
n,m = map(int,input().split())
a = list(map(int,input().split()))
if 2 in a and 3 in a:
    a.remove(2)
    m -=1
if 2 in a and 5 in a:
    a.remove(2)
    m -=1
if 3 in a and 5 in a:
    a.remove(3)
    m -=1
if 6 in a and 9 in a:
    a.remove(6)
    m -=1
for w in range(1,10):
    if n < f(w):
        a.remove(w)
        m -=1
a.sort()

dp = [[0]*(m+1) for i in range(n+1)]


def g(k):
    cand = [0]*(m+1)
    for i in range(m):
        if k - f(a[i])>=0:
            if cand[0] <= dp[k-f(a[i])][0]+1 and dp[k-f(a[i])][0] != 0:
                for r in range(m+1):
                    cand[r] = dp[k-f(a[i])][r]
                cand[0] += 1
                cand[i+1] += 1
    if sum(cand) != 0:
        dp[k] = cand
for i in range(m):
    if f(a[i]) <= n:
        dp[f(a[i])][0] = 1
        dp[f(a[i])][i+1] = 1

for j in range(1,n+1):
    g(j)

ass = ''

for i in range(m):
    for k in range(dp[n][m-i]):
        ass += str(a[m-i-1])
print(ass)        

### FIXED CODE ###

# cook your dish here
def f(x):
    if x == 1:
        return 2
    if x == 2:
        return 5
    if x == 3:
        return 5
    if x == 4:
        return 4
    if x == 5:
        return 5
    if x == 6:
        return 6
    if x == 7:
        return 3
    if x == 8:
        return 7
    if x == 9:
        return 6
n,m = map(int,input().split())
a = list(map(int,input().split()))
if 2 in a and 3 in a:
    a.remove(2)
    m -=1
if 2 in a and 5 in a:
    a.remove(2)
    m -=1
if 3 in a and 5 in a:
    a.remove(3)
    m -=1
if 6 in a and 9 in a:
    a.remove(6)
    m -=1
for w in range(1,10):
    if n < f(w) and w in a:
        a.remove(w)
        m -=1
a.sort()
m = len(a)

dp = [[0]*(m+1) for i in range(n+2)]


def g(k):
    cand = [0]*(m+1)
    for i in range(m):
        if k - f(a[i])>=0:
            if cand[0] <= dp[k-f(a[i])][0]+1 and dp[k-f(a[i])][0] != 0:
                for r in range(m+1):
                    cand[r] = dp[k-f(a[i])][r]
                cand[0] += 1
                cand[i+1] += 1
    if sum(cand) != 0:
        dp[k] = cand
for i in range(m):
    if f(a[i]) <= n:
        dp[f(a[i])][0] = 1
        dp[f(a[i])][i+1] = 1

for j in range(1,n+1):
    g(j)

ass = ''

for i in range(m):
    for k in range(dp[n][m-i]):
        ass += str(a[m-i-1])
print(ass)
n = int(input())
p = list(map(int,input().split()))

ans = 0
for i in range(n):
    if i == 0:
        ans += 1
        m = p[0]
        continue
    if p[i] <= m:
        ans += 1
        m = p[i]

print(ans)

### FIXED CODE ###

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

if n == m:
    print('Yes')
else:
    print('No')
A, op, B = input().split()
if op == "+":
    print(A + B)
else:
    print(A - B)


### FIXED CODE ###

A, op, B = input().split()
A = int(A)
B = int(B)
if op == "+":
    print(A + B)
else:
    print(A - B)
(a b) = input()
print a * b
print a * 2 + b * 2

### FIXED CODE ###


l = map(int, raw_input().split())
 
print "%d %d" % (l[0]*l[1], (l[0]+l[1])*2)
s = input().strip()

a = 0
b = 0

for i in s:
    if s[i] == 'A':
        a = i
    elif s[i] == 'Z':
        b = i
print(b-a+1)


### FIXED CODE ###

s = input().strip()

a = []
b = []

for i in range(len(s)):
    if s[i] == 'A':
        a.append(i)
    elif s[i] == 'Z':
        b.append(i)
print(max(b)-min(a)+1)
import math

def solve():
    a, b = map(int, input().split())
    return a*b//math.gcd(a, b)

print(solve())

### FIXED CODE ###

from fractions import gcd

def solve():
    a, b = map(int, input().split())
    return  a * b // gcd(a,b)

print(solve())
import sys
N, L, T = [int(x) for x in input().strip().split(" ")]

xys = []
candidates = []
for line in sys.stdin:
    x, y = line.strip().split(" ")
    x, y = int(x), int(y)
    xys.append((x,y))
    candidates.append((x + (1 if y == 1 else -1) * T)%L)

x0, y0 = xys[0]

dxs = []
pr_x = None
counter = 0
for x, y in xys[1:]:
    if y != y0:
        if pr_x == None:
            if y0 == 1:
                a = (x - x0)
        else:
            dxs.append(x - pr_x)
        pr_x = x
        counter += 1
if y0 == 2:
    a = (L - pr_x) + x0

ree = (2*T)%L
num_round = (2*T)//L
ree = ree - a
if ree < 0:
    max_i = 0
else:
    for i, dx in enumerate(dxs if y0 == 1 else dxs[::-1]):
        ree = ree - dx
        if ree < 0:
            max_i = i + 1
            break
    else:
        max_i = counter

c_n = num_round * counter + max_i

rep = ( 
        ((1 if y0 == 1 else -1) * (c_n % N) % N),
        ((x0 + (1 if y0 == 1 else -1) * (T % L)) % L)
        )
print(rep)
result = []

candidates = sorted(candidates)

for i, c in enumerate(candidates):
    if c == rep[1]:
        start = i - rep[0]
        break

for j in range(N):
    if ree != 0:
        print(candidates[(start + j) % N])
    else:
        1/0


### FIXED CODE ###


import sys
N, L, T = [int(x) for x in input().strip().split(" ")]

xys = []
candidates = []
for line in sys.stdin:
    x, y = line.strip().split(" ")
    x, y = int(x), int(y)
    xys.append((x,y))
    candidates.append((x + (1 if y == 1 else -1) * T)%L)

x0, y0 = xys[0]

dxs = []
pr_x = None
counter = 0
for x, y in xys[1:]:
    if y != y0:
        if pr_x == None:
            if y0 == 1:
                a = (x - x0)
        else:
            dxs.append(x - pr_x)
        pr_x = x
        counter += 1

if pr_x == None:
    for x in candidates:
        print(x)
    sys.exit()
if y0 == 2:
    a = (L - pr_x) + x0

ree = (2*T)%L
num_round = (2*T)//L
ree = ree - a
if ree <= 0:
    max_i = 0
else:
    for i, dx in enumerate(dxs if y0 == 1 else dxs[::-1]):
        ree = ree - dx
        if ree <= 0:
            max_i = i + 1
            break
    else:
        max_i = counter

if ree == 0 and y0 == 2:
    max_i += 1

c_n = num_round * counter + max_i

rep = ( 
        ((1 if y0 == 1 else -1) * (c_n % N) % N),
        ((x0 + (1 if y0 == 1 else -1) * (T % L)) % L)
        )


candidates = sorted(candidates)

for i, c in enumerate(candidates):
    if c == rep[1]:
        start = i - rep[0]
        break

for j in range(N):
    print(candidates[(start + j) % N])
S = int(input())
if S == "ABC":
  print("ARC")
else:
  print("ABC")


### FIXED CODE ###

S = input()
if S == "ABC":
  print("ARC")
else:
  print("ABC")
a, op, b = map(int, input().split())
while True:
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif:
        print(a / b)
    else:
        break

### FIXED CODE ###

while True:
    a, op, b = map(str, input("").split())
    a = int(a)
    b = int(b)
    if op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)
    elif op == "?":
        break
A,B,K = map(int, input().split())
X = list(range(A,B+1))
ans = X[:K] + X[-K:]

for _ in sorted(set(ans)):
  print(_)

### FIXED CODE ###

A,B,K = map(int, input().split())
X = range(A,B+1)

for _ in sorted(set(X[:K]) | set(X[-K:])):
  print(_)
X, Y = map(int, input().split())

if (Y%2 == 1):
  print("No")
elif (Y > (X*4)):
  print("No")
else:
  yes = false
  for i in range(1,X+1):
    fNum = i
    tNum = X-i
    if ((fNum*4)+(tNum*2)==Y):
      print("Yes")
      yes = True
  if not (false):
    print("No")
  

### FIXED CODE ###

X, Y = map(int, input().split())

if (Y%2 == 1):
  print("No")
elif (Y > (X*4)):
  print("No")
else:
  yes = False
  for i in range(0,X+1):
    fNum = i
    tNum = X-i
    if ((fNum*4)+(tNum*2)==Y):
      print("Yes")
      yes = True
  if not (yes):
    print("No")
N, K = map(int, input().split())
P = [(int(x)+1)/2 for x in input().split()]

total=ans=sum(P[:K])
for n in range(K,N):
  total+=P[n]-P[n-K]
  ans=max(ans, total)

print(ans)


### FIXED CODE ###

a,b=input().split()
ST={}
ST[a], ST[b] = map(int, input().split())
ST[input()]-=1

for k,v in ST.items():
  print(v,end=' ')
N, K = map(int, input().split())
A = list(map(int, input().split()))
for i in range(K, N):
    if A[i-2]*A[i-1]*A[i-3] > A[i-4]*A[i-3]*A[i-2]:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

N, K =map(int, input().split())
A = list(map(int, input().split()))
for i in range(N-K):
    if A[K+i] > A[i]:
        print('Yes')
    else:
        print('No')
a, b, c = map(int, input().split())
x = [sorted(a, b, c)]

print(x[3]*10 + x[1] + x[2])

### FIXED CODE ###

a, b, c = map(int, input().split())
x = sorted([a, b, c])

print(x[2]*10 + x[0] + x[1])
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(1,n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if 1>m[r][c]or m[r][c]>x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()


### FIXED CODE ###

def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if not 0<m[r][c]<=x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()
a,b = map(str,input().split())
ab= int(a+b)
if int(squrt(ab))**2 == ab:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

from math import sqrt
a,b = map(str,input().split())
ab= int(a+b)
if int(sqrt(ab))**2 == ab:
  print("Yes")
else:
  print("No")
N,M = map(int, input().split())
Si = []
Ci = []
check1 = 0
check2 = 0
check3 = 0
lastcheck = 0
sum = 0
for i in range(M):
    S,C = map(int, input().split())
    Si.append(S)
    Ci.append(C)
if N==1:
    for i in range (M):
        sum +=C[i]
        check3  = i
        if C[i] != C[check3]:
            lastcheck=0
elif N==2:
    for i in range (M):
        if Si[i] == 2:
            sum +=C[i]*10
            check2 = i
            if C[i] != C[check2]:
                lastcheck=0
        else:
            sum +=C[i]
            check3=i
            if C[i] != C[check3]:
                lastcheck=0
else:
    for i in range (M):
        if Si[i] == 1:
            sum+=int(Ci[i]*100)
            check1 = i
            if int(C[i]) != int(C[check1]):
                lastcheck=0
        elif Si[i] == 2:
            sum +=C[i]*10
            check2 = i
            if C[i] != C[check2]:
                lastcheck=0
        else:
            sum +=C[i]
            check3=i
            if C[i] != C[check3]:
                lastcheck=0
if lastcheck == 0:
    print('-1')
else:
    print(sum)
            

### FIXED CODE ###

N,M = map(int, input().split())
Si = [0]*M
Ci = [0]*M
lastcheck = 1
precheck = 0
sum = 0
for i in range(M):
    Si[i], Ci[i] = map(int, input().split())
if N==1:
    for i in range (M):
        sum +=Ci[i]
        if Si[i]==1 and Ci[i]==0:
            sum =0
        for j in range(i+1,M):
            if Si[i]==Si[j]:
                sum-=int(Ci[i])
                if Ci[i] != Ci[j]:
                    lastcheck=0
elif N==2:
    for i in range (M):
        if Si[i] == 1:
            if Si[i]==1 and Ci[i]==0:
                lastcheck=0
            sum +=Ci[i]*10
            for j in range(i+1,M):
                if Si[i]==Si[j]:
                    sum-=int(Ci[i]*10)
                    if Ci[i] != Ci[j]:
                        lastcheck=0
        else:
            sum +=Ci[i]
            for j in range(i+1,M):
                if Si[i] == Si[j]:
                    sum-=int(Ci[i])
                    if Ci[i] != Ci[j]:
                        lastcheck=0
else:
    for i in range (M):
        if Si[i] == 1:
            if Si[i]==1 and Ci[i]==0:
                lastcheck=0
            sum+=int(Ci[i]*100)
            for j in range(i+1,M):
                if Si[i]==Si[j]:
                    sum-=int(Ci[i]*100)
                    if Ci[i] != Ci[j]:
                        lastcheck=0
        elif Si[i] == 2:
            sum +=Ci[i]*10
            for j in range(i+1,M):
                if Si[i] == Si[j]:
                    sum-=int(Ci[i]*10)
                    if Ci[i] != Ci[j]:
                        lastcheck=0
        else:
            sum +=Ci[i]
            for j in range(i+1,M):
                if Si[i] == Si[j]:
                    sum-=int(Ci[i])
                    if Ci[i] != Ci[j]:
                        lastcheck=0
for i in range(M):
    if Si[i] == 1:
        precheck+=1
if precheck == 0:
    if N == 3:
        sum +=100
    elif N == 2:
        sum +=10
    else:
        sum+=0
if lastcheck == 0:
    print('-1')
else:
    print(sum)
print("A{}C".format("B" if int(input()<1200 else "R"))

### FIXED CODE ###

print("A{}C".format("B"if int(input())<1200else"R"))
n=int(input())

print(int((n-1)*n//2))

### FIXED CODE ###

S=input()
T=input()

ans=0
for i in range(3):
  if S[i]==T[i]:
    ans+=1
print(ans)
while True:
    num = input()
    ret = 0
    for i in num:
        ret += num
    print(num)


### FIXED CODE ###

while True:
    num = input()
    if(num == "0"): break
    ret = 0
    for i in num:
        ret += int(i)
    print(ret)
import bisect,sys 
input=sys.stdin.readline 
a,b,Q=map(int,input().split())
INF=10**18
s=[-INF]+[int(input()) for _ in range(A)]+[INF]
t=[-INF]+[int(input()) for _ in range(B)]+[INF]
for q in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(s,x),bisect.bisect_right(t,x)
    res=INF 
    for S in [s(b-1),s(b)]:
        for T in [t(d-1),t(d)]:
            d1,d2=abs(S-x)+abs(T-S),abs(T-x)+abs(T-S)
            res=min(res,d1,d2)
    print(res)

### FIXED CODE ###

import bisect,sys 
input=sys.stdin.readline 
a,b,Q=map(int,input().split())
INF=10**18
s=[-INF]+[int(input()) for _ in range(a)]+[INF]
t=[-INF]+[int(input()) for _ in range(b)]+[INF]
for q in range(Q):
    x=int(input())
    b,d=bisect.bisect_right(s,x),bisect.bisect_right(t,x)
    res=INF 
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2=abs(S-x)+abs(T-S),abs(T-x)+abs(T-S)
            res=min(res,d1,d2)
    print(res)
x, y, a, b, c = map(int, input().split())
ps = list(map(int, input().split()))
qs = list(map(int, input().split()))
rs = list(map(int, input().split()))
ps.sort()
ps = ps[-x:]
qs.sort()
qs = qs[-y:]
pqs = ps + qs
pqs.sort()
rs.sort(reverse=True)

answer = sum(pqs)
for i in range(c):
    diff = rs[i] - pqs[i]
    if diff < 0:
        break
    answer += diff

print(answer)


### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
ps = list(map(int, input().split()))
qs = list(map(int, input().split()))
rs = list(map(int, input().split()))
ps.sort()
ps = ps[-x:]
qs.sort()
qs = qs[-y:]
pqs = ps + qs
pqs.sort()
rs.sort(reverse=True)

answer = sum(pqs)
for i in range(min(x+y, c)):
    diff = rs[i] - pqs[i]
    if diff < 0:
        break
    answer += diff

print(answer)
#!/usr/bin/env python3
import sys


def solve(N: int, X: int, T: int):
    i = 0
    A = 0
    while:
        if A < 0:
            break
        A = N - X*i
        i+=1

    return print(i*T)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, X, T)

if __name__ == '__main__':
    main()
~                 

### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int, X: int, T: int):
    i = 1
    A = 0
    while(True):
        A = N - X*i

        if A <= 0:
            break

        i+=1

    return print(i*T)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    T = int(next(tokens))  # type: int
    solve(N, X, T)

if __name__ == '__main__':
    main()
from functools import reduce
from operator import mul


def end_of_loop():
    raise StopIteration


def main():
    N, K = map(int, input().split())
    print(sum(reduce(mul, (0.5
                           if i << j < K
                           else end_of_loop()
                           for j in range(bin(K)-2)), 1 / N)
              for i in range(1, N + 1)))
    return


main()


### FIXED CODE ###

from functools import reduce
from operator import mul


def main():
    N, K = map(int, input().split())
    ans = []
    lst = []
    for i in range(1, N + 1):
        lst.clear()
        for j in range(K):
            if K <= i << j:
                break
            lst.append(0.5)
        ans.append(reduce(mul, lst, 1 / N))
    print(sum(ans))
    return


main()
from scipy.special import comb
n, a, b = map(int,input().split())
v = list(map(int, input().split()))

v.sort(reverse=True)
max_avg = sum(v[:a]) / a
min_v = min(v[:a])


ans = 0
for i in range(a, b+1):
    if max_avg != sum(v[:i]) / i: break
    cnt1 = v[:i].count(min_v)
    cnt2 = v.count(min_v)
    ans += comb(cnt2, cnt1)

print(max_avg)
print(int(ans))

### FIXED CODE ###

import math
def comb(n, k):
    return math.factorial(n) // (math.factorial(n - k) * math.factorial(k))

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

v.sort(reverse=True)
max_avg = sum(v[:a]) / a
min_v = min(v[:a])

ans = 0
for i in range(a, b+1):
    if max_avg != sum(v[:i]) / i: break
    cnt1 = v[:i].count(min_v)
    cnt2 = v.count(min_v)
    ans += comb(cnt2, cnt1)

print(max_avg)
print(int(ans))
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt, gcd
from copy import deepcopy

def main():
    
    d,n = map(int, input().split())
    a_list = []
    ans = 0
    if d == 0:
        for i in range(1,100):
            a_list.append(i)
    elif d == 1:
        for i in range(100, 10000, 100):
            a_list.append(i)
    else:
        for i in range(10000, 1000000, 10000):
            a_list.append(i)

    print(a_list[n-1])
    
if __name__ == "__main__":
    main()

### FIXED CODE ###

d,n = map(int,input().split())
li = []
for i in range(1,102):
    if i != 100:
        li.append(i*100**d)
print(li[n-1])
A= input() 
B= input()
C= input()
D= input()
L=A+B
R=C+D
if L>R:
  print('Left')
elif L==R:
  print('Balanced')
else :
  print('Right')


### FIXED CODE ###

a , b, c ,d = map(int,input().split(' '))
L=a+b
R=c + d
if L> R:
    print('Left')
elif L<R:
    print('Right')
else:
    print('Balanced ')
n = int(input())
a = list(map(int, input().split()))
q = int(input())

l = {}
ans = []
for e in a:
    l[e] = l[e] + 1 if l.get(e) else 1

for _ in range(q):
    b, c = map(int, input().split())
    l[c] = l[c] + l[b] if l.get(c) else l[b]
    del l[b]
    sum = 0
    for k, v in l.items():
        sum += k * v
    ans.append(sum)

for sum in ans:
    print(sum)

### FIXED CODE ###

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

l = [0] * 100001
for i in a:
    l[i] += 1

s = sum(a)

for _ in range(q):
    b, c = map(int, input().split())
    s += (c - b) * l[b]
    l[c] += l[b]
    l[b] = 0
    print(s)
s = int(input())
if s==1:
    print(4)
elif s==2:
    print(4)
else:
    print(func(s))

### FIXED CODE ###

def func(n):
    count = 1
    while(n!=4):
        if n%2==0:
            n = n // 2
        else:
            n = 3*n + 1
        count += 1
    return count + 3


s = int(input())
if s==1:
    print(4)
elif s==2:
    print(4)
elif 3<=s and s<=100:
    print(func(s))
else:
    print(0)
import stdin from sys
n = int(stdin.readline())
li = int(stdin.readlines())
m = min(li)
if n % m == 0:
    print(n//m + 4)
else:
    print(n//m + 5)

### FIXED CODE ###

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
m = min(a,b,c,d,e)
if n % m == 0:
    print(n//m + 4)
else:
    print(n//m + 5)
import sys

c=["light fly", "fly", "bantam", "feather", "light", "light welter",
   "welter", "light middle", "middle", "light heavy", "heavy"]
w=[48,51,54,57,60,64,69,75,81,91]
for s in map(float,sys.stdin):
    i=0;
    while w[i]<s:
        i+=1
    print c[i]

### FIXED CODE ###

import sys

c=["light fly", "fly", "bantam", "feather", "light", "light welter",
   "welter", "light middle", "middle", "light heavy", "heavy"]
w=[48,51,54,57,60,64,69,75,81,91]
for s in map(float,sys.stdin):
    i=0
    for e in w:
        if e<s: i+=1
    print c[i]
a = int(input())
b = input()
if a%2 == 0:
  print("Yes" if a[:(a/2-1)] == a[(a/2):] else "No")
else:
  print("No")

### FIXED CODE ###

a = int(input())
b = input()
if a%2 == 0:
  print("Yes" if b[:int(a/2)] == b[int(a/2):] else "No")
else:
  print("No")
#!/usr/bin/env python3

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

price = n
while True:
    st = set(int(x) for x in str(price))
    l = len(st)
    if len([x for x in st if x not in D]) == l:
        print(price)
        break
    price += 1

### FIXED CODE ###

#!/usr/bin/env python3

import sys
  
if sorted(sys.stdin.readline().split()) == ['5', '5', '7']:
  print('YES')
else:
  print('NO')