peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import bisect

N = int(input())
al = list(map(int, input().split()))
bl = list(map(int, input().split()))
cl = list(map(int, input().split()))
al.sort()
# print(al)
bl.sort()
# print(bl)
cl.sort()
# print(cl)

cnt = 0
for i in range(N):
    cnt_ab = bisect.bisect_left(al, bl[i])  # bl[b] = 6 idx= 3
    cnt_bc = len(cl) - bisect.bisect(cl, bl[i])  # bl[b] = 6 idx2= 1
    # print(cnt_ab,cnt_bc)
    cnt += cnt_ab * cnt_bc

print(cnt)
# Judge status: Wrong Answer
N,M = map(int,input().split())
n = M // N
if n <= 10**5:
    for i in range(n):
        x = n - i
        if M % x == 0:
            print(x)
            quit()
else:
    for i in range(10**5):
        x = N + i
        if M % x == 0:
            print(M//x)
            quit()
# Judge status: Accepted
N = int(input())
A=list(map(int, input().split()))

const = 10**18

if 0 in A:
    print(0)
    exit(0)

result = 1
for i in A:
    result *= i
    if result>const:
        print(-1)
        exit(0)
print(result)
# Judge status: Wrong Answer
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]

for i in range(n-1):
  j=i
  t=l[j][1]
  t+=l[j][0]
  while j<n-2:
    j+=1
    temp_t=t-l[j][1]
    if temp_t<0:
      t=l[j][1]
    elif temp_t%l[j][2]!=0:
      t+=temp_t%l[j][2]
    t+=l[j][0]

  print(t)
print(0)
# Judge status: Accepted
N = int(input())
A = [int(input()) for _ in range(N)]

ans = 0
for i in range(N-1):
    if A[i] % 2 == 0 or A[i+1] == 0:
        continue
    A[i] -= 1
    A[i+1] -= 1
    ans += 1

for i in A:
    ans += i // 2

print(ans)
# Judge status: Accepted
s = input()
if s == 'Sunny':
    print('Cloudy')
elif s == 'Cloudy':
    print('Rainy')
else :
    print('Sunny')
# Judge status: Accepted
# keyenceが先頭にある場合と最後にある場合、それ以外は真ん中にある場合
s = input()
keyence = "keyence"
for i in range(len(keyence)):
    if s[: i + 1] == keyence[: i + 1] and s[-i + 1 :] == keyence[-i + 1]:
        print("YES")
        exit()
print("NO")
# Judge status: Accepted
s = input()

if(s[-1] == 's'):
  print(s+'es')
else:
  print(s+"s")
# Judge status: Wrong Answer
n,x = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
for i in range(n):
    if x >= a[i]:
        ans += 1
        x -= a[i]
    else:
        break
if x > 0 and ans != 0:
    ans -= 1
print(ans)
# Judge status: Accepted
a=input()
flag=False
if a[0]!=a[1]:
    flag=True
if a[1]!=a[2]:
    flag=True

if flag:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def cmb(n, r, p):
    A = 1
    B = 1
    r = min(r, n - r)
    for i in range(r):
        A = A * (n-i) % p
        B = B * (i+1) % p
    return A * pow(B, p-2, p) % p

n, a, b = map(int, input().split())
p = 10**9 + 7
A = pow(2, n, p) - 1 - cmb(n, a, p) - cmb(n, b, p)
A = A%p
print(A)
# Judge status: Accepted
n = int(input())
if n%1000==0:
    print(0)
else:
    print(1000-n%1000)
# Judge status: Wrong Answer
N=int(input())
S=input()
cnt=[1]*26
for i in range(len(S)):
  cnt[ord(S[i])-ord('a')]+=1
ans=1
for i in range(26):
  ans*=cnt[i]
print(ans-1)
# Judge status: Wrong Answer
import itertools
N, M ,Q = map(int, input().split())
l = []
for i in range(Q):
  a, b, c, d = map(int, input().split())
  l.append([a, b, c, d])
  
num = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
nums = list(itertools.combinations_with_replacement(num, 10))
scores = []
for row in nums:
  score = 0
  i = 0
  while i < Q:
    if row[l[i][1]-1]-row[l[i][0]-1] == l[i][2]:
      score += l[i][3]
    i += 1
  scores.append(score)
  
print(max(scores))
# Judge status: Accepted
n= int(input())
ans=0
for i in range(1,n+1,2):
    cnt=0
    for j in range(1,i+1):
        if i%j==0:
            cnt+=1
    if cnt==8:
        ans+=1
print(ans)
# Judge status: Wrong Answer
s=list(input())

l=[]
for i in s[1::2]:
  l.append(i)

new_l=[]
for i in s[::2]:
  new_l.append(i)

num='No'
for a,b in zip(new_l,l):
  
  if a == 'U' or a == 'R' or a == 'D':
    if b == 'U' or b == 'L' or b == 'D':
      num='Yes'
  else:
    num='No'
print(num)
# Judge status: Wrong Answer
n, m = list(map(int, input().split()))

if n == m:
  print(max(n-2, 0) * max(m-2, 0))
  
else:
  print(max(n-2, 1) * max(m-2, 1))
# Judge status: Wrong Answer
N = int(input())
A = int(input())
for a in range(A+1):
    if (N-a)%500 == 0:
        print("YES")
        exit()
print("NO")
# Judge status: Accepted
S = input()

ans = 0
l, r = 0, 0
i = 0
while i < len(S):
    while i < len(S) and S[i] == "<":
        l += 1
        i += 1
    while i < len(S) and S[i] == ">":
        r += 1
        i += 1
    ans += l * (l + 1) // 2
    ans += r * (r + 1) // 2
    ans -= min(l, r)
    l, r = 0, 0
print(ans)
# Judge status: Wrong Answer
from operator import itemgetter
H,N = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]

L.sort(key=itemgetter(1))

dp = [10**9]*(H+1)
dp[0] = 0
for i in range(1, H+1):
    for j in range(N):
        if i < L[j][0]:
            continue
        dp[i] = min(dp[i], L[j][1]+dp[i-L[j][0]])

print(dp[H])
# Judge status: Accepted
a, b, c = map(int, input().split())
if a < c < b or b < c < a:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
a,b,x = map(int,input().split())
cnt2 = b//x
cnt1 = (a-1)//x
print(cnt2-cnt1)
# Judge status: Accepted
import math
N = int(input())
fn = {i+1:0 for i in range(N)}
rtN = int(math.sqrt(N))+1

def n(x,y,z):
    return x**2 + y**2 + z**2 + x*y + y*z + z*x

for x in range(1, rtN):
    for y in range(1, rtN):
        for z in range(1, rtN):
            n_ = n(x,y,z)
            try:
                fn[n_] += 1
            except KeyError:
                pass

for k in fn.values():
    print(k)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
crash = 0
cnt = 0
for i in A:
  if i == cnt:
    cnt += 1
  else:
    crash += 1
if cnt == 0:
  print(-1)
else:
  print(crash)
# Judge status: Accepted
s=input()
t=input()
if t[:len(s)]==s:
    print("Yes")
else:print("No")
# Judge status: Accepted
x,y=map(int,input().split())

cnt=0
while y>=x:
    cnt+=1
    x*=2

print(cnt)
# Judge status: Accepted
def main():
    N = int(input())
    S = input()

    count = 0
    for i in range(N-1, -1, -1):
        if S[i] == ")":
            count +=1
        else:
            if count:
                count -= 1
            else:
                S += ")"
    S = "("*count + S
    print(S)

if __name__ == "__main__":
    main()
# Judge status: Accepted
A, B = map(int, input().split())
S = input()
flag = False
for i in range(A):
  if S[i] == "-":
    flag=True
if S[A] != "-":
  flag=True
for i in range(A+1, A+B+1):
  if S[i] == "-":
    flag=True
if flag:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
c1 = input()
c2 = input()
print('YES' if c2 == c1[::-1] else 'NO')
# Judge status: Wrong Answer

n = int(input())
a = 1
status = 0
count = 0
l = []

for i in range(1,n):
    if i % 2 ==0:
        break
    else:
        for j in range(1,n):
            if j % a == 0:
                count += 1
            else:
                break

            if count == 8:
                l.append(1)

print(sum(l))
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))

odd = 0
double = 0
quatro = 0

for i in a:
  if i % 2 == 1:
    odd += 1
  else:
    if i % 4 == 0:
      quatro += 1
    else:
      double += 1

if double == N:
  print("Yes")
  exit()
plus = 0
if double != 0:
  plus = 1
if plus + odd - 1 <= quatro:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
S=list(input())
#print(S)
q=int(input())
x=0
appends=[[] for i in range(2)]
for i in range(q):
    s=list(input().split())
    if int(s[0])==1:
        x+=1
    else:
        appends[(x+int(s[1])+1)%2].append(s[2])
        #print(appends)
if  x%2==1:
    S=S[::-1]
S=appends[x%2][::-1]+S+appends[(x+1)%2]
#print(S)
for k in S:
    print(k,end='')
# Judge status: Accepted
# coding: utf-8
# Your code here!
import sys
import math
n=int(input())
ans=n
for i in range(1,int(math.sqrt(n))+1):
    if n%i==0:
        a=i
        b=int(n/i)
        if a+b-2<ans:
            ans=a+b-2
print(ans)
# Judge status: Wrong Answer
x=int(input())
print('Yes' if x in (3,5,7) else 'No')
# Judge status: Accepted
n = int(input())
s = input()
ans = 0
for i in range(n):
  x = set(s[:i])
  y = set(s[i:])
  a = len(x&y)
  if ans < a:
    ans = a
print(ans)
# Judge status: Wrong Answer
N = int(input())
s = str(input())
t = str(input())

if s==t:
    print(s)
    exit()

for i in range(1,N+1):
    ans = s + t[-i:]
    if ans[-N:] == t:
        break
print(ans)
# Judge status: Accepted
N,K=map(int,input().split())
S=input()

ch_list=[]
for i in range(1,N):
  if S[i-1]!=S[i]:
    ch_list.append(i)
#print(ch_list)
len_ch=len(ch_list)

if len_ch>2*K:
  print(N-1-len_ch+2*K)
else:
  print(N-1)
# Judge status: Accepted
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

S = input()
N = len(S)
ans = 0
for i in range(N):
    for j in range(N - i + 1):
        if all(c in 'AGCT' for c in S[i:i + j]):
            ans = max(ans, j)
print(ans)
# Judge status: Wrong Answer
N,M=map(int,input().split())
k=M
s=0
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[0])
for i in range(N):
  while k>0:
    if k>A[i][1]:
      s+=A[i][0]*A[i][1]
      k=k-A[i][1]
    else:
      s+=A[i][0]*k
      k=0
print(s)
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    if i >= k:
        if a[i] > a[i-k]:
            print('Yes')
        else:
            print('No')
# Judge status: Accepted
s = input()
result = True

for i in range(len(s)):
    
    if i%2 == 0:
        if s[i]=="L":
            result = False
            break
    else:
        if s[i]=="R":
            result = False
            break


if result:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n

n, k = map(int, input().split())
print(min(gcd(n, k), n%k))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

res = 0
prev = -1
for i in range(N):
	res += B[A[i]-1]
	if prev+1 == A[i]-1:
		res += C[prev]
	prev = A[i]-1 
print(res)
# Judge status: Accepted
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
xyc = [list(map(int, input().split())) for _ in range(M)]

ans = 10 ** 5 + 10 ** 5
for x, y, c in xyc:
  if a[x - 1] + b[y - 1] - c < ans:
    ans = a[x - 1] + b[y - 1] - c
m_price = min(a) + min(b)

print(ans if ans < m_price else m_price)
# Judge status: Accepted
n, *a = map(int, open(0).read().split())
ans = 1
for i in range(n):
    if ans == -1:
        if a[i] == 0:
            ans = 0
            break
    else:
        ans *= a[i]
        if ans > 10**18:
            ans = -1
print(ans)
# Judge status: Wrong Answer
import sys

*a, = map(int, sys.stdin.readline().split())

def main():
    ans = 'bust' if sum(a) == 22 else 'win'
    print(ans)

if __name__ ==  '__main__':
    main()
# Judge status: Accepted
import numpy as np
C = np.array([[int(x) for x in input().split()] for _ in range(3)])
ans = 'Yes'
for i in range(2):
    if not(C[0,i+1]-C[0,i] == C[1,i+1]-C[1,i] == C[2,i+1]-C[2,i]):
        ans = 'No'
    if not(C[i+1,0]-C[i,0] == C[i+1,1]-C[i,1] == C[i+1,2]-C[i,2]):
        ans = 'No'
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())

if a + b == c or a + c == b or b + c == a:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
#Problem B
N = int(input())
a = list(map(int,input().split()))

cnt = 0

for i in range(N):
    if i%2 != 0 and a[i] %2 != 0:
        cnt += 1
        
print(cnt)
# Judge status: Accepted
A_V = input().split()
A = int(A_V[0])
V = int(A_V[1])
B_W = input().split()
B = int(B_W[0])
W = int(B_W[1])
T = int(input())
 
if V - W <= 0:
  print('NO')
elif T < abs(B-A)/(V-W):
  print('NO')
else:
  print('YES')
# Judge status: Wrong Answer
n, k =map(int, input().split())
a = list(map(int, input().split()))
if n == k:
    print(1)
else:
    print(int(n / (k - 1)))
# Judge status: Accepted
N=int(input())
p_list=[]

if N%2==0:
  count=0
  while N%2==0:
    count+=1
    N/=2
  p_list.append([2,count])

i=3
while i<N**0.5+1:
  if N%i==0:
    count=0
    while N%i==0:
      count+=1
      N/=i
    p_list.append([i,count])
  i+=2

if N!=1:
  p_list.append([int(N),1])

result=0
for i in range(len(p_list)):
  j=1
  while p_list[i][1]>=j:
    p_list[i][1]-=j
    j+=1
    result+=1
print(result)
# Judge status: Wrong Answer
n,k = map(int,input().strip().split())
d = list(input().split())
for x in range(n,100000):
    for y in d:
        if y in str(x):
            break
        else:
            print(x)
            break
# Judge status: Accepted
def solve():
    MOD = 10**9 + 7

    S = int(input())

    N = S//3

    dp = [[0]*(S+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(1, N+1):
        for j in range(3, S+1):
            dp[i][j] = (dp[i][j-1] + dp[i-1][j-3]) % MOD

    ans = sum([dp[i][S] for i in range(N+1)]) % MOD
    print(ans)


solve()
# Judge status: Accepted
n = int(input())
s = input()
cnt = s.count("R") * s.count("G") * s.count("B")
for i in range(n-2):
    for j in range(i+1, n-1):
        if s[i] == s[j]:
            continue
        k = j - i + j
        if k > n-1:
            continue
        if s[i] == s[k] or s[j] == s[k]:
                continue
        cnt -= 1
print(cnt)
# Judge status: Wrong Answer
from collections import defaultdict
def main():
    N = int(input())
    c = defaultdict(int)

    for i in range(N):
        c[input()] += 1

    print("AC × {}".format(c["AC"]))
    print("WA × {}".format(c["WA"]))
    print("TLE × {}".format(c["TLE"]))
    print("RE × {}".format(c["RE"]))

if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())

ans = 0

for i in range(1, N+1):
  ans += i

print(ans)
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
for i in range(M):
  A[0] //= 2
  if N > 1:
    j = 0
    while A[j] < A[j+1]:
      A[j], A[j+1] = A[j+1], A[j]
      j += 1
      if j == N-2:
        break
#  print(A)
print(sum(A))
# Judge status: Accepted
import numpy as np
N, L = map(int, input().split())
taste = [L+i for i in range(N)]
if L < 0:
    print(sum(taste) + min(np.abs(taste)))
else:
    print(sum(taste) - min(np.abs(taste)))
# Judge status: Accepted
import sys
input = sys.stdin.readline
S = input().strip()
Q = int(input())
f = 0
add = ['', '']
for q in range(Q):
    query = input().strip()
    if query == '1':
        f ^= 1 
    else:
        _, F, C = query.split(' ')
        add[int(F)-1^f] += C
print(''.join([add[f][::-1], S[::(f*-1*2)+1], add[f*-1+1]]))
# Judge status: Accepted
def main():
    import math

    N = int(input())
    
    ans_list = [0 for i in range(N)]
    
    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):

                left_eq = x * x + y * y + z * z + x * y + y * z + z * x
                if (left_eq <= N):
                    ans_list[left_eq - 1] += 1
    
    for i in range(N):
        print(ans_list[i])

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c = map(int,input().split())
d = 0
while d <= b:
  if (a*d)%b == c:
    print('YES')
    break
  elif d == b:
    print('NO')
  d += 1
# Judge status: Accepted
x = int(input())
x1 = (x%500)
a = (x1//5)*5
a2 = (x//500)*1000


print(a+a2)
# Judge status: Accepted
a = int(input())
A = []
n = 1

while True:
  n+=1
  A+=[a]
  
  if a%2==0:
    a//=2
  else:
    a=1+3*a
  
  if a in A:
    print(n)
    break
# Judge status: Accepted
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

n = readline()
l = list(map(int, readline().split()))
print('Yes' if sum(l) > 2 * max(l) else 'No')
# Judge status: Wrong Answer
N = int(input())
A = [[int(x) for x in input().split()]for i in range(N)]
T = 0            ####現在時刻
place = (0,0)    ####現在地
for i in range(N):
  if ((A[i][0]-T) + abs(A[i][1]-place[0]) + abs(A[i][2]-place[1]))%2 == 0:
    T = A[i][0]
    place = (A[i][1], A[i][2])
  else:
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
n, m = map(int, input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
elif n==2 or m==2:
    print(0)
else:
    print((m-2)*(n-2))
# Judge status: Wrong Answer
n = int(input())
d = list(map(int,input().split()))
cnt=0
for i in range(1,len(d)+1):
    arc = 0
    abc = 0
    for j in d:
        if j >= i:
            arc+=1
        else:
            abc+=1
    if arc==abc:
        cnt+=1
print(cnt)
# Judge status: Wrong Answer
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = [a[i]^a[i+1] for i in range(n-1)]
res = [26]
for i in range(n-1):
    res.append(res[-1]^b[i])
print(*res)
# Judge status: Wrong Answer
a,b=map(int,input().split())
x=a*b
for i in range(2,max(a,b)//2+1):
  if a%i==0 and b%i==0:
    a//=i
    b//=i
    x//=i
print(x)
# Judge status: Accepted
n,a,b = list(map(int, input().split()))
s = input()
success = 0
success_b = 0
for S in s:
    if S == 'a' and success < a + b:
        print('Yes')
        success += 1
    elif S == 'b' and success < a + b and success_b < b:
        print('Yes')
        success += 1
        success_b += 1
    else:
        print('No')
# Judge status: Accepted
N, M = map(int, raw_input().split())

ans = 0
p = 1
while p*p<=M:
  if M%p==0:
    if M/p>=N:
      ans = max(ans, p)
    if p>=N:
      ans = max(ans, M/p)
  p += 1
print ans
# Judge status: Accepted
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, D: int):
    from math import ceil
    print(ceil(N/(2*D+1)))
    return



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
    D = int(next(tokens))  # type: int
    solve(N, D)

if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
w = [input() for _ in range(n)]

last = ""
s = set()

for i in range(n):
    if i != 0:
        if (last != w[i][0]) or w[i] in s:
            print("No")
            exit()
    s.add(w[i])
    last = w[i][-1]


print("Yes")
# Judge status: Accepted
f = lambda:map(int,input().split())
n,m = f()
ll = [list(f()) for _ in range(m)]
l = [0]*n
d = {}
for p,y in sorted(ll,key=lambda k:k[1]):
  l[p-1] += 1
  d[y] = str(p).zfill(6)+str(l[p-1]).zfill(6)
for l in ll:
  print(d[l[1]])
# Judge status: Wrong Answer
# 長さN
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

import itertools

p = 0
q = 0
n = list(itertools.permutations(range(1,N+1)))
for i in range(len(n)):
    if list(n[i]) == P:
        p = i
    elif list(n[i]) == Q:
        q = i

print(abs(p-q))
# Judge status: Accepted
def main():
    #input data
    import sys
    input = lambda:sys.stdin.readline().strip()
    N = int(input())
    S = input()
    
    #solve
    right=0
    left=0

    for i in range(N):
        if S[i]=='(':
            right+=1
        else:
            if right:
                right-=1
            else:
                left+=1
    print(left*'('+S+right*')')

if __name__=='__main__':
    main()
# Judge status: Accepted
import sys

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

if n == 0:
	print(0)
	sys.exit()
if n == 1:
	if a == b:
		print(1)
		sys.exit()
	else:
		print(0)
		sys.exit()
if a > b:
	print(0)
	sys.exit()

maximum = (a+b) + b*(n-2)
minimum = (a+b) + a*(n-2)

print(maximum-minimum+1)
# Judge status: Accepted
S = input()
ans = 0
if(S[0] == '1'):
  ans += 1
if(S[1] == '1'):
  ans += 1
if(S[2] == '1'):
  ans += 1
print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
log = list(map(int, input().split()))

left = 0
right = 10**9

while right - left > 1:
  
  mid = (left + right) // 2
  
  cut = 0
  for i in range(n):
    cut += -(log[i]//-mid)-1

  if cut > k:
    left = mid
  else:
    right = mid
    
print(right)
# Judge status: Accepted
n=input()
c=0
for i in range(1,int(len(n))):
    if n[i]=="9":
        c+=1
if c==len(n)-1:
    print(int(n[0])+9*(len(n)-1))
else:
    print(int(n[0])+9*(len(n)-1)-1)
# Judge status: Wrong Answer
H, N = map(int, input().split())
M = dict(iter([tuple(map(int, input().split())) for i in range(N)]))
dp = [float('inf') for i in range(H + 1)]
dp[0] = 0

for i in range(H + 1):
    for a, b in M.items():
        dp[i] = min(dp[i], dp[max(0, i - a)] + b)

print(dp[H])
# Judge status: Accepted
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

n, k = inm()
print(*[i for i in range(k-n+1, n+k)])
# Judge status: Accepted
line = input()
n, t = [int(n) for n in line.split()]
min_coust = 0
route = 0
for _ in range(n):
    line = input()
    coust, time = [int(n) for n in line.split()]
    if min_coust == 0 and time <= t:
        min_coust = coust
    elif time <= t and coust <= min_coust:
        min_coust = coust
ans = "TLE" if min_coust== 0 else min_coust
print(ans)
# Judge status: Wrong Answer
K,X = map(int,input().split())
if 500*K >= X :
    print('yes')
else:
    print('no')
# Judge status: Wrong Answer
from bisect import bisect_left
n = int(input())
a = [int(input())*(-1) for i in range(n)]

LIS = [a[0]]
for v in a:
    if LIS[-1] < v:
        LIS.append(v)
    else:
        LIS[bisect_left(LIS, v)] = v
 
print(len(LIS))
# Judge status: Accepted
N,M=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans=0
table=make_divisors(M)
table.sort()

for i in table:
    if i<=M//N:
        ans=i
        
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    S = readline().rstrip().decode()
    if N % 2 != 0:
        print('No')
    elif S[:N//2] == S[N//2:]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
# Judge status: Accepted
import numpy as np

X, N = (int(x) for x in input().split())
if N == 0:
    print(X)
else:
    p = np.array([int(x) for x in input().split()])
    x_arange = set(np.arange(-100, 101))
    p_x = set(np.array(p - X))
    sub_list = list(x_arange - p_x)
    sub_abs_list = np.abs(np.array(sub_list))

    min_sub = min(sub_abs_list)
    if (X - min_sub) not in p:
        print(X - min_sub)
    else:
        print(X + min_sub)
# Judge status: Wrong Answer
a,b = map(int,input().split())
print(a,b)
if a == b:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a, b, t = map(int, input().split())
ans = b
c = a
if a  > t -1 :
    print(0)
    exit()
while True:
    ans += b
    c += a
    if c  > t + 1:
        ans -= b
        break
print(ans)
# Judge status: Accepted
A,B,K=map(int,input().split())
if A==B:
  print(A)
  exit()
if B-A<K:
  K=B-A
l=list()
for i in range(A,A+K):
  l.append(i)
for i in range(B-K+1,B+1):
  l.append(i)
l=set(l)
l=sorted(l)
for i in range(len(l)):
  print(l[i])
# Judge status: Accepted
N = int(input())
s = [input() for i in range(N)]

AC = s.count('AC')
WA = s.count('WA')
TLE = s.count('TLE')
RE  = s.count('RE')

print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))