Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
s = list(input())
mod = 10 ** 9 + 7

nagasa = len(s)


ans = pow(26, k, mod)
bunbo = 1
bunshi = 1
for i in range(1, k + 1):
    bunbo *= nagasa - 1 + i
    bunshi *= pow(i, mod - 2, mod)
    bunbo %= mod
    bunshi %= mod
    temp = bunbo * bunshi
    temp %= mod
    temp *= pow(25, i, mod)
    temp %= mod
    temp *= pow(26, k - i, mod)
    temp %= mod
    ans += temp
    ans %= mod

print(ans)


Fixed submission:
k = int(input())
s = list(input())
mod = 10 ** 9 + 7

nagasa = len(s)


ans = pow(26, k, mod)
bunbo = 1
bunshi = 1
for i in range(1, k + 1):
    bunbo *= nagasa - 1 + i
    bunshi *= pow(i, mod - 2, mod)
    bunbo %= mod
    bunshi %= mod
    temp = bunbo * bunshi
    temp %= mod
    temp *= pow(25, i, mod)
    temp %= mod
    temp *= pow(26, k - i, mod)
    temp %= mod
    ans += temp
    ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

k = int(input())
s = list(input())
mod = 10 ** 9 + 7

nagasa = len(s)

n = nagasa + k
N = 1500 ** 2
Nsq = 1500
fact = np.arange(N, dtype=np.int64).reshape(Nsq, Nsq)
fact[0, 0] = 1
for n in range(1, Nsq):
    fact[:, n] *= fact[:, n - 1]
    fact[:, n] %= mod
for n in range(1, Nsq):
    fact[n] *= fact[n - 1, -1]
    fact[n] %= mod
fact = fact.ravel()
fact_inv = np.arange(1, N + 1, dtype=np.int64)[::-1].reshape(Nsq, Nsq)
fact_inv[0, 0] = pow(int(fact[N - 1]), mod - 2, mod)
for n in range(1, Nsq):
    fact_inv[:, n] *= fact_inv[:, n - 1]
    fact_inv[:, n] %= mod
for n in range(1, Nsq):
    fact_inv[n] *= fact_inv[n - 1, -1]
    fact_inv[n] %= mod
fact_inv = fact_inv.ravel()[::-1]


def comb(n, r):
    if r < 0 or n - r < 0:
        return 0
    res = fact[n]
    res *= fact_inv[n - r]
    res %= mod
    res *= fact_inv[r]
    res %= mod
    return res


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

print(ans)


Fixed submission:
k = int(input())
s = list(input())
mod = 10 ** 9 + 7

nagasa = len(s)


ans = pow(26, k, mod)
bunbo = 1
bunshi = 1
for i in range(1, k + 1):
    bunbo *= nagasa - 1 + i
    bunshi *= pow(i, mod - 2, mod)
    bunbo %= mod
    bunshi %= mod
    temp = bunbo * bunshi
    temp %= mod
    temp *= pow(25, i, mod)
    temp %= mod
    temp *= pow(26, k - i, mod)
    temp %= mod
    ans += temp
    ans %= mod

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
s = input()
mod = 10 ** 9 + 7

nagasa = len(s)

n = nagasa + k

N = n + 5
bikkuri = [0 for i in range(N)]
bikkuri[0] = 1
gyaku = [0 for i in range(N)]
gyaku[0] = 1
for i in range(1, N):
    bikkuri[i] = (i * bikkuri[i - 1]) % mod
    gyaku[i] = pow(bikkuri[i], mod - 2, mod)


def comb(n, r):
    if r < 0 or n - r < 0:
        return 0
    return (bikkuri[n] * gyaku[r] * gyaku[n - r]) % mod


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

print(ans)


Fixed submission:
k = int(input())
s = list(input())
mod = 10 ** 9 + 7

nagasa = len(s)


ans = pow(26, k, mod)
bunbo = 1
bunshi = 1
for i in range(1, k + 1):
    bunbo *= nagasa - 1 + i
    bunshi *= pow(i, mod - 2, mod)
    bunbo %= mod
    bunshi %= mod
    temp = bunbo * bunshi
    temp %= mod
    temp *= pow(25, i, mod)
    temp %= mod
    temp *= pow(26, k - i, mod)
    temp %= mod
    ans += temp
    ans %= mod

print(ans)