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

Solution (Python):

import math

class Prime:
    seed_primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97]

    def is_prime(self, n):
        is_prime_common = self.is_prime_common(n)
        if is_prime_common is not None:
            return is_prime_common

        if n < 2000000:
            return self.is_prime_bf(n)
        else:
            return self.is_prime_mr(n)

    def is_prime_common(self, n):
        if n == 1: return False
        if n in Prime.seed_primes: return True
        if any(map(lambda x: n % x == 0, self.seed_primes)): return False

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

    def is_prime_mr(self, n):
        d = n - 1
        while d % 2 == 0:
            d //= 2

        witnesses = self.get_witnesses(n)

        for w in witnesses:
            y = pow(w, d, n)

            while d != n - 1 and y != 1 and y != n - 1:
                y = (y ** 2) % n
                d *= 2

            if y != n - 1 and d % 2 == 0:
                return False

        return True

    def get_witnesses(self, num):
        def _get_range(num):
            if num < 2047:
                return 1
            if num < 1373653:
                return 2
            if num < 25326001:
                return 3
            if num < 3215031751:
                return 4
            if num < 2152302898747:
                return 5
            if num < 3474749660383:
                return 6
            if num < 341550071728321:
                return 7
            if num < 38255123056546413051:
                return 9
            return 12

        return self.seed_primes[:_get_range(num)]

    def gcd(self, a, b):
        if a < b:
            a, b = b, a
        if b == 0:
            return a
        while b:
            a, b = b, a % b
        return a

    @staticmethod
    def f(x, n, seed):
        p = Prime.seed_primes[seed % len(Prime.seed_primes)]
        return (p * x + seed) % n

    def find_factor(self, n, seed=1):
        if self.is_prime(n):
            return n

        x, y, d = 2, 2, 1
        count = 0
        while d == 1:
            count += 1
            x = self.f(x, n, seed)
            y = self.f(self.f(y, n, seed), n, seed)
            d = self.gcd(abs(x - y), n)

        if d == n:
            return self.find_factor(n, seed+1)
        return self.find_factor(d)

    def find_factors(self, n):
        primes = {}
        if self.is_prime(n):
            primes[n] = 1
            return primes

        while n > 1:
            factor = self.find_factor(n)

            primes.setdefault(factor, 0)
            primes[factor] += 1

            n //= factor

        return primes

prime = Prime()

def main():
    [N, M] = list(map(int, input().split()))

    prime = Prime()

    factors = prime.find_factors(M)
    d = 10 ** 9 + 7

    r = 1
    for v in factors.values():
        if v == 1:
            r *= N
            r %= d
        else:
            lst = [i for i in range(2, v + 1)]
            for i in range(1, v + 1):
                r *= N + v - i
                for j in range(len(lst)):
                    if r % lst[j] == 0:
                        r //= lst[j]
                        lst.pop(j)
                        break
            for j in range(len(lst)):
                r //= lst[j]
            r %= d

    print(r)


if __name__ == '__main__':
    main()

Solution (Python):
n, m = map(int, input().split())
MOD = 1000000007
def comb(x, y):
    ret = 1
    for a in range(x, x - y, -1):
        ret = ret * a % MOD
    ret = ret * inverse(fact(y)) % MOD
    return ret

def fact(x):
    if x == 0:
        return 1
    return x * fact(x - 1) % MOD


def inverse(x):
    return pow(x, MOD - 2, MOD)
ans = 1
for i in range(2, 100000):
    if i > m:break
    cnt = 0
    while m % i == 0:
        cnt += 1
        m //= i
    ans = ans * comb(cnt + n - 1, cnt) % MOD
if m != 1:
    ans = ans * comb(n, 1) % MOD

print(ans)

Solution (Python):
n, m = map(int, input().split())
MOD = 1000000007
def comb(x, y):
    ret = 1
    for a in range(x, x - y, -1):
        ret *= a
    for b in range(y, 0, -1):
        ret //= b
    return ret

ans = 1
for i in range(2, 100000):
    if i > m:break
    cnt = 0
    while m % i == 0:
        cnt += 1
        m //= i
    ans *= comb(cnt + n - 1, cnt)
if m != 1:
    ans *= comb(n, 1)

print(ans % MOD)

Solution (Python):
from collections import Counter
from scipy.misc import comb
c=Counter()
n,m=map(int,input().split())
t=2
while(t**2 <= m):
    if m%t:
        t+=1
        continue
    while m%t==0:
        c[t]+=1
        m//=t
if m>1:c[m]+=1
a=1
for i in c:
    a=a*comb(n+c[i]-1,n-1,exact=1)%(10**9+7)
print(a)

Solution (Python):
import math
import random
from scipy.misc import comb
class Prime:
    seed_primes=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97]
    def is_prime(self,n):
        is_prime_common=self.is_prime_common(n)
        if is_prime_common is not None:return is_prime_common
        if n<2000000:return self.is_prime_brute_force(n)
        return self.is_prime_miller_rabin(n)
    def is_prime_common(self,n):
        if n==1:return False
        if n in Prime.seed_primes:return True
        if any(map(lambda x:n%x==0,self.seed_primes)):return False
    def is_prime_brute_force(self,n):
        for k in range(2,int(math.sqrt(n))+1):
            if n%k==0:return False
        return True
    def is_prime_miller_rabin(self,n):
        d=n-1
        while d&1==0:d>>=1
        witnesses=self.get_witnesses(n)
        for w in witnesses:
            y=pow(w,d,n)
            while d!=n-1and y!=1and y!=n-1:
                y=y*y%n
                d<<=1
            if y!=n-1and d&1==0:return False
        return True
    def get_witnesses(self,num):
        def _get_range(num):
            if num<2047:return 1
            if num<1373653:return 2
            if num<25326001:return 3
            if num<3215031751:return 4
            if num<2152302898747:return 5
            if num<3474749660383:return 6
            if num<341550071728321:return 7
            if num<3825123056546413051:return 9
            return 12
        return self.seed_primes[:_get_range(num)]
    def gcd(self,a,b):
        if a<b:return self.gcd(b,a)
        if b==0:return a
        while b:a,b=b,a%b
        return a
    @staticmethod
    def f(x,n,seed):
        p=Prime.seed_primes[seed%len(Prime.seed_primes)]
        return(p*x+seed)%n
    def find_factor(self,n,seed=1):
        if self.is_prime(n):return n
        x,y,d=2,2,1
        count=0
        while d==1:
            count+=1
            x=self.f(x,n,seed)
            y=self.f(self.f(y,n,seed),n,seed)
            d=self.gcd(abs(x-y),n)
        if d==n:
            return self.find_factor(n,seed+1)
        return self.find_factor(d)
    def find_factors(self,n):
        primes={}
        if self.is_prime(n):
            primes[n]=1
            return primes
        while n>1:
            factor=self.find_factor(n)
            primes.setdefault(factor,0)
            primes[factor]+=1
            n//=factor
        return primes
n,m=map(int,input().split())
a=1
for c in Prime().find_factors(m).values():
    a=a*comb(n+c-1,c,exact=1)%(10**9+7)
print(a)

Solution (Python):


mod = 10 ** 9 + 7


'''Snippets for combination.

Available functions:
- count_combination: Count the total number of combinations.
'''


def count_combination(n: int, r: int, mod: int = 10 ** 9 + 7) -> int:
    '''Count the total number of combinations.
        nCr % mod.

    Args:
        n   : Elements. Int of number (greater than 1).
        r   : The number of r-th combinations. Int of number (greater than 0).
        mod : Modulo. The default is 10 ** 9 + 7.

    Returns:
        The total number of combinations.

    Landau notation: O(n)

    See:
    https://qiita.com/derodero24/items/91b6468e66923a87f39f
    '''

    if r > (n - r):
        return count_combination(n, n - r)

    if r == 0 or r == n:
        return 1

    if r == 1:
        return n

    multiple = 1
    division = 1

    for i in range(r):
        multiple *= n - i
        division *= i + 1
        multiple %= mod
        division %= mod

    return multiple * pow(division, mod - 2, mod) % mod


def solve(n: int, m: int):
    from math import sqrt

    ans = 1
    remain = m

    for j in range(2, int(sqrt(m)) + 1):
        if remain % j == 0:
            count = 0

            while remain % j == 0:
                count += 1
                remain //= j

            ans *= count_combination(n + count - 1, n - 1)
            ans %= mod

    if remain != 1:
        ans *= count_combination(n, 1)
        ans %= mod

    return ans


def main():
    n, m = map(int, input().split())

    
    
    print(solve(n, m))


if __name__ == '__main__':
    main()

Solution (Python):
N,M = map(int,input().split())
MOD = 10**9+7
from collections import Counter
c = Counter()
m = 2

while(m**2 <= M):
    if M%m == 0:
        while(M%m == 0):
            c[m] += 1
            M //= m
    else:
        m += 1
if M > 1 : c[M] += 1
MAXN = N+100
fac = [0 for _ in range(MAXN)]
inv = [0 for _ in range(MAXN)]
finv = [0 for _ in range(MAXN)]
fac[0] = fac[1] = 1
inv[1] = 1
finv[0] = finv[1] = 1
for i in range(2,MAXN):
    fac[i] = (i*fac[i-1]) % MOD
    inv[i] = (-inv[MOD%i]*(MOD//i))%MOD
    finv[i] = (finv[i-1]*inv[i])%MOD

def comb(n,k):
    return (fac[n]*(finv[k]*finv[n-k]%MOD))%MOD
ans = 1
for i in c:
    ans *= comb(c[i]+N-1,N-1)
    ans %= MOD
print(ans)

Solution (Python):
import math
n,m =map(int,input().split())
 
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(int(n))
  return table
 
a =prime_decomposition(m)

def combination(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

ans=1
count = 1
if not a:
  print(ans)
  exit()

for i in range(1,len(a)):
  if a[i-1]== a[i]:
    count +=1
  else:
    ans *= combination(count+n-1,count)
    ans %=1000000007
    count = 1
    
ans *= combination(count+n-1,count)
ans %=1000000007
print(ans)

Solution (Python):
import math
import collections

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


def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


def comb(n,k,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 = factorial(n) % p
    b = factorial(k) % p
    c = factorial(n - k) % p
    return (a * power_func(b, p - 2, p) * power_func(c, p - 2, p)) % p


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

def m():
    ans = 1
    f = prime_factors(M)
    counts = collections.Counter(f)
    for k,v in counts.items():
        ans *= comb(v + N-1, N-1, MOD)
    return ans % MOD

print(m())

Solution (Python):

import math
def factoring(n,dict_count = {}):
    sup = math.floor(pow(n,1/2))
    n_new = n
    for i in range(2,sup + 1):
        if n % i == 0:
            n_new = n // i
            if i in dict_count:
                dict_count[i] += 1
            else:
                dict_count[i] = 1
            break
    if n == n_new:
        if n_new in dict_count:
            dict_count[n_new] += 1
        else:
            dict_count[n_new] = 1
        return sorted(list(dict_count.items()))
    return factoring(n_new,dict_count)

def comb(n,r):
    r = min(r,n-r)
    result = 1
    for i in range(n-r+1,n+1):
        result *= i
    for i in range(1,r+1):
        result //= i
    return result

N,M = map(int,input().split())
if M == 1:
    print(1)
    exit()
ans = 1
for a,b in factoring(M):
    ans *= comb(b+N-1,b)
    ans %= 10**9 + 7
print(ans)

Solution (Python):
from collections import Counter
import sys
sys.setrecursionlimit(1000000)
N, M = map(int, input().split())
mod = 10**9+7

factor = []
tmp = M
i = 2
while i**2 <= M:
    while tmp % i == 0:
        factor.append(i)
        tmp //= i
    i += 1
if tmp != 1:
    factor.append(tmp)

arr = Counter(factor).values()


dp = [-1 for _ in range(200001)]


def factorize(n):
    if dp[n] != -1:
        return dp[n]
    if n == 1:
        return 1
    return n*factorize(n-1)


def combination(n, k):
    i = n
    res = 1
    while i > n-k:
        res *= i
        i -= 1
    return res//factorize(k)

ans = 1
for elem in arr:
    ans *= combination(elem+N-1, elem)
    ans %= mod

print(ans)

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

def nprf(n):
    pf = {}
    for i in range(2, int(n ** 0.5)+1):
        while n % i == 0:
            pf[i] = pf.get(i, 0) + 1
            n //= i
    if n > 1:
        pf[n] = 1
    return pf

def comb(n, k):
    k = min(k, n-k)
    result = 1
    for i in range(n-k+1, n+1):
        result *= i
    for i in range(1, k+1):
        result //= i
    return result

ans = 1
for v in nprf(m).values():
    ans = ans * comb(v+n-1, v) % mod
    
print(ans)

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

def prf(n):
    pf = {}
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            pf[i] = pf.get(i, 0) + 1
            n //= i
    if n > 1:
        pf[n] = 1
    return pf

def comb(n, k):
    k = min(k, n-k)
    result = 1
    for i in range(n-k+1, n+1):
        result *= i
    for i in range(1, k+1):
        result //= i
    return result

ans = 1
for v in prf(m).values():
    ans = ans * comb(n-1+v, v) % mod
    
print(ans)

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

f = []
p = 2
while p * p <= m:
    if m % p != 0:
        p += 1
        continue
    c = 0
    while m % p == 0:
        c += 1
        m //= p
    f.append(c)
    p += 1
if m != 1:
    f.append(1)


def comb(a, b):
    ret = 1
    r = min(b, a-b)
    for i in range(a-r+1, a+1):
        ret *= i
    for j in range(1, r+1):
        ret //= j

    return (int)(ret)


ans = 1
for i in f:
    ans *= comb(i+n-1, i)
print(ans % mod)

Solution (Python):

def prf(m):
    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
        
    return pf


def comb(n, k):
    k = min(k, n - k)
    result = 1
    for i in range(n, n - k, -1):
        result *= i
    for i in range(1, k + 1):
        result //= i 
    return result
 
n, m = map(int, input().split())
mod = 10 ** 9 + 7

ans = 1
for i in prf(m).values():
    ans = ans * comb(n - 1 + i, i) % mod
    
print(ans)

Solution (Python):
MOD = 10 ** 9 + 7

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

f = []
p = 2
while p * p <= M:
    if M % p != 0:
        p += 1
        continue
    c = 0
    while M % p == 0:
        c += 1
        M //= p
    f.append(c)
    p += 1
if M != 1:
    f.append(1)

ans = 1
for i in f:
    c = 1
    for j in range(i):
        c = c * (N + j) // (j + 1)
    ans = ans * c % MOD
print(ans)

Solution (Python):
from math import factorial

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

pdic={}

p=2
while M>1:
    c=0
    while M%p==0:
        c+=1
        M//=p
    if c>0:
        pdic[p]=c
    p+=1

ans=1
tmp=factorial(N-1)

for p in pdic.keys():
    e=pdic[p]
    ans*=factorial(N+e-1)//(factorial(e)*tmp)

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

Solution (Python):
from math import factorial

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

pdic={}

p=2
while p**2<=M:
    c=0
    while M%p==0:
        c+=1
        M//=p
    if c>0:
        pdic[p]=c
    p+=1
if M>1:
    pdic[M]=1

ans=1
tmp=factorial(N-1)

for p in pdic.keys():
    e=pdic[p]
    ans*=factorial(N+e-1)//(factorial(e)*tmp)

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

Solution (Python):
from collections import Counter
from itertools import combinations_with_replacement
N, M = map(int, input().split())
mod = 10 ** 9 + 7


def nHk(n, k):
    value = 1
    nk = n + k - 1
    k = min(nk-k, k)
    for i in range(k):
        value = (value * nk) % mod
        nk -= 1
    for x in range(1, k + 1):
        value = (value * pow(x, mod-2, mod)) % mod
    return value



def prime_factorization(n):
    table = []
    for x in range(2, int(n**0.5)+1):
        while n % x == 0:
            table.append(x)
            n //= x
    if n > 1:
        table.append(n)
    return table


ans = 1
T = prime_factorization(M)
C = Counter(T)
for v in C.values():
    ans = ans * nHk(N, v) % mod

print(ans)

Solution (Python):
import math

def prime_factorize(n):
    ret = []
    
    for i in range(2, int(math.sqrt(n))+1):
        if n % i != 0:
            continue
        e = 0
        while n % i == 0:
            e += 1
            n //= i
        ret += [(i, e)]

    if n != 1:
        ret += [(n, 1)]

    return ret


def extgcd(a, b):
    x,y, u,v = 0,1, 1,0
    while a != 0:
        q, r = b//a, b%a
        m, n = x-u*q, y-v*q
        b,a, x,y, u,v = a,r, u,v, m,n
        g = b
    return x, y, g


def modinv(a, m):
    x, y, g = extgcd(a, m)
    if g != 1:
        print ("[+]Inverse does not exist.")
    else:
        return ((m + x) % m) % m


def mod_comb(n, r, mod):
    ans_mul, ans_div = 1, 1

    for i in range(r):
        ans_mul *= (n-i)
        ans_div *= (i+1)
        ans_mul %= mod
        ans_div %= mod

    return ans_mul * modinv(ans_div, mod) % mod


def main():
    N, M = map(int, input().split())
    v = prime_factorize(M)
    MOD = int(10**9+7)
    ans = 1

    for i in v:
        ans *= mod_comb(N+i[1]-1, i[1], MOD)
        ans %= MOD
    print (ans)

main()

Solution (Python):
import math

def prime_factorize(n):
    ret = []
    
    for i in range(2, int(math.sqrt(n))+1):
        if n % i != 0:
            continue
        e = 0
        while n % i == 0:
            e += 1
            n //= i
        ret += [(i, e)]

    if n != 1:
        ret += [(n, 1)]

    return ret


def extgcd(a, b):
    x,y, u,v = 0,1, 1,0
    while a != 0:
        q, r = b//a, b%a
        m, n = x-u*q, y-v*q
        b,a, x,y, u,v = a,r, u,v, m,n
        g = b
    return x, y, g


def modinv(a, m):
    x, y, g = extgcd(a, m)
    if g != 1:
        print ("[+]Inverse does not exist.")
    else:
        return ((m + x) % m) % m


def calc_comb(n, r, mod):
    ans_mul, ans_div = 1, 1

    for i in range(r):
        ans_mul *= (n-i)
        ans_div *= (i+1)
        ans_mul %= mod
        ans_div %= mod

    return ans_mul * modinv(ans_div, mod) % mod


def main():
    N, M = map(int, input().split())
    v = prime_factorize(M)
    MOD = int(10**9+7)
    ans = 1

    for i in v:
        ans *= calc_comb(N+i[1]-1, i[1], MOD)
        ans %= MOD
    print (ans)

main()

Solution (Python):
import math

def prime_factorize(n):
    ret = []
    
    for i in range(2, int(math.sqrt(n))+1):
        if n % i != 0:
            continue
        e = 0
        while n % i == 0:
            e += 1
            n //= i
        ret += [(i, e)]

    if n != 1:
        ret += [(n, 1)]

    return ret


def extgcd(a, b):
    x,y, u,v = 0,1, 1,0
    while a != 0:
        q, r = b//a, b%a
        m, n = x-u*q, y-v*q
        b,a, x,y, u,v = a,r, u,v, m,n
        g = b
    return x, y, g


def modinv(a, m):
    x, y, g = extgcd(a, m)
    if g != 1:
        print ("[+]Inverse does not exist.")
    else:
        return ((m + x) % m) % m


def calc_comb(n, k, mod):
    if k > n-k:
        return calc_comb(n, n-k, mod)

    ans_mul, ans_div = 1, 1

    for i in range(k):
        ans_mul *= (n-i)
        ans_div *= (i+1)
        ans_mul %= mod
        ans_div %= mod

    return (ans_mul * modinv(ans_div, mod) % mod)


def main():
    N, M = map(int, input().split())
    v = prime_factorize(M)
    MOD = int(10**9+7)
    ans = 1

    for i in v:
        ans *= calc_comb(N+i[1]-1, i[1], MOD)
        ans %= MOD
    print (ans)

main()

Solution (Python):
Mod = 10**9+7
inv = [0]*41
inv[1] = 1
for i in range(2,41):
  inv[i] = (-(Mod//i)*inv[Mod%i])%Mod
n,m = map(int,input().split())

primes = []
k = 2
while k*k <= m:
  f = 1
  for p in primes:
    if k%p == 0:
      f = 0
      break
  if f == 1:
    primes += [k]
  k += 1


d = {}
a = m
for p in primes:
  c = 0
  while a%p == 0:
    c += 1
    a //= p
  if c>0:
    d[p] = c
if a > 1:
  d[a] = 1


s = 1
for k in d.values():
  
  t = 1
  for i in range(k):
    t = t*(k+n-1-i)*inv[i+1]%Mod
  s = s*t%Mod
print(s)

Solution (Python):
import math

mod = 1000000007

def modinverse(a, m):
    x = 0
    y = 1
    gcd = m
    px = 1
    py = 0
    pgcd = a
    temp = 0

    while gcd > 0:
        quotient = pgcd // gcd

        temp = x
        x = px - quotient * temp
        px = temp

        temp = y
        y = py - quotient * temp
        py = temp

        temp = gcd
        gcd = pgcd - quotient * temp
        pgcd = temp
    if px < 0:
        px += m
    return px

def combination(n, r):
    u = 1
    for i in range(n, n - r, -1):
        u = (u * i) % mod
    d = 1
    for i in range(r, 1, -1):
        d *= i
    inverse = modinverse(d, mod)
    return (u * inverse) % mod
 
 

prime = [2]
N, M = map(int, input().split())   
count = 0
for i in range(3, math.floor(math.sqrt(M)) + 1, 2):
    f = True
    for x in prime:
        if i % x == 0:
            f = False
            break
    if f:
        prime.append(i)

c = [0 for i in range(len(prime))]
num = M
for i in range(len(prime)):
    while num % prime[i] == 0:
        c[i] += 1
        num = num // prime[i]
if num != 1:
    prime.append(num)
    c.append(1)

ans = 1
for i in range(len(prime)):
    if c[i] != 0:
        ans *= combination(c[i] + N - 1, c[i])
        ans %= mod

print(ans)

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

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

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)]


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])

    return result;


table, counter = prime_decomposition(M)
result = 1

for i in counter:
    a = cmb_(int(i)+int(N)-1,int(N)-1)

    result *= a

print(result%(10**9+7))

Solution (Python):
def prime_factorize(num):
    """
    This function performs prime factorization on the input natural number.
    The result is returned in the form of a dictionary with the prime number as the key
    and its number as the value.
    :param num:
    :return prime_factor: Dictionary with the prime number as the key and its number as the value.
    """
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor



def combination(n, r):
    r = min(n-r, r)
    result = 1
    for i in range(n, n-r, -1):
        result *= i
    for i in range(1, r+1):
        result //= i
    return result


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

prime_fac = prime_factorize(m)
for v in prime_fac.values():
    r *= combination(v + n - 1, v)
mod = 1000000000 + 7
print(r % mod)

Solution (Python):
def prime_factorize(num):
    """
    This function performs prime factorization on the input natural number.
    The result is returned in the form of a dictionary with the prime number as the key
    and its number as the value.
    :param num:
    :return prime_factor: Dictionary with the prime number as the key and its number as the value.
    """
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor


from math import factorial


def comb(n, r, R):
    if n not in R:
        a = factorial(n)
        R[n] = a
    else:
        a = R[n]

    if n - r not in R:
        b = factorial(n - r)
        R[n - r] = b
    else:
        b = R[n - r]

    if r not in R:
        c = factorial(r)
        R[r] = c
    else:
        c = R[r]
    return a // (b * c)


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

R = dict()
prime_fac = prime_factorize(m)
for v in prime_fac.values():
    r *= comb(v + n - 1, v, R)
mod = 1000000000 + 7
print(r % mod)

Solution (Python):
def prime_factorize(num):
    """
    This function performs prime factorization on the input natural number.
    The result is returned in the form of a dictionary with the prime number as the key
    and its number as the value.
    :param num:
    :return prime_factor: Dictionary with the prime number as the key and its number as the value.
    """
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor


from math import factorial


def comb(n, r, R):
    if n not in R:
        a = factorial(n)
        R[n] = a
    else:
        a = R[n]

    if n - r not in R:
        b = factorial(n - r)
        R[n - r] = b
    else:
        b = R[n - r]

    if r not in R:
        c = factorial(r)
        R[r] = c
    else:
        c = R[r]
    return a // (b * c)


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

R = dict()
prime_fac = prime_factorize(m)
for v in prime_fac.values():
    r *= comb(v + n - 1, v, R)
mod = 1000000000 + 7
print(r % mod)

Solution (Python):
def prime_factorize(num):
    """
    This function performs prime factorization on the input natural number.
    The result is returned in the form of a dictionary with the prime number as the key
    and its number as the value.
    :param num:
    :return prime_factor: Dictionary with the prime number as the key and its number as the value.
    """
    prime_factor = {}
    i = 2
    while i ** 2 <= num:
        while num % i == 0:
            num //= i
            if i in prime_factor.keys():
                prime_factor[i] += 1
            else:
                prime_factor[i] = 1
        i += 1
    if num > 1:
        prime_factor[num] = 1
    return prime_factor


from math import factorial


def comb(n, r):
    return factorial(n) // (factorial(n-r) * factorial(r))


n, m = map(int, input().split())
r = 1
prime_fac = prime_factorize(m)
for v in prime_fac.values():
    r *= comb(v+n-1, v)
mod = 1000000000 + 7
print(r % mod)

Solution (Python):
import collections

def factor(m):
    num=m
    s=[]
    i=2
    while i*i<=m:
        if num%i:
            i+=1
        else:
            s.append(i)
            num//=i
    if num!=1:
        s.append(num)
    return s

def conb(n,r):
    r=min(r,n-r)
    N,R=n,r
    if r==1:
        return n
    elif r==0:
        return 1
    else:
        for i in range(1,r):
            N*=n-i
            R*=r-i
        return N//R
	
n,m=map(int,input().split())
a=factor(m)
b=collections.Counter(a)
mod=10**9+7
ans=1
for i in b.values():
    ans=(ans*conb(n+i-1,n-1))%mod
print(ans)

Solution (Python):
import collections

def factor(m):
    num=m
    s=[]
    i=2
    while i*i<=m:
        if num%i:
            i+=1
        else:
            s.append(i)
            num//=i
    if num!=1:
        s.append(num)
    return s

def conb(n, r):
	N, R = n, r
	for i in range(1, r):
		N *= n-i
		R *= r-i
	return N // R
	
n,m=map(int,input().split())
a=factor(m)
b=collections.Counter(a)
mod=10**9+7
ans=1
for i in b.values():
    ans=(ans*conb(n+i-1,i))%mod
print(ans)

Solution (Python):
N, M = [int(_) for _ in input().split()]

mod = 10 ** 9 + 7
MAX_N = 10 ** 5 + 100


def calc_factorial(max_i):
    factorial = [1] * max_i
    for i in range(1, max_i):
        factorial[i] = (i * factorial[i - 1]) % mod
    return factorial


def calc_factorization(n):
    factorization = {}
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            factorization[i] = 1
            n = n // i
            while n % i == 0:
                factorization[i] += 1
                n = n // i
    if n > 1:
        factorization[n] = 1
    return factorization


def comb(factorial, n, k, mod):
    a = factorial[n] % mod
    b = (factorial[k] * factorial[n - k]) % mod
    b_ = pow(b, mod - 2, mod)
    return (a * b_) % mod

C = calc_factorization(M)

factorial = calc_factorial(MAX_N)

res = 1
for c in C.items():
    res *= comb(factorial, (c[1] + N - 1), c[1], mod) 

print(res % mod)

Solution (Python):
MOD = int(1e9) + 7


def countup(N, s):
    dp = [0] * (s+1)
    dp[s] = 1
    for _ in range(N):
        for i in range(s):
            dp[i] = sum(dp[i:s+1]) % MOD
    return dp[0]


def main():
    N, M = map(int, input().split())
    F = {}
    i = 2
    while M > 1:
        while M % i == 0:
            if i not in F:
                F[i] = 0
            F[i] += 1
            M //= i
        i += 1
    retval = 1
    for i in F:
        retval *= countup(N, F[i])
        retval %= MOD
    print(retval)


if __name__ == "__main__":
    main()

Solution (Python):
import collections

def factor(m):
  q = m
  r = []
  i = 2
  while i * i <= m:
    if q % i:
      i += 1
    else:
      r.append(i)
      q //= i
  if q != 1:
    r.append(q)
  return r

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

r = factor(m)
v = collections.Counter(r)
c = 1
for value in v.values():
  temp = 1
  for i in range(value):
    temp *= value + n - 1 - i
  for i in range(value):
    temp //= i + 1
  temp %= p
  c = c * temp % p
print(c)