Problem:


Score: 600 points

Problem Statement

How many strings can be obtained by applying the following operation on a string S exactly K times: "choose one lowercase English letter and insert it somewhere"?

The answer can be enormous, so print it modulo (10^9+7).

Constraints

K is an integer between 1 and 10^6 (inclusive).

S is a string of length between 1 and 10^6 (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

K
S

Output

Print the number of strings satisfying the condition, modulo (10^9+7).

Sample Input 1

5
oof

Sample Output 1

575111451

For example, we can obtain proofend, moonwolf, and onionpuf, while we cannot obtain oofsix, oofelevennn, voxafolt, or fooooooo.

Sample Input 2

37564
whydidyoudesertme

Sample Output 2

318008117



Sample input:
5
oof


Sample output:
575111451

Submission status: Runtime Error

Solution code:
import sys                                                                                                                                                                                                  
                                                                                                                                                                                                            
kMod = 10**9 + 7                                                                                                                                                                                            
                                                                                                                                                                                                            
def read_int():                                                                                                                                                                                             
    l = sys.stdin.readline().rstrip('\n').split(' ')                                                                                                                                                        
    return int(l[0])                                                                                                                                                                                        
                                                                                                                                                                                                            
def read_int_list():                                                                                                                                                                                        
    l = sys.stdin.readline().rstrip('\n').split(' ')                                                                                                                                                        
    return [int(i) for i in l]                                                                                                                                                                              
                                                                                                                                                                                                            
K = read_int()                                                                                                                                                                                              
S = sys.stdin.readline().rstrip('\n')                                                                                                                                                                       
                                                                                                                                                                                                            
memo = {}                                                                                                                                                                                                   
def cnt(n, rest):                                                                                                                                                                                           
    if n == 0:                                                                                                                                                                                              
        if rest > 0:                                                                                                                                                                                        
            return 0                                                                                                                                                                                        
        else:                                                                                                                                                                                               
            return 1                                                                                                                                                                                        
    key = (n, rest)                                                                                                                                                                                         
    if key in memo:                                                                                                                                                                                         
        return memo[key]                                                                                                                                                                                    
    ans = 0                                                                                                                                                                                                 
    ans += 25 * cnt(n-1, rest)                                                                                                                                                                              
    ans += cnt(n-1, rest-1)                                                                                                                                                                                 
    ans %= kMod                                                                                                                                                                                             
    memo[key] = ans                                                                                                                                                                                         
    return ans                                                                                                                                                                                              
                                                                                                                                                                                                            
print(cnt(K+len(S), len(S)))

Submission status: Runtime Error

Solution code:
K = int(input())
S = input()

mod = 10**9+7
ls = len(S)

dp = [[0]*(ls) for _ in range(K+ls)]
dp[0][0] = 25
dp[0][1] = 1

for i in range(1, K+ls):
    dp[i][0] = dp[i-1][0]*25%mod
    for j in range(1, ls):
        dp[i][j] += dp[i-1][j-1]
        dp[i][j] += dp[i-1][j]*25 % mod

x = 1
for i in range(K+ls):
    x *= 26
    x %= mod

res = x - sum(dp[-1])

while res < 0:
    res += mod

print(res)

Submission status: Runtime Error

Solution code:
import sys                                                                                                                                                                                                  
                                                                                                                                                                                                            
kMod = 10**9 + 7                                                                                                                                                                                            
                                                                                                                                                                                                            
def read_int():                                                                                                                                                                                             
    l = sys.stdin.readline().rstrip('\n').split(' ')                                                                                                                                                        
    return int(l[0])                                                                                                                                                                                        
                                                                                                                                                                                                            
def read_int_list():                                                                                                                                                                                        
    l = sys.stdin.readline().rstrip('\n').split(' ')                                                                                                                                                        
    return [int(i) for i in l]                                                                                                                                                                              
                                                                                                                                                                                                            
K = read_int()                                                                                                                                                                                              
S = sys.stdin.readline().rstrip('\n')                                                                                                                                                                       
                                                                                                                                                                                                            
memo = {}                                                                                                                                                                                                   
def cnt(n, rest):                                                                                                                                                                                           
    if n == 0:                                                                                                                                                                                              
        if rest > 0:                                                                                                                                                                                        
            return 0                                                                                                                                                                                        
        else:                                                                                                                                                                                               
            return 1                                                                                                                                                                                        
    key = (n, rest)                                                                                                                                                                                         
    if key in memo:                                                                                                                                                                                         
        return memo[key]                                                                                                                                                                                    
    ans = 0                                                                                                                                                                                                 
    ans += 25 * cnt(n-1, rest)                                                                                                                                                                              
    ans += cnt(n-1, rest-1)                                                                                                                                                                                 
    ans %= kMod                                                                                                                                                                                             
    memo[key] = ans                                                                                                                                                                                         
    return ans                                                                                                                                                                                              
                                                                                                                                                                                                            
print(cnt(K+len(S), len(S)))

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

K = int(input())
S = str(input())
mod = 10**9+7
lens = len(S)
length = lens+K

L = 1
pow_dic = {}
pow_dic[0] = 1
for i in range(1, 10**6+2):
    L = L*i%mod
    pow_dic[i] = L
ans = 0
for rest in range(K+1):
    lenall = length-rest-1
    nlens = lens-1
    l = pow_dic[lenall]*pow(pow_dic[lenall-nlens], mod-2, mod)%mod
    r = pow_dic[nlens]
    comb = l*pow(r, mod-2, mod)%mod
    ans += pow(25, K-rest, mod)*pow(26, rest, mod)*comb%mod
    ans %= mod
print(ans%mod)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from functools import lru_cache
sys.setrecursionlimit(1_000_002)

MOD = 1000000007  # type: int

@lru_cache(maxsize=None)
def f(k, n):
    if k == 0:
        return 1
    if n == 0:
        return pow(26, k, MOD)
    return (25 * f(k-1, n) + f(k, n-1)) % MOD

def solve(K: int, S: str):
    return f(K, len(S)) 

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    print(solve(K, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Runtime Error

Solution code:
from sys import setrecursionlimit
setrecursionlimit(10**7)

MOD = 10**9+7
K = int(input())
S = input()
l = K + len(S)
def calc(n, m):
    if n == m: return 1
    elif n < m: return 0
    elif m == 0: return pow(26, n, MOD)
    return ((25*calc(n-1, m))%MOD + (calc(n-1, m-1))%MOD)%MOD
print(calc(l, len(S)))

Submission status: Runtime Error

Solution code:
from sys import setrecursionlimit
setrecursionlimit(10**7)

MOD = 10**9+7
K = int(input())
S = input()
l = K + len(S)
def calc(n, m):
    print(n,m)
    if n == m: return 1
    elif n < m: return 0
    elif m == 0: return pow(26, n, MOD)
    return ((25*calc(n-1, m))%MOD + (calc(n-1, m-1))%MOD)%MOD
print(calc(l, len(S)))

Submission status: Runtime Error

Solution code:
mod = 10**9+7
k = int(input())
s = input()
n = len(s)


def inv(a, mod):
    r = [1, 0, a]
    w = [0, 1, mod]
    while w[2] != 1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0], r[1]-q*w[1], r[2]-q*w[2]]
        r = w
        w = r_new
    x, y = w[0], w[1]    # a*x+y*mod = 1
    return (mod+x % mod) % mod


max_num = 2*10**5+1
fact = [0 for _ in range(max_num)]
ifact = [0 for _ in range(max_num)]

fact[0] = fact[1] = 1
ifact[0] = ifact[1] = 1

for i in range(2, max_num):
    fact[i] = fact[i-1] * i % mod

ifact[max_num-1] = inv(fact[max_num-1], mod)

for i in range(2, max_num):
    ifact[max_num-i] = (ifact[max_num-i+1] * (max_num-i+1)) % mod


def comb(x, y):
    if x < 0 or y < 0 or x < y:
        return 0
    else:
        return fact[x] * ifact[y] * ifact[x-y] % mod


ans = 0
for i in range(k+1):
    ans += comb(n-1+i, i)*pow(25, i, mod)*pow(26, k-i, mod)
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
mod = 10**9 + 7  # 998244353 # 変える


def table():
    k = 2 * 10**5 + 5  # 変える
    fac = [1] * k
    finv = [1] * k
    inv = [0] * k
    inv[1] = 1
    for i in range(2, k):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


fac, finv = table()


def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


k = int(input())
s = input()
n = len(s) - 1
ans = 1
for i in range(k + 1):
    x = pow(26, k - i, mod) * pow(25, i, mod) % mod
    ans += (comb(n + i, i) * x)
    ans %= mod
print((ans - 1) % mod)

Submission status: Runtime Error

Solution code:
mod = 10**9 + 7  # 998244353 # 変える


def table():
    k = 2 * 10**5 + 5  # 変える
    fac = [1] * k
    finv = [1] * k
    inv = [0] * k
    inv[1] = 1
    for i in range(2, k):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


fac, finv = table()


def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


k = int(input())
s = input()
n = len(s) - 1
ans = 1
for i in range(k + 1):
    x = pow(26, k - i, mod) * pow(25, i, mod) % mod
    ans += (comb(n + i, i) * x)
print((ans - 1) % mod)

Submission status: Runtime Error

Solution code:
import numpy as np

mod = 10 ** 9 + 7

K = int(input())
S = input()

dp = np.ones((len(S) + K + 1, len(S) + 1), dtype=int) * (-1)


def count(length, str_length):
    if length == 0: return 0
    if length == str_length: return 1
    if length < str_length: return 0
    if str_length == 0: return (26 ** length) % mod
    result = dp[length][str_length]
    if result >= 0: return result
    dp[length][str_length] = (count(length - 1, str_length - 1) + 25 * count(length - 1, str_length)) % mod
    return dp[length][str_length]


print(count(len(S) + K, len(S)))

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
K=int(input())
S=input()
M=len(S)
N=K+M
mod=10**9+7
ans=pow(26,N,mod)
class Data():
    def __init__(self):
        self.power=1
        self.rev=1     
class Combi():
    def __init__(self,N,mod):
        self.lists=[Data() for _ in range(N+1)]
        self.mod=mod  
        for i in range(2,N+1):
            self.lists[i].power=((self.lists[i-1].power)*i)%self.mod
        self.lists[N].rev=pow(self.lists[N].power,self.mod-2,self.mod)
        for j in range(N,0,-1):
            self.lists[j-1].rev=((self.lists[j].rev)*j)%self.mod

    def combi(self,K,R):
        if K<R:
            return 0
        else:
            return ((self.lists[K].power)*(self.lists[K-R].rev)*(self.lists[R].rev))%self.mod
        
c=Combi(2*10**6,mod)
for i in range(M):
    ans-=c.combi(N,i)*pow(25,N-i,mod)
    ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
K = int(input())
S = list(input())
MOD = 10 ** 9 + 7

from functools import lru_cache

@lru_cache(maxsize = 100)
def f(S,K):
  if S == 0:
    return 26 ** K % MOD
  else:
    if K == 0:
      return 1
    else:
      return ( f(S-1,K) % MOD + f(S,K-1)*25  % MOD ) % MOD
    
print(f(len(S),K))

Submission status: Runtime Error

Solution code:
K=int(input())
S=input()
n=K+len(S)
MAX=1000000
fac=[0]*MAX
finv=[0]*MAX
inv=[0]*MAX
MOD=10**9+7
#テーブルを作る前処理
def COMinit():
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,MAX):
      fac[i] = fac[i-1] * i % MOD
      inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
      finv[i] = finv[i - 1] * inv[i] % MOD

#二項係数計算
def comb(n,k):
  if (n < k):
    return 0
  if (n < 0 or k < 0):
    return 0
  else:
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

COMinit()
com=1
q=(26**K)%(10**9+7)
ans=0
for i in range(K+1):
  ans+=(q*comb(len(S)+i-1,i))%(10**9+7)#comb(len(S)+i-1,len(S)-1))%(10**9+7)
  q=(q*423076927)%(10**9+7)
  #com=(com*(len(S)+i))//(i+1)
print(ans%(10**9+7))
#print((25*576923081)%(10**9+7))

Submission status: Runtime Error

Solution code:
import sys

stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  # ignore trailing spaces

# 大きい数用


mod = 10**9 + 7
N = 10 ** 6  # 出力の制限
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for i in range(2, N + 1):
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)


K = ni()
S = ns()
s_len = len(S)
mod = 10 ** 9 + 7
ans = 0

total = K + s_len

rui = 1

cmb = 1

for i in range(total, s_len - 1, -1):
    ans = (ans + cmb * rui) % mod
    # print(ans)
    rui = (rui * 25) % mod
    cmb = (cmb * i * inverse[total - i + 1]) % mod
print(ans)

Submission status: Runtime Error

Solution code:
K = int(input())
S = input()
N = len(S)
MOD = 10**9 + 7

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

for i in range(N + K):
    for j in range(min(N, i) + 1):
        d = dp[i][j] % MOD
        dp[i + 1][j + 1] += d
        dp[i + 1][j] += d * 25

ans = 0
for j in range(N):
    ans += dp[N + K][j]
print((pow(26, N + K, MOD) - ans % MOD) % MOD)

Submission status: Runtime Error

Solution code:
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10**9 + 7  #出力の制限
N = 300000
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  #逆元テーブル
inverse = [0, 1]  #逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

K = int(input())
S = len(input())
ans = 0
for i in range(S, S + K + 1):
    ans += cmb(S + K, i, mod) * pow(25, K + S - i, mod)
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
n = 10**6
mod = 10 ** 9 + 7
fact = [1]*(n+1)
rfact = [1]*(n+1)
r = 1
for i in range(1, n+1):
  fact[i] = r = r * i % mod
rfact[n] = r = pow(fact[n], mod-2, mod)
for i in range(n, 0, -1):
  rfact[i-1] = r = r * i % mod

# nPk (mod MOD) を求める
def perm(n, k):
  return fact[n] * rfact[n-k] % mod

# nCk (mod MOD) を求める
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % mod

k = int(input())
s = input()

len_s = len(s)
ans = 0
for i in range(len_s,k+len_s+1):
    ans += (comb(i-1,len_s-1) * pow(25,i-len_s,mod) * pow(26,k+len_s-i,mod)) % mod
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
mod = 10**9+7
rng = 1000100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0 or n<k:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
k = int(input())
s = input()
n = len(s)
ans = pow(26,n+k,mod)
for i in range(n):
  ans -= pow(25,n+k-i,mod)*cmb(n+k,i)
  ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

K=int(input())
S=input()

dp=[[0]*(len(S)+1) for _ in range(K+len(S)+1)]
dp[0][0]=1
for i in range(K+len(S)):
    for j in range(len(S)+1):
        if j==len(S):
            dp[i+1][j]+=dp[i][j]*26
        else:
            dp[i+1][j]+=dp[i][j]*25
        if j+1<=len(S):
            dp[i+1][j+1]+=dp[i][j]
            dp[i+1][j+1]%=MOD
        dp[i+1][j]%=MOD
print(dp[-1][-1])

Submission status: Runtime Error

Solution code:
mod = 10**9 + 7

fact_range = 10**6
facts = [1] * (fact_range + 1)
for i in range(0, fact_range):
    facts[i+1] = facts[i] * (i + 1) % mod

ifacts = [1] * (fact_range + 1)
ifacts[fact_range] = pow(facts[fact_range], mod - 2, mod)
for i in range(fact_range, 0, -1):
    ifacts[i-1] = ifacts[i] * i % mod

def comb(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return facts[n] * ifacts[n-k] % mod * ifacts[k] % mod

k = int(input())
s = len(input())
ans = 0
for a in range(k + 1):
    ans += pow(25, a, mod) * pow(26, k-a, mod) % mod * comb(s-1+a, a)
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n):
    res = [None] * n
    for i in range(n):
        res[i] = II()
    return res
def LIR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI()
    return res
def FR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LFR(n):
    res = [None] * n
    for i in range(n):
        res[i] = IF()
    return res
def LIR_(n):
    res = [None] * n
    for i in range(n):
        res[i] = LI_()
    return res
def SR(n):
    res = [None] * n
    for i in range(n):
        res[i] = S()
    return res
def LSR(n):
    res = [None] * n
    for i in range(n):
        res[i] = LS()
    return res
mod = 1000000007
inf = float('INF')
fact = [i for i in range(10 ** 6 + 1)]
fact[0] = 1
for i in range(10 ** 6):
    fact[i + 1] *= fact[i]
    fact[i + 1] %= mod
invfact = fact[:]
invfact[-1] = pow(invfact[-1], mod - 2, mod)
for i in range(10 ** 6, 0, -1):
    invfact[i - 1] = i * invfact[i]
    invfact[i - 1] %= mod

def combination_mod(n, k, mod):
    """ power_funcを用いて(nCk) mod p を求める """ 
    """ nCk = n!/((n-k)!k!)を使用 """
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = fact[n]
    b = invfact[k]
    c = invfact[n - k]
    return (a * b * c) % mod

#solve
def solve():
    k = II()
    s = S()
    ans = pow(26, len(s) + k, mod)
    sk = len(s) + k
    for i in range(len(s)):
        ans -= combination_mod(sk, i, mod) * pow(25, sk - i, mod)
        ans %= mod
    print(ans)
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()
    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]

####

from collections import defaultdict as ddic
def memo(f):
    """ Memoization decorator for functions taking one or more arguments. """
    class memodict(dict):
        def __init__(self, f):
            self.f = f
        def __call__(self, *args):
            return self[args]
        def __missing__(self, key):
            ret = self[key] = self.f(*key)
            return ret
    return memodict(f)

def brute(K,S):
    MOD = 10 ** 9 + 7
    N = len(S)
    N2 = N + K
    talk = ddic(int)
    #@memo
    def dp(i, j):
        if i> N2: return 0
        if i==N2:
            if j >= N:
                talk[j] += 1
            return +(j >= N)
        ans = dp(i+1, j+1)
        ans += 25 * dp(i+1, j)
        #ans %= MOD
        return ans
    ans = dp(0,0)
    #print("!", talk)
    return ans #dp(0,0)
    
def solve(K, S):
    MOD = 10 ** 9 + 7
    N = len(S)
    N2 = N + K
    # how many strings length N2 have S as substring?
    A = [ord(c)-ord('a') for c in S]

    BIG =10**6
    fac = [1, 1]
    for x in xrange(2, BIG+1):
        fac.append(fac[-1] * x  %MOD)
    inv = [1] * (BIG + 1)
    inv[BIG] = pow(fac[-1], MOD-2, MOD)
    for x in xrange(BIG-1, -1, -1):
        inv[x] = inv[x+1] * (x+1) % MOD

    def binom(n, k):
        ans = fac[n]
        ans *= inv[n-k]
        ans %= MOD
        
        ans *= inv[k]
        ans %= MOD
        return ans

    #pow26 = [1]
    pow25 = [1]
    for x in xrange(1, BIG + 1):
        pow25.append(pow25[-1] * 25  %MOD)
    #    pow26.append(pow26[-1] * 26  %MOD)
    #print pow25[:8]
    #print pow26[:8]
    ans = 0
    for n in xrange(N, N2 + 1):
        bns = binom(N2, n)   * pow25[N2- n] % MOD
        #print("!", binom(N2, n))
        #bns *= pow26[N
        ans+=bns
        ans %= MOD
    return ans

    #return binom(N2, N) % MOD

"""
def deltas(row):
    return [row[i+1] - row[i] for i in xrange(len(row) - 1)]
for k in range(1, 10):
    row = []
    for n in range(1, 10):
        x = solve(k, 'a' * n)
        row.append(x)
    print k, row
    print deltas(row)
    print deltas(deltas(row))
    print deltas(deltas(deltas(row)))
"""
#print solve(1, 'a'), brute(1, 'a')
#print solve(2, 'a'), brute(2, 'a')
#print solve(3, 'abc'), brute(3, 'abc')
print solve(rri(), rr())