Harryxun/stf_run huggingface dataset:
#c
n,m,x=map(int, input().split())
sp = [list(map(int, input().split())) for _ in range(m)]

import copy
result = []
def test(i,i_sum,cost):
    
    flag = 0
    if i <= n:
        for j in range(m):
            if i_sum[j] < x:
                flag = 1
                break

        if flag == 1:
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])#参考書を使わない場合

                for j in range(1,m+1):#参考書を使う場合
                    i_sum[j-1] += sp[i-1][j]
                cost[0] += sp[i-1][0]
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])
        else:
            result.append(cost[0])
test(0,[0]*n,[0])

if result != []:
    print(min(result))
else:
    print(-1)

### FIXED CODE ###

#c
n,m,x=map(int, input().split())
sp = [list(map(int, input().split())) for _ in range(n)]

import copy
result = []
def test(i,i_sum,cost):
    
    flag = 0
    if i <= n:
        for j in range(m):
            if i_sum[j] < x:
                flag = 1
                break

        if flag == 1:
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])#参考書を使わない場合

                for j in range(1,m+1):#参考書を使う場合
                    i_sum[j-1] += sp[i-1][j]
                cost[0] += sp[i-1][0]
                test(copy.deepcopy(i)+1, i_sum[:],cost[:])
        else:
            result.append(cost[0])
test(0,[0]*m,[0])

if result != []:
    print(min(result))
else:
    print(-1)
#ABC057.B
N,M = int(input().split())
L1 = []
L2 = []

for i in range(N):
    a,b = map(int,input().split())
    L1.append([a,b])
for m in range(M):
    c,d = map(int,input().split())
    L2.append([c,d])

L3 = []
for j in range(N):
    for l in range(M):
        L3.append(abs(L1[j][0]-L2[l][0]) + abs(L1[j][1]-L2[l][1]))
    print(L3.index(min(L3))+1)

### FIXED CODE ###

#ABC057.B
N,M = map(int,input().split())
L1 = []
L2 = []

for i in range(N):
    a,b = map(int,input().split())
    L1.append([a,b])
for m in range(M):
    c,d = map(int,input().split())
    L2.append([c,d])

for j in range(N):
    L3 = []
    for l in range(M):
        L3.append(abs(L1[j][0]-L2[l][0]) + abs(L1[j][1]-L2[l][1]))
    print(L3.index(min(L3))+1)
"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""
def found(a,n):
    if(n==1 and n in a):
        return True
    elif(n==1 and n not in a):
        return False
    elif(n>len(a)):
        return False
    for i in range(len(a)-1,-1,-1):
        if(a[i]==n):
            return found(a[0:i],n-1)
    return False
            
            
            
n=int(input())
a=list(map(int,input().split()))
ans=-1
for i in range(n-1,-1,-1):
    x=a[i]
    if(found(a[0:i],x-1)):
        ans=max(ans,x)
        
if(n==1 and a==[1]):
    ans=1
if(ans!=-1):
    print(n-ans)
else:
    print(-1)
        

### FIXED CODE ###

"""
int(input())
map(int,input().split())
list(map(int,input().split()))

"""

n=int(input())
a=list(map(int,input().split()))
i=1
for j in range(len(a)):
    if(a[j]==i):
        i+=1
if(1 not in a):
    print(-1)
else:
    print(n-i+1)
h,w,k=map(int,input().split())

def amida(h,w,k):
    memo=[[-1 for _ in range(w)] for _ in range(h)]
    memo[0][0]=amida_h1_total(w-1)
    if w>1:
        memo[0][1]=amida_h1_total(w-2)
    for i in range(2,w):
        memo[0][i]=0
    def _amida(h,k):
        if k<=0 or k>w:
            return 0
        if memo[h-1][k-1]>=0:
            return memo[h-1][k-1]
        memo[h-1][k-1]=sum((_amida(h-1,k-1)*amida_h1_total(k-2)*amida_h1_total(w-k),
                            _amida(h-1,k)  *amida_h1_total(k-1)*amida_h1_total(w-k),
                            _amida(h-1,k+1)*amida_h1_total(k-1)*amida_h1_total(w-k-1)))%1000000007
        return memo[h-1][k-1]
    return _amida(h,k)
print(amida(h,w,k))

### FIXED CODE ###

h,w,k=map(int,input().split())
def amida_h1_total(w):
    if w<0:
        return 0
    if w==0:
        return 1
    return amida_h1_total(w-1)+amida_h1_total(w-2)
def amida(h,w,k):
    memo=[[-1 for _ in range(w)] for _ in range(h)]
    memo[0][0]=amida_h1_total(w-1)
    if w>1:
        memo[0][1]=amida_h1_total(w-2)
    for i in range(2,w):
        memo[0][i]=0
    def _amida(h,k):
        if k<=0 or k>w:
            return 0
        if memo[h-1][k-1]>=0:
            return memo[h-1][k-1]
        memo[h-1][k-1]=sum((_amida(h-1,k-1)*amida_h1_total(k-2)*amida_h1_total(w-k),
                            _amida(h-1,k)  *amida_h1_total(k-1)*amida_h1_total(w-k),
                            _amida(h-1,k+1)*amida_h1_total(k-1)*amida_h1_total(w-k-1)))%1000000007
        return memo[h-1][k-1]
    return _amida(h,k)
print(amida(h,w,k))
a = int(input())
b = []
if a <= 1000000:
for i in range(a):
    if i % 15 == 0:
      pass
    elif i % 3 == 0:
      pass
    elif i % 5 == 0:
      pass
    else:
      b.append(i)
else:
  pass
print(sum(b))


### FIXED CODE ###

a = int(input())
b = []

for i in range(a+1):
    if i % 3 == 0 and i % 5 == 0:
      pass
    elif i % 3 == 0:
      pass
    elif i % 5 == 0:
      pass
    else:
      b.append(i)
print(sum(b))
import itertools
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s

def bitadd(BIT,i,x):
  while i<=2**n:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

def tentou(X):
  ret=0
  BIT=[0]*64
  BIT.insert(0,0)
  for i1 in range(n):
    x=X[i1]+1
    ret+=i1-bitsum(BIT,x)
    bitadd(BIT,x,1)
  return ret
N=[int(i) for i in range(n)]
nn=2**n
ans=float("inf")
for _ in range(n//2+1):
  for com in itertools.combinations(N,2*_):
    i=0
    for ura in com:
      i+=2**ura
    E,O=[],[]
    for j in range(n):
      if i&(1<<j)==0:
        if j%2==0:
          E.append(A[j]*100+j)
        else:
          O.append(A[j]*100+j)
      else:
        if j%2==0:
          O.append(B[j]*100+j)
        else:
          E.append(B[j]*100+j)
    if len(E)!=(n+1)//2:
      continue
    else:
      E.sort()
      O.sort()

      chk=True
      C=[E[0]%100]
      prev=E[0]//100
      for i in range(1,n):
        ii=i//2
        if i%2==0:
          C.append(E[ii]%100)
          if E[ii]//100<prev:
            chk=False
            break
          else:
            prev=E[ii]//100
        else:
          C.append(O[ii]%100)
          if O[ii]//100<prev:
            chk=False
            break
          else:
            prev=O[ii]//100
    
    if chk:
      ans=min(ans,tentou(C))
print(-1 if ans==float("inf") else ans)



### FIXED CODE ###

import itertools
n=int(input())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
def bitsum(BIT,i):
  s=0
  while i>0:
    s+=BIT[i]
    i-=i&(-i)
  return s

def bitadd(BIT,i,x):
  while i<=64:
    BIT[i]+=x
    i+=i&(-i)
  return BIT

def tentou(X):
  ret=0
  BIT=[0]*64
  BIT.insert(0,0)
  for i1 in range(n):
    x=X[i1]+1
    ret+=i1-bitsum(BIT,x)
    bitadd(BIT,x,1)
  return ret
N=[int(i) for i in range(n)]
nn=2**n
ans=float("inf")
for _ in range(n//2+1):
  for com in itertools.combinations(N,2*_):
    i=0
    for ura in com:
      i+=2**ura
    E,O=[],[]
    for j in range(n):
      if i&(1<<j)==0:
        if j%2==0:
          E.append(A[j]*100+j)
        else:
          O.append(A[j]*100+j)
      else:
        if j%2==0:
          O.append(B[j]*100+j)
        else:
          E.append(B[j]*100+j)
    if len(E)!=(n+1)//2:
      continue
    else:
      E.sort()
      O.sort()

      chk=True
      C=[E[0]%100]
      prev=E[0]//100
      for i in range(1,n):
        ii=i//2
        if i%2==0:
          C.append(E[ii]%100)
          if E[ii]//100<prev:
            chk=False
            break
          else:
            prev=E[ii]//100
        else:
          C.append(O[ii]%100)
          if O[ii]//100<prev:
            chk=False
            break
          else:
            prev=O[ii]//100
    
    if chk:
      ans=min(ans,tentou(C))
print(-1 if ans==float("inf") else ans)
import heapq


def small_multiple(k):
    # kの倍数で各桁の総数が最も小さくなるような、各桁の総数
    dist = [float("inf")] * k
    q = []
    # kで割った余りが1になるような最小の数は1
    heapq.heappush(q, (1, 1))

    while q:
        n, c = heapq.heappop(q)
        if dist[n] <= c:
            continue
        print(n, c)
        dist[n] = c

        if dist[(n+1) % k] > c + 1:
            heapq.heappush(q, ((n + 1) % k, c + 1))
        if dist[(n*10) % k] > c:
            heapq.heappush(q, ((n * 10) % k, c))

    print(dist[0])


def main():
	k = int(input())
    small_multiple(k)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import heapq


def small_multiple(k):
    # kの倍数で各桁の総数が最も小さくなるような、各桁の総数
    dist = [float("inf")] * k
    q = []
    # kで割った余りが1になるような最小の数は1
    heapq.heappush(q, (1, 1))

    while q:
        n, c = heapq.heappop(q)
        if dist[n] <= c:
            continue
        dist[n] = c

        if dist[(n + 1) % k] > c + 1:
            heapq.heappush(q, ((n + 1) % k, c + 1))
        if dist[(n * 10) % k] > c:
            heapq.heappush(q, ((n * 10) % k, c))

    print(dist[0])


def main():
    k = int(input())
    small_multiple(k)


if __name__ == "__main__":
    main()
n = input()
n = int(n)

if n == 0:
	print(0)

elif n == 1:
	_ = input()
	print(0)

else:
	h = []

	for i in range(n):
		h.append(int(input()))

	rnd = int(n/2) - 1
	count = 0

	for i in range(rnd, n-1):
		if h[i+1] <= h[i]:
			count += 1

	print(count)

### FIXED CODE ###

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

count = 0
count_list = [0]

for i in range(n-1):
	if(h[i+1] <= h[i]):
		count += 1
		count_list.append(count)
	else:
		count = 0

print(max(count_list))
S = str(input())
if S[-3:] = "nny":
    print(Cloudy)
elif S[-2:] = "dy":
    print(Rainy)
else:
    print(Sunny)


### FIXED CODE ###

S = str(input())
if S[-3:] == "nny":
    print("Cloudy")
elif S[-2:] == "dy":
    print("Rainy")
else:
    print("Sunny")
n = int(input())
S = []
for i in range(n):
    S.append(input())


ans = set(S[0])

for j in range(1,N):
    ans = ans & set(S[j])

print(str(ans))

### FIXED CODE ###

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

print((n-1)*(m-1))
x,y = input().split()
x = int(x)
y = int(y)
if x < y:
  a = y
  b = x
else:
  a = x
  b = y
 
while b:
  a, b = b, a % b
 
print(int(x*y/a))

### FIXED CODE ###

a = input()
b = input()
 
answer_list = ["1","2","3"]
answer_list.remove(a)
answer_list.remove(b)
 
print(answer_list[0])
N, M = map(int, input().split())
memo = [-1]*N
def dfs(dic, p, memo):
    if memo[p] != -1:
        return memo[p]
    m = 0
    for d in dic[p]:
        m = max(m, dfs(dic, d, memo)+1)
    memo[p] = m
    return m
dic = [[] for i in range(N)]
for m in range(M):
    x, y = map(int, input().split())
    dic[x-1].append(y-1)
ans = 0
for i in range(N):
    k= dfs(dic, i, memo)
    ans = max(ans,k)
print(ans)

### FIXED CODE ###

import sys
 
sys.setrecursionlimit(100000)
 
N, M = map(int, input().split(" "))
G = [[] for _ in range(N)]
 
for _ in range(M):
    x, y = map(int, input().split(" "))
    G[x-1].append(y-1)
dp = [-1] * N
def pathlen(G, dp, v):
    if dp[v] != -1:
        return dp[v]
 
    plen = 0
    for i in G[v]:
        plen = max(plen, pathlen(G, dp, i)+1)
    dp[v] = plen
    return plen
ans = 0
for i in range(N):
    ans = max(ans, pathlen(G, dp, i))
print(ans)
import time
import random
def calc(a) :
    sum = 0
    for i in range(len(a) - 1):
        sum += abs(a[i + 1] - a[i])
    return sum

def crossList(a,b):
    y = []
    if len(a) > len(b):
        for i in range(len(b)):
            y.append(a[i])
            y.append(b[i])
        y.append(a[i+1])
    elif len(a) < len(b): 
        for i in range(len(a)):
            y.append(b[i])
            y.append(a[i])
        y.append(b[i+1])
    else :
        for i in range(len(a)):
            y.append(b[i])
            y.append(a[i])
    return y

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()
b = []
c = []
f = []
g = []
if len(a) % 2 == 1:
    b = a[0:int((len(a) - 1)/2) ]
    c = a[int((len(a) - 1)/2) : len(a)]
else :
    b = a[0:int((len(a) )/2)  ]
    c = a[int((len(a) )/2) : len(a)]
c.reverse()
g.reverse()
d = []
e = []
h = []
j = []
forward = True;
for i in range(len(b)):
    if forward:
        d.append(b[i])
    else :
        d.insert(0,b[i])
    forward = not forward
forward = True

for i in range(len(c)):
    if forward:
        e.append(c[i])
    else :
        e.insert(0,c[i])
    forward = not forward
forward = True
h = d[:]
j = e[:]
h.append(j.pop(-1))
print(max(calc(crossList(d,e)),calc(crossList(d[::-1],e[::-1])),
          calc(crossList(d,e[::-1])),calc(crossList(d[::-1],e)),
          calc(crossList(h[::-1],j[::-1])),calc(crossList(h,j[::-1])),
          calc(crossList(h[::-1],j)),calc(crossList(h,j))))



### FIXED CODE ###

import time
import random
def calc(a) :
    sum = 0
    for i in range(len(a) - 1):
        sum += abs(a[i + 1] - a[i])
    return sum

def crossList(a,b):
    y = []
    if len(a) > len(b):
        for i in range(len(b)):
            y.append(a[i])
            y.append(b[i])
        y.append(a[i+1])
    elif len(a) < len(b): 
        for i in range(len(a)):
            y.append(b[i])
            y.append(a[i])
        y.append(b[i+1])
    else :
        for i in range(len(a)):
            y.append(b[i])
            y.append(a[i])
    return y

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()
b = []
c = []
if len(a) % 2 == 1:
    b = a[0:int((len(a) - 1)/2) ]
    c = a[int((len(a) - 1)/2) : len(a)]
else :
    b = a[0:int((len(a) )/2)  ]
    c = a[int((len(a) )/2) : len(a)]
c.reverse()
d = []
e = []
forward = True;
for i in range(len(b)):
    if forward:
        d.append(b[i])
    else :
        d.insert(0,b[i])
    forward = not forward
forward = True

for i in range(len(c)):
    if forward:
        e.append(c[i])
    else :
        e.insert(0,c[i])
    forward = not forward

h = d[:]
j = e[:]
if len(a) % 2 == 1:
    if (len(h) % 2 == 0) :
        h.append(j.pop(-1))
    else:
        h.insert(0,j.pop(0))

print(max(calc(crossList(d,e)),calc(crossList(d[::-1],e[::-1])),
          calc(crossList(d,e[::-1])),calc(crossList(d[::-1],e)),
          calc(crossList(h[::-1],j[::-1])),calc(crossList(h,j[::-1])),
          calc(crossList(h[::-1],j)),calc(crossList(h,j))))
if d is 0:
    print(n + n//100)
if d is 1:
    if n is 100:
        print(100*100+100)
    else:
        print(n*100)
if d is 2:
    if n is 100:
        print(100*10000+10000)
    else:
        print(n*10000)

### FIXED CODE ###

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

if d is 0:
    print(n + n//100)
if d is 1:
    if n is 100:
        print(100*100+100)
    else:
        print(n*100)
if d is 2:
    if n is 100:
        print(100*10000+10000)
    else:
        print(n*10000)
N, K = map(int, input().split())

height_list = [0] * N

for n in range(N):
    height_list[n] = int(input())
height_list = sorted(height_list, reverse=True)

diff_list = [0] * (N - 2)

for i in range(N - 2):
    diff_list[i] = height_list[i] - height_list[i + K - 1]
print(min(diff_list))

### FIXED CODE ###

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

height_list = [0] * N

for n in range(N):
    height_list[n] = int(input())
height_list = sorted(height_list, reverse=True)

diff_list = [0] * (N - K + 1)

for i in range(N - K + 1):
    diff_list[i] = height_list[i] - height_list[i + K - 1]
print(min(diff_list))
import math
import sys
from collections import defaultdict

input = sys.stdin.readline
mod = 1000000007

n = int(input())

n2 = [1]
for _ in range(n):
    n2.append(n2[-1] * 2 % mod)

zero = 0
plus = defaultdict(int)
minus = defaultdict(int)

for _ in range(n):
    a, b = map(int, input().split())
    if a * b == 0:
        zero += 1
    p = math.gcd(a, b)
    a //= p
    b //= p
    if a * b > 0:
        plus[(abs(a), abs(b))] += 1
    else:
        minus[(abs(b), abs(a))] += 1


ans = zero + 1
ans %= mod
n -= zero

for k, v in plus.items():
    if minus[k] > 0:
        ans *= (n2[v] + n2[minus[k]] - 1)
        ans %= mod
        n -= v + minus[k]

ans *= n2[n]
print(ans - 1)


### FIXED CODE ###

import math
import sys
from collections import defaultdict

input = sys.stdin.readline
mod = 1000000007

n = int(input())

n2 = [1]
for _ in range(n):
    n2.append(n2[-1] * 2 % mod)

zero = 0
plus = defaultdict(int)
minus = defaultdict(int)

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero += 1
        continue
    elif a == 0:
        plus[(1, 0)] += 1
    elif b == 0:
        minus[(1, 0)] += 1
    else:
        p = math.gcd(a, b)
        a //= p
        b //= p
        if a * b > 0:
            plus[(abs(a), abs(b))] += 1
        else:
            minus[(abs(b), abs(a))] += 1

n -= zero
ans = 1

for k, v in plus.items():
    if minus[k] > 0:
        ans *= (n2[v] + n2[minus[k]] - 1)
        ans %= mod
        n -= v + minus[k]

ans *= n2[n]
ans %= mod
ans += zero - 1
ans %= mod
print(ans)
#coding: UTF-8

A = int(input())
B = int(input())
C = int(input())

if sum([A, B]) >= C:
    print ('Yes')
else:
    print('No')


### FIXED CODE ###

#coding: UTF-8

A,B,C = list(map(int, input().split()))

if sum([A, B]) >= C:
    print ('Yes')
else:
    print ('No')
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
    
ans = t[0]
    
for i in range(n-1):
    ans = int(ans * t[i+1] / gcd(ans , t[i+1]))
    
print(int(ans))

### FIXED CODE ###

def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

n = int(input())
t = [0]*n
for i in range(n):
    t[i] = int(input())
    
ans = t[0]
    
for i in range(1,n):
    ans = ans * t[i] // gcd(ans , t[i])
    
print(ans)
n = input()
m = [0] * n
max = [0] * n
kijun = [0] * n
rieki = [0] * n
max_rieki = 0
for i in xrange(n):
 m[i] = input()


for i in xrange(n-1):
 max[i] = m[i+1] 
 kijun[i] = m[i]
 for j in xrange(i+1,n): 
  if max[i] < m[j]:
      max[i] = m[j]
 rieki[i] = max[i] - kijun[i]
 print rieki[i]
max_rieki = rieki[0]
for i in xrange(1,n):
  if rieki[i] > max_rieki:
   max_rieki = rieki[i]

print max_rieki

### FIXED CODE ###

n = input()
m = [0] * n
max_rieki = -1000000000



for i in xrange(n):
 m[i] = input()

min_rieki = m[0]
for i in xrange(1,n): 
  if max_rieki < m[i] - min_rieki:
     max_rieki = m[i] - min_rieki
  if min_rieki > m[i]:
     min_rieki = m[i]

print max_rieki
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]


for i in range(H):
    for j in range(W):
        if(S[i][j]=="."):
            continue
        exist = False
        for k in range(4):
            if(not 0<=i+dy[k]<H or not 0<=j+dx[k]<W):
                continue
            if(S[i+dy[k]][j+dx[k]]=="#"):
                exist = True
        if(exist==False):
            print("No")
            break
            
if(exist==True):
    print("Yes")

### FIXED CODE ###

import sys

H, W = map(int, input().split())
S = [list(input()) for i in range(H)]
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]

for i in range(H):
    for j in range(W):
        if(S[i][j]=="."):
            continue
        exist = False
        for k in range(4):
            if(0<=i+dy[k]<H and 0<=j+dx[k]<W and S[i+dy[k]][j+dx[k]]=="#"):
                exist = True
        if(exist==False):
            print("No")
            sys.exit()     
print("Yes")
import sys
sys.setrecursionlimit(10**6)


def f(n):
    p = n % (bin(n).count('1'))
    if p == 0:
        return 1
    else:
        return f(p) + 1


def main(input, print):
    N = int(input())
    X = int(input(), 2)
    for i in reversed(range(N)):
        b = 1 << i
        a = X ^ b
        print(f(a))


if __name__ == '__main__':
    main(sys.stdin.readline, print)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)


def f(n):
    if n == 0:
        return 1
    p = n % (bin(n).count('1'))
    return f(p) + 1


def main(input, print):
    N = int(input())
    X = list(map(int, list(input().strip())))
    ans = [0] * N

    pcnt = 0
    for i in range(N):
        if X[i] == 1:
            pcnt += 1
    for is_up in range(2):
        current_pcnt = pcnt
        if is_up:
            current_pcnt -= 1
        else:
            current_pcnt += 1
        if current_pcnt <= 0:
            continue
        total = 0
        for i in range(N):
            total = (total*2) % current_pcnt
            total += X[i]
        current_mask = 1
        for i in reversed(range(N)):
            if(X[i] == is_up):
                current_total = total
                if is_up:
                    current_total = (current_total-current_mask+current_pcnt) % current_pcnt
                else:
                    current_total = (current_total+current_mask) % current_pcnt
                ans[i] = f(current_total)
            current_mask = current_mask * 2 % current_pcnt

    for i in range(N):
        print(ans[i])


if __name__ == '__main__':
    main(sys.stdin.readline, print)
k = int(input())
from collections import deque
d = deque([1])
discovered = {1:1}
while true:
  q = d.popleft()
  if q == 0: 
  	print(discovered[q])
  	quit()
  if (q*10)%k not in discovered:
    if (q*10)%k == 0:
      
    d.appendleft((q*10)%k)
    discovered[(q*10)%k] = discovered[q]
  if q+1 not in discoverd:
    d.append(q+1)
    discovered[q+1] = discovered[q]+1
    
    

### FIXED CODE ###

k = int(input())
from collections import deque
d = deque( )
d.append((1,1))
discovered = set()
while True:
  node, cost = d.popleft()
  discovered |= {node}
  if node == 0: 
  	print(cost)
  	quit()
  if (node*10)%k not in discovered:
    d.appendleft( ((node*10)%k  ,cost))
  if (node+1)%k not in discovered:
    d.append((node+1,cost+1))
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(k+1,n):
      if l[i]!=l[j]!=l[k]:
        if l[i]+l[j]>l[k]:
        ans+=1

print(ans)

### FIXED CODE ###

ss=str(input())
a=int(ss.count("R"))

if ss=="RSR":
  a=1

print(a)
a,b,c,d=(int(input) for _ in range(4))
print(min(a,b)+min(c,d))

### FIXED CODE ###

a,b,c,d=(int(input()) for _ in range(4))
print(min(a,b)+min(c,d))
a=input()
b=input()
if a !=b:
    print("H")
else:
    print("D")

### FIXED CODE ###

a=input()
if a[0] !=a[2]:
    print("D")
else:
    print("H")
i = int(input())
count=0
while i < p:
  p = p*1.01
  count +=1
print(count)

### FIXED CODE ###

X = int(input())

Y = 100
count = 0

while (X > Y):
  Y += int(0.01*Y)
  count += 1
print(count)
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
q=i1()
import math
for i in range(q):
 [a,b]=i2()
 x=a*b
 c=int(math.sqrt(x))
 if c**2==x:
    c-=1
 z=2*c
 if  int(x//c)==c:
   z-=1
 if x%c==0 and (int(x//c)-1)==c:
   z-=1
 if a<=c :
   z-=1
 if b<=c:
   z-=1
 print(z)

### FIXED CODE ###

def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
q=i1()
import math
y=[]
for i in range(q):
 y.append(i2())

for a,b in y:
 x=a*b
 c=int(math.sqrt(x))
 if c**2==x:
    c-=1
 z=2*c
 if c>0 and (x//c)==c:
   z-=1
 if c>0 and x%c==0 and (x//c-1)==c:
   z-=1
 if a<=c:
   z-=1
 if b<=c:
   z-=1
 print(z)
a=input()
flag=False
ans=0
hold=0
for i in range(3):
    if a[i]=='R' and not flag:
        ans=1
        flag=not flag
        hold=max(hold,ans)

    elif a[i]=='R' and flag:
        ans+=1
        hold=max(hold,ans)

    else:
        ans=0
        flag=False


return(hold)


### FIXED CODE ###

a=input()
flag=False
ans=0
hold=0
for i in range(3):
    if a[i]=='R' and not flag:
        ans=1
        flag=not flag
        hold=max(hold,ans)

    elif a[i]=='R' and flag:
        ans+=1
        hold=max(hold,ans)

    else:
        ans=0
        flag=False


print(hold)
n = int(input())
a = list(map(int,input().split()))
if 0 in a:
    print(0)
    sys.exit()
for num in range(n):
    x *= a[num]
    if x > 10**18:
        print(-1)
        sys.exit()
print(x)



### FIXED CODE ###

import sys
n = int(input())
a = list(map(int,input().split()))
x = 1
if 0 in a:
    print(0)
    sys.exit()
for num in range(n):
    x  *= a[num]
    if x > 10**18:
        print(-1)
        sys.exit()
print(x)