Problem:


Score : 400 points

Problem Statement

You are given positive integers N and M.

How many sequences a of length N consisting of positive integers satisfy a_1 \times a_2 \times ... \times a_N = M? Find the count modulo 10^9+7.

Here, two sequences a' and a'' are considered different when there exists some i such that a_i' \neq a_i''.

Constraints

All values in input are integers.

1 \leq N \leq 10^5

1 \leq M \leq 10^9

Input

Input is given from Standard Input in the following format:

N M

Output

Print the number of the sequences consisting of positive integers that satisfy the condition, modulo 10^9 + 7.

Sample Input 1

2 6

Sample Output 1

4

Four sequences satisfy the condition: \{a_1, a_2\} = \{1, 6\}, \{2, 3\}, \{3, 2\} and \{6, 1\}.

Sample Input 2

3 12

Sample Output 2

18

Sample Input 3

100000 1000000000

Sample Output 3

957870001



Sample input:
2 6


Sample output:
4

Submission status: Runtime Error

Solution code:
import numpy as np
from operator import mul
from functools import reduce
import math

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

factor = {}
n = M
f = 2
while n > 1:
    if n%f == 0:
        if not f in factor:
            factor[f] = 1
        else:
            factor[f] += 1
        n = n//f
        continue
    f += 1
#print(factor)

max_v = max(factor.values())

def comb(n,r):
    nk = reduce(mul, range(n, n-r, -1), 1)
    rk = reduce(mul, range(1, r+1), 1)
    return nk//rk

ans = 1
for i in factor.values():
    ans *= math.factorial(i+N-1)//(math.factorial(i)*math.factorial(N-1))
    #ans *= comb(i+N-1, N-1)
print(int(ans)%(10**9+7))

Submission status: Runtime Error

Solution code:
import numpy as np
from operator import mul
from functools import reduce

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

factor = {}
n = M
f = 2
while n > 1:
    if n%f == 0:
        if not f in factor:
            factor[f] = 1
        else:
            factor[f] += 1
        n = n//f
        continue
    f += 1
#print(factor)

max_v = max(factor.values())

def comb(n,r):
    nk = reduce(mul, range(n, n-r, -1), 1)
    rk = reduce(mul, range(1, r+1), 1)
    return nk//rk

ans = 1
for i in factor.values():
    ans *= comb(i+N-1, N-1)
print(int(ans)%(10**9+7))

Submission status: Runtime Error

Solution code:
from collections import Counter
N,M = map(int,input().split())
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a = 1
  b = 1
  c = 1
  for i in range(1,n+1):
    a = (a*i)%p
  for i in range(1,k+1):
    b = (b*i)%p
  for i in range(1,n-k+1):
    c = (c*i)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
mod = 10**9 + 7
num = prime_factorize(M)
numc = Counter(num)
nums = list(numc.values())
H = [0 for i in range(max(nums)+1)]
for i in set(nums):
    H[i] = comb(N+i-1,i,mod)
ans = 1
for i in nums:
    count = H[i]
    ans = (ans*count)%mod
print(ans)

Submission status: Runtime Error

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
N,M = map(int,input().split())
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a = 1
  b = 1
  c = 1
  for i in range(1,n+1):
    a = (a*i)%p
  for i in range(1,k+1):
    b = (b*i)%p
  for i in range(1,n-k+1):
    c = (c*i)%p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
def prime_dict(n):
    a = {}
    if n%2 == 0:
        a[2] = 1
        n//=2
    while n%2 == 0:
        a[2] += 1
        n //= 2
    f = 3
    while f*f <= n:
        if n%f == 0:
            if f not in a:
                a[f] = 1
            else:
                a[f] += 1
        else:
            f += 2
    if n!= 1:
        a[n] = 1
    return a
mod = 10**9 + 7
dicta = prime_dict(M)
nums = list(dicta.values())
H = [0 for i in range(max(nums)+1)]
for i in set(nums):
    H[i] = comb(N+i-1,i,mod)
ans = 1
for i in nums:
    count = H[i]
    ans = (ans*count)%mod
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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

factor = {}
n = M
f = 2
while n > 1:
    if n%f == 0:
        if not f in factor:
            factor[f] = 1
        else:
            factor[f] += 1
        n = n//f
        continue
    f += 1
#print(factor)

jlen = max(factor.values())
a = list(factor.values())
dp = np.ones((N+1, jlen+1))
for i in range(N):
    for j in range(1,jlen+1):
        
        if j == 1:
            dp[i+1,j] = i+2

        else:
            dp[i+1,j] = dp[i+1,j-1] + dp[i][j]# - dp[i,j-1-1]

d = dp[N-1]

ans = 1
for i in a:
    ans *= d[i]
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
import numpy as np

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

factor = {}
n = M
f = 2
while n > 1:
    if n%f == 0:
        if not f in factor:
            factor[f] = 1
        else:
            factor[f] += 1
        n = n//f
        continue
    f += 1
print(factor)

jlen = max(factor.values())
a = list(factor.values())
dp = np.ones((N+1, jlen+1))
for i in range(N):
    for j in range(1,jlen+1):
        
        if j == 1:
            dp[i+1,j] = i+2

        else:
            dp[i+1,j] = dp[i+1,j-1] + dp[i][j]# - dp[i,j-1-1]

d = dp[N-1]

ans = 1
for i in a:
    ans *= d[i]
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
from math import floor, sqrt
from collections import defaultdict
def factors(n):
    d = defaultdict(int)
    for i in range(2,floor(sqrt(n))+1):
        while n % i == 0:
            n //= i
            d[i] += 1
        if n == 1:
            break
    if n != 1:
        d[n] += 1
    return d
def inv(x, mod):
    k = mod - 2
    ret = 1
    while k > 0:
        if k&1:
            ret = (ret*x) % mod
        x = (x*x) % mod
        k >>= 1
    return ret
N, M = map(int,input().split())
mod = 10**9+7
dic = factors(M)
K = len(dic)
SIZE = N+max(dic.values())
fact = [None]*(SIZE+1)
finv = [None]*(SIZE+1)
fact[0] = 1
for i in range(1,SIZE+1):
    fact[i] = (fact[i-1]*i) % mod
finv[SIZE] = inv(fact[SIZE], mod=mod)
for i in range(SIZE, 0, -1):
    finv[i-1] = (finv[i]*i) % mod
def comb(n,k):
    tmp = (finv[k]*finv[n-k]) % mod
    return (fact[n]*tmp) % mod
ans = 1
for p in dic:
    ans = (ans*comb(dic[p]+N-1, dic[p])) % mod
print(ans)

Submission status: Runtime Error

Solution code:
from math import floor, sqrt
from collections import defaultdict
def factors(n):
    d = defaultdict(int)
    for i in range(2,floor(sqrt(n))+1):
        while n % i == 0:
            n //= i
            d[i] += 1
        if n == 1:
            break
    if n != 1:
        d[n] += 1
    return d
def inv(x, mod):
    k = mod - 2
    ret = 1
    while k > 0:
        if k&1:
            ret = (ret*x) % mod
        x = (x*x) % mod
        k //= 2
    return ret
N, M = map(int,input().split())
mod = 10**9+7
dic = factors(M)
K = len(dic)
SIZE = N+max(dic.values())
fact = [None]*(SIZE+1)
finv = [None]*(SIZE+1)
fact[0] = 1
for i in range(1,SIZE+1):
    fact[i] = (fact[i-1]*i) % mod
finv[SIZE] = inv(fact[SIZE], mod=mod)
for i in range(SIZE, 0, -1):
    finv[i-1] = (finv[i]*i) % mod
def comb(n,k):
    tmp = (finv[k]*finv[n-k]) % mod
    return (fact[n]*tmp) % mod
ans = 1
for p in dic:
    ans = (ans*comb(dic[p]+N-1, dic[p])) % mod
print(ans)

Submission status: Runtime Error

Solution code:
class Solution:

    def solve(self, N: int, M: int) -> int:

        mod = 10**9+7
        INT_MAX = 10**9

        # calculate {m+n}C{n}

        def egcd(a, b):
            if a == 0:
                return b, 0, 1
            else:
                g, y, x = egcd(b % a, a)
                return g, x - (b // a) * y, y

        def modinv(a, m):
            g, x, y = egcd(a, m)
            if g != 1:
                raise Exception('modular inverse does not exist')
            else:
                return x % m

        def combination(n: int, r: int, mod: int = 10**9+7) -> int:
            r = min(r, n-r)
            res = 1
            for i in range(r):
                res = res * (n-i) * modinv(i+1, mod) % mod
            return res

        # prime list

        isPrime = [True] * (INT_MAX + 1)
        isPrime[0], isPrime[1] = False, False
        primes = []

        for i in range(2, len(isPrime)):
            if isPrime[i] == True:
                primes.append(i)
                for j in range(2 * i, len(isPrime), i):
                    isPrime[j] = False

        # solve

        m = M
        answer = 1
        factors = {}
        while m > 1:
            for p in primes:
                factors[p] = 0

                while m % p == 0:
                    m //= p
                    factors[p] += 1

                if factors[p] > 0:
                    answer *= combination(N + factors[p] - 1, N - 1, mod=mod)
                    answer %= mod

        return answer


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(N, M))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def primeFactors(n):
    res = []
    while n%2==0:
        res.append(2)
        n //= 2
    x = 3
    while n>1 and n>=x*x:
        while n%x==0:
            res.append(x)
            n //= x
        x += 2
    if n>1:
        res.append(n)
    return res

class BiCoeff(object):
    def __init__(self, MAX, m):
        super(BiCoeff, self).__init__()
        fac = [0]*MAX
        finv = [0]*MAX
        inv = [0]*MAX

        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2,MAX):
            fac[i] = (fac[i-1]*i)%m
            inv[i] = m - (inv[m%i] * (m//i))%m
            finv[i] = (finv[i-1] * inv[i])%m

        self.MAX = MAX
        self.m = m
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def calc(self,n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return (self.fac[n] * (self.finv[k]*self.finv[n-k])%self.m)%self.m

from collections import defaultdict
MOD = 10**9 + 7
n,m = map(int, input().split())

bicoeff = BiCoeff(3*n,MOD)

d = defaultdict(int)
for p in primeFactors(m):
    d[p] += 1

res = 1
for v in d.values():
    res *= bicoeff.calc(n-1+v,n-1)
    res %= MOD
print(res)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def primeFactors(n):
    res = []
    while n%2==0:
        res.append(2)
        n //= 2
    x = 3
    while n>1 and n>=x*x:
        while n%x==0:
            res.append(x)
            n //= x
        x += 2
    if n>1:
        res.append(n)
    return res

class BiCoeff(object):
    def __init__(self, MAX, m):
        super(BiCoeff, self).__init__()
        fac = [0]*MAX
        finv = [0]*MAX
        inv = [0]*MAX

        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2,MAX):
            fac[i] = (fac[i-1]*i)%m
            inv[i] = m - (inv[m%i] * (m//i))%m
            finv[i] = (finv[i-1] * inv[i])%m

        self.MAX = MAX
        self.m = m
        self.fac = fac
        self.finv = finv
        self.inv = inv

    def calc(self,n,k):
        if n<k:
            return 0
        if n<0 or k<0:
            return 0
        return (self.fac[n] * (self.finv[k]*self.finv[n-k])%self.m)%self.m

from collections import defaultdict
MOD = 10**9 + 7
n,m = map(int, input().split())

bicoeff = BiCoeff(2*n,MOD)

d = defaultdict(int)
for p in primeFactors(m):
    d[p] += 1

res = 1
for v in d.values():
    res *= bicoeff.calc(n-1+v,n-1)
    res %= MOD
print(res)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict
import math
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
d = defaultdict(int)
M_ = M
MOD = 10 ** 9 + 7

if M == 1:
    print(1)
    exit()

while True:
    for i in range(2, int(M_ ** 0.5) + 1):
        if M_ % i == 0:
            M_ //= i
            d[i] += 1
            break
    else:
        if M_ != 1:
            d[M_] += 1
        break

maxi = max(d.values())
fact = [0] * (maxi + N + 1)
p = 1

def nCr(n, r):
    if r > n - r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    ret = 1
    for i in range(r+1):
        ret *= (n-(i-1))
        ret //= i

    return ret

ans = 1
nCr_d = {}
for key, val in d.items():
    if (val+N-1, N-1) not in nCr_d:
        nCr_d[(val+N-1, N-1)] = nCr(val+N-1, N-1)
    ans = (ans * nCr_d[(val+N-1, N-1)]) % MOD

print(ans)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict
import math
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
d = defaultdict(int)
M_ = M
MOD = 10 ** 9 + 7
while True:
    for i in range(2, int(M_ ** 0.5) + 1):
        if M_ % i == 0:
            M_ //= i
            d[i] += 1
            break
    else:
        if M_ != 1:
            d[M_] += 1
        break

maxi = max(d.values())
fact = [0] * (maxi + N + 1)
p = 1

def nCr(n, r):
    if r > n - r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    ret = 1
    for i in range(n, n-r, -1):
        ret *= i
    for i in range(2, r+1):
        ret //= i

    return ret
    # return (math.factorial(n) // math.factorial(n - r) // math.factorial(r)) % MOD

ans = 1
nCr_d = {}
for key, val in d.items():
    if (val+N-1, N-1) not in nCr_d:
        nCr_d[(val+N-1, N-1)] = nCr(val+N-1, N-1)
    ans = (ans * nCr_d[(val+N-1, N-1)]) % MOD

print(ans)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict
import math
input = sys.stdin.readline
N, M = [int(x) for x in input().strip().split()]
d = defaultdict(int)
M_ = M
MOD = 10 ** 9 + 7
while True:
    for i in range(2, int(M_ ** 0.5) + 1):
        if M_ % i == 0:
            M_ //= i
            d[i] += 1
            break
    else:
        if M_ != 1:
            d[M_] += 1
        break

maxi = max(d.values())
fact = [0] * (maxi + N + 1)
p = 1

def nCr(n, r):
    if r > n - r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    return math.factorial(n) // math.factorial(n - r) // math.factorial(r)

ans = 1
nCr_d = {}
for key, val in d.items():
    if (val+N-1, N-1) not in nCr_d:
        nCr_d[(val+N-1, N-1)] = nCr(val+N-1, N-1)
    ans = (ans * nCr_d[(val+N-1, N-1)]) % MOD

print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
MOD = 10**9+7


# 繰り返し二乗法
# 普通の pow() より高速
def pow2(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans


# 逆元
# a^{-1} mod を計算する
def mod_inv(a, m):
    return pow2(a, m-2, m)


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)
    # 10C3 = (10*9*8)/(3*2*1)
    # 10*9*8 -> ans_mul
    # 3*2*1 -> ans_div
    ans_mul = 1
    ans_div = 1
    for i in range(b):
        ans_mul *= a - i
        ans_div *= i + 1
        ans_mul %= MOD
        ans_div %= MOD
    # ans_mul / ans_div をやりたい
    # ans_div の逆元を使って求める
    ans = ans_mul * mod_inv(ans_div, MOD)
    return ans


# M を素因数分解
m_nokori = M
ans = 1
for i in range(2, M+1):
    if m_nokori == 1:
        break
    cnt = 0
    while m_nokori % i == 0:
        cnt += 1
        m_nokori //= i
    # cnt が 2^X とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:
from math import sqrt
from scipy.special import comb

n, m = map(int, input().split())
mod = 10 ** 9 + 7


def sieve(x):
    primes = []
    li = list(range(2, x + 1))

    while li[0] <= sqrt(x):
        p = li[0]
        primes.append(p)
        li = [e for e in li if e % p != 0]

    primes += li
    return primes


def prime_fact(x):
    primes = sieve(int(sqrt(x)) + 1)
    d = {}

    for p in primes:
        cnt = 0
        while x % p == 0:
            x //= p
            cnt += 1

        if cnt:
            d[p] = cnt

    if x != 1:
        d[x] = 1

    return d


pf = prime_fact(m)
ans = 1
for v in pf.values():
    ans *= comb(v + n - 1, v, exact=True)
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPI(i,f,n) for(int i=(f);i<(n);++i)
using namespace std;
typedef long long ll;

const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector< ll > frac;

int main() {
  // 前処理
  COMinit();

  ll N,M;
  cin >> N >> M;
  // Mの素因数分解
  ll mm = M;
  for (ll i=2; i*i<=mm; ++i ) {
    ll cnt = 0;
    while ( mm % i == 0 ) {
      cnt++;
      mm /= i;
    }
    if (cnt != 0) frac.emplace_back( cnt );
  }
  if (mm !=1 )  frac.emplace_back( 1 );
  ll ans = 1;
  for ( auto x : frac ) {
    ans = (ans * COM( x + N-1, x )) % MOD;
  }
  cout << (ans%MOD) << endl;
}

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 = 2*10**5+5
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 )

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


n,m=map(int,input().split())
A=factorization(m)
if m==1:
  print(1)
else:
  ans=1
  for i in range(len(A)):
    ans=ans*cmb(n+A[i][1]-1,A[i][1],mod)
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
import math
from collections import Counter

n, m = map(int, input().split())
mod = 10**9 + 7

K = 20
fact = [0] * (n+1+K)
ifact = [0] * (n+1+K)
fact[0] = 1
for i in range(1,n+1+K):
    fact[i] = fact[i-1] * i % mod
ifact[n+K] = pow(fact[n+K], mod-2, mod)
for i in reversed(range(1,n+1+K)):
    ifact[i-1] = ifact[i] * i % mod

def comb(n, k):
    return fact[n] * ifact[n-k] % mod * ifact[k] % mod

def getprime(n):
    primes = []
    i = 2
    while n >= i * i:
        while n % i == 0:
            n //= i
            primes.append(i)
        i += 1
    if n != 1:
        primes.append(n)
    return primes

ans = 1
counter = Counter(getprime(m))
for k in counter.values():
    ans *= comb(n+k-1, k)
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
import math
from collections import Counter

n, m = map(int, input().split())
mod = 10**9 + 7

K = 20
fact = [0] * (n+1+K)
ifact = [0] * (n+1+K)
fact[0] = 1
for i in range(1,n+1+K):
    fact[i] = fact[i-1] * i % mod
ifact[n+K] = pow(fact[n+K], mod-2, mod)
for i in reversed(range(1,n+1+K)):
    ifact[i-1] = ifact[i] * i % mod

def comb(n, k):
    return fact[n] * ifact[n-k] % mod * ifact[k] % mod

def getprime(n):
    primes = []
    i = 2
    while n > i * i:
        while n % i == 0:
            n //= i
            primes.append(i)
        i += 1
    if n != 1:
        primes.append(n)
    return primes

ans = 1
counter = Counter(getprime(m))
for k in counter.values():
    ans *= comb(n+k-1, k)
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
import math
from collections import Counter

n, m = map(int, input().split())
mod = 10**9 + 7

fact = [0] * (n+21)
ifact = [0] * (n+21)
fact[0] = 1
for i in range(1,n+21):
    fact[i] = fact[i-1] * i % mod
ifact[n+20] = pow(fact[n+20], mod-2, mod)
for i in reversed(range(1,n+21)):
    ifact[i-1] = ifact[i] * i % mod

def comb(n, k):
    return fact[n] * ifact[n-k] % mod * ifact[k] % mod

def getprime(n):
    primes = []
    i = 2
    while n > i * i:
        while n % i == 0:
            n //= i
            primes.append(i)
        i += 1
    if n != 1:
        primes.append(n)
    return primes

ans = 1
counter = Counter(getprime(m))
print(counter)
for k in counter.values():
    print(n+k-1, k, comb(n+k-1, k))
    ans *= comb(n+k-1, k)
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
 
N,M=map(int,input().split())
primes0=prime_factorize(M)
keys=list(set(primes0))
primes={}
for i in range(len(keys)):
  k=keys[i]
  primes[k]=0
  for j in range(len(primes0)):
    if primes0[j]==k:
      primes[k]+=1
 
def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    if n < k or n < 0 or k < 0:
        return 0
    else: 
        k = min(k, n-k)
        return fac[n] * ifac[k] * ifac[n-k] % mod
 
def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
 
mod=10**9+7
fac,ifac=make_tables(mod,N*3)
ans=1
for i in range(len(keys)):
  ans*=cmb(N+primes[keys[i]]-1, primes[keys[i]], mod, fac, ifac)
  ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
 
N,M=map(int,input().split())
if M==1:
  print(1)
else:
  primes0=prime_factorize(M)
  keys=list(set(primes0))
  primes={}
  for i in range(len(keys)):
    k=keys[i]
    primes[k]=0
    for j in range(len(primes0)):
      if primes0[j]==k:
        primes[k]+=1

  def cmb(n, k, mod, fac, ifac): #calc nCk under mod
      if n < k or n < 0 or k < 0:
          return 0
      else: 
          k = min(k, n-k)
          return fac[n] * ifac[k] * ifac[n-k] % mod

  def make_tables(mod, n): #Make factorial and inverse tables under mod 
      fac = [1, 1] # factorial table
      ifac = [1, 1] #factorial of inverse table
      inverse = [0, 1] #inverse

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

  mod=10**9+7
  fac,ifac = make_tables(mod,N*2)
  ans=1
  for i in range(len(keys)):
    ans*=cmb(N+primes[keys[i]]-1, primes[keys[i]], mod, fac, ifac)
    ans%=mod
  print(ans)

Submission status: Runtime Error

Solution code:
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

N,M=map(int,input().split())
primes0=prime_factorize(M)
keys=list(set(primes0))
primes={}
for i in range(len(keys)):
  k=keys[i]
  primes[k]=0
  for j in range(len(primes0)):
    if primes0[j]==k:
      primes[k]+=1

def cmb(n, k, mod, fac, ifac): #calc nCk under mod
    if n < k or n < 0 or k < 0:
        return 0
    else: 
        k = min(k, n-k)
        return fac[n] * ifac[k] * ifac[n-k] % mod
 
def make_tables(mod, n): #Make factorial and inverse tables under mod 
    fac = [1, 1] # factorial table
    ifac = [1, 1] #factorial of inverse table
    inverse = [0, 1] #inverse
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac

mod=10**9+7
fac,ifac = make_tables(mod,N*2)
ans=1
for i in range(len(keys)):
  ans*=cmb(N+primes[keys[i]]-1, primes[keys[i]], mod, fac, ifac)
  ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
import math
import sys
input = sys.stdin.readline

def main():
    N,M = map(int,input().split())
    div_list = []
    d = 2
    ans = 1
    MOD = 10**9+7
    while M != 1:
        count = 0
        while M%d == 0:
            count += 1
            M //= d
        div_list.append(count)
        d += 1
    _m = max(div_list)
    fac = [1]
    for i in range(1,_m+N):
        fac.append(fac[-1]*i%MOD)
    use = max(N-1,_m)
    
    def power(x,y):
        if y == 0:return 1
        elif y == 1:return x%MOD
        elif y%2 == 0:return power(x,y//2)**2%MOD
        else:return power(x,y//2)**2*x%MOD
        
    invfac = [0 for _ in range(use+1)]
    invfac[-1] = power(fac[use],MOD-2)
    for i in range(use-1,-1,-1):
        invfac[i] = invfac[i+1]*(i+1)%MOD
        
    for i in div_list:
        a = fac[i+N-1]
        b = invfac[i]
        c = invfac[N-1]
        ans *= (a*b*c)%MOD
        
    print(ans%MOD)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#  Copyright: this code was written at 2020. for AtCoder by Silviase

# Lib
import math


def mod_comb(n1, n2):
    return fac_tab[n1] * fac_tab[n2].inv() * fac_tab[n1 - n2].inv()


class ModInt:
    MOD = int(1e9 + 7)

    # int (演算子) ModIntはダメ

    def __init__(self, x):
        self.x = x % self.MOD

    # ModInt(op){ModInt, Int}に対応している
    def __add__(self, other):
        return self.__class__((self.x + other.x) % self.MOD) if isinstance(other, ModInt) else self.__class__(
            (self.x + other) % self.MOD)

    def __sub__(self, other):
        return self.__class__((self.x - other.x) % self.MOD) if isinstance(other, ModInt) else self.__class__(
            (self.x - other) % self.MOD)

    def __mul__(self, other):
        return self.__class__((self.x * other.x) % self.MOD) if isinstance(other, ModInt) else self.__class__(
            (self.x * other) % self.MOD)

    # 逆元をかけることに等しい
    def __truediv__(self, other):
        return self.__mul__(other.inv()) if isinstance(other, ModInt) else self.__mul__(ModInt(other).inv())

    # powは第三引数まで指定することで最適化される
    def __pow__(self, power, Modulo=MOD):
        return self.__class__(pow(self.x, power, Modulo))

    def _fac(self):
        mx = ModInt(1)
        for _i in range(self.x, 1, -1):
            mx = mx * _i
        return mx

    # mi_C_kをModInt型で返す
    def _comb(self, _k):
        if isinstance(_k, ModInt):
            if self < _k:
                return ModInt(0)
            return self._fac() * _k._fac().inv() * (self - _k)._fac().inv()
        else:
            if self < _k:
                return ModInt(0)
            return self._fac() * ModInt(_k)._fac().inv() * ModInt(self.x - _k)._fac().inv()

    def inv(self):
        return self.__pow__(self.MOD - 2)

    def __str__(self):
        return str(self.x)

    def __lt__(self, other):
        return self.x < other.x if isinstance(other, ModInt) else self.x < other


# Lib

# Code
# 素因数分解はルートまで,それ以上で残ったら一つ追加していけばいいことがわかる
# 各素因数についてx個あるのであれば(n+x)Cxであればいいことがわかる
# factに関しては毎回計算すると爆発するのでtableを持っておけばいいことがわかる
n, k = map(int, input().split())
result = ModInt(1)
fac_tab = [ModInt(1)] * (2 * n)
for i in range(1, len(fac_tab)):
    fac_tab[i] = fac_tab[i - 1] * i

for i in range(2, int(math.sqrt(k) + 1)):
    tmp_cnt = 0
    while k % i == 0:
        k /= i
        tmp_cnt += 1
    result = result * mod_comb(n + tmp_cnt - 1, tmp_cnt)
    # print(result)

if k != 1:
    result = result * (n + 1)
print(str(result))

Submission status: Runtime Error

Solution code:
import math
from collections import Counter
n, m = map(int, input().split())

prime_count = Counter()
for i in range(2, math.ceil(math.sqrt(m))+1):
    while m % i == 0:
        m /= i
        prime_count[i] += 1
if m > 1:
    prime_count[int(m)] += 1

b_max = max([i for i in prime_count.values()])

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
Mod = 10**9+7
def COMinit():
    #N_C_kのN
    for i in range(2, n+b_max+1):
        fac.append(fac[-1]*i%Mod)
        inv.append((-inv[Mod%i] * (Mod//i)) % Mod)
        finv.append(finv[-1] * inv[-1] % Mod)


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

ans = 1
COMinit()
for b in prime_count.values():
    ans *= COM(n+b-1, n-1)
    ans %= Mod 

print(ans)

Submission status: Runtime Error

Solution code:
import math
from collections import Counter
n, m = map(int, input().split())

prime_count = Counter()
for i in range(2, math.ceil(math.sqrt(m))+1):
    while m % i == 0:
        m /= i
        prime_count[i] += 1
if m > 1:
    prime_count[int(m)] += 1

b_max = max([i for i in prime_count.values()])

fac = [1, 1]
finv = [1, 1]
inv = [0, 1]
Mod = 10**9+7
def COMinit():
    #N_C_kのN
    for i in range(2, n+b_max):
        fac.append(fac[-1]*i%Mod)
        inv.append((-inv[Mod%i] * (Mod//i)) % Mod)
        finv.append(finv[-1] * inv[-1] % Mod)


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

ans = 1
COMinit()
for b in prime_count.values():
    ans *= COM(n+b-1, n-1)
    ans %= Mod 

print(ans)

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce
from collections import Counter

def cmb(n, r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def prime_factor(n):
    ass = []
    for i in range(2, int(n ** 0.5) + 1):
        while n  % i == 0:
            ass.append(i)
            n = n // i
    if n != i:
        ass.append(n)
    return ass

def main():
    N, M = map(int, input().split())
    num_list = prime_factor(M)
    MOD = 10 ** 9 + 7
    C = Counter(num_list)
    ans = 1
    for i, j in C.items():
        if i == 1:
            continue
        ans *= cmb(j+N-1, j)
        ans %= MOD
    print(ans)



if __name__ == "__main__":
    main()