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:
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)`
    が成り立つ。
    """
    primes = prime_facts(M)
    ret = 1
    for k in primes.values():
        ret *= pi(0, k - 1, N) // fact(k)

    return ret % 1_000_000_007


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

Submission status: Runtime Error

Solution code:
from math import sqrt


def divisors(n: int) -> list:
    res = []

    sn = int(sqrt(n))
    if sn * sn == n:
        res.append(sn)
    else:
        sn += 1

    for d in range(1, sn):
        if n % d == 0:
            res = [d] + res + [n//d]

    return res


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)`
    が成り立つ。
    """
    primes = prime_facts(M)
    ret = 1
    for k in primes.values():
        ret *= pi(0, k - 1, N) // fact(k)

    return ret % 1_000_000_007


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

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

vector<pair<long long, long long> > prime_factorize(long long n) {
  vector<pair<long long, long long> > res;
  for (long long p = 2; p * p <= n; ++p) {
    if (n % p != 0) continue;
    int num = 0;
    while (n % p == 0) { ++num; n /= p; }
    res.push_back(make_pair(p, num));
  }
  if (n != 1) res.push_back(make_pair(n, 1));
  return res;
}

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

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++){
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
    finv[i] = finv[i-1] * inv[i] % MOD;
  }
}
long long COM(int n, int k){
  if(n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main(){
  ll N,M;
  cin >> N >> M;
  COMinit();
  auto vec = prime_factorize(M);

  ll ans = 1;
  for(auto v: vec){
    int num = v.second;
    ll ret = COM(num+N-1,N-1);
    ans = ans*ret % MOD;
  }

  cout << ans << endl;



  return 0;
}

Submission status: Runtime Error

Solution code:
import math
import sympy

def kai(n):
    return math.factorial(n)

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

prime = sympy.factorint(M)

ans = 1
for v in prime.values():
    ans  =  ans * (kai(N+v-1)/(kai(v)*kai(N-1)))

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

Submission status: Runtime Error

Solution code:
import math
import sympy

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

def kai(n):
    return math.factorial(n)

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

prime = sympy.factorint(M)

ans = 1
for v in prime.values():
    ans  =  ans * (kai(N+v-1)/(kai(v)*kai(N-1)))

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

Submission status: Runtime Error

Solution code:
from scipy.special import comb

n, m= [int(i) for i in input().split(" ")]

c = []
i = 2
mt = m

while i * i <= mt:
    ci = 0
    while mt % i == 0:
        mt = mt // i
        ci += 1
    if ci > 0:
        c.append(ci)
    i += 1
if mt > 1:
    c.append(1)
    
p = 1
for j in range(0, len(c)):
    p *= comb(n - 1 + c[j], c[j], exact=True)

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

Submission status: Runtime Error

Solution code:
def gen_to_list(func):
    def wrapper(*args):
        return list(func(*args))
    return wrapper
def memorize(func):
    memo = {}
    def wrapper(*args):
        if args not in memo:
            memo[args] = func(*args)
        return memo[args]
    return wrapper
@gen_to_list
def factorize(n, factor=2, index=0):
    counter = 0
    while True:
        if n%factor==0:
            n //=factor
            counter += 1
        else:
            break
    if counter>0:
        yield (factor, counter)
    if factor**2 < n:
        yield from factorize(n, factor+1)
    elif n>2:
        yield (n, 1)
@memorize
def choose(N, M):
    if M>N:
        return 0
    if N==0 or M==0:
        return 1
    else:
        return N*choose(N-1, M-1)//M
def ans(N, M):
    val = 1
    for _, r in factorize(M):
        val *= choose(N+r-1, r)
        val %= (10**9+7)
    return val
print(ans(*map(int, input().split())))

Submission status: Runtime Error

Solution code:
# 2 6=>4 (1,6)*2,(2,3)*2
# 3 12=>18 (1,1,12)*3,(1,2,6)*6,(1,3,4)*6,(2,2,3)*3
import math
def comb(a,b): # aCb
    return math.factorial(a)//math.factorial(a-b)//math.factorial(b)

n,m=map(int,input().split())
rootm=int(m**0.5)
divisor={}
tmp=m
for i in range(2,m+1):
    while tmp%i==0:
        tmp//=i
        divisor.setdefault(i,0)
        divisor[i]+=1
    if tmp==1:
        break
print(divisor)
cnt=1
for key in divisor:
    tmp=0
    for c in range(1,divisor[key]+1):
        tmp+=comb(n,c)
    cnt*=tmp
print(cnt%1000000007)

Submission status: Runtime Error

Solution code:
import scipy
import math

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

M = m
lst, count = [],[]
for i in range(2,int(math.sqrt(m))+1):
    while M % i == 0:
        M = M // i
        if i not in lst:
            count.append(1)
            lst.append(i)
        else:
            count[-1] += 1
if M > 1:
    lst.append(M)
    count.append(1)       

ans = 1
for i in count:
    ans = ans * scipy.special.comb(i+n-1,i)
    ans = ans % (10**9+7) 

print(int(ans))

Submission status: Runtime Error

Solution code:
import scipy.special
import math

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

M = m
lst, count = [],[]
for i in range(2,int(math.sqrt(m))+1):
    while M % i == 0:
        M = M // i
        if i not in lst:
            count.append(1)
            lst.append(i)
        else:
            count[-1] += 1
if M > 1:
    lst.append(M)
    count.append(1)       

ans = 1
for i in count:
    ans = ans * scipy.special.comb(i+n-1,i)
    ans = ans % (10**9+7) 

print(int(ans))

Submission status: Runtime Error

Solution code:
import scipy.special
import math

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

M = m
lst, count = [],[]
for i in range(2,int(math.sqrt(m))+1):
    while M % i == 0:
        M = M // i
        if i not in lst:
            count.append(1)
            lst.append(i)
        else:
            count[-1] += 1
if M > 1:
    lst.append(M)
    count.append(1)       

ans = 1
for i in count:
    ans *= scipy.special.comb(i+n-1,i)
    ans = ans % (10**9+7) 

print(int(ans))

Submission status: Runtime Error

Solution code:
import scipy.special

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

M = m
lst, count = [],[]
for i in range(2,int(math.sqrt(m))+1):
    while M % i == 0:
        M = M // i
        if i not in lst:
            count.append(1)
            lst.append(i)
        else:
            count[-1] += 1
if M > 1:
    lst.append(M)
    count.append(1)       

ans = 1
for i in count:
    ans *= scipy.special.comb(i+n-1,i)
    ans = ans % (10**9+7) 

print(int(ans))

Submission status: Runtime Error

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

M = m
lst, count = [],[]
for i in range(2,int(math.sqrt(m))+1):
    while M % i == 0:
        M = M // i
        if i not in lst:
            count.append(1)
            lst.append(i)
        else:
            count[-1] += 1
if M > 1:
    lst.append(M)
    count.append(1)       

ans = 1
for i in count:
    ans *= scipy.special.comb(i+n-1,i)
    ans = ans % (10**9+7) 

print(int(ans))

Submission status: Runtime Error

Solution code:
import math
import random
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)
    # nのすべての素因数を見つける
    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
class Factorial:
    def __init__(self,n,mod):
        self.f=[1]
        for i in range(1,n+1):
            self.f.append(self.f[-1]*i%mod)
        self.i=[pow(self.f[-1],mod-2,mod)]
        for i in range(1,n+1)[::-1]:
            self.i.append(self.i[-1]*i%mod)
        self.i.reverse()
    def factorial(self,i):
        return self.f[i]
    def ifactorial(self,i):
        return self.i[i]
    def comb(self,n,k):
        return self.f[n]*self.i[n-k]%mod*self.i[k]%mod
mod=10**9+7
n,m=map(int,input().split())
*d,=Prime().find_factors(m).values()
f=Factorial(n+max(d),mod)
ans=1
for t in d:
    ans=ans*f.comb(n-1+t,t)%mod
print(ans)

Submission status: Runtime Error

Solution code:
from scipy.misc import comb
c=Counter()
n,m=map(int,input().split())
t=2
while t*t<=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)

Submission status: Runtime Error

Solution code:
import math
p=[]
d=[i+1for i in range(1,10**5)]
while 1:
    t=d[0]
    if math.sqrt(10**5)<=t:
        p+=d
        break
    p.append(t)
    d=[e for e in d if e%t]
n,m=map(int,input().split())
a=1
while m>1:
    t=p.pop(0)
    if m%t:
        continue
    c=0
    while not m%t:
        m//=t
        c+=1
    a=a*math.factorial(n+c-1)//(math.factorial(n-1)*math.factorial(c))%(10**9+7)
print(a)

Submission status: Runtime Error

Solution code:
import math
from scipy.special import comb
p=[]
d=[i+1for i in range(1,10**5)]
while 1:
    t=d[0]
    if math.sqrt(10**5)<=t:
        p+=d
        break
    p.append(t)
    d=[e for e in d if e%t]
n,m=map(int,input().split())
a=1
while m>1:
    t=p.pop(0)
    if m%t:
        continue
    c=0
    while not m%t:
        m//=t
        c+=1
    a=a*math.factorial(n+c-1)//(math.factorial(n-1)*math.factorial(c))%(10**9+7)
print(a)

Submission status: Runtime Error

Solution code:
import math
from scipy.special import comb
p=[]
d=[i+1for i in range(1,10**5)]
while 1:
    t=d[0]
    if math.sqrt(10**5)<=t:
        p+=d
        break
    p.append(t)
    d=[e for e in d if e%t]
n,m=map(int,input().split())
a=1
while m>1:
    t=p.pop(0)
    if m%t:
        continue
    c=0
    while not m%t:
        m//=t
        c+=1
    a=a*comb(n+c-1,c,exact=1)%(10**9+7)
print(a)

Submission status: Runtime Error

Solution code:
#nの約数列挙
def devisor(n):
    ans = []
    if n == 1:return [1]
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            if i != n//i:
                ans.append(i)
                ans.append(n//i)
            else:
                ans.append(i)
            

    return ans       

#n個の正数の積でmになる場合の数
def cnt(n,m):
    ans = 0
    if n == 1:return 1
    s = devisor(m)
    for i in s:
        ans += cnt(n-1,m//i)
    return ans


N,M = list(map(int,input().split()))
print(cnt(N,M))

Submission status: Runtime Error

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

l_prime = [0]*(n+1)
N = n
ran = range(3, N+1)

while n % 2 == 0:
    l_prime[2] += 1
    n /= 2

for i in ran:
    while n != 1:
        if n % i == 0:
            n /= i
            l_prime[i] += 1
        else:
            i += 2


def fact(n):
    tmp = 1
    while n != 0:
        tmp *= n
        n -= 1

    return tmp


def comb(a, b):
    if a < b:
        print("err")

    return (int)(fact(a)/(fact(a-b)*fact(b)))


res = 1
for i in range(1, N+1):
    ele = l_prime[i]
    if ele != 0:
        ret = comb(ele+m-1, ele)
        res *= ret

print(res % (10**9+1))

Submission status: Runtime Error

Solution code:
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)

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

Submission status: Runtime Error

Solution code:
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 calc():
    MOD, MAX_V = int(10**9+7), 1000
    table = [ [0]*MAX_V for _ in range(MAX_V) ]
    table[0][0] = 1
    for i in range(1, MAX_V):
        table[i][0] = 1
        for j in range(1, MAX_V):
            table[i][j] = (table[i-1][j-1] + table[i-1][j]) % MOD
    return table


def main():
    N, M = map(int, input().split())
    v = prime_factorize(M)

    table = calc()
    ans = 1

    for i in v:
        ans *= int(table[N+i[1]-1][i[1]])
    
    print (ans)

main()

Submission status: Runtime Error

Solution code:
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)
    if r==0:
      return 1
    else:
    	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)

Submission status: Runtime Error

Solution code:
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)
    if r==0:
      return 1
    else:
      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)

Submission status: Runtime Error

Solution code:
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
    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)

Submission status: Runtime Error

Solution code:
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
    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)

Submission status: Runtime Error

Solution code:
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, min(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,n-1))%mod
print(ans)

Submission status: Runtime Error

Solution code:
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,n-1))%mod
print(ans)

Submission status: Runtime Error

Solution code:
import math
import sympy
n, m = map(int, input().split())
di = sympy.factorint(m)
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans = 1
mod = 10 ** 9 + 7
for i in di:
    ans = ans * comb(di[i] + n - 1, di[i]) % mod
print(ans)

Submission status: Runtime Error

Solution code:
mod = 10 ** 9 + 7
N, M = [int(_) for _ in input().split()]

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


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


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


# 素因数分解
factorization(M)

# 階乗を用意
calc_factorial()

ans = 1
for k, v in factorize_result.items():
    ans *= comb(N + v - 1, v) % mod

print(ans % mod)

Submission status: Runtime Error

Solution code:
import math
from scipy.misc import comb
 
N, M = map(int, input().split())
li1 = []
li2 = []
a = 1

for j in range(2, int(math.sqrt(M))):
    dest = int(math.sqrt(j))
    for i in range(2,dest):
        if j % i == 0:
            continue
    li1.append(j)

for k in range(len(li1)):
    if M % li1[k] != 0:
        continue
    c = 0
    x = M
    while x % li1[k] == 0:
        x = x / li1[k]
        c += 1
    li2.append(c)

for l in range(len(li2)):
    a *= comb(li2[l] + N - 1, N - 1)

print(int(a))

Submission status: Runtime Error

Solution code:
import math
from scipy.misc import comb
 
N, M = map(int, input().split())
li1 = []
li2 = []
a = 1

for j in range(2, int(math.sqrt(M))):
    dest = int(math.sqrt(j))
    for i in range(2,dest):
        if j % i == 0:
            continue
    li1.append(j)

for k in len(li1):
    if M % li1[k] != 0:
        continue
    c = 0
    x = M
    while x % li1[k] == 0:
        x = x / li1[k]
        c += 1
    li2.append(c)

for l in len(li2):
    a *= comb(li2[l] + N - 1, N - 1)

print(a)

Submission status: Runtime Error

Solution code:
import math
import scipy.special

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

def factorize(M):
    P = []
    F = []
    for m in range(2, int(math.sqrt(M))+1):
        n = 0
        while M % m == 0:
            M/= m
            n +=1
        if n != 0:
            P.append(m)
            F.append(n)
    if M != 1:
        P.append(M)
        F.append(1)
    return P,F

P, F = factorize(M)

X = 1
for f in F:
    X *= int(scipy.special.comb(N+f-1, f, exact=True))
    X %= int(pow(10,9)+7)

print(X)

Submission status: Runtime Error

Solution code:
from scipy.special import comb 
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 inpl(): return [int(i) for i in input().split()]

mod = 10**9+7
N, M = inpl()

ans = 1
for i in prf(M).values():
    ans = ans*comb(N+i-1, i, exact = True)%mod
print(ans)

Submission status: Runtime Error

Solution code:
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 inpl(): return [int(i) for i in input().split()]
mod = 10**9+7
N, M = inpl()
fac = [1 for _ in range(2*N+1)]
for i in range(2*N):
    fac[i+1] = (i+1)*fac[i]%mod

inv = [1 for _ in range(2*N+1)]
for i in range(2,2*N+1):
    inv[i] = (-(mod//i) * inv[mod%i]) %mod    

facinv = [1 for _ in range(2*N+1)]
for i in range(2*N):
    facinv[i+1] = inv[i+1]*facinv[i]%mod

ans = 1
for i in prf(M).values():
    ans = ans*fac[N+i-1]*facinv[i]*facinv[N-1]%mod
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
b = list(map(int,input().split()))
 
#b = list(set(a))
b.sort()
 
if len(b) > 1:
    l = len(b)//2
    print(b[l])
else:
    print(b[0])

Submission status: Runtime Error

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

#b = list(set(a))
b.sort()
print(b)
 
if len(b) > 1:
    l = len(b)//2
    print(b[l])
else:
    print(b[0])

Submission status: Runtime Error

Solution code:
import math

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

sqrt_m = math.sqrt(m)
sqrt_m = int(sqrt_m) + 1

mod = 10**9 + 7
fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, sqrt_m + 2):
    fac.append(fac[i-1] * i % mod)
    inv.append(mod - inv[mod%i] * (mod//i) % mod)
    finv.append(finv[i-1] * inv[i] % mod)

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


prime = []
for i in range(2, sqrt_m + 1):
    count = 0
    while m % i == 0:
        m = m // i
        count += 1
    if count > 0:
        prime.append(count)
if m > 1:
    prime.append(1)

ans = 1
for i in prime:
    ans *= nck(n-1+i, i)
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
import math

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

mod = 10**9 + 7
fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n+5):
    fac.append(fac[i-1] * i % mod)
    inv.append(mod - inv[mod%i] * (mod//i) % mod)
    finv.append(finv[i-1] * inv[i] % mod)

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

sqrt_m = math.sqrt(m)
sqrt_m = int(sqrt_m) + 1
prime = []
for i in range(2, sqrt_m + 1):
    count = 0
    while m % i == 0:
        m = m // i
        count += 1
    if count > 0:
        prime.append(count)
if m > 1:
    prime.append(1)

ans = 1
for i in prime:
    ans *= nck(n-1+i, i)
    ans %= mod

print(ans)

Submission status: Runtime Error

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import Counter

def factorize(n: int):
    d = Counter()
    m= 2
    
    while m*m <= n:
        while n%m == 0:
            n //= m
            d[m] += 1
            
        m += 1
        
    if n > 1:
        d[n] += 1
        
    return d

# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv
       
# nの階乗のリスト
def fact(n:int, mod:int) -> list:
    fac = [1,1]
    res = 1
    for i in range(2,n+1):
        res = res*i%mod
        fac.append(res)
    return fac

# nの階乗の逆元のリスト
def fact_inv(n:int, inv:list, mod:int) -> list:
    facInv = [1,1]
    for i in range(2,n+1):
        facInv.append(facInv[i-1]*inv[i] % mod)
    return facInv
        
# 二項係数
def nCr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if not (0<=r and r<=n):
        return 0
    
    return ((fac[n]*facInv[r]) % mod) * facInv[n-r] % mod

# 重複組み合わせ
def nHr(n:int, r:int, mod:int, fac:list, facInv:list) -> int:
    if r<0 or n<0:
        return 0
    
    else:
        return nCr(n+r-1,r,mod,fac,facInv)

n,m = li()
MOD = 10**9+7

inv = inv_mod(10**5, MOD)
fac = fact(10**5, MOD)
facinv = fact_inv(10**5,inv,MOD)

md = factorize(m)

ans = 1
for k,v in md.items():
    ans *= nHr(n,v,MOD,fac,facinv)
    ans %= MOD
    
print(ans)