Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int, input().split()))

ans = 0
for c in range(1, N):
    a = 0
    se = set(list(range(N)))
    for i in range(1, (N-1)//c):
        if i*c not in se or N-1-i*c not in se or i*c == N-1-i*c:
            break
        se.remove(i*c)
        se.remove(N-1-i*c)
        a += S[i*c] + S[N-1-i*c]
        ans = max(ans, a)
print(ans)

Fixed submission:
N = int(input())
S = list(map(int, input().split()))

ans = 0
for c in range(1, N):
    a = 0
    if (N-1) % c:
        for i in range(1, (N-1)//c):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
    else:
        se = set(list(range(N)))
        for i in range(1, (N-1)//c):
            if i*c not in se or N-1-i*c not in se or i*c == N-1-i*c:
                break
            se.remove(i*c)
            se.remove(N-1-i*c)
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(int, input().split()))

ans = 0
for c in range(N):
    a = 0
    if (N-1) % c:
        for i in range(1, (N-1)//c):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
    else:
        for i in range(1, (N-1)//(2*c)):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
print(ans)

Fixed submission:
N = int(input())
S = list(map(int, input().split()))

ans = 0
for c in range(1, N):
    a = 0
    if (N-1) % c:
        for i in range(1, (N-1)//c):
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
    else:
        se = set(list(range(N)))
        for i in range(1, (N-1)//c):
            if i*c not in se or N-1-i*c not in se or i*c == N-1-i*c:
                break
            se.remove(i*c)
            se.remove(N-1-i*c)
            a += S[i*c] + S[N-1-i*c]
            ans = max(ans, a)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
S = [input() for _ in range(N)]
a = 0
b = 0
ans = 0
aru = False
zenaru = True
for s in S:
    TB = (s[0] == 'B')
    TA = (s[-1] == 'A')
    ans += s.count('AB')
    if TB:
        b += 1
        aru = True
    if TA:
        a += 1
        aru = True
    if TA ^ TB:
        zenaru = False
if a == 0 or b == 0:
    print(ans)
    sys.exit()
print(ans + min(a, b) - zenaru)



Fixed submission:
N, K = map(int, input().split())
print(N - K + 1)
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for a in A for b in B]
AB.sort()
AB = AB[-K:]
ABC = [ab + c for ab in AB for c in C]
ABC.sort()
for v in ABC[-1:-K-1:-1]:
    print(v)


Fixed submission:
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = [a + b for a in A for b in B]
AB.sort()
AB = AB[-K:]
ABC = [ab + c for ab in AB for c in C]
ABC.sort()
for v in ABC[-1:-K-1:-1]:
    print(v)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
s = input()
TD = [sys.stdin.readline().split() for _ in range(Q)]

def check(k):
    np = k
    for t, d in TD:
        if s[np] == t:
            if d == 'L':
                np -= 1
            else:
                np += 1
        if not 0 <= np <= N-1:
            return False
    return True

ok = N
ng = -1
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if check(med):
        ok = med
    else:
        ng = med

L = ok

ok = -1
ng = N
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if check(med):
        ok = med
    else:
        ng = med

R = ok
print(R - L + 1)

Fixed submission:
N, Q = map(int, input().split())
S = input()
TX = [list(input().split()) for _ in range(Q)]
def checkl(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i < 0:
            return False
        if i == N:
            i = N - 1
    return True
def checkr(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i > N - 1:
            return False
        if i == -1:
            i = 0
    return True

ok = N
ng = -1
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkl(med):
        ok = med
    else:
        ng = med
L = ok
ok = -1
ng = N
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkr(med):
        ok = med
    else:
        ng = med
R = ok
print(max(0, R - L + 1))

Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
TX = [list(input().split()) for _ in range(Q)]
def checkl(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i < 0:
            return False
    return True
def checkr(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i > N - 1:
            return False
    return True

ok = N
ng = -1
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkl(med):
        ok = med
    else:
        ng = med
L = ok
ok = -1
ng = N
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkr(med):
        ok = med
    else:
        ng = med
R = ok
print(max(0, R - L + 1))


Fixed submission:
N, Q = map(int, input().split())
S = input()
TX = [list(input().split()) for _ in range(Q)]
def checkl(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i < 0:
            return False
        if i == N:
            i = N - 1
    return True
def checkr(i):
    for t, x in TX:
        if S[i] == t:
            i += 1 if x == 'R' else -1
        if i > N - 1:
            return False
        if i == -1:
            i = 0
    return True

ok = N
ng = -1
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkl(med):
        ok = med
    else:
        ng = med
L = ok
ok = -1
ng = N
while abs(ok - ng) > 1:
    med = (ok + ng)//2
    if checkr(med):
        ok = med
    else:
        ng = med
R = ok
print(max(0, R - L + 1))
Buggy python submission (verdict: Time Limit Exceeded):
def inpl(): return list(map(int, input().split()))

MLE = [[0]*10000 for _ in [0]*10000]

A, B = inpl()
print([A+B, B-A][B%A > 0])
    

Fixed submission:
def inpl(): return list(map(int, input().split()))

A, B = inpl()
print([A+B, B-A][B%A > 0])

Buggy python submission (verdict: Runtime Error):
def inpl(): return list(map(int, input().split()))

def match(x):
    return (2, 5, 5, 4, 5, 6, 3, 7, 6)[x-1]
N, M = inpl()
A = inpl()
A.sort(reverse = True)
matnum = set([match(a) for a in A])
maxdig = 1
Dig = [{0}]
for i in range(1,1+N//min(matnum)):
    k = set()
    for v in Dig[-1]:
        for a in matnum:
            k.add(a+v)
    if N in k:
        maxdig = i
    Dig.append(k)
N1 = N
anstr = ''
for i in range(maxdig, 0, -1):
    for a in A:
        if N1-match(a) in Dig[i-1]:
            anstr += str(a)
            N1 -= match(a)
            break
        
print(anstr)


Fixed submission:
def inpl(): return list(map(int, input().split()))

A, B = inpl()
print([A+B, B-A][B%A > 0])
Buggy python submission (verdict: Runtime Error):
import sys
from collections import deque
def input(): return sys.stdin.readline()
def inpl(): return [int(i) for i in input().split()]
from collections import defaultdict
N, M = inpl()
Edge = defaultdict(lambda: [])
Par = set(range(N)) 
for _ in range(N-1+M):
    A, B = inpl()
    Par.discard(B-1)
    Edge[A-1].append(B-1)
par = list(Par)[0]
dist = [0]*N
Q = deque([par])
while Q:
    st = Q.pop()
    for en in Edge[st]:
        if dist[en] < dist[st] + 1:
            dist[en] = dist[st] + 1
            if len(Edge[en]) == 1:
                Q.append(en)
            else:
                Q.appendleft(en)
Ans = [0]*N
Q = deque([par]) 
while Q:
    st = Q.pop()
    for en in Edge[st]:
        if dist[en] == dist[st] + 1:
            Ans[en] = st+1
            Q.appendleft(en)
for i in Ans:
    print(i)    


Fixed submission:
def inpl(): return [int(i) for i in input().split()]
N, A, B = inpl()
print(min(A,B), max(A+B-N, 0))
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
def inpl(): return [int(i) for i in input().split()]
def f(y):
    return abs(x-A[y])
N, Q = inpl()
A = inpl()
SA = list(itertools.accumulate(A))
if N%2 :
    B = [v for i, v in enumerate(A) if not i%2]
    B = [0] + list(itertools.accumulate(B))
else:
    B = [v for i, v in enumerate(A) if i%2]
    B = [0] + list(itertools.accumulate(B))
    
for _ in range(Q):
    x = int(input())
    lo = 1
    hi = -(-N//2) + 1
    while hi - lo >1:
        mid = (lo+hi)//2
        if mid == 1:
            continue
        if max(f(N-mid-1), f(N-2*mid+1)) <= f(N-mid):
            lo = mid
        else:
            hi = mid    
    print(SA[N-1] - SA[N-lo-1] + B[-((2*lo-N)//2)])
   

Fixed submission:
import itertools
import sys
def input(): return sys.stdin.readline()
def inpl(): return [int(i) for i in input().split()]
def f(y):
    return abs(x-A[y])
N, Q = inpl()
A = inpl()
SA = list(itertools.accumulate(A))
if N%2 :
    B = [v for i, v in enumerate(A) if not i%2]
    B = [0] + list(itertools.accumulate(B))
else:
    B = [v for i, v in enumerate(A) if i%2]
    B = [0] + list(itertools.accumulate(B))
    
for _ in range(Q):
    x = int(input())
    lo = 1
    hi = -(-N//2) + 1
    while hi - lo >1:
        mid = (lo+hi)//2
        if mid == 1:
            continue
        if max(f(N-mid-1), f(N-2*mid+1)) <= f(N-mid):
            lo = mid
        else:
            hi = mid    
    print(SA[N-1] - SA[N-lo-1] + B[-((2*lo-N)//2)])
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left as bl
def LIS(L):
    if not L:
        return 0
    seq = [L[0]]
    for i in L[1:]:
        if seq[-1] < i:
            seq.append(i)
        else:
            seq[bl(seq, i)] = i
    return len(seq)

def LCS(S, T):
    ls = len(S)
    lt = len(T)
    S = [-1] + [ord(s) for s in S]
    T = [-2] + [ord(t) for t in T]
    dp = [0]*((ls+1)*(lt+1))
    geta = ls + 1
    for j in range(1, lt+1):
        for i in range(1, ls+1):
            if S[i] == T[j]:
                dp[geta*j + i] = dp[geta*(j-1) + i-1] + 1
            else:
                dp[geta*j + i] = max(dp[geta*(j-1) + i], dp[geta*j + i-1])
    if not dp[-1]:
        return ''
    ans = [0]*dp[-1]
    i, j = ls, lt
    ctr = -1
    for _ in range(ls + lt):
        if i == 0 or j == 0:
            break
        if S[i] == T[j]:
            ans[ctr] = S[i]
            i -= 1
            j -= 1
            ctr -= 1
        elif dp[(j-1)*geta + i] >= dp[j*geta + i-1]:
            j -= 1
        else:
            i -= 1
    return ''.join([chr(a) for a in ans])

def LCS_length(S, T, alps = 150):
    S = [ord(s) for s in S]
    T = [ord(t) for t in T]
    M = [[] for _ in range(alps)]
    for i, s in enumerate(S):
        M[s].append(i)
    L = []
    for t in T:
        L.extend(reversed(M[t]))
    if not L:
        return 0
    return LIS(L)

s = input().strip()
t = input().strip()
print(LCS(s, t))
assert len(LCS(s, t)) == LCS_length(s, t), 'chigau'


Fixed submission:
def LCS(S, T):
    ls = len(S)
    lt = len(T)
    S = [-1] + [ord(s) for s in S]
    T = [-2] + [ord(t) for t in T]
    dp = [0]*((ls+1)*(lt+1))
    geta = ls + 1
    for j in range(1, lt+1):
        for i in range(1, ls+1):
            if S[i] == T[j]:
                dp[geta*j + i] = dp[geta*(j-1) + i-1] + 1
            else:
                dp[geta*j + i] = max(dp[geta*(j-1) + i], dp[geta*j + i-1])
    if not dp[-1]:
        return ''
    ans = [0]*dp[-1]
    i, j = ls, lt
    ctr = -1
    for _ in range(ls + lt):
        if i == 0 or j == 0:
            break
        if S[i] == T[j]:
            ans[ctr] = S[i]
            i -= 1
            j -= 1
            ctr -= 1
        elif dp[(j-1)*geta + i] >= dp[j*geta + i-1]:
            j -= 1
        else:
            i -= 1
    return ''.join([chr(a) for a in ans])
s = input().strip()
t = input().strip()
print(LCS(s, t))
Buggy python submission (verdict: Runtime Error):
K = list(map(int, input().strip()))
D = int(input())
mod = 10**9+7
a = 0
for i in range(1, J+1):
    if sum(map(int, str(i))) % D == 0:
        a += 1
print(a%mod)
dp = [0]*D
dp[0] += 1
S = 0
for k in K:
    dp[S%D] -= 1
    dp2 = [0]*(D+10)
    for j, d in enumerate(dp):
        dp2[j] += d
        dp2[j+10] -= d
    for j in range(1, D+10):
        dp2[j] = (dp2[j-1] + dp2[j]) % mod
    for j in range(10):
        dp2[(D+j)%D] = (dp2[(D+j)%D] + dp2[D+j]) % mod 
    dp = dp2[:D]
    for j in range(k+1):
        dp[(S+j)%D] = (dp[(S+j)%D] + 1)%mod
    S += k
print((dp[0]-1)%mod)

Fixed submission:
K = list(map(int, input().strip()))
D = int(input())
mod = 10**9+7

dp = [0]*D
dp[0] += 1
S = 0
for k in K:
    dp[S%D] -= 1
    dp2 = [0]*(D+10)
    for j, d in enumerate(dp):
        dp2[j] += d
        dp2[j+10] -= d
    for j in range(1, D+10):
        dp2[j] = (dp2[j-1] + dp2[j]) % mod
    for j in range(10):
        dp2[(D+j)%D] = (dp2[(D+j)%D] + dp2[D+j]) % mod 
    dp = dp2[:D]
    for j in range(k+1):
        dp[(S+j)%D] = (dp[(S+j)%D] + 1)%mod
    S += k
print((dp[0]-1)%mod)

Buggy python submission (verdict: Runtime Error):
K = list(map(int, J.strip()))
D = int(input())
mod = 10**9+7
a = 0
for i in range(1, J+1):
    if sum(map(int, str(i))) % D == 0:
        a += 1
print(a%mod)
dp = [0]*D
dp[0] += 1
S = 0
for k in K:
    dp[S%D] -= 1
    dp2 = [0]*(D+10)
    for j, d in enumerate(dp):
        dp2[j] += d
        dp2[j+10] -= d
    for j in range(1, D+10):
        dp2[j] = (dp2[j-1] + dp2[j]) % mod
    for j in range(10):
        dp2[(D+j)%D] = (dp2[(D+j)%D] + dp2[D+j]) % mod 
    dp = dp2[:D]
    for j in range(k+1):
        dp[(S+j)%D] = (dp[(S+j)%D] + 1)%mod
    S += k
print((dp[0]-1)%mod)


Fixed submission:
K = list(map(int, input().strip()))
D = int(input())
mod = 10**9+7

dp = [0]*D
dp[0] += 1
S = 0
for k in K:
    dp[S%D] -= 1
    dp2 = [0]*(D+10)
    for j, d in enumerate(dp):
        dp2[j] += d
        dp2[j+10] -= d
    for j in range(1, D+10):
        dp2[j] = (dp2[j-1] + dp2[j]) % mod
    for j in range(10):
        dp2[(D+j)%D] = (dp2[(D+j)%D] + dp2[D+j]) % mod 
    dp = dp2[:D]
    for j in range(k+1):
        dp[(S+j)%D] = (dp[(S+j)%D] + 1)%mod
    S += k
print((dp[0]-1)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10**9+7
frac = [1]*364364
for i in range(2,364364):
    frac[i] = i * frac[i-1]%mod
fraci = [None]*364364
fraci[-1] = pow(frac[-1], mod -2, mod)
for i in range(-2, -364364-1, -1):
    fraci[i] = fraci[i+1] * (364364 + i + 1) % mod
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%mod

def count(a, b):
    (r1, c1), (r2, c2) = RC[a], RC[b]
    if c2 < c1:
        return 0
    return comb(r2-r1 + c2-c1, r2-r1)

H, W, N = map(int, input().split())

RC = [list(map(int, input().split())) for _ in range(N)] + [[1, 1], [H, W]]
RC.sort()

dpe = [0]*(N+2)
dpo = [0]*(N+2)
dpe[0] += 1

for i in range(1, N+2):
    rese = 0
    reso = 0
    for k in range(i):
        rese = (rese + count(k, i)*dpo[k]) % mod
        reso = (reso + count(k, i)*dpe[k]) % mod
    dpe[i] = rese
    dpo[i] = reso

print((dpo[-1] - dpe[-1]) % mod)

Fixed submission:
mod = 10**9+7
frac = [1]*364364
for i in range(2,364364):
    frac[i] = i * frac[i-1]%mod
fraci = [None]*364364
fraci[-1] = pow(frac[-1], mod -2, mod)
for i in range(-2, -364364-1, -1):
    fraci[i] = fraci[i+1] * (364364 + i + 1) % mod
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%mod

def count(a, b):
    (r1, c1), (r2, c2) = RC[a], RC[b]
    if c2 < c1:
        return 0
    return comb(r2-r1 + c2-c1, r2-r1)

H, W, N = map(int, input().split())

RC = [list(map(int, input().split())) for _ in range(N)] + [[1, 1], [H, W]]
RC.sort()

dpe = [0]*(N+2)
dpo = [0]*(N+2)
dpe[0] += 1

for i in range(1, N+2):
    rese = 0
    reso = 0
    for k in range(i):
        t = count(k, i)
        if not t:
            continue
        rese = (rese + t*dpo[k]) % mod
        reso = (reso + t*dpe[k]) % mod
    dpe[i] = rese
    dpo[i] = reso

print((dpo[-1] - dpe[-1]) % mod)
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate, combinations
N, K = map(int, input().split())
A = list(map(int, input().split()))

SA = list(accumulate(A)) + [0]
B = A[:]

for l, r in combinations(range(N), 2):
    B.append(SA[r] - SA[l-1])

ans = 0
for i in range(42, -1, -1):
    ans *= 2
    B1 = [b for b in B if 2**i & b]
    if len(B1) >= K:
        ans += 1
        B = B1[:]

print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
S = sum(A)

ans = 10**12
Ans = None
for i, a in enumerate(A):
    if abs(S - N*a) < ans:
        ans = abs(S - N*a)
        Ans = i
print(Ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
readline = sys.stdin.readline

H, W = map(int, readline().split())
G = [[0]*W for _ in range(H)]
L1 = [[0]*1000 for _ in range(W+H-1)]
geta1 = W-1
L2 = [[0]*1000 for _ in range(W+H-1)]
for i in range(H):
    S = [1 if s == '#' else 0 for s in readline().strip()]
    for j in range(W):
        G[i][j] = S[j]
        if S[j]:
            L1[i-j+geta1][i] = 1
            L2[i+j][i] = 1
for sub in range(W+H-1):
    for i in range(630):
        L1[sub][i] += L1[sub][i-1]
        L2[sub][i] += L2[sub][i-1]

res = 0
for su in range(2*max(H, W)+1):
    for w in range(max(0, su-H+1), min(W, su+1)):
        h = su-w
        if not G[h][w]:
            continue
        for k in range(1, min(h+1, W-w)):
            if not G[h-k][w+k]:
                continue
            idx1 = h+w-2*k
            if 0 <= idx1 < H+W-1:
                res += L2[idx1][h-k-1] - L2[idx1][h-2*k]
            idx2 = h+w+2*k
            if 0 <= idx2 < H+W-1:
                res += L2[idx2][h+k-1] - L2[idx2][h]

for mi in range(1-W, H):
    for w in range(max(0, -mi), min(W, H-mi)):
        h = mi + w
        if not G[h][w]:
            continue
        for k in range(1, min(H-h, W-w)):
            if not G[h+k][w+k]:
                continue
            idx1 = h-w-2*k + geta1
            if 0 <= idx1 < H+W-1:
                res += L1[idx1][h] - L1[idx1][h-k-1]
            idx2 = h-w+2*k + geta1
            if 0 <= idx2 < H+W-1:
                res += L1[idx2][h+2*k] - L1[idx2][h+k-1]

print(res)

Fixed submission:
import sys
readline = sys.stdin.readline

H, W = map(int, readline().split())
G = [[0]*W for _ in range(H)]
L1 = [[0]*1000 for _ in range(W+H-1)]
geta1 = W-1
L2 = [[0]*1000 for _ in range(W+H-1)]
for i in range(H):
    S = [1 if s == '#' else 0 for s in readline().strip()]
    for j in range(W):
        G[i][j] = S[j]
        if S[j]:
            L1[i-j+geta1][i] = 1
            L2[i+j][i] = 1
for sub in range(W+H-1):
    for i in range(630):
        L1[sub][i] += L1[sub][i-1]
        L2[sub][i] += L2[sub][i-1]

res = 0
for su in range(2*max(H, W)+1):
    for w in range(max(0, su-H+1), min(W, su+1)):
        h = su-w
        if not G[h][w]:
            continue
        for k in range(1, min(h+1, W-w)):
            if not G[h-k][w+k]:
                continue
            idx1 = h+w-2*k
            if 0 <= idx1 < H+W-1:
                res += L2[idx1][h-k-1] - L2[idx1][h-2*k]
            idx2 = h+w+2*k
            if 0 <= idx2 < H+W-1:
                res += L2[idx2][h+k-1] - L2[idx2][h]

for mi in range(1-W, H):
    for w in range(max(0, -mi), min(W, H-mi)):
        h = mi + w
        if not G[h][w]:
            continue
        for k in range(1, min(H-h, W-w)):
            if not G[h+k][w+k]:
                continue
            idx1 = h-w-2*k + geta1
            if 0 <= idx1 < H+W-1:
                res += L1[idx1][h] - L1[idx1][h-k-1]
            idx2 = h-w+2*k + geta1
            if 0 <= idx2 < H+W-1:
                res += L1[idx2][h+2*k] - L1[idx2][h+k-1]

print(res)
Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
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()]
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

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

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

Buggy python submission (verdict: Runtime Error):
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)

Fixed submission:
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()]
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

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

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