Buggy python submission (verdict: Time Limit Exceeded):
from scipy.misc import comb


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

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


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

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


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

print(ans)


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


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

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


N, M = map(int, input().split())
MOD = 10**9+7
# M を素因数分解
rest = M
ans = 1
for i in range(2, int(M ** 0.5) + 1):
    cnt = 0
    while rest % i == 0:
        cnt += 1
        rest //= i
    # cnt が 2^X 1とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD
if rest != 1:
    cnt = 1
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
MOD = 10**9+7

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


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

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


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

print(ans)


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


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

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


N, M = map(int, input().split())
MOD = 10**9+7
# M を素因数分解
rest = M
ans = 1
for i in range(2, int(M ** 0.5) + 1):
    cnt = 0
    while rest % i == 0:
        cnt += 1
        rest //= i
    # cnt が 2^X 1とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD
if rest != 1:
    cnt = 1
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
MOD = 10**9+7


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


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


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


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

print(ans)


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


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

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


N, M = map(int, input().split())
MOD = 10**9+7
# M を素因数分解
rest = M
ans = 1
for i in range(2, int(M ** 0.5) + 1):
    cnt = 0
    while rest % i == 0:
        cnt += 1
        rest //= i
    # cnt が 2^X 1とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD
if rest != 1:
    cnt = 1
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
MOD = 10**9+7


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


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


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

print(ans)


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


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

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


N, M = map(int, input().split())
MOD = 10**9+7
# M を素因数分解
rest = M
ans = 1
for i in range(2, int(M ** 0.5) + 1):
    cnt = 0
    while rest % i == 0:
        cnt += 1
        rest //= i
    # cnt が 2^X 1とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD
if rest != 1:
    cnt = 1
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
MOD = 10**9+7


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


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


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

print(ans)


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


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

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


N, M = map(int, input().split())
MOD = 10**9+7
# M を素因数分解
rest = M
ans = 1
for i in range(2, int(M ** 0.5) + 1):
    cnt = 0
    while rest % i == 0:
        cnt += 1
        rest //= i
    # cnt が 2^X 1とか 3^X の X の部分
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD
if rest != 1:
    cnt = 1
    ans *= combination(N+cnt-1, N-1)
    ans %= MOD

print(ans)