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:
memo = [{} for _ in range(30)]
MOD = 10 ** 9 + 7

def combo(p,q):
    if p == 0:
        return 1
    elif q == 0 or q == p:
        return 1
    elif q in memo[p]:
        return memo[p][q]
    else:
        ret = (combo(p-1,q-1) + combo(p-1,q)) % MOD
        memo[p][q] = ret
        return ret

#print(combo(2,1))

n,m = map(int,input().split())
fac = [0] * (m+1)
mm = m
for i in range(2,m+1):
    while mm % i == 0:
        mm = mm // i
        fac[i] += 1
        #print(mm,fac)

count = 1

for i in range(2,m+1):
    if fac[i] >= 1:
        count = (count * combo(fac[i]+n-1,fac[i])) % MOD
    #print(count)
    
print(count)

Submission status: Runtime Error

Solution code:
MOD = 10 ** 9 +7

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

div = []

for i in range(1,int(m ** (1/2)) + 1):
    if m % i == 0:
        div.append(i)
        div.append(m//i)

memo = [{} for _ in range(m+1)]
def count(k,n):
    if n == 1:
        return 1
    if n in memo[k]:
        return memo[k][n]
    ret = 0
    for x in div:
        if k % x == 0:
            ret = (ret + count(k//x,n-1)) % MOD
    memo[k][n] = ret
    return ret

print(count(m,n))

Submission status: Runtime Error

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

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

mf = factorize(m)
from collections import Counter

c = Counter(mf)
ans = 1
from scipy.misc import comb
for i in list(c.values()):
  ans*= comb((i+(n-1)),i)

print(round(ans)%mod)

Submission status: Runtime Error

Solution code:
import sys
import math
def input():
    return sys.stdin.readline()[:-1]

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if n!=1:
        factor.append(n)
    return factor

n,m=map(int,input().split())
mod=10**9+7
li=trial_division(m)
tmp=li[0]
countli=[]
count=1
for i in range(1,len(li)):
    if tmp!=li[i]:
        countli.append(count)
        count=1
    else:
        count+=1
    tmp=li[i]
countli.append(count)
ans=1
for i in range(len(countli)):
    ans*=combinations_count(countli[i]+n-1,countli[i])
print(ans%mod)

Submission status: Runtime Error

Solution code:
import sys
import math
def input():
    return sys.stdin.readline()[:-1]

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def trial_division(n):
    factor = []
    tmp = int(math.sqrt(n)) + 1
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            factor.append(num)
    if n!=1:
        factor.append(n)
    return factor

n,m=map(int,input().split())
mod=10**9+7
li=trial_division(m)
tmp=li[0]
countli=[]
count=1
for i in range(1,len(li)):
    if tmp!=li[i]:
        countli.append(count)
        count=1
    else:
        count+=1
    tmp=li[i]
countli.append(count)
ans=1
for i in range(len(countli)):
    ans*=combinations_count(countli[i]+n-1,countli[i])
print(ans)

Submission status: Runtime Error

Solution code:
import math
import collections
def main():
    N, M = map(int, input().split())
    mod = pow(10, 9) + 7

    ps = factorize(M)
    K = max(ps.values())

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

    ref = powerquick(pow1[-1], mod-2, mod) # ((N+K)!)^-1 % mod
    invpow1 = [ref]
    for i in range(N+K, 0, -1):
        invpow1.append(invpow1[-1]*i % mod)
    invpow1 = invpow1[::-1]

    # for i in range(len(pow1)):
    #     print(pow1[i]*invpow1[i] % mod)
    # print(invpow1)
    # print(pow1)

    ans = 1
    for p in ps:
        l = ps[p]
        v = pow1[l+N-1]*invpow1[N-1]*invpow1[l] % mod
        ans = (ans * v) % mod

    # print(factorize(35))
    return ans
    # if M == 1: return 1

def powerquick(x, y, mod):
    if y == 0: return 1
    if y == 1: return x % mod
    if y % 2 == 0:
        return pow(powerquick(x, y//2, mod), 2) % mod
    else:
        return pow(powerquick(x, y//2, mod), 2) * x % mod


def factorize(n):
    ps = collections.defaultdict(int)
    if n == 1: return ps
    if isPrime(n):
        ps[n] += 1
        return ps

    p = 1
    while n > 1:
        while not isPrime(p):
            p += 1
        count = 0
        while n % p == 0:
            count += 1
            n = n // p
        if count > 0:
            ps[p] = count
            if isPrime(n):
                ps[n] += 1
                return ps
        p += 1
    return ps

def isPrime(n):
    if n == 1: return False
    for i in range(2, int(math.sqrt(n)+1)):
        if n % i == 0:
            return False
    return True

if __name__ == '__main__':
    print(main())

Submission status: Runtime Error

Solution code:
from sympy import factorint

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

mod = 10**9+7

def comb(n, r) :
    if n - r < r: r = n - r
    if r < 0: return 0
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

vv = factorint(m).values()
ans = 1
for v in vv :
    a = 0
    for i in range(min(n, v)) :
        a += comb(n, i+1)*comb(v-1, i)
    ans *= a
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
import copy
import math
import collections

inf = (10 ** 9) + 7
n, m = map(int, input().split())
prime_dict = {}
m_copy = copy.deepcopy(m)
while (m_copy % 2 == 0):
    m_copy = int(m_copy // 2)
    if 2 not in prime_dict.keys():
        prime_dict[2] = 1
    else:
        prime_dict[2] += 1
for i in range(3, int(math.sqrt(m)) + 1, 2):
    while (m_copy % i == 0):
        m_copy = int(m_copy // i)
        if i not in prime_dict.keys():
            prime_dict[i] = 1
        else:
            prime_dict[i] += 1
if m_copy != 1:
    if m_copy not in prime_dict.keys():
        prime_dict[m_copy] = 1
    else:
        prime_dict[m_copy] += 1
b = list(prime_dict.values())
ans = 1
for bb in b:
    ans *= dp[n - 1][bb]
    ans = ans % inf
print(ans)

Submission status: Runtime Error

Solution code:
import copy
inf = (10 ** 9) + 7
n, m = map(int, input().split())
prime_list = []
m_copy = copy.deepcopy(m)
while (m_copy % 2 == 0):
    m_copy = int(m_copy // 2)
    prime_list.append(2)
for i in range(3, int(math.sqrt(m)) + 1, 2):
    while (m_copy % i == 0):
        m_copy = int(m_copy // i)
        prime_list.append(i)
if m_copy != 1:
    prime_list.append(m_copy)
import collections
k = collections.Counter(prime_list)
b = list(k.values())
import math
ans = 1
for bb in b:
    ans *= math.factorial(bb + n - 1) % inf
    ans *= pow(math.factorial(bb), inf - 2, inf)
    ans *= pow(math.factorial(n - 1), inf - 2, inf)
    ans = ans % inf
print(ans)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
prime_list = [2]
for i in range(3, int(m // 2) + 1, 2):
    calc = True
    if m % i == 0:
        for j in prime_list:
            if (i % j != 0):
                continue
            else:
                calc = False
                break
        if calc:
            prime_list.append(i)
a = []
for prime in prime_list:
    while m % prime == 0:
        a.append(prime)
        m = int(m // prime)
import collections
k = collections.Counter(a)
b = list(k.values())
import math
ans = 1
for bb in b:
    ans *= math.factorial(bb + n - 1) % inf
    ans *= pow(math.factorial(bb), inf - 2, inf)
    ans *= pow(math.factorial(n - 1), inf - 2, inf)
    ans = ans % inf
print(ans)

Submission status: Runtime Error

Solution code:
import collections
import sys

def primes(n):
  is_prime=[True]*(n+1)
  is_prime[0]=False
  is_prime[1]=False
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=False
  return [i for i in range(n+1) if is_prime[i]]

def fact(n):
  l=primes(int(n**0.5)+1)
  L=[]
  for i in range(len(l)):
    while n%l[i]==0:
      n=n//l[i]
      L.append(l[i])
    if n==1:
      break
  if n!=1:
    L.append(n)
  return L

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

n,M=map(int,input().split())
if n==1 and M==1:
  print(1)
  sys.exit()
m=10**9+7
x=list(collections.Counter(fact(M)).values())

g1=[1,1]
g2=[1,1]
inverse=[0,1]

for i in range(2,max(x)+n):
  g1.append((g1[-1]*i)%m)
  inverse.append((-inverse[m%i]*(m//i))%m)
  g2.append((g2[-1]*inverse[-1])%m)

ans=1

for i in range(len(x)):
  ans*=cmb(x[i]+n-1,x[i],m)
  ans%=m
print(ans)

Submission status: Runtime Error

Solution code:
import collections

def primes(n):
  is_prime=[True]*(n+1)
  is_prime[0]=False
  is_prime[1]=False
  for i in range(2,int(n**0.5)+1):
    if not is_prime[i]:
      continue
    for j in range(i*2,n+1,i):
      is_prime[j]=False
  return [i for i in range(n+1) if is_prime[i]]

def fact(n):
  l=primes(int(n**0.5)+1)
  L=[]
  for i in range(len(l)):
    while n%l[i]==0:
      n=n//l[i]
      L.append(l[i])
    if n==1:
      break
  if n!=1:
    L.append(n)
  return L

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

n,M=map(int,input().split())
m=10**9+7
x=list(collections.Counter(fact(M)).values())

g1=[1,1]
g2=[1,1]
inverse=[0,1]

for i in range(2,max(x)+n):
  g1.append((g1[-1]*i)%m)
  inverse.append((-inverse[m%i]*(m//i))%m)
  g2.append((g2[-1]*inverse[-1])%m)

ans=1

for i in range(len(x)):
  ans*=cmb(x[i]+n-1,x[i],m)
  ans%=m
print(ans)

Submission status: Runtime Error

Solution code:
import math
N,M = list(map(int,input().split(" ")))
MOD = 10 ** 9 + 7
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) % X

    return result % X

ans = 1
fac = factorize(M)
for temp in fac:
    num = temp[1]
    ans *= cmb(num + N - 1,num)
    ans %= MOD
print(ans)

Submission status: Runtime Error

Solution code:
import sys
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
if m==1
print(1)
sys.exit()
Max=max(list(pf.values()))
f_mod=[1]*(Max+n+1)
f_mod_inverse=[1]*(Max+n+1)
for i in range(1,Max+n+1):
  f_mod[i]=(f_mod[i-1]*i)%MOD
  f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD  
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)

Submission status: Runtime Error

Solution code:
import sys
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
if n==1:
  print(1)
  sys.exit()
Max=max(list(pf.values()))
f_mod=[1]*(Max+n+1)
f_mod_inverse=[1]*(Max+n+1)
for i in range(1,Max+n+1):
  f_mod[i]=(f_mod[i-1]*i)%MOD
  f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD  
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)

Submission status: Runtime Error

Solution code:
import sys
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
if n==1
print(1)
sys.exit()
Max=max(list(pf.values()))
f_mod=[1]*(Max+n+1)
f_mod_inverse=[1]*(Max+n+1)
for i in range(1,Max+n+1):
  f_mod[i]=(f_mod[i-1]*i)%MOD
  f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD  
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)

Submission status: Runtime Error

Solution code:
import sys
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]
md=10**9+7

n,m=map(int,input().split())
s=[[0,0]]
if m==1:
  s.append([1,1])
for i in range(2,int(m**(0.5)+1)):
  k=0
  frag = 0
  if m%i!=0:
    frag = 1
  while m%i==0:
    m=int(m/i)
    k=k+1
  if frag == 0:
    s.append([i,k])
if m!=1:
  s.append([m,1])
q = [0]*(len(s)-1)
for i in range(1,len(s)):
  q[i-1] = s[i][1]

t = 1
for i in range(len(q)):
  c = cmb(n-1+q[i],q[i])
  t = t*(c%md)
  
print(t%md)

Submission status: Runtime Error

Solution code:
from collections import defaultdict

mod = 10 ** 9 + 7


def cmb(n, r):
    if n < r:
        return 0  # <-直した
    if r > n - r:
        return cmb(n, n - r)
    if r == 0:
        return 1
    if r == 1:
        return n
    res = f[n]
    res *= invs[r]
    res %= mod
    res *= invs[n - r]
    res %= mod
    return res


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

x = M
i = 2
while i * i <= M:
    t = 0
    while x % i == 0:
        x //= i
        t += 1
    if t > 0:
        d[i] = t
    i += 1
if x > 1:
    d[x] = 1

max_v = max(d.values())

f = [-1] * (N - 1 + max_v + 1)
f[0] = 1
t = 1
for i in range(1, N - 1 + max_v + 1):
    t *= i
    t %= mod
    f[i] = t

# print(d)

inv = pow(t, mod - 2, mod)
invs = [-1] * (N - 1 + max_v + 1)
invs[N - 1 + max_v] = inv
for i in range(N - 1 + max_v - 1, 0, -1):
    inv *= (i + 1)  # <-直した
    inv %= mod
    invs[i] = inv

ans = 1
for cnt in d.values():
    ans *= cmb(N - 1 + cnt, cnt)
    ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
Max=max(list(pf.values()))
f_mod=[1]*(Max+n+1)
f_mod_inverse=[1]*(Max+n+1)
for i in range(1,Max+n+1):
  f_mod[i]=(f_mod[i-1]*i)%MOD
  f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD  
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
f_mod=[1]*(m+1)
f_mod_inverse=[1]*(m+1)
for i in range(1,m+1):
  f_mod[i]=(f_mod[i-1]*i)%MOD
  f_mod_inverse[i]=(f_mod_inverse[i-1]*inv_mod(i)) % MOD  
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
f_mod=[1]*(m+1)
f_mod_inverse=[1]*(m+1)
for i in range(1,m+1):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i) % MOD  
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
f_mod=[1]*(m+1)
f_mod_inverse=[1]*(m+1)
for i in range(1,m+1):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i) % MOD  
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD,f_mod)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
f_mod=[1]*(n+1)
f_mod_inverse=[1]*(n+1)
for i in range(1,n+1):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(i) % MOD  
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans%MOD)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
MOD = 10**9+7
ans=1
def inv_mod(a, p=MOD):
    def inv_mod_sub(a, p):
        if a == 1:
            return 1, 0
        else:
            d, r = p//a, p%a
            x, y = inv_mod_sub(r, a)
            return y-d*x, x
    if p < 0: p = -p
    a %= p
    return inv_mod_sub(a,p)[0] % p

def comb_mod(n, k):
    if k < 0 or k > n:
        return 0
    else:
        return f_mod[n]*f_mod_inverse[k]*f_mod_inverse[n-k] % MOD
f_mod=[1]*(n+1)
f_mod_inverse=[1]*(n+1)
for i in range(1,n+1):
  f_mod[i]=f_mod[i-1]*i%MOD
  f_mod_inverse[i]=f_mod_inverse[i-1]*inv_mod(n)%MOD  
pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
for i in pf.values():
  ans*=comb_mod(i+n-1,n-1)
print(ans)

Submission status: Runtime Error

Solution code:
import math
def factorize(m):
    b = 2
    fct = [0]*(10**5)
    while b * b <= m:
        while m % b == 0:
            m //= b
            fct[b] +=1
        b = b + 1
    if m > 1:
        fct[m]+=1
    return fct

def comb(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    else:
        return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

N, M = map(int, input().split())
ans = 1
M_fact = factorize(M)

for i in M_fact:
    if i != 0: #i個をN通りに分ける→i+N-1,i
        ans *= comb(N+i-1,i)
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())

from collections import Counter
 
def soinsuu(n):
    list_=[]
    while(n!=1):
        for i in range(2,int(n**0.5)+1):
            if n%i==0:
                list_.append(i)
                n=n//i
                break
        else:
            list_.append(n)
            n=1
    return sorted(list_)
 
def product(a):
    pro=1
    for b in a:
        pro=pro*b%mod
    return pro
 
#n!,nPr,nCrの高速計算
def n_func(n,mod=10**9+7):
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%mod
    return ans
def inv_n(n,mod=10**9+7):
    return pow(n,mod-2,mod)
def nPr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod
def nCr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)*n_func(r,mod)%mod
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod
    
p=list(Counter(soinsuu(M)).values())
print(product([nCr(N+p[i]-1,p[i]) for i in range(len(p))]))

Submission status: Runtime Error

Solution code:
mod=10**9+7
N,M=map(int,input().split())
from collections import defaultdict
yaku=defaultdict(int)
now=M
for i in range(2,1+M):
    if now**0.5<i:
        yaku[now]+=1
        break
    while now%i==0:
        yaku[i]+=1
        now//=i
    if now==1:
        break
kaijo=[0]*(1+N)
kaijo[0]=1
for i in range(1,1+N):
    kaijo[i]=kaijo[i-1]*i%mod
gyaku=[0]*(1+N)
gyaku[N]=pow(kaijo[N],mod-2,mod)
for i in range(N,0,-1):
    gyaku[i-1]=gyaku[i]*i%mod
def calc(N,x):
    dp=defaultdict(list)
    dp[1].append([1])
    for i in range(1,x):
        for L in dp[i]:
            if L[-1]+i<=x:
                dp[i+L[-1]].append(L+[L[-1]])
            M=L.copy()
            M[-1]+=1
            dp[i+1].append(M)
    res=0
    for L in dp[x]:
        now=kaijo[N]*gyaku[N-len(L)]%mod
        cnt=defaultdict(int)
        for l in L:
            cnt[l]+=1
        for k,v in cnt.items():
            now=now*gyaku[v]%mod
        res=(res+now)%mod
    return res
ans=1
for k,v in yaku.items():
    ans=ans*calc(N,v)%mod
print(ans)

Submission status: Runtime Error

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

from math import factorial
from collections import Counter

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

def product(a):
    pro=1
    for b in a:
        pro=pro*b%mod
    return pro

#n!,nPr,nCrの高速計算
def n_func(n,mod=10**9+7):
    ans=1
    for i in range(1,n+1):
        ans=(ans*i)%mod
    return ans
def inv_n(n,mod=10**9+7):
    return pow(n,mod-2,mod)
def nPr(n,r,mod=10**9+7):
    ans=n_func(n-r,mod)
    ans=inv_n(ans,mod)
    return ans*n_func(n,mod)%mod

def dp(cur,init,seq,lest,num):
    if cur==N:
        if lest==0:
            cnt=sorted(list(Counter(seq).values()),reverse=True)
            #print(cnt)
            bunbo=product(map(factorial,cnt[1:]))%mod
            memo[num]=(memo[num]+nPr(sum(cnt),sum(cnt[1:]),mod)//bunbo)%mod #ここがおかしい
    elif lest==0:
        dp(N,init,seq+[0]*(N-cur),0,num)
    else:
        for i in range(0,lest+1):
            if cur==0:
                dp(cur+1,init,seq+[i],lest-i,num)
            elif i<=seq[-1]:
                dp(cur+1,init,seq+[i],lest-i,num)

p=list(Counter(soinsuu(M)).values())
memo=[0]*len(p)

for i in range(len(p)):
    dp(0,p[i],[],p[i],i)
#print(memo)
print(product(memo))
#print(p)

Submission status: Runtime Error

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


def solve(s):
    n, m = map(int, s.split())
    divisor = []
    for i in range(2, int(m**0.5) + 1):
        if m % i == 0:
            divisor.append(i)
    divisor += [m // d for d in divisor[::-1]] + [m]
    ld = len(divisor)

    def search(ded, use, j):
        if ded == 0:
            return 0
        if ded == 1:
            count = Counter(use)
            base = reduce(mul, range(n - len(use) + 1, n + 1))
            for v in list(count.values()):
                base //= factorial(v)
            return base
        if len(use) >= n:
            return 0

        tmp = [
            search(ded // divisor[i], use + [divisor[i]], i)
            for i in range(j, ld)
            if ded % divisor[i] == 0
        ]
        return sum(tmp) if tmp else 0

    return search(m, [], 0) % (10**9 + 7)


print(solve(input()))

Submission status: Runtime Error

Solution code:
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int n,m, cnt = 0;

map<int ,int> e;
void unique_factorization(int n){
    int m = sqrt(n + 0.5);
    
    for (int i = 2; i <= m; i++){
        while (n%i == 0) {
            n/= i;
            e[i] ++;
            cnt++;
        }
        if(n==1) break;
    }
    if(n>1){e[n]++;cnt++;}
}

using ll = long long;
const int mod = 1e9 + 7;
int fac[N], finv[N];

ll quick_pow(ll a, ll b) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}

void init_fac_mod(int to){
    //only when mod is prime
    fac[0] = finv[0] = 1;
    for(int i = 1; i <= to; ++i)
        fac[i]=(ll)fac[i-1]*i%mod;
    finv[to] = quick_pow(fac[to], mod-2);
    for(int i = to-1; i; --i)
        finv[i] = (ll)finv[i+1]*(i+1)%mod;
}

struct modular {
    int value;
    modular(long long v = 0) { value = v % mod; if (value < 0) value += mod;}
    modular(long long a, long long b) : value(0){ *this += a; *this /= b;}
    modular& operator+=(modular const& b) {value += b.value; if (value >= mod) value -= mod; return *this;}
    modular& operator-=(modular const& b) {value -= b.value; if (value < 0) value += mod;return *this;}
    modular& operator*=(modular const& b) {value = (long long)value * b.value % mod;return *this;}
    //其他函数调用mexp(modular(10),3);
    friend modular mexp(modular a, long long e) {
        modular res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
        return res;
    }
    friend modular inverse(modular a) { return mexp(a, mod - 2); }
    modular& operator/=(modular const& b) { return *this *= inverse(b); }
    friend modular operator+(modular a, modular const b) { return a += b; }
    friend modular operator-(modular a, modular const b) { return a -= b; }
    friend modular operator-(modular const a) { return 0 - a; }
    friend modular operator*(modular a, modular const b) { return a *= b; }
    //除法只有在mod是素数可用;
    friend modular operator/(modular a, modular const b) { return a /= b; }
    friend ostream& operator<<(ostream& os, modular const& a) {return os << a.value;}
    friend istream& operator>>(istream& is, modular & a){long long value; is >> value;a.value = 0; a += value;  return is;}
    friend bool operator==(modular const& a, modular const& b) {return a.value == b.value;}
    friend bool operator!=(modular const& a, modular const& b) {return a.value != b.value;}
};


int comb(int n, int m){
    //n!/(m!(n-m)!
    return (ll)fac[n] * finv[m] % mod * finv[n - m]% mod;
}



int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>n>>m;
    
    unique_factorization(m);
    
    init_fac_mod(1e5);
    modular ans = 1;
    
    for (auto i : e) {
        ans *= comb(i.second + n-1, n-1);
    }
    
    
    cout<<ans<<endl;
    
    return 0;
}

Submission status: Runtime Error

Solution code:
from collections import Counter
from math import factorial as f
N, M = map(int, input().split())
a1, a2 = 2, M
a = []
while a2 != 1:
    if a2 % a1 == 0:
        a.append(a1)
        a2 //= a1
    else:
        a1 += 1
ca = Counter(a)
sa = sum(ca.values())
p = 1
for v in ca.values():
    p *= f(sa + v - 1) // (f(v) * f(sa - 1))
print(p * (f(N) // (f(sa) * f(N - sa))) % (10 ** 9 + 7))

Submission status: Runtime Error

Solution code:
def FACT(DICT, N):
    FACT = DICT
    LIM = int((N**0.5)//1)+1
    for i in range(2, LIM):
        if N%i == 0:
            FACT[i] = 0
        while N%i == 0:
            FACT[i] += 1
            N //= i
        if len(FACT) == len(DICT):
            FACT[N] = 1
            return FACT
    return FACT(FACT, N)

def comb_rep(n, r):
    N = n+r-1
    ANS = 1
    for R in range(r):
        ANS *= N-R
        ANS /= R+1
    return int(ANS)

MOD = 10**9+7
n, m = map(int, input().split())
factor = FACT({}, m)
ans = 1
for i in factor:
    ans *= comb_rep(n, factor[i])
    ans %= MOD
print(ans)

Submission status: Runtime Error

Solution code:
def FACT(DICT, N):
    FACT = DICT
    LIM = int((N**0.5)//1)+1
    for i in range(2, LIM):
        if N%i == 0:
            FACT[i] = 0
        while N%i == 0:
            FACT[i] += 1
            N //= i
        if len(FACT) == len(DICT):
            FACT[N] = 1
            return FACT
    return FACT(FACT, N)

def comb_rep(n, r):
    N = n+r-1
    ANS = 1
    for R in range(r):
        ANS *= N-R
        ANS /= R+1
    return int(ANS)

n, m = map(int, input().split())
factor = FACT({}, m)
ans = 1
for i in factor:
    ans *= comb_rep(n, factor[i])
print(ans)

Submission status: Runtime Error

Solution code:
import collections
import math
n,m=map(int,input().split())
flag=0
P=[]
p=m
while flag==0:
  cur=p
  for i in range(2,int(p**0.5)+1):
    if p%if==0:
      P.append(i)
      p//=i
      break
  if p==cur:
    P.append(p)
    flag=1
c=collections.Counter(P)
Primes=set(P)
def f(i):
  return math.factorial(i)
def fn(i):
  return f(n+i-1)//(f(n-1)*f(i))
ans=1
for p in Primes:
  ans*=fn(c[p])
print(ans)