Harryxun/stf_run huggingface dataset:
N,M = map(int,input().split())
List = list(map(int,input().split()))

a = [0,2,5,5,4,5,6,3,7,6]

kazu = [a[List[i]] for i in range(M)]

def dddd(kazu,X):
  dp = [ [ 0 for j in range(X+1)]  for i in range(M)]

  for i in range(M):
    for j in range(X):
      if kazu[i] <= j:
        dp[i][j+1] = max(dp[i][j+1-kazu[i]] + 1,dp[i-1][j+1])
      else:
        dp[i][j+1] = dp[i-1][j+1]
  return dp[-1]
   
keta_arr = dddd(kazu,N)
keta = keta_arr[-1]
List.sort(reverse=True)
ans = []
x = 0

for i in range(keta):
  d = 0
  for aa in List:
    k = a[aa]
    if N-k > 0:
      if keta_arr[-k-1-x] == keta-i-1 and keta-i-1 != 0 and d == 0:
        ans.append(aa)
        d = 1
        x += k
        N = N-k
        if N == 0:
          break
        continue
    elif N == k and keta-i-1 == 0 and d == 0:
      ans.append(aa)
      d = 1
      N = 0
  if N == 0:
    break
ans.sort(reverse=True)
print(int(''.join(map(str,ans))))

### FIXED CODE ###

N,M = map(int,input().split())
List = list(map(int,input().split()))

a = [0,2,5,5,4,5,6,3,7,6]

kazu = [a[List[i]] for i in range(M)]

def dddd(kazu,X):
  dp = [ [ -float('inf') for j in range(X+1)]  for i in range(M)]
  for i in range(M):
    dp[i][0] = 0

  for i in range(M):
    for j in range(X+1):
      if kazu[i] <= j:
        dp[i][j] = max(dp[i][j-kazu[i]] + 1,dp[i-1][j])
      else:
        dp[i][j] = dp[i-1][j]
  return dp[-1]
   
keta_arr = dddd(kazu,N)
keta = keta_arr[-1]
List.sort(reverse=True)
ans = []

while keta>0:
  for aa in List:
    k = a[aa]
    if N-k < 0:
      continue
    if N-k >= 0:
      if keta_arr[N-k] == keta-1:       
        ans.append(aa)
        N = N-k
        keta -= 1
        break
ans.sort(reverse=True)
print(int(''.join(map(str,ans))))
s = input()
k = int(input())

a = 0
for i in range(k+1):
  if s[i] != '1':
    a = 1
    print(int(s[i]))
    break
if a = 0:
  print(1)

### FIXED CODE ###

s = list(map(int,list(input())))
k = int(input())

a = 0
i = 0

while a < k:
  a += min(s[i]**70, k)
  i +=1

print(s[i-1])
def gcd(a, b):
    if a > b:
        big = a
        small = b
    else:
        big = b
        small = a
    while True:
        remain = big % small
        if remain == 0:
            break
        big = small
        small = remain
    return small

def factorize(n):
    result = {}
    dev = 2
    while dev ** 2 <= n:
        cnt = 0
        while n % dev == 0:
            n //= dev
            cnt += 1
        result[dev] = cnt
        dev += 1
    if n > 1:
        if max(result) == n:
            result[n] += 1
        else:
            result[n] = 1
    return result

A, B = [int(x) for x in input().split()]
gcd_AB = gcd(A, B)
fct = factorize(gcd_AB)
print(len(fct) + 1)

### FIXED CODE ###

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

def factorize(n):
    a = 2
    lst = []
    while a * a <= n:
        if n % a == 0:
            n = n / a
            lst.append(a)
        else:
            a += 1
    if n > 1:
        lst.append(n)
    return lst

A, B = [int(x) for x in input().split()]
lst = factorize(gcd(A, B))
print(len(set(lst)) + 1)
n, a, b = map(int, input().split())
s = "b" * a + "r" * b
if a == 0 and b == 0:
    print(0)
if s[n % (a + b)] == "b":
    bcnt = n % (a+b)
else:
    bcnt = a
print(n // (a + b) * a + bcnt)



### FIXED CODE ###

n, a, b = map(int, input().split())
if a == 0 and b == 0:
    print(0)
    exit()
if n % (a + b) < a:
    bcnt = n % (a+b)
else:
    bcnt = a
print(n // (a + b) * a + bcnt)
import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


A,V=nm()
B,W=nm()
T=int(input())

d=abs(A-B)
move_s=(V-W)
if(move_s<=0):
    print("NO")
    sys.exit(0)
if(T<=((d//move_s)+1)):
    print("NO")
    sys.exit(0)
print("YES")



T1=d//move_b
T2=(d%move_b)//move_b
if((d%move_b)%move_b!=0):
    print('No')
    sys.exit(0)
if(T2+T1<=T):
    print('yes')
    sys.exit(0)
else:
    print('No')
    sys.exit(0)


### FIXED CODE ###

import sys
import  math
import fractions
from collections import defaultdict
stdin = sys.stdin
     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))


A,V=nm()
B,W=nm()
T=int(input())

d=abs(A-B)
move_s=(V-W)
if(move_s<=0):
    print("NO")
    sys.exit(0)
if(((d//move_s))<=(T-1) or ((d//move_s)==T and (d%move_s==0)) ):
    print("YES")
    sys.exit(0)
print("NO")
A,B=map(int,input()split())
print(A*B-A-B+1)

### FIXED CODE ###

A,B=map(int,input().split())
print(A*B-A-B+1)
s = input()
n = len(s)
def dfs(i,f):
  if i == n:
    return sum(list(map(int,f.split("+"))))
  return dfs(i + 1, f + s[i + 1]) + \
           dfs(i + 1, f + "+" + s[i + 1])
print(dfs(0,0))

### FIXED CODE ###

s = list(input())
n = len(s)-1
def dfs(x,y):
  ans = 0
  if x == n:
    return sum(list(map(int,"".join(y).split("+"))))
  else:
    return dfs(x+1,y+"+"+s[x+1])+dfs(x+1,y+s[x+1])
print(dfs(0,s[0]))
H, W = map(int, input().split())
a = []
for i in range(H):
  b = list(input().split())
  a.append(b)
c = []
for i in range(2*H):
  d = []
  for j in range(W):
    d.append(a[(i + 1)//2][j])
  c.append(d)
print(c)

### FIXED CODE ###

H, W = map(int, input().split())
a = []
for i in range(H):
  b = list(input())
  a.append(b)
for i in range(2*H):
  for j in range(W):
    if j != W - 1:
      print(a[i//2][j],end="")
    else:
      print(a[i//2][j])
N, K=map(int, input().split())
nums=list()
nums.append(N)

while abs(N-K)<N:
    N=abs(N-K)
    nums.append(N)
print(min(nums))

### FIXED CODE ###

A, B, C=map(int, input().split())
print(C,A,B)
n = int(input())
frag = True
for i in range(n):
  if i*108//100 = n:
    print(i)
    frag=False
    break
if frag:
  print(":(")


### FIXED CODE ###

import sys
n = int(input())
 
for i in range(n+1):
  if i*108//100 == n:
    print(i)
    sys.exit()
    
print(":(")
from collections import Counter

N = int(input())
s = input()
cnt = Counter(s)
R = cnt.get('R', 0)
G = cnt.get('G', 0)
B = cnt.get('B', 0)
ans = R * G * B
for i in range(N-1):
  for j in range(i+1, N):
    if s[i] != s[j] and 2*j-i < n and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
      ans -= 1
print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
s = input()
cnt = Counter(s)
R = cnt.get('R', 0)
G = cnt.get('G', 0)
B = cnt.get('B', 0)
ans = R * G * B
for i in range(N-1):
  for j in range(i+1, N):
    if s[i] != s[j] and 2*j-i < N and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
      ans -= 1
print(ans)
'''
Created on 2016/03/18

@author: toshi
'''
from veusz.document.export import m_inch

#n = map(int, raw_input())
n = int(raw_input())
A = map(int, raw_input().split())
#q = map(int, raw_input())
q = int(raw_input())
m = map(int, raw_input().split())

A = sorted(A)

def sum_A(A, n, pos, sum, m, flg):
    if flg[0] == "yes":
        return 0
    if sum == m:
        flg[0] = "yes"
        return 0
    if pos + 1 > n - 1:
        return 0
    sum_A(A, n, pos + 1, sum + A[pos], m, flg)
    sum_A(A, n, pos + 1, sum, m, flg)

for i, m_i in enumerate(m):
    sum = 0
    flg = ["no"]
    sum_A(A, n, 0, sum, m_i, flg)
    print flg[0]

### FIXED CODE ###

def sequence(A, n):
    dic = {}
    
    def solve(i, m):
        if (i, m) in dic:
            return dic[(i, m)]
        if m == 0:
            dic[(i, m)] = True
        elif i >= n:
            dic[(i, m)] = False
        elif solve(i+1, m):
            dic[(i, m)] = True
        elif solve(i+1, m-A[i]):
            dic[(i, m)] = True
        else:
            dic[(i, m)] = False
        return dic[(i, m)]
    
    return solve

if __name__ == '__main__':
    n = int(raw_input())
    A = map(int, raw_input().split())
    q = int(raw_input())
    m = map(int, raw_input().split())

    solve = sequence(A, n)
    for m_i in m:
        print "yes" if solve(0, m_i) else "no"
# -*- config: utf-8 -*-
 
 
 
for i in range(10):
    a,b,c = map(int,raw_input().split())
    j = 0
 
 
    if a + b == c or a + c == b or b + c== a:
        j=1
 
    if(j == 1):
        print 'Yes'
    else:
        print 'No'
 
 
 

### FIXED CODE ###

# -*- config: utf-8 -*-
 
 
 
 
a,b,c = map(int,raw_input().split())
j = 0
 
 
if a + b == c or a + c == b or b + c== a:
    j=1
 
if(j == 1):
    print 'Yes'
else:
    print 'No'
Xs = raw_input()
  Ys = raw_input()
  count = 0
  a = 0

  for j in range(len(Ys) + 1):
    dp[0][j + 1] = Ys[j] 
  for i in range(len(Xs) + 1):
    dp[i + 1][0] = Xs[i]

  for j in range(1, len(Ys) + 1):
    for i in range(a + 1, len(Xs) + 1):
      if dp[i][0] == dp[0][j]:
         count = count + 1
         a = i 
         break
   
  print count

### FIXED CODE ###

def solve_lcs():
    x = raw_input()
    y = raw_input()
 
    a = len(x)
    b = len(y)
    c1 = [0 for i in range(b+1)]
    for i in range(a):
        e1 = x[i]
        c2 = c1+[]
        for j in range(b):
            if e1 == y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
 
n = input()
for i2 in range(n):
    print solve_lcs()
n = int(input())
record = [ [ [ [0 for r in range(10)] for f in range(3)] ] for b in range(4)]
for i in range(n):
    b,f,r,v = [int(a) in input().split(" ")]
    record[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in record[b]:
        print( " ".join([str(x) for x in f])
    if b != 3:
        print("#" * 20)
        

### FIXED CODE ###

n = int(input())
record = [ [ [0 for r in range(10)] for f in range(3)] for b in range(4)]
for _ in range(n):
    b,f,r,v = [int(i) for i in input().split(" ")]
    record[b - 1][f - 1][r - 1] += v
for b1 in range(4):
    for f in record[b1]:
        print(" "+" ".join([str(x) for x in f]))
    if b1 != 3:
        print("#" * 20)
from sys import stdin
import math

A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]


def div(n, x, y):
    lcs = int(x * y / math.gcd(x, y))
    return n - int(n // x) - int(n // y) + int(n // lcs)


print(div(B, C, D) - div(A - 1, C, D))


### FIXED CODE ###

from sys import stdin
import fractions

A, B, C, D = [int(x) for x in stdin.readline().rstrip().split()]


def div(n, x, y):
    lcs = int(x * y / fractions.gcd(x, y))
    return n - int(n // x) - int(n // y) + int(n // lcs)


print(div(B, C, D) - div(A - 1, C, D))
n = int(input())
if n = 1:
  print(1)
  exit()
xy = []
for _ in range(n):
  x, y = map(int, input().split())
  xy.append([x, y])

vecs = {}
for i in range(n):
  for j in range(i+1, n):
    if xy[i][0] < xy[j][0]:
      vec = (xy[j][0] - xy[i][0], xy[j][1] - xy[i][1])
    elif xy[i][0] > xy[j][0]:
      vec = (xy[i][0] - xy[j][0], xy[i][1] - xy[j][1])
    else:
      vec = (0, abs(xy[j][1] - xy[i][1]))
    
    if vec in vecs:
      vecs[vec] += 1
    else:
      vecs[vec] = 1

vec_max = max(list(vecs.values()))
print(n - vec_max)
    

### FIXED CODE ###

n = int(input())
if n == 1:
  print(1)
  exit()
xy = []
for _ in range(n):
  x, y = map(int, input().split())
  xy.append([x, y])

vecs = {}
for i in range(n):
  for j in range(i+1, n):
    if xy[i][0] < xy[j][0]:
      vec = (xy[j][0] - xy[i][0], xy[j][1] - xy[i][1])
    elif xy[i][0] > xy[j][0]:
      vec = (xy[i][0] - xy[j][0], xy[i][1] - xy[j][1])
    else:
      vec = (0, abs(xy[j][1] - xy[i][1]))
    
    if vec in vecs:
      vecs[vec] += 1
    else:
      vecs[vec] = 1

vec_max = max(list(vecs.values()))
print(n - vec_max)
i = raw_input()

while (i):
	i -= 1
	st = []
	n = raw_input()

	for s in n:
		st.append(s)

	s.sort()
	a = int("".join())
	b = int("".join(s[::-1]))

	print b - a

### FIXED CODE ###

i = int(raw_input())

while (i):
	i -= 1
	st = []
	n = raw_input()

	for s in n:
		st.append(s)

	st.sort()
	a = int("".join(st))
	b = int("".join(st[::-1]))

	print b - a
s=input()
k=int(input())
cnt=0
i=0
while s[i] =="1" and i<=len(s):
    cnt+=1
    i+=1

#print(cnt)
if k<=cnt:
    print(1)
else:
    #if len(s)==1:
        #print(s[0])
    #else:
    print(s[i])

### FIXED CODE ###

s=input()
k=int(input())
cnt=0
i=0
while s[i] =="1" and i<=len(s):
    cnt+=1
    i+=1
    if i==len(s):
        break

#print(cnt)
if k<=cnt:
    print(1)
else:
    print(s[i])
print(input[::2])

### FIXED CODE ###

s = input()

print(s[::2])
N = input()
K = input()
mod = N%K
if mod=0:
  print("0")
else:
  print("1")


### FIXED CODE ###

N, K = map(int, input().split())
if N%K == 0:
  print(0)
else:
  print(1)
h, w, m = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(m)]

c = [0 for _ in range(h)]
r = [0 for _ in range(w)]
bakuset = {}
for i, j in hw:
    # print(i, j)
    c[i-1] += 1
    r[j-1] += 1
    if not str(i-1) + "+" + str(j-1) in bakuset:
        bakuset[str(i-1) + "+" + str(j-1)] = 0
    # print(bakuset, i-1, j-1)
    bakuset[str(i-1) + "+" + str(j-1)] += 1

ans = max(c) + max(r)

mc = max(c)
mr = max(r)
cc = []
rr = []

for i in range(h):
    if c[i] == mc:
        cc.append(i)

for i in range(h):
    if r[i] == mr:
        rr.append(i)

flag = 10**10

for i in cc:
    for j in rr:
        if not str(i) + "+" + str(j) in bakuset:
            flag = 0
            break
        flag = min(flag, bakuset[str(i) + "+" + str(j)])
    if not flag:
        break

if flag:
    ans -= 1

print(ans)

### FIXED CODE ###

h, w, m = map(int, input().split())
hw = [list(map(int, input().split())) for _ in range(m)]

c = [0 for _ in range(h)]
r = [0 for _ in range(w)]
bakuset = {}
for i, j in hw:
    # print(i, j)
    c[i-1] += 1
    r[j-1] += 1
    if not str(i-1) + "+" + str(j-1) in bakuset:
        bakuset[str(i-1) + "+" + str(j-1)] = 0
    # print(bakuset, i-1, j-1)
    bakuset[str(i-1) + "+" + str(j-1)] += 1

ans = max(c) + max(r)

mc = max(c)
mr = max(r)
cc = []
rr = []

for i in range(h):
    if c[i] == mc:
        cc.append(i)

for i in range(w):
    if r[i] == mr:
        rr.append(i)

flag = 10**10

for i in cc:
    for j in rr:
        if not str(i) + "+" + str(j) in bakuset:
            flag = 0
            break
        flag = min(flag, bakuset[str(i) + "+" + str(j)])
    if not flag:
        break

if flag:
    ans -= flag

print(ans)
from math import pi
r=float(import())
print("{0:.5f} {1:.5f}".format(pi*r*r, 2*pi*r))

### FIXED CODE ###

from math import pi
r=float(input())
print("{0:.5f} {1:.5f}".format(pi*r*r, 2*pi*r))
def inp():
    while True:
        data=raw_input()
        if not data: break
        yield data
A = [map(int, i.split()) for i in list(inp())]
for i in A:
    print len(str(i[0]*i[1]))

### FIXED CODE ###

results=[]
from sys import stdin
for line in stdin:
    a, b = (int(i) for i in line.split())
    results.append(len(str(a+b)))
for i in results:
    print i
n = int(input())
a = list(map(int, input().split()))
result = 1

for i in range(n):
  result = a[i] * result
  
if result >= 10000000000000000000:
  result = -1

print(result)


### FIXED CODE ###

from sys import stdin
A, B = list(map(float,input().split()))

result = int(A * B)

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


sc = [list(map(int, input().split())) for i in range(m)]

k = 0

ans = [-5]*n

for i in range(m):
    if ans[sc[i][0]-1] == -5:
        ans[sc[i][0]-1] = sc[i][1]
    elif ans[sc[i][0]-1] != sc[i][1]:
        k = 1
    else:
        continue

if k == 1:
    print(-1)
elif m == 0:
  if n == 1:
    print(0)
  elif n ==2:
    print(10)
  else:
    print(100)
elif ans[0] == 0:
    if n == 1:
        print(0)
    else:
        print(-1)
else:
    for i in range(3):
        if ans[i] == -5:
            ans[i] = 0
    if ans[0] == 0:
        ans[0] = 1
    ans = [str(i) for i in ans]
    ans = "".join(ans)
    print(int(ans))

### FIXED CODE ###

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

if m == 0:
  if n == 1:
    print(0)
  elif n == 2:
    print(10)
  else:
    print(100)
else:
    sc = [list(map(int, input().split())) for i in range(m)]

    k = 0

    ans = [-5] * n

    for i in range(m):
        if ans[sc[i][0] - 1] == -5:
            ans[sc[i][0] - 1] = sc[i][1]
        elif ans[sc[i][0] - 1] != sc[i][1]:
            k = 1

    if k == 1:
        print(-1)
    elif ans[0] == 0:
        if n == 1:
            print(0)
        else:
            print(-1)
    else:
        for i in range(n):
            if ans[i] == -5:
                ans[i] = 0
        if ans[0] == 0:
            ans[0] = 1
        ans = [str(i) for i in ans]
        ans = "".join(ans)
        print(int(ans))
from itertools import product
N, A = map(int, input().split())
x = list(map(int, input().split()))
x_max = max(x)

dp = [[[0 for s in range(x_max * (N + 1))] for n in range(N + 1)] for i in range(N + 1)]
dp[0][0][0] = 1

for i, n, s in product(range(1, N + 1), range(N + 1), range(x_max * (N + 1))):
    if s < x[i - 1]:
        dp[i][n][s] = dp[i - 1][n][s]
    elif 0 < n and x[i - 1] <= s:
        dp[i][n][s] = dp[i - 1][n][s] + dp[i - 1][n - 1][s - x[i - 1]]

ans = sum([dp[N][n][n*A] for n in range(1, N + 1)])
print(ans)

### FIXED CODE ###

from itertools import product

N, A = map(int, input().split())
x = [int(xi) for xi in input().split()]
y = [xi - A for xi in x]
X = max(max(x), A)

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

dp[0][N * X] = 1
for k, t in product(range(1, N + 1), range(2 * N * X + 1)):
    if k > 0 and (t - y[k - 1] < 0 or t - y[k - 1] > 2 * N * X):
        dp[k][t] = dp[k - 1][t]
    elif k > 0 and t - y[k - 1] <= 2 * N * X:
        dp[k][t] = dp[k - 1][t] + dp[k - 1][t - y[k - 1]]

print(dp[N][N * X] - 1)
n=int(input())
a=list(map(int,input().split()))
ans=30
for i in a:
  x=0
  while True:
    if i%2==1:
      break
    else:
    x+=1
    i=i//2
    continue
  ans=min(ans,x)
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
ans=30
for i in a:
  x=0
  while True:
    if i%2==1:
      break
    else:
      x+=1
      i=i//2
      continue
  ans=min(ans,x)
print(ans)
N=int(intput())

print(N//3)

### FIXED CODE ###

N=int(input())
 
print(N//3)
# coding: utf-8
n = int(input())

high = list(map(int, input().split()))
max_high = []
count =1

for i in range(1,n):
    x = high[:i]
    if(max(x) <= high[i]):
        count++
        
print(count)

### FIXED CODE ###

#coding: utf-8
a, b = map(int, input().split())
result = 0
     
if(a>b):
    result += a
    a = a-1
else:
    result += b
    b = b-1
     
result += max(a,b)
print(result)
import sys

def all_lighted(input, mod, pattern):
    for i, bulb in enumerate(input):
        if bin(bulb and pattern).count('1') % 2 == pattern[i]:
            next
        else:
            return False
    
    return True


def main():
    num_switch, num_bulb = [int(x) for x in sys.stdin.readline().split()]
    input = [0] * num_bulb

    for bulb in input:
        for x in sys.stdin.readline().split()[1:]:
            bulb += 2**(int(x) - 1)

    mod = [int(x) for x in sys.stdin.readline().split()]

    count = 0

    for i in range(2 ** num_switch):
        if all_lighted(input, mod, i): count += 1

    print(count)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

def all_lighted(input, mod, pattern):
    for i, bulb in enumerate(input):
        if bin(bulb & pattern).count('1') % 2 == mod[i]:
            next
        else:
            return False
    
    return True


def main():
    num_switch, num_bulb = [int(x) for x in sys.stdin.readline().split()]
    input = [0] * num_bulb

    for i in range(num_bulb):
        for x in sys.stdin.readline().split()[1:]:
            input[i] += 2**(int(x) - 1)

    mod = [int(x) for x in sys.stdin.readline().split()]

    count = 0

    for pattern in range(2 ** num_switch):
        if all_lighted(input, mod, pattern): count += 1

    print(count)


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

wrk = 0
for i in n:
    wrk += int(i)

if int(n) % wrk == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

print(min(n*a,b))
MOD = 10**9 + 7

fact = [1] * 1100000
invfact = [1] * 1100000

for i in range(1, 1100000):
    fact[i] = fact[i-1] * i % MOD

invfact[1100000 - 1] = pow(fact[1100000 - 1], MOD-2, MOD)

for i in range(1100000-1, 0, -1):
    invfact[i-1] = invfact[i] * i % MOD


def nCk(n, k):
    return fact[n] * invfact[k] * invfact[n-k] % MOD


k = int(input())
n = len(input())

ans = 0

for l in range(n, n+k+1):
    ans += pow(25, l - n, MOD) * nCk(l-1, n-1) * pow(26, n+k-l, MOD) % MOD
    ans %= MOD

print(ans)

### FIXED CODE ###

MOD = 10**9 + 7

fact = [1] * 2200000
invfact = [1] * 2200000

for i in range(1, 2200000):
    fact[i] = fact[i-1] * i % MOD

invfact[2200000 - 1] = pow(fact[2200000 - 1], MOD-2, MOD)

for i in range(2200000-1, 0, -1):
    invfact[i-1] = invfact[i] * i % MOD


def nCk(n, k):
    return fact[n] * invfact[k] * invfact[n-k] % MOD


k = int(input())
n = len(input())

ans = 0

for l in range(n, n+k+1):
    ans += pow(25, l - n, MOD) * nCk(l-1, n-1) * pow(26, n+k-l, MOD) % MOD
    ans %= MOD

print(ans)
n=int(input())
lists=[[ 0 for j in range(10)]for i in range(10)]
for i in range(1,n+1):
    a=str(i)
    lists[int(a[0])][int(a[-1])]+=1
c=0
for i in range(1,10):
    for j in range(1,10):
        c+=lists[i][j])*lists[j][i]
print(c)        


### FIXED CODE ###

n=int(input())
lists=[[ [] for j in range(10)]for i in range(10)]
for i in range(1,n+1):
    a=str(i)
    lists[int(str(a[0]))][int(str(a[-1]))].append(i)
c=0
for i in range(1,10):
    for j in range(1,10):
        c+=len(lists[i][j])*len(lists[j][i])
print(c)
import math
 
N=int(input())



A=[]

for i in range(1,int(math.sqrt(N))):
  if N % i ==0:
    A.append(i)
    A.append(int(N/i))
    
A.sort()
base = int(len(A)/2)
print(A[base]-1 +A[base-1] -1)

### FIXED CODE ###

import math
 
N=int(input())

A=[]

for i in range(1,int(math.sqrt(N))+1):
  if N % i ==0:
    A.append(i)
    A.append(int(N/i))
    
A.sort()
base = int(len(A)/2)

print(A[base]-1 +A[base-1] -1)
b=input()
A,C,T,G=map(str,raw_input().split())
if b=="A":
    print "C"
if b=="C":
    print "A"
if b=="T":
    print "G"
if b=="G":
    print "T"
    

### FIXED CODE ###

b=raw_input()
if b=="A":
    print "T"
if b=="T":
    print "A"
if b=="C":
    print "G"
if b=="G":
    print "C"
N=int(input())
a=list(map(int,input().split()))
a=[a[i]-a[0] for i in a]
cnt=0
for i in range(len(a)):
    if a[i]>=0:
        cnt+=1
print(cnt)

### FIXED CODE ###

N=int(input())
a=list(map(int,input().split()))
cnt=0
for i in range(N):
    if max(a[:i+1])==a[i]:
    	cnt+=1
print(cnt)
import sys

n = int(sys.stdin.readline())

dp = [0 for i in range(n+1)]
cost = list(map(int, sys.stdin.readline()))

dp[1] = cost[0]
dp[2] = abs(dp[1] - cost[2])


for i in range(3, n+1):
  dp[i] = min(dp[i-1] + abs(cost[i+1] - cost[i]), dp[i-2] + abs(cost[i-1] - cost[i+1]))
  
print(dp[n])

### FIXED CODE ###

import sys

n = int(sys.stdin.readline())

dp = [0 for i in range(n+1)]
cost = list(map(int, sys.stdin.readline().split())) # 0~3
cost.insert(0, 0)

dp[2] = abs(cost[1] - cost[2])


for i in range(3, n+1):
  dp[i] = min(dp[i-1] + abs(cost[i-1] - cost[i]), dp[i-2] + abs(cost[i-2] - cost[i]))
  
print(dp[n])
import math

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

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

ans = 1000000001
for i in range(n):
    v = abs(x - a[i])

    if v < ans:
        ans = v

    gcd = math.gcd(v, ans)
    if gcd < ans:
        ans = gcd

print(ans)

### FIXED CODE ###

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

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

def gcd(la, lb):
    if la < lb:
        tmp = a
        la = lb
        lb = tmp

    r = la % lb

    while r != 0:
        la = lb
        lb = r
        r = la % lb

    return lb

ans = 1000000001
for i in range(n):
    v = abs(x - a[i])

    if v < ans:
        ans = v

    g = gcd(v, ans)
    if g < ans:
        ans = g

print(ans)