Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03209 (python)

Fixed submission:
def f(n):
    return 2**(n+2)-3
def g(n):
    return 2**(n+1)-1
def p(x,n):
    if x==1:
        return 0
    if n==1:
        if 2<=x<=4:
            return x-1
        elif x>4:
            return 3
    if x==f(n-1)+2:
        return g(n-1)+1
    if x>=2*f(n-1)+2:
        return 2*g(n-1)+1
    if x<f(n-1)+2:
        return p(x-1,n-1)
    if x<2*f(n-1)+2:
        return g(n-1)+1+p(x-f(n-1)-2,n-1)
N,X = map(int,input().split())
print(p(X,N))

Buggy submission (verdict: Runtime Error):
memo1 = {}
def f(i):
    if i==0:
        return 1
    if i in memo1:
        return memo1[i]
    memo1[i] = 2*f(i-1)+3
    return memo1[i]
memo2 = {}
def g(i):
    if i==0:
        return 1
    if i in memo2:
        return memo2[i]
    memo2[i]=2*g(i-1)+1
    return memo2[i]
N,X = map(int,input().split())
cnt = 0
while X>0:
    if X>=f(N-1)+2:
        cnt += 1+g(N-1)
        X -= f(N-1)+2
    else:
        X -= 1
    N -= 1
print(cnt)

Buggy submission (verdict: Runtime Error):
memo1 = {}
def cho(n):
    if n==0:
        return 1
    if n in memo1:
        return memo1[n]
    memo1[n] = 2*cho(n-1)+3
    return memo1[n]
memo2 = {}
def pat(n):
    if n==0:
        return 1
    if n in memo2:
        return memo2[n]
    memo2[n] = 2*pat(n-1)+1
    return memo2[n]
N,X = map(int,input().split())
cnt = 0
k = N
while X>0:
    if X==1:
        break
    elif X==cho(k)//2:
        cnt += pat(k-1)
        break
    elif X<cho(k)//2:
        k -= 1
        X -= 1
    elif X==cho(k)//2+1:
        cnt += 1+pat(k-1)
        break
    else:
        cnt += pat(k-1)+1
        X -= cho(k-1)+2
        k -= 1
print(cnt)
Problem p03252 (python)

Fixed submission:
S = input().strip()
T = input().strip()
F = {}
flag = 0
for i in range(len(S)):
    a = S[i]
    b = T[i]
    if a not in F:
        F[a] = b
    if F[a] != b:
        flag = 1
        break
    for c in F:
        if c!=a and F[c]==b:
            flag = 1
            break
if flag==1:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
def chain(k,y):
    if y in D or y==S[cur]:
        return 0
    for i in G[y]:
        if T[i]==y:
            return 1
        hist[i] = 1
        z = T[i]
        return chain(i,z)
S = input().strip()
T = input().strip()
D = [chr(i) for i in range(97,123)]
G = {}
for i in range(len(S)):
    x = S[i]
    if x in D:
        D.remove(x)
    if x not in G:
        G[x] = []
    G[x].append(i)
hist = [0 for _ in range(len(S))]
ind = 0
for i in range(len(S)):
    if hist[i]==1:continue
    x = S[i]
    y = T[i]
    if x!=y:
        for j in G[x]:
            cur = j
            hist[j]=1
            ind = chain(j,y)
            if ind==1:break
        if ind==1:break
if ind==0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
def chain(x,y):
    if y in D or y==cur:
        return 0
    for i in G[y]:
        if T[i]==y:
            return 1
        hist[i] = 1
        z = T[i]
        return chain(y,z)
S = input().strip()
T = input().strip()
D = [chr(i) for i in range(97,123)]
G = {}
for i in range(len(S)):
    x = S[i]
    if x in D:
        D.remove(x)
    if x not in G:
        G[x] = []
    G[x].append(i)
hist = [0 for _ in range(len(S))]
ind = 0
for i in range(len(S)):
    if hist[i]==1:continue
    x = S[i]
    y = T[i]
    hist[i]=1
    if x!=y:
        cur = x
        ind = chain(cur,y)
        if ind==1:break
if ind==0:
    print("Yes")
else:
    print("No")
Problem p03464 (python)

Fixed submission:
K = int(input())
A = list(map(int,input().split()))
B = [2,2]
for i in range(K-1,-1,-1):
    a = A[i]
    bmin = B[0]
    bmax = B[1]
    if bmin%a==0:
        bmin = bmin
    else:
        bmin = (bmin//a+1)*a
    if bmin>bmax:
        B = []
        break
    else:
        if bmax%a==0:
            bmax = bmax+a-1
        else:
            bmax = (bmax//a)*a+a-1
        B = [bmin,bmax]
if len(B)==0:
    print(-1)
else:
    print(B[0],B[1])

Buggy submission (verdict: Runtime Error):
import math
K = int(input())
A = list(map(int,input().split()))
if A[N-1]!=2:
    print(-1)
elif K==1:
    print(2,3)
else:
    nmin = 2
    nmax = 2+A[K-1]-1
    flag = 0
    for i in range(K-2,-1,-1):
        b = A[i]
        nmin = math.ceil(nmin/b)*b
        nmax = math.floor(nmax/b)*b
        if nmin>nmax:
            flag = 1
            break
        nmax += b-1
    if flag==1:
        print(-1)
    else:
        print(nmin,nmax)
Problem p03723 (python)

Fixed submission:
A,B,C = map(int,input().split())
if A%2==1 or B%2==1 or C%2==1:
    print(0)
elif A==B and A==C:
    print(-1)
else:
    a = 0
    while A%2==0:
        A //= 2
        a += 1
    b = 0
    while B%2==0:
        B //= 2
        b += 1
    c = 0
    while C%2==0:
        C //= 2
        c += 1
    cnt = min(a,b,c)
    if [a,b,c].count(cnt)<3:
        print(cnt)
    else:
        print(cnt+1)

Buggy submission (verdict: Runtime Error):
A,B,C = map(int,input().split())
if A%2==1 or B%2==1 or C%2==1:
    cnt = 0
elif A==B and A==C:
    cnt = -1
else:
    a = 0
    while A%2==0:
        A //= 2
        a += 1
    b = 0
    while B%2==0:
        B //= 2
        b += 1
    c = 0
    while C%2==0:
        C //= 2
        c += 1
    cnt = min(a,b,c)
if [a,b,c].count(cnt)<3:
    print(cnt)
else:
    print(cnt+1)
Problem p03806 (python)

Fixed submission:
INFTY = 10**4
N,Ma,Mb = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
dp = [[[INFTY for _ in range(401)] for _ in range(401)] for _ in range(N+1)]
dp[0][0][0] = 0
for i in range(1,N+1):
    for j in range(401):
        for k in range(401):
            dp[i][j][k] = dp[i-1][j][k]
            a = A[i-1][0]
            b = A[i-1][1]
            c = A[i-1][2]
            if j>=a and k>=b:
                dp[i][j][k] = min(dp[i][j][k],dp[i-1][j-a][k-b]+c)
cmin = INFTY
for j in range(1,401):
    for k in range(1,401):
        if j*Mb==k*Ma:
            cmin = min(cmin,dp[N][j][k])
if cmin>=INFTY:
    print(-1)
else:
    print(cmin)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
from bisect import bisect_left
N,Ma,Mb = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
if N==1:
    if A[0][0]*Mb==A[0][1]*Ma:
        print(A[0][2])
    else:
        print(-1)
else:
    A1 = A[:N//2]  # N//2
    A2 = A[N//2:]  # N-N//2
    B1 = []
    for k in range(1,N//2+1):
        for x in combinations(range(N//2),k):
            cnt1 = 0
            cnt2 = 0
            for i in x:
                cnt1 += Ma*A1[i][1]-Mb*A1[i][0]
                cnt2 += A1[i][2]
            B1.append((cnt1,cnt2))
    B2 = []
    for k in range(1,N-N//2+1):
        for x in combinations(range(N-N//2),k):
            cnt1 = 0
            cnt2 = 0
            for i in x:
                cnt1 += Ma*A2[i][1]-Mb*A2[i][0]
                cnt2 += A2[i][2]
            B2.append((cnt1,cnt2))
    B1 = sorted(B1,key=lambda x:x[1])
    B1 = sorted(B1,key=lambda x:x[0])
    B2 = sorted(B2,key=lambda x:x[1])
    B2 = sorted(B2,key=lambda x:x[0])
    cmin = 10000
    for b1 in B1:
        b,c = b1[0],b1[1]
        ind = bisect_left(B2,(-b,0))
        if B2[ind][0]==-b:
            cmin = min(cmin,c+B2[ind][1])
    if cmin>=10000:
        print(-1)
    else:
        print(cmin)

Buggy submission (verdict: Runtime Error):
from itertools import combinations
from bisect import bisect_left
N,Ma,Mb = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(N)]
A1 = A[:N//2]  # N//2
A2 = A[N//2:]  # N-N//2
B1 = []
for k in range(1,N//2+1):
    for x in combinations(range(N//2),k):
        cnt1 = 0
        cnt2 = 0
        for i in x:
            cnt1 += Ma*A1[i][1]-Mb*A1[i][0]
            cnt2 += A1[i][2]
        B1.append((cnt1,cnt2))
B2 = []
for k in range(1,N-N//2+1):
    for x in combinations(range(N-N//2),k):
        cnt1 = 0
        cnt2 = 0
        for i in x:
            cnt1 += Ma*A2[i][1]-Mb*A2[i][0]
            cnt2 += A2[i][2]
        B2.append((cnt1,cnt2))
B1 = sorted(B1,key=lambda x:x[1])
B1 = sorted(B1,key=lambda x:x[0])
B2 = sorted(B2,key=lambda x:x[1])
B2 = sorted(B2,key=lambda x:x[0])
cmin = 10000
for b1 in B1:
    b,c = b1[0],b1[1]
    ind = bisect_left(B2,(-b,0))
    if B2[ind][0]==-b:
        cmin = min(cmin,c+B2[ind][1])
if cmin>=10000:
    print(-1)
else:
    print(cmin)
Problem p03821 (python)

Fixed submission:
N = int(input())
cnt = 0
A = []
B = []
C = []
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append((b-a)%b) 
cnt = C[-1]
for i in range(-2,-N-1,-1):
    C[i] = (C[i]-cnt)%B[i]
    cnt += C[i]
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
cnt = 0
for _ in range(N):
    a,b = map(int,input().split())
    cnt += (a-b)%a
print(cnt)
Problem p02623 (python)

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

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))


#Aだけのときのmax

s = 0
j = 0
for i in range(n):
    if s + a[i] > k:
        break
    else:
        s += a[i]
        j += 1


ans = [j]

for l in range(m):
    flag = True
    s += b[l]
    while s > k:
        s -= a[j-1]
        j -= 1
        if j < 0:
            flag = False
            break
    
    if not flag:
        break
    else:
        ans.append(l + 1 + j)
        #print(ans)

print(max(ans))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n, m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))


s = []
t = []


for i in range(n):
    #print(k + a[i])
    if len(s) > k:
        break
    elif len(s) < k < len(s) + a[i]:
        s += [i] * (k + 1 - len(s))
    else:
        s += [i] * a[i]

if len(s) <k:
    s += [n] * (k + 1 - len(s))

for i in range(m):
    if len(t) > k:
        break
    elif len(t) < k < len(t) + b[i]:
        t += [i] * (k + 1 - len(t))
    else:
        t += [i] * b[i]

if len(t) <k:
    t += [m] * (k + 1 - len(t))

m = 0

# print(s)
# print(t)

#print(s[-1], t[-1])

if len(s) + len(t) - 2 <= k:
    m = s[-1] + t[-1]
else:
    for i in range(k+1):
        m = max(m, s[i] + t[k-i])

print(m)
Problem p02685 (python)

Fixed submission:
import math

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

MOD=998244353

fact = [0] * (n+1)
inv = [0] * (n+1)
factinv = [0] * (n+1)

fact[0]=fact[1]=1
inv[1]=1
factinv[0]=factinv[1]=1

for i in range(2,n+1):
    fact[i] = fact[i-1] * i % MOD
    inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
    factinv[i] = factinv[i-1] * inv[i] % MOD

def cbn(n, k, fact, factinv, MOD):
    return fact[n] * factinv[n-k] * factinv[k] % MOD

def power(x, n, MOD):
    if n == 0:
        return 1
    elif n % 2 == 0:
        return power(x*x % MOD , n // 2, MOD) % MOD
    else:
        return x * power(x * x % MOD, n // 2, MOD) % MOD

s = 0
for i in range(k+1):
    s += cbn(n-1, i, fact, factinv, MOD) * m * power(m-1, n-1-i, MOD)

print(s % MOD)

Buggy submission (verdict: Runtime Error):
n, m, k = list(map(int, input().split()))

x = pow(m-1, n-k-1, 998244353)
c = m * ((m-1) ** k)

s = c


for i in range(1, k+1):
    c = c * (n-i) // (i * (m-1))
    s += c 

print((s * x) % 998244353)

Buggy submission (verdict: Runtime Error):
n, m, k = list(map(int, input().split()))

c = m * ((m-1) ** (n-1))

s = c


for i in range(1, k+1):
    c = c * (n-i) // (i * (m-1))
    s += c

print(s % 998244353)

Buggy submission (verdict: Runtime Error):
n, m, k = list(map(int, input().split()))

c = m * ((m-1) ** (n-1))

s = c


for i in range(1, k+1):
    if i > 0:
        c = c * (n-i) // (i * (m-1))
    s += c 

print(s % 998244353)

Buggy submission (verdict: Runtime Error):
n, m, k = list(map(int, input().split()))

s = 0


c = m * ((m-1) ** (n-1))


for i in range(k+1):
    if i > 0:
        c = c * (n-i) // (i * (m-1))
    s += c  % 998244353

print(s % 998244353)

Buggy submission (verdict: Runtime Error):
import math

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

s = 0

for i in range(k+1):
    s += (math.factorial(n-i) // (math.factorial(n-2*i) * math.factorial(i)) ) * m * ((m-1) ** (n-i-1))

print(s % 998244353)
Problem p02757 (python)

Fixed submission:
from collections import Counter

n, p = list(map(int, input().split()))

s = input()


a = 0
t = list(map(int, list(s)))
t.reverse()


if p == 2:
    for i in range(n):
        if t[i] % 2 == 0:
            a += len(t) - i 
elif p == 5:
    for i in range(n):
        if t[i] % 5 == 0:
            a += len(t) - i 

else:
    u = []
    k = 1
    l = 0
    for i in t:
        l = (l + i*k) % p
        u.append(l)
        k = k * 10 % p

    c = Counter(u)
    a += c[0]
    for i in c.values():
        if i > 1:
            a += i * (i-1) // 2


print(a)

Buggy submission (verdict: Runtime Error):
from collections import Counter

n, p = list(map(int, input().split()))

s = int(input())

a = 0
t = []

while s > 0:
    d = s // 10
    r = s % 10
    t.append(r)
    s = d

if p == 2:
    for i in range(len(t)):
        if t[i] % 2 == 0:
            a += len(t) - i 
elif p == 5:
        if t[i] % 5 == 0:
            a += len(t) - i 

else:
    u = []
    k = 1
    for i in range(len(t)):
        if i == 0:
            u.append(t[i]*k % p)
        else:
            u.append((u[i-1] + t[i]*k) % p)
        k *= 10
    c = Counter(u)

    a += c[0]
    for i in c.values():
        if i > 1:
            a += i * (i-1) // 2


print(a)

Buggy submission (verdict: Runtime Error):
n, p = list(map(int, input().split()))

s = int(input())

a = 0
t = []

while s > 0:
    d = s // 10
    r = s % 10
    t.append(r)
    s = d

if p == 2:
    for i in range(len(t)):
        if t[i] % 2 == 0:
            a += len(t) - i 
elif p == 5:
        if t[i] % 5 == 0:
            a += len(t) - i 

else:
    u = []
    k = 1
    for i in range(len(t)):
        u.append(t[i]*k % p)
        k *= 10

    for i in range(len(u)):
        for j in range(i, len(u)):
            if sum(u[i:j+1]) % p == 0:
                a += 1

print(a)
Problem p02781 (python)

Fixed submission:
import math
import itertools

n = int(input())
k = int(input())

f = len(str(n))

if f < k:
    print(0)
else:
    #f-1桁以内に収まる数

    en = 1
    for i in range(k):
        en *= f-1-i

    de = math.factorial(k)


    s = en // de * pow(9, k)


    #f桁目によって絞る

    kami = int(str(n)[0])

    en = 1
    for i in range(k-1):
        en *= f-1-i

    de = math.factorial(k-1)


    s += (en // de * pow(9, k-1)) * (kami-1)


    #以下上1桁は同じ数字

    keta = list(range(f-1))
    num = list(range(1,10))

    b =  kami * pow(10, f-1)
    m = 0


    if k == 1:
        m = b
        if m <= n:
            s += 1
    else:
        for d in itertools.product(num, repeat=k-1):
            for c in itertools.combinations(keta, k-1):
                m = b
                for i in range(k-1):
                    m +=  d[i] * pow(10, c[i])
                if m <= n:
                    s += 1

    print(s)

Buggy submission (verdict: Runtime Error):
import math
import itertools

n = int(input())
k = int(input())

if (n < 99 and k == 3) or (n < 9 and k == 2):
    print(0) 

else:
    f = len(str(n))

    #f-1桁以内に収まる数

    en = 1
    for i in range(k):
        en *= f-1-i

    de = math.factorial(k)


    s = en // de * pow(9, k)

    #print(s)
    #f桁目によって絞る

    kami = int(str(n)[0])

    en_2 = 1
    for i in range(k-1):
        en_2 *= f-1-i

    de_2 = math.factorial(k-1)


    s += (en_2 // de_2 * pow(9, k-1)) * (kami-1)


    #以下上1桁は同じ数字

    keta = list(range(f-1))
    num = list(range(1,10))

    b =  kami * pow(10, f-1)
    m = 0

    if k == 1:
        s += 1
    elif k == 2:
        s += 9*(f-2) + int(str(n)[1])
    else:
        kami2 = int(str(n)[1])

        en_3 = (f-2)*(f-3)

        de_3 = 2


        s += (en_3 // de_3 * pow(9, k-1))  + kami2 * 9 * (f-2)

    print(s)

Buggy submission (verdict: Runtime Error):
import math
import itertools

n = int(input())
k = int(input())

f = len(str(n))

#f-1桁以内に収まる数

en = 1
for i in range(k):
    en *= f-1-i

de = math.factorial(k)


s = en // de * pow(9, k)

#print(s)
#f桁目によって絞る

kami = int(str(n)[0])

en_2 = 1
for i in range(k-1):
    en_2 *= f-1-i

de_2 = math.factorial(k-1)


s += (en_2 // de_2 * pow(9, k-1)) * (kami-1)


#以下上1桁は同じ数字

keta = list(range(f-1))
num = list(range(1,10))

b =  kami * pow(10, f-1)
m = 0

if k == 1:
    s += 1
elif k == 2:
    s += 9*(f-2) + int(str(n)[1])
else:
    kami2 = int(str(n)[1])

    en_3 = (f-2)*(f-3)

    de_3 = 2


    s += (en_3 // de_3 * pow(9, k-1))  + kami2 * 9 * (f-2)

print(s)
Problem p02862 (python)

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

def make_fact_list(n, MOD):
    # make factorial list from 0 to n
    fact = [0] * (n+1)
    inv = [0] * (n+1)
    factinv = [0] * (n+1)

    fact[0]=fact[1]=1
    inv[1]=1
    factinv[0]=factinv[1]=1

    for i in range(2,n+1):
        fact[i] = fact[i-1] * i % MOD
        inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
        factinv[i] = factinv[i-1] * inv[i] % MOD
    
    return fact, factinv

def cbn(n, k, MOD, fact = [], factinv = []):
    if len(fact) == 0 and len(factinv) == 0:
        fact, factinv = make_fact_list(n, MOD)
    return fact[n] * factinv[n-k] * factinv[k] % MOD


MOD = pow(10, 9) + 7
x, y = list(map(int, input().split()))

if (2*x-y) % 3 != 0 or (2*y-x) % 3 != 0:
    print(0)
elif (2*x-y) // 3 < 0 or (2*y-x) // 3 < 0:
    print(0)
else:
    s = (2*x-y) // 3
    t = (2*y-x) // 3

    fact, factinv = make_fact_list(s + t + 1, MOD)
    print(cbn(s+t, s, MOD, fact, factinv) % MOD)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def make_fact_list(n, MOD):
    # make factorial list from 0 to n
    fact = [0] * (n+1)
    inv = [0] * (n+1)
    factinv = [0] * (n+1)

    fact[0]=fact[1]=1
    inv[1]=1
    factinv[0]=factinv[1]=1

    for i in range(2,n+1):
        fact[i] = fact[i-1] * i % MOD
        inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
        factinv[i] = factinv[i-1] * inv[i] % MOD
    
    return fact, factinv

def cbn(n, k, MOD, fact = [], factinv = []):
    if len(fact) == 0 and len(factinv) == 0:
        fact, factinv = make_fact_list(n, MOD)
    return fact[n] * factinv[n-k] * factinv[k] % MOD


MOD = pow(10, 9) + 7
x, y = list(map(int, input().split()))

if (2*x-y) % 3 != 0 or (2*y-x) % 3 != 0:
    print(0)
else:
    s = (2*x-y) // 3
    t = (2*y-x) // 3

    fact, factinv = make_fact_list(s + t, MOD)
    print(cbn(s+t, s, MOD, fact, factinv))
Problem p03011 (python)

Fixed submission:
p, q, r = list(map(int, input().split()))

print(p + q + r - max([p, q, r]))

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))

MOD = pow(10, 9) + 7

dp = [0] * (n+1)

dp[0] = 1

broken = [False] * (n+1)
for i in range(m):
    broken[int(input())] = True

c = 1

for i in range(1, n+1):
    if broken[i]:
        dp[i] = 0
    else:
        if i == 1:
            dp[i] = dp[i-1] % MOD
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % MOD

print(dp[-1] % MOD)
Problem p03013 (python)

Fixed submission:
n, m = list(map(int, input().split()))

MOD = pow(10, 9) + 7

dp = [0] * (n+1)

dp[0] = 1

broken = [False] * (n+1)
for i in range(m):
    broken[int(input())] = True

c = 1

for i in range(1, n+1):
    if broken[i]:
        dp[i] = 0
    else:
        if i == 1:
            dp[i] = dp[i-1] % MOD
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % MOD

print(dp[-1] % MOD)

Buggy submission (verdict: Runtime Error):
n, m = list(map(int, input().split()))

MOD = pow(10, 9) + 7

dp = [0] * (n+1)

dp[0] = 1

broken = int(input())
c = 1

for i in range(1, n+1):
    if i == broken:
        dp[i] = 0
        if c < m:
            broken = int(input())
            c += 1
    else:
        if i == 1:
            dp[i] = dp[i-1] % MOD
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % MOD

print(dp[n] % MOD)
Problem p03253 (python)

Fixed submission:
from collections import Counter

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

if m == 1:
    print(1)
else:

    MOD = pow(10, 9) + 7

    def prime_factorize(n):
        a = []
        while n % 2 == 0:
            a.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                a.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            a.append(n)
        return a

    def make_fact_list(n, MOD):
        # make factorial list from 0 to n
        fact = [0] * (n+1)
        inv = [0] * (n+1)
        factinv = [0] * (n+1)

        fact[0]=fact[1]=1
        inv[1]=1
        factinv[0]=factinv[1]=1

        for i in range(2,n+1):
            fact[i] = fact[i-1] * i % MOD
            inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
            factinv[i] = factinv[i-1] * inv[i] % MOD
        
        return fact, factinv

    def cbn(n, k, MOD, fact = [], factinv = []):
        if len(fact) == 0 and len(factinv) == 0:
            fact, factinv = make_fact_list(n, MOD)
        return fact[n] * factinv[n-k] * factinv[k] % MOD


    d = Counter(prime_factorize(m)).most_common()

    l = d[0][1] + n 

    fact, factinv = make_fact_list(l, MOD)

    a = 1

    for k, v in d:
        a *= cbn(v + n - 1, v, MOD, fact = fact, factinv = factinv) % MOD

    print(a % MOD)

Buggy submission (verdict: Runtime Error):
from collections import Counter

n, m = list(map(int, input().split()))
MOD = pow(10, 9) + 7

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def make_fact_list(n, MOD):
    # make factorial list from 0 to n
    fact = [0] * (n+1)
    inv = [0] * (n+1)
    factinv = [0] * (n+1)

    fact[0]=fact[1]=1
    inv[1]=1
    factinv[0]=factinv[1]=1

    for i in range(2,n+1):
        fact[i] = fact[i-1] * i % MOD
        inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
        factinv[i] = factinv[i-1] * inv[i] % MOD
    
    return fact, factinv

def cbn(n, k, MOD, fact = [], factinv = []):
    if len(fact) == 0 and len(factinv) == 0:
        fact, factinv = make_fact_list(n, MOD)
    return fact[n] * factinv[n-k] * factinv[k] % MOD


d = Counter(prime_factorize(m)).most_common()

l = d[0][1] + n 

fact, factinv = make_fact_list(l, MOD)

a = 1

for k, v in d:
    a *= cbn(v + n - 1, v, MOD, fact = fact, factinv = factinv) % MOD

print(a % MOD)
Problem p02624 (python)

Fixed submission:
N = int(input())

yaku = [0]*(N+1)
for i in range(1,N+1):
    yaku[i] = ((N//i)/2) * (2*i + ((N//i)-1)*i)

print(int(sum(yaku)))

Buggy submission (verdict: Runtime Error):

import sympy
N = int(input())

out=0
for i in range(1,N+1):
    out+=i * len(sympy.divisors(i))
print(out)