Buggy python submission (verdict: Time Limit Exceeded):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    
    k = int(input())
    s = input()
    n = len(s)
    mod = 10**9+7
    p25 = [0]*(k+1)
    p26 = [0]*(k+1)
    c = [0]*(k+1)

    p25[0], p26[0] = 1, 1
    c[0]= 1
    for i in range(1, k+1):
        p25[i] = p25[i-1]*25
        p25[i] %= mod
        p26[i] = p26[i-1]*26
        p26[i] %= mod
        c[i] = (n+i-1)*c[i-1]
        c[i] *= pow(i, mod-2, mod)
        c[i] %= mod
    p25.reverse()
    c.reverse()
    ans = 0
    for i in range(k+1):
        tmp = p25[i]*p26[i]*c[i]
        tmp %= mod
        ans += tmp
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    
    k = int(input())
    s = input()
    n = len(s)
    mod = 10**9+7
    p25 = [0]*(k+1)
    p26 = [0]*(k+1)
    c = [0]*(k+1)

    p25[0], p26[0] = 1, 1
    c[0]= 1
    for i in range(1, k+1):
        p25[i] = p25[i-1]*25
        p25[i] %= mod
        p26[i] = p26[i-1]*26
        p26[i] %= mod
        c[i] = (n+i-1)*c[i-1]
        c[i] *= pow(i, mod-2, mod)
        c[i] %= mod
    p25.reverse()
    c.reverse()
    ans = 0
    for i in range(k+1):
        tmp = p25[i]*p26[i]*c[i]
        tmp %= mod
        ans += tmp
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
class Combination():
    def __init__(self, n, mod=10**9+7):
        self.mod = mod
        self.fac = [1]*(n+1)
        for i in range(1,n+1):
            self.fac[i] = self.fac[i-1] * i % self.mod
        self.invfac = [1]*(n+1)
        self.invfac[n] = pow(self.fac[n], self.mod - 2, self.mod)
        for i in range(n-1, 0, -1):
            self.invfac[i] = self.invfac[i+1] * (i+1) % self.mod

    def combination(self, n, r):
        return self.fac[n] * self.invfac[r] % self.mod * self.invfac[n-r] % self.mod

    def permutation(self, n, r):
        return self.factorial(n) * self.invfactorial(n-r) % self.mod

    def factorial(self, i):
        return self.fac[i]

    def invfactorial(self, i):
        return self.invfac[i]


def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    
    k = int(input())
    s = input()
    n = len(s)
    mod = 10**9+7
    c = Combination(n+k)
    p25 = [0]*(k+1)
    p26 = [0]*(k+1)
    p25[0], p26[0] = 1, 1
    for i in range(1, k+1):
        p25[i] = p25[i-1]*25
        p25[i] %= mod
        p26[i] = p26[i-1]*26
        p26[i] %= mod

    ans = 0
    for i in range(k+1):
        tmp = c.combination(n+k-i-1, n-1)
        tmp *= p25[k-i]
        tmp %= mod
        tmp *= p26[i]
        tmp %= mod
        ans += tmp
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    
    k = int(input())
    s = input()
    n = len(s)
    mod = 10**9+7
    p25 = [0]*(k+1)
    p26 = [0]*(k+1)
    c = [0]*(k+1)

    p25[0], p26[0] = 1, 1
    c[0]= 1
    for i in range(1, k+1):
        p25[i] = p25[i-1]*25
        p25[i] %= mod
        p26[i] = p26[i-1]*26
        p26[i] %= mod
        c[i] = (n+i-1)*c[i-1]
        c[i] *= pow(i, mod-2, mod)
        c[i] %= mod
    p25.reverse()
    c.reverse()
    ans = 0
    for i in range(k+1):
        tmp = p25[i]*p26[i]*c[i]
        tmp %= mod
        ans += tmp
        ans %= mod
    print(ans)


if __name__ == '__main__':
    main()