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:
N,M=map(int,input().split())
MOD=(10**9)+7
def trial_division(n):
    #素因数を格納するリスト
    factor = []
    #2から√n以下の数字で割っていく
    tmp = int(n**0.5) + 2
    for num in range(2,tmp):
        count=0
        while n % num == 0:
            n //= num
            count+=1
        if count>0:
          factor.append(count)
    #リストが空ならそれは素数
    if not factor:
        return [1]
    elif n!=1:
        factor.append(1)
        return factor
    else:
        return factor
      
def combinations_count(n, r):
    if n==r:
      return 1
    re = combinations_count(n - 1, r) * n // (n - r)
    return re


factor=trial_division(M)

ans=1
for a in factor:
  ans*=combinations_count(a+N-1,a)
  ans%=MOD
print(ans)

Submission status: Runtime Error

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

factor = []
tmp = int(m ** (1/2)) + 1
for i in range(2, tmp):
    while m % i == 0:
        m //= i
        factor.append(i)
if m > 1:
    factor.append(m)
num = list(collections.Counter(factor).most_common())

ans = 1
for i in range(len(num)):
    ans *= (math.factorial(num[i] + n - 1) // (math.factorial(n - 1) * math.factorial(num[i])) % 1000000007)
    ans %= 1000000007
print(ans)

Submission status: Runtime Error

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

fact_dict = {}
i = 2

max_num = 0

while M > 1:
    count = 0
    while M % i == 0:
        M //= i
        count += 1
    if count > 0:
        max_num = max(max_num, count)
        fact_dict[i] = count
    i += 1

def comb(whole, choice):
    choice = min(choice, whole-choice)
    result = 1
    for i in range(whole-choice+1, whole+1):
        result *= i
    for i in range(2, choice+1):
        result //= i
    return result

ans = 1
for _, num in fact_dict.items():
    ans *= comb(N+num-1, N-1)
print(ans%mod)

Submission status: Runtime Error

Solution code:
n,m=map(int, input().split())
def is_prime(N):
    is_prime=[True]*(N+1)
    is_prime[0:2]=False,False
    for i in range(int(N**0.5)+1):
        if is_prime[i]==False:
            continue
        for j in range(i*2,N+1,i):
            is_prime[j]=False
    return is_prime
def primes(N):
    prime=is_prime(N)
    return [i for i in range(N+1) if prime[i]]
def prime_factorization(n):
    ps=primes(int(n**0.5))
    r=[]
    for i,p in enumerate(ps):
        num=0
        while(True):
            x,y=divmod(n,p)
            if y!=0:
                break
            n=x
            num+=1
        if num>0:
            r.append((p,num))
    if n>1:
        r.append((n,1))
    return r

f=prime_factorization(m)
from scipy.special import perm, comb
ans=1
mod=10**9+7
for p in f:
    ans*=comb(p[1]+n-1,n-1,exact=True)
    ans%=mod
print(ans)

Submission status: Runtime Error

Solution code:
import sys
from functools import reduce
sys.setrecursionlimit(1000000)
n,m=map(int,input().split())
dic=dict()
sqrm=int(m**0.5)
for i in range(2,sqrm+1):
    if m%i==0:dic[i]=0
    while m%i==0:
        dic[i]+=1
        m//=i
if m>sqrm:dic[m]=1
ans=1
def comb(a,b):
    p=1
    for i in range(a,a-b,-1):
        p*=i
    for i in range(2,b+1):
        p//=i
    return p
l=[comb(i+n-1,i) for i in dic.values()]
print(reduce(lambda x,y: x*y%1000000007, l))

Submission status: Runtime Error

Solution code:
import math
def cb_count(n,r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def factorization(n):
    ans = {}
    if n > 1 and n % 1 == 0:
        for i in range(2, int(n**0.5)+1):
            if n % i == 0:
                if i in ans.keys():
                    ans[i] = ans[i]+1
                else:
                    ans[i] = 1
                #print("%d = %i"%(n,i),end="")
                m = n // i
                j = 2
                while j <= m:
                    if m % j == 0:
                        if j in ans.keys():
                            ans[j] = ans[j]+1
                        else:
                            ans[j] = 1
                        #print("*%d"%j,end="")
                        m = m // j
                        j = 2
                    else:
                        j += 1
                break
        else:
            ans = ["Prime"]
            #print("%d is a prime number"%n,end="")
    else:
        ans = ["Error"]
        #print("error",end="")
    return ans
    #print()

n,m = list(map(int,input().split()))
# print(cb_count(n,m))
fct = factorization(m)
ans = 1
for k in fct.keys():
    ans *= cb_count(n+fct[k]-1,fct[k])

ans = ans % (10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import itertools


N,M = map(int,input().split())
primes = {}
# primes[1] = 1
tmp = 2
while M != 1:
    if M%tmp==0:
        M //= tmp
        if tmp in primes.keys():
            primes[tmp] += 1
        else:
            primes[tmp] = 1
    else:
        tmp += 1

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

# print(primes)
ans = 1
for key in primes.keys():
    ans *= combination(N,primes[key])
    if ans > (10**9+7):
        ans = ans % (10**9+7)

print(ans)

Submission status: Runtime Error

Solution code:
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, 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_factorized = factorize(M)
mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
ans = 1
for i in range( 2, 2**N + 1 ):
  g1.append( ( g1[-1] * i ) % mod )
  inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
  g2.append( (g2[-1] * inverse[-1]) % mod )
    
    
for i in m_factorized:
  k = i[1] 
  ans *= cmb(N-1+k,k,mod)
  ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
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, 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_factorized = factorize(M)
mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
ans = 1
for i in range( 2, 2**N + 1 ):
  g1.append( ( g1[-1] * i ) % mod )
  inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
  g2.append( (g2[-1] * inverse[-1]) % mod )
    
    
for i in m_factorized:
  k = i[1] 
  ans *= cmb(N-1+k,k,mod)
  ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
from math import factorial as fact
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
num = []
p_flag = [True]*(int(M**0.5)+1)

for i in range(2, int(M**0.5)+2):
    if p_flag:
        for j in range(2*i, int(M**0.5)+2, i):
            p_flag[j] = False

        cnt = 0
        while M % i == 0:
            cnt += 1
            M //= i
        if cnt > 0:
            num.append(cnt)
        if M == 1:
            break
else:
    num.append(1)

ans = 1
for i in num:
    ans = (ans * fact(N-1+i)//(fact(i)*fact(N-1))) % (10**9+7)
print(ans)

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce

# 素因数分解して、重複組み合わせを数える。
n,m = map(int,input().split())
MOD = 10**9+7

# 素因数分解
def factorize(n):
    fct = [] # Prime Factor
    b, e = 2, 0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b, e = b+1, 0
    if n>1:
        fct.append((n,1))
    return fct

# 組み合わせ計算(nCr)
def nCr(n,r):
    r = min(r,n-r)
    if r == 0:
        return 1
    over = reduce(mul, range(n,n-r,-1))
    under = reduce(mul,range(1,r+1))
    return over // under

f = factorize(m)
ans=1
for p,num in f:
    ans *= nCb(num+n-1,num)
    ans %= 10**9+7
 
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())

def prime(n):#素数かどうか＿素数なら1、そうでないなら0
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

#def prime_l(n):
#    for i in range(2,n+1):
#        if prime(i)==1:
#            yield i
#def prime_l(n):#n以下の素数のリスト
#    l=[1 for i in range(2,n+1)]#2からnの、n-1個 インデは-2
#    for i in range(n-1):#0からn-2 上記−２=インデ
#        if prime(i+2):
#            for j in range(2,n//(i+2)+1):#何倍のが0になるか
#                l[(i+2)*j-2]=0
#    return l

def prime_l(n):
    l=[1 for i in range(2,n+1)]#2からn インデは-2
    #sq_n=n**(1/2)
    for i in range(n-1):
        if l[i]==1:
            for j in range(2*(i+2),n+1,i+2):
                l[j-2]=0
    l1=[]
    for i in range(n-1):
        if l[i]==1:
            l1.append(i+2)
    return l1


def modpow(a,n,p):#a^n mod p
    res=1
    while n>0:
        if n&1:#１とのビット論理積が１、つまり奇数
            res=res*a%p
        a=a*a%p
        n>>=1
        #ビットの右シフト_2進数表記のnを小数点を固定して右に１桁ずらす_１桁小さくなる
    return res

if m==1:
    print(1)
else:
    #l=[i+2 for i in prime_l(int(1e9))]
    #l=prime_l(int(m**(1/2))) if m>=4 else prime_l(m)
    l=prime_l(int(m**(1/2)))#√までにしておくと、1にならずに残ったものは素数
    #ll=next(l)
    i=0
    d={}
    while m!=1 and i!=len(l)-1:
        if m%(l[i])==0:
            d[l[i]]=1
            m/=l[i]
            while m%(l[i])==0:
                d[l[i]]+=1
                m/=l[i]
        #ll=next(l)
        i+=1
        #while l[i]==0:
        #    i+=1
    if m!=1:
        d[m]=1
    #s_k=0
    #for i in d.values():
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    #for i in range(n+d_max-1):# 1!,2!,,,,(n+d_max-1)!
    #    n_fac*=i+1
    for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!
        n_fac*=i+1
        n_fac=n_fac%mod
        fac_l.append(n_fac)

    fac_1_l=[]
    for i in range(n+d_max-1):
        fac_1_l.append(modpow(fac_l[i],mod-2,mod))
    w=1
    for dv in d.values():
        w*=fac_l[n+dv-1]
        w=w%mod
        #n_n_fac=fac_l[n-dv]
        #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))
        #print(div)
        #if div>w:
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())

def prime(n):#素数かどうか＿素数なら1、そうでないなら0
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

#def prime_l(n):
#    for i in range(2,n+1):
#        if prime(i)==1:
#            yield i
#def prime_l(n):#n以下の素数のリスト
#    l=[1 for i in range(2,n+1)]#2からnの、n-1個 インデは-2
#    for i in range(n-1):#0からn-2 上記−２=インデ
#        if prime(i+2):
#            for j in range(2,n//(i+2)+1):#何倍のが0になるか
#                l[(i+2)*j-2]=0
#    return l

def prime_l(n):
    l=[1 for i in range(2,n+1)]#2からn インデは-2
    #sq_n=n**(1/2)
    for i in range(n-1):
        if l[i]==1:
            for j in range(2*(i+2),n+1,i+2):
                l[j-2]=0
    l1=[]
    for i in range(n-1):
        if l[i]==1:
            l1.append(i+2)
    return l1


def modpow(a,n,p):#a^n mod p
    res=1
    while n>0:
        if n&1:#１とのビット論理積が１、つまり奇数
            res=res*a%p
        a=a*a%p
        n>>=1
        #ビットの右シフト_2進数表記のnを小数点を固定して右に１桁ずらす_１桁小さくなる
    return res

if m==1:
    print(1)
else:
    #l=[i+2 for i in prime_l(int(1e9))]
    #l=prime_l(int(m**(1/2))) if m>=4 else prime_l(m)
    l=prime_l(int(m**(1/2)))#√までにしておくと、1にならずに残ったものは素数
    #ll=next(l)
    i=0
    d={}
    while m!=1 and i!=len(l):
        if m%(l[i])==0:
            d[l[i]]=1
            m/=l[i]
            while m%(l[i])==0:
                d[l[i]]+=1
                m/=l[i]
        #ll=next(l)
        i+=1
        #while l[i]==0:
        #    i+=1
    if m!=1:
        d[m]=1
    #s_k=0
    #for i in d.values():
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    #for i in range(n+d_max-1):# 1!,2!,,,,(n+d_max-1)!
    #    n_fac*=i+1
    for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!
        n_fac*=i+1
        n_fac=n_fac%mod
        fac_l.append(n_fac)

    fac_1_l=[]
    for i in range(n+d_max-1):
        fac_1_l.append(modpow(fac_l[i],mod-2,mod))
    w=1
    for dv in d.values():
        w*=fac_l[n+dv-1]
        w=w%mod
        #n_n_fac=fac_l[n-dv]
        #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))
        #print(div)
        #if div>w:
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())

def prime(n):#素数かどうか＿素数なら1、そうでないなら0
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

#def prime_l(n):
#    for i in range(2,n+1):
#        if prime(i)==1:
#            yield i
#def prime_l(n):#n以下の素数のリスト
#    l=[1 for i in range(2,n+1)]#2からnの、n-1個 インデは-2
#    for i in range(n-1):#0からn-2 上記−２=インデ
#        if prime(i+2):
#            for j in range(2,n//(i+2)+1):#何倍のが0になるか
#                l[(i+2)*j-2]=0
#    return l

def prime_l(n):
    l=[1 for i in range(2,n+1)]#2からn インデは-2
    #sq_n=n**(1/2)
    for i in range(n-1):
        if l[i]==1:
            for j in range(2*(i+2),n+1,i+2):
                l[j-2]=0
    l1=[]
    for i in range(n-1):
        if l[i]==1:
            l1.append(i+2)
    return l1


def modpow(a,n,p):#a^n mod p
    res=1
    while n>0:
        if n&1:#１とのビット論理積が１、つまり奇数
            res=res*a%p
        a=a*a%p
        n>>=1
        #ビットの右シフト_2進数表記のnを小数点を固定して右に１桁ずらす_１桁小さくなる
    return res

if m==1:
    print(1)
else:
    #l=[i+2 for i in prime_l(int(1e9))]
    l=prime_l(int(m**(1/2))) if m>=4 else prime_l(m)
    #ll=next(l)
    i=0
    d={}
    while m!=1:
        if m%(l[i])==0:
            d[l[i]]=1
            m/=l[i]
            while m%(l[i])==0:
                d[l[i]]+=1
                m/=l[i]
        #ll=next(l)
        i+=1
        #while l[i]==0:
        #    i+=1
    #s_k=0
    #for i in d.values():
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    #for i in range(n+d_max-1):# 1!,2!,,,,(n+d_max-1)!
    #    n_fac*=i+1
    for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!
        n_fac*=i+1
        n_fac=n_fac%mod
        fac_l.append(n_fac)

    fac_1_l=[]
    for i in range(n+d_max-1):
        fac_1_l.append(modpow(fac_l[i],mod-2,mod))
    w=1
    for dv in d.values():
        w*=fac_l[n+dv-1]
        w=w%mod
        #n_n_fac=fac_l[n-dv]
        #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))
        #print(div)
        #if div>w:
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())

def prime(n):#素数かどうか＿素数なら1、そうでないなら0
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

#def prime_l(n):
#    for i in range(2,n+1):
#        if prime(i)==1:
#            yield i
#def prime_l(n):#n以下の素数のリスト
#    l=[1 for i in range(2,n+1)]#2からnの、n-1個 インデは-2
#    for i in range(n-1):#0からn-2 上記−２=インデ
#        if prime(i+2):
#            for j in range(2,n//(i+2)+1):#何倍のが0になるか
#                l[(i+2)*j-2]=0
#    return l

def prime_l(n):
    l=[1 for i in range(2,n+1)]#2からn インデは-2
    #sq_n=n**(1/2)
    for i in range(n-1):
        if l[i]==1:
            for j in range(2*(i+2),n+1,i+2):
                l[j-2]=0
    l1=[]
    for i in range(n-1):
        if l[i]==1:
            l1.append(i+2)
    return l1


def modpow(a,n,p):#a^n mod p
    res=1
    while n>0:
        if n&1:#１とのビット論理積が１、つまり奇数
            res=res*a%p
        a=a*a%p
        n>>=1
        #ビットの右シフト_2進数表記のnを小数点を固定して右に１桁ずらす_１桁小さくなる
    return res

if m==1:
    print(1)
else:
    #l=[i+2 for i in prime_l(int(1e9))]
    l=prime_l(int(m**(1/2)))
    #ll=next(l)
    i=0
    d={}
    while m!=1:
        if m%(l[i])==0:
            d[l[i]]=1
            m/=l[i]
            while m%(l[i])==0:
                d[l[i]]+=1
                m/=l[i]
        #ll=next(l)
        i+=1
        #while l[i]==0:
        #    i+=1
    #s_k=0
    #for i in d.values():
    #    s_k+=i
    #print(d.values())
    mod=int(1e9+7)
    n_fac=1
    fac_l=[1]#0!
    d_max=max(d.values())
    #for i in range(n+d_max-1):# 1!,2!,,,,(n+d_max-1)!
    #    n_fac*=i+1
    for i in range(n+d_max-1):# 0!,1!,2!,,,,(n+d_max-1)!
        n_fac*=i+1
        n_fac=n_fac%mod
        fac_l.append(n_fac)

    fac_1_l=[]
    for i in range(n+d_max-1):
        fac_1_l.append(modpow(fac_l[i],mod-2,mod))
    w=1
    for dv in d.values():
        w*=fac_l[n+dv-1]
        w=w%mod
        #n_n_fac=fac_l[n-dv]
        #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))
        #print(div)
        #if div>w:
        #    w+=1e9+7
        #w=int(w/div)
        w=w*fac_1_l[n-1]%mod
        w=w*fac_1_l[dv]%mod
    print(w)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())

def prime(n):#素数かどうか＿素数なら1、そうでないなら0
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

def prime_l(n):
    for i in range(2,n+1):
        if prime(i)==1:
            yield i

def modpow(a,n,p):#a^n mod p
    res=1
    while n>0:
        if n&1:#１とのビット論理積が１、つまり奇数
            res=res*a%p
        a=a*a%p
        n>>=1
        #ビットの右シフト_2進数表記のnを小数点を固定して右に１桁ずらす_１桁小さくなる
    return res

#l=[i+2 for i in prime_l(int(1e9))]
l=prime_l(int(1e9))
ll=next(l)
d={}
while m!=1:
    if m%ll==0:
        d[ll]=1
        m/=ll
        while m%ll==0:
            d[ll]+=1
            m/=ll
    ll=next(l)
#s_k=0
#for i in d.values():
#    s_k+=i
for dk in d.keys():
    #print(dk)
    #print(d[dk])
    pass

mod=int(1e9+7)
n_fac=1
fac_l=[]
d_max=max(d.values())
for i in range(n+d_max-1):# 1!,2!,,,,(n+d_max-1)!
    n_fac*=i+1
    n_fac=n_fac%mod
    fac_l.append(n_fac)
#for i in range(n+d_max):
#    print(fac_l[i])
fac_1_l=[]
for i in range(n+d_max-1):
    fac_1_l.append(modpow(fac_l[i],mod-2,mod))
w=1
for dv in d.values():
    w*=fac_l[n+dv-1-1]
    w=w%mod
    #n_n_fac=fac_l[n-dv]
    #div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))
    #print(div)
    #if div>w:
    #    w+=1e9+7
    #w=int(w/div)
    w=w*fac_1_l[n-1-1]%mod
    w=w*fac_1_l[dv-1]%mod
print(w)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter
from itertools import product
from math import factorial

# prime numbers
primes = list(range(int(10**9 ** 0.5) + 1))
primes[1] = 0
for i in range(2, int(len(primes) ** 0.5) + 1):
    if primes[i]:
        for j in range(2 * i, len(primes), i):
            primes[j] = 0

def main():
    N, M = LI()
    # 素因数分解
    factors = Counter()
    for i in range(int(M ** 0.5) + 1):
        if primes[i]:
            while M % i == 0:
                factors[i] += 1
                M //= i
        if M < i:
            break
    if M != 1:
        factors[M] += 1
    ans = 1
    for k in factors.values():
        a, b = 1, 1
        for i in range(1, k + 1):
            a *= N + k - i
            b *= i
        ans = (ans * (a // b)) % MOD

    return ans % MOD

print(main())

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter
from itertools import product
from math import factorial

# prime numbers
primes = list(range(int(10**9 ** 0.5) + 1))
primes[1] = 0
for i in range(2, int(len(primes) ** 0.5) + 1):
    if primes[i]:
        for j in range(2 * i, len(primes), i):
            primes[j] = 0

def main():
    N, M = LI()
    # 素因数分解
    factors = Counter()
    for i in range(int(M ** 0.5) + 1):
        if primes[i]:
            while M % i == 0:
                factors[i] += 1
                M //= i
        if M < i:
            break
    if M != 1:
        factors[M] += 1
    ans = 1
    for k in factors.values():
        ans *= factorial(k + N - 1) // (factorial(N - 1) * factorial(k))
        ans %= MOD

    return ans % MOD

print(main())

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())

def prime(n):#素数かどうか＿素数なら1、そうでないなら0
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

def prime_l(n):
    for i in range(2,n+1):
        if prime(i)==1:
            yield i
#l=[i+2 for i in prime_l(int(1e9))]
l=prime_l(int(1e9))
ll=next(l)
d={}
while m!=1:
    if m%ll==0:
        d[ll]=1
        m/=ll
        while m%ll==0:
            d[ll]+=1
            m/=ll
    ll=next(l)
#s_k=0
#for i in d.values():
#    s_k+=i
for dk in d.keys():
    #print(dk)
    #print(d[dk])
    pass
n_fac=1
fac_l=[]
d_max=max(d.values())
for i in range(n+d_max):# 1!,2!,,,,
    n_fac*=i+1
    n_fac=int(n_fac%(1e9+7))
    fac_l.append(n_fac)
#for i in range(n+d_max):
    print(fac_l[i])
w=1
for dv in d.values():
    w*=fac_l[n+dv-1-1]
    w=int(w%(1e9+7))
    #n_n_fac=fac_l[n-dv]
    div=int((fac_l[n-1-1]*fac_l[dv-1])%(1e9+7))
    #print(div)
    if div>w:
        w+=1e9+7
    w=int(w/div)
print(w)

Submission status: Runtime Error

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def power_func(a,b,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

class comb_calclator():
    def __init__(self, N, p):
        self.N = N
        self.p = p
        self.frac_N = [0 for i in range(N + 1)]
        self.frac_N[0] = 1L
        self.comb_N = {}
        for i in range(1, N + 1):
            self.frac_N[i] = (self.frac_N[i - 1] * i ) % p

    def comb(self, n, r):
        if n<0 or r<0 or n<r: return 0
        if n==0 or r==0: return 1
        if (n, r) in self.comb_N:
            return self.comb_N[(n, r)]
        a = self.frac_N[n]
        b = self.frac_N[r]
        c = self.frac_N[n - r]
        self.comb_N[(n, r)] = (a*power_func(b,self.p-2,self.p)*power_func(c,self.p-2, self.p))% self.p
        self.comb_N[(n, n - r)] = self.comb_N[(n, r)]
        return self.comb_N[(n, r)]


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), long(input_raw[1])]
    prime = prime_decomposition(M)
    prime_num = {}
    for p in prime:
        if p not in prime_num:
            prime_num[p] = 1
        else:
            prime_num[p] += 1

    cmb = comb_calclator(N * 2, 1000000007)
    count = 1L
    for p in prime_num:
        count = (count * cmb.comb(N + prime_num[p]- 1, prime_num[p])) % 1000000007

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

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
            if b in fct.keys():
                fct[b] += 1
            else:
                fct[b] = 1
        b = b + 1
    if n > 1:
        fct[n] = 1
    return fct

from scipy.special import comb
fac_list = factorize(M)
ans = 1
for k, v in fac_list.items():
    ans *= comb(v+N-1, v)
    if ans >= mod:
        ans %= mod

print(int(ans))

Submission status: Runtime Error

Solution code:
import sympy
sympy.factorint(2016)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
if a==1:
    print(1)
    exit()
from collections import Counter
from operator import mul
from functools import reduce
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 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
mod=10**9+7
print(reduce(mul,map(lambda x:cmb(a-1+x,a-1),Counter(factorize(b)).values()))%mod)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
if a==1 and b==1:
    print(1)
    exit()
from collections import Counter
from operator import mul
from functools import reduce
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 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
mod=10**9+7
print(reduce(mul,map(lambda x:cmb(a-1+x,a-1),Counter(factorize(b)).values()))%mod)

Submission status: Runtime Error

Solution code:
a,b=map(int,input().split())
from collections import Counter
from operator import mul
from functools import reduce
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 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
mod=10**9+7
print(reduce(mul,map(lambda x:cmb(a-1+x,a-1),Counter(factorize(b)).values()))%mod)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
def div(x,y):
    if x%y!=0:
        return 0
    else:
        return 1+div(int(x/y),y)

p=[]

def fact(s):
    if len(p)!=0:
        k=p[-1]
    else:
        k=2
    for i in range(2,max(int(s**0.5) +2,2)):
        a=div(s,i)
        if a==0:
            0
        else:
            p.append(a)
            s=int(s/i**a)
            
fact(m)
#print(p)
mo=10**9+7
from scipy.special import comb
ans=1
if len(p)==0:
    ans=1
else:
    for i in p:
        ans=ans*comb(i+n-1, i, exact=True) % mo
        #print(ans,comb(i+n-1, i, exact=True))
print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
import math
from scipy import special
a=[]
ans=1
def calc(n):#nの素因数分解
    for i in range(2,int(n**0.5)+10):
        count=0
        while n%i==0:
            n//=i
            count+=1
        if count>=1:
            a.append([i,count])
    if n!=1:
        a.append([n,1])
calc(M)
for i in range(len(a)):
    ans*=special.comb(a[i][1]+N-1,a[i][1],True)
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
def prime_facts(n: int) -> dict:
    res = {}
    d = 2
    while n > 1:
        if n % d == 0:
            res[d] = 1
            n //= d

        while n % d == 0:
            res[d] += 1
            n //= d

        if d == 2:
            d += 1
        else:
            d += 2

    return res


def pi(start: int, stop: int, n: int) -> int:
    """(N+start)x...x(N+stop) を計算する。
    """
    res = 1
    for i in range(start, stop+1):
        res *= (n + i)
    return res


def fact(n: int) -> int:
    """n!を計算する。
    """
    res = 1
    for i in range(n):
        res *= (i + 1)
    return res


def factorization(N: int, M: int) -> int:
    """以下の説明において、F(N, M) はこの関数と同値。

    `a1 x a2 x ... x aN = M (式 1)`
    となる数列 {aN} の組み合わせ数を F(N, M) とする。

    まず、(式 1)より {aN} は全て M の約数であることは明らか。

    ここで、M の約数列を {dm} とする。今、aN = di とすると、
    `a1 x a2 x ... x a{N-1} = M // di`
    が成り立ち、これを満たす数列 {a{N-1}} の組み合わせ数は F(N-1, M//di) である。

    aN は任意の di を取れるので、結局、
    `F(N, M) = sigma{di} F(N-1, M//di) = sigma{di} F(N-1, M)` (式 2)
    が成り立つ。

    さらに、M を場合分けして考える。

    M = 1 のとき、(式 2)より
    `F(N, 1) = F(N-1, 1) = ... = F(1, 1) = 1` (式 3)
    が成り立つ。

    M = p (p は素数)のとき、(式 2)と(式 3)より、
    `F(N, p) = F(N-1, p) + F(N-1, 1) = F(N-1, p) + 1`
    が成り立つ。この漸化式をとけば、
    `F(N, p) = N`
    が成り立つ。

    M = p^k (p は素数)の時、めんどくさい計算の果てに
    `F(N, p^k) = PI{i=0}{k-1}(N+i) / k!`
    が成り立つ。

    M = p1...pk (pi は全て異なる素数)の時、めんどくさい計算の果てに
    `F(N,p1...pk) = N^k`

    M = p1^k1 ... pm^km (pi は全て異なる素数)の時、めんどくさい計算の果てに
    `F(N,p1^k1...pm^km) = F(N,p1^k1)...F(N,pm^km)`
    が成り立つ。
    """
    pi = [1] * 101
    fact = [1] * 101
    for i in range(1, 101):
        pi[i] = (N+i-1) * pi[i-1]
        fact[i] = i * fact[i-1]
    primes = prime_facts(M)
    raise Exception()
    ret = 1
    for k in primes.values():
        ret *= pi[k] // fact[k]

    return ret % 1000000007


if __name__ == "__main__":
    N, M = map(int, input().split())
    ans = factorization(N, M)
    print(ans)