Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
from itertools import accumulate
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
ruiseki = list(accumulate(A[::-1]))

# 自分以上の数の個数がM個以上になる値のうち最大のもの
ok = 0
ng = 10 ** 15
while ok + 1 < ng:
    mid = (ok + ng) // 2
    cnt = 0
    ans = 0
    for a in A:
        x = bisect.bisect_left(A, mid - a)
        cnt += N - x
        if N - x >= 1:
            ans += ruiseki[N - x - 1] + (N - x) * a
    if cnt >= M:
        ok = mid
    else:
        ng = mid
# okで終わってる場合はcntがM個以上の場合があるから過分を引く
# ngで終わってる場合は残りM-cnt個のokを足す
print(ans + ok * (M - cnt)) 

Fixed submission:
from itertools import accumulate
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
ruiseki = list(accumulate(A[::-1]))

def syakutori(mid):
    x = 0
    cnt = 0
    ans = 0
    for i in range(N)[::-1]: # 大きい方から
        while x < N:
            if A[i] + A[x] >= mid:
                cnt += N - x
                if N - x >= 1:
                    ans += A[i] * (N - x) + ruiseki[N - x - 1]
                break
            else:
                x += 1

    return cnt, ans

# 自分以上の数の個数がM個以上になる値のうち最大のもの
ok = 0
ng = 10 ** 15
while ok + 1 < ng:
    mid = (ok + ng) // 2
    cnt, ans = syakutori(mid)
    if cnt >= M:
        ok = mid
    else:
        ng = mid
# okで終わってる場合はcntがM個以上の場合があるから過分を引く
# ngで終わってる場合は残りM-cnt個のokを足す
print(ans + ok * (M - cnt))
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = int(input())
ans = [1, 2, 3]
ans.pop(A)
ans.pop(B)
print(ans[0])

Fixed submission:
A = int(input())
B = int(input())
ans = [1, 2, 3]
ans.remove(A)
ans.remove(B)
print(ans[0])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque
sys.setrecursionlimit(10 ** 7)

N = int(input())
count = [[] for _ in range(N)]
inputs = []

for _ in range(N - 1):
    a, b = map(int, input().split())
    count[a - 1].append(b - 1)
    count[b - 1].append(a - 1)
    inputs.append(sorted([a - 1, b - 1]))

K = 0
for c in count:
    K = max(K, len(c))
print(K)

def dfs(root, count):
    done = [-1 for _ in range(N)]
    done[root] = 0
    info = []
    d = deque([root])
    r = d.pop()
    childs = count[r]
    tmp = 1
    for c in childs:
        if done[c] == -1:
            d.append([c, r, tmp])
            tmp += 1
            done[c] += 1
    while d:
        data = d.pop()
        info.append(data)
        childs = count[data[0]]
        tmp = 1
        for c in childs:
            if done[c] == -1:
                if tmp != data[2]:
                    d.append([c, data[0], tmp])
                else:
                    tmp += 1
                    d.append([c, data[0], tmp])
                tmp += 1
                done[c] += 1
    return info

info = dfs(0, count)
info_new = [[sorted([i[0], i[1]]), i[2]] for i in info]

for i in inputs:
    for k in info_new:
        if i == k[0]:
            print(k[1])

Fixed submission:
import sys
from collections import deque, OrderedDict
sys.setrecursionlimit(10 ** 7)

N = int(input())
count = [[] for _ in range(N)]
inputs = OrderedDict()

for _ in range(N - 1):
    a, b = map(int, input().split())
    count[a - 1].append(b - 1)
    count[b - 1].append(a - 1)
    inputs["-".join(list(map(str, sorted([a - 1, b - 1]))))] = 0

K = 0
for c in count:
    K = max(K, len(c))
print(K)

def dfs(root, count, inputs):
    done = [-1 for _ in range(N)]
    done[root] = 0
    d = deque([root])
    r = d.pop()
    childs = count[r]
    tmp = 1
    for c in childs:
        if done[c] == -1:
            d.append([c, r, tmp])
            tmp += 1
            done[c] += 1
    while d:
        data = d.pop()
        inputs["-".join(list(map(str, sorted(data[:2]))))] = data[2]
        childs = count[data[0]]
        tmp = 1
        for c in childs:
            if done[c] == -1:
                if tmp != data[2]:
                    d.append([c, data[0], tmp])
                else:
                    tmp += 1
                    d.append([c, data[0], tmp])
                tmp += 1
                done[c] += 1
    
    return inputs

inputs = dfs(0, count, inputs)

for i in inputs.values():
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
import math
N, K = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))
F = list(map(int, sys.stdin.readline().rstrip().split()))
A.sort()
F.sort()

cost = []
for i in range(N):
    cost.append((-A[i] * F[N - 1 - i], A[i], F[N - 1 - i], A[i]))
heapq.heapify(cost)

while K > 0:
    max_1, a_1, f_1, nokori_1 = heapq.heappop(cost)
    max_2, a_2, f_2, nokori_2 = heapq.heappop(cost)
    if max_1 == 0:
        break
    c = math.ceil((max_2 - max_1 + 1) / f_1)
    num = min(K, c)
    if num <= nokori_1:
        heapq.heappush(cost, (min(max_1 + f_1 * num, 0), a_1, f_1, nokori_1 - num))
        heapq.heappush(cost, (max_2, a_2, f_2, nokori_2))
        K -= num
    else:
        heapq.heappush(cost, (min(max_1 + f_1 * a_1, 0), a_1, f_1, nokori_1 - a_1))
        heapq.heappush(cost, (max_2, a_2, f_2, nokori_2))
        break

print(-cost[0][0])

Fixed submission:
import sys
import math
N, K = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))
F = list(map(int, sys.stdin.readline().rstrip().split()))
A.sort()
A = A[::-1]
F.sort()

def test(x):
    res = 0
    for i in range(N):
        t = A[i] * F[i]
        if t > x:
            res += math.ceil((t - x) / F[i])
    
    return res <= K

ng = -1
ok = 10**18

while ng + 1 < ok:
    mid = (ng + ok) // 2
    if test(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import heapq
import math
N, K = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))
F = list(map(int, sys.stdin.readline().rstrip().split()))
A.sort()
F.sort()

cost = []
for i in range(N):
    cost.append((-A[i] * F[N - 1 - i], A[i], F[N - 1 - i]))
heapq.heapify(cost)

while K > 0:
    max_1, a_1, f_1 = heapq.heappop(cost)
    max_2, a_2, f_2 = heapq.heappop(cost)
    if max_1 == 0:
        break
    c = math.ceil((max_2 - max_1 + 1) / f_1)
    num = min(K, c)
    if num <= a_1:
            heapq.heappush(cost, (min(max_1 + f_1 * num, 0), a_1, f_1))
            heapq.heappush(cost, (max_2, a_2, f_2))
            K -= num
    else:
        heapq.heappush(cost, (min(max_1 + f_1 * a_1, 0), a_1, f_1))
        heapq.heappush(cost, (max_2, a_2, f_2))
        break

print(-cost[0][0])

Fixed submission:
import sys
import math
N, K = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))
F = list(map(int, sys.stdin.readline().rstrip().split()))
A.sort()
A = A[::-1]
F.sort()

def test(x):
    res = 0
    for i in range(N):
        t = A[i] * F[i]
        if t > x:
            res += math.ceil((t - x) / F[i])
    
    return res <= K

ng = -1
ok = 10**18

while ng + 1 < ok:
    mid = (ng + ok) // 2
    if test(mid):
        ok = mid
    else:
        ng = mid
print(ok)
Buggy python submission (verdict: Time Limit Exceeded):
import math
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0

for a in range(N - 2):
    b = a + 1
    c = a + 2
    while c < N and b < N - 1:
        if L[c] >= L[a] + L[b]:
            ans += c - 1 - b
            b += 1
            if b == c:
                c += 1
        else:
            if c == N - 1:
                ans += c - b
                b += 1
            else:
                c += 1
        
print(ans)        

Fixed submission:
import math
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0

for a in range(N - 2):
    b = a + 1
    c = a + 2
    while c < N and b < N - 1:
        if L[c] >= L[a] + L[b]:
            ans += c - 1 - b
            b += 1
            if b == c:
                c += 1
        else:
            if c == N - 1:
                ans += (c - b) * (c - b + 1) // 2 
                break
            else:
                c += 1
        
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
count = []

for _ in range(N):
    tmp = collections.OrderedDict(sorted(collections.Counter([s for s in input()]).items()))
    count.append("".join(list(tmp.keys())) + "".join(map(str, list(tmp.values()))))
        
ans = 0
for v in collections.Counter(count).values():
    ans += v * (v - 1) // 2

print(ans)

Fixed submission:
import collections
N = int(input())
count = []

for _ in range(N):
    s = "".join(sorted(input()))
    count.append(s)

ans = 0
for v in collections.Counter(count).values():
    ans += v * (v - 1) // 2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections
N = int(input())
count = {}

for _ in range(N):
    tmp = collections.OrderedDict(sorted(collections.Counter([s for s in input()]).items()))
    key = "".join(list(tmp.keys())) + "".join(map(str, list(tmp.values())))
    if key not in count.keys():
        count[key] = 1
    else:
        count[key] += 1
        
ans = 0
for v in [v for v in count.values() if v > 1]:
    ans += v * (v - 1) // 2

print(ans)

Fixed submission:
import collections
N = int(input())
count = []

for _ in range(N):
    s = "".join(sorted(input()))
    count.append(s)

ans = 0
for v in collections.Counter(count).values():
    ans += v * (v - 1) // 2

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())

value = [[] for _ in range(10 ** 5 + 1)]

for _ in range(N):
    a, b = map(int, input().split())
    value[a].append(-1 * b)

for v in value:
    heapq.heapify(v)


ans = 0
for i in range(1, M + 1):
    my_max = 0
    for j, k in enumerate(range(i), 1):
        if len(value[j]) > 0:
            tmp = -1 * heapq.heappop(value[j])
            if my_max < tmp:
                my_max = tmp
            else:
                heapq.heappush(value[j], tmp * -1)
    ans += my_max

print(ans)
        

Fixed submission:
import heapq
N, M = map(int, input().split())
value = [[] for _ in range(10 ** 5 + 1)]

for _ in range(N):
    a, b = map(int, input().split())
    value[a].append(-1 * b)

koho = value[1]
heapq.heapify(koho)

ans = 0
for i in range(1, M + 1):
    if len(koho) > 0:
        ans += -1 * heapq.heappop(koho)
    if i < M:
        for v in value[i + 1]:
            heapq.heappush(koho, v)

print(ans)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# N = int(input())
# S = input()
A, B = map(int, input().split())
# A = list(map(int, input().split()))
if (A + B) % 2 == 0:
    print((A + B)) // 2)
else:
    print("IMPOSSIBLE")

Fixed submission:
#!/usr/bin/env python3
# N = int(input())
# S = input()
A, B = map(int, input().split())
# A = list(map(int, input().split()))
if (A + B) % 2 == 0:
    print((A + B) // 2)
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
total = sum(A)

def solver(k):
    global ans
    ans = [k]
    if k % 2 == 1:
        return False
    b = k
    for i in range(N - 1):
        b = 2 * A[i] - b
        ans.append(b)
        if b % 2 == 1 or b < 0:
            return False
    if ans[0] + ans[-1] == 2 * A[-1]:
        return True
    else:
        return False

for i in range(total // 2 + 1):
    if solver(2 * i):
        print(" ".join(map(str, ans)))
        exit()

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

def solver(k):
    global ans
    ans = [k]
    for i in range(N - 1):
        ans.append(2 * A[i] - ans[i])
    if not ans[0] + ans[-1] == 2 * A[-1]:
        x = (2 * A[-1] - ans[0] - ans[-1]) // 2
        for i in range(N):
            if i % 2 == 0:
                ans[i] += x
            else:
                ans[i] -= x
solver(0)
print(" ".join(map(str, ans)))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
d = list(map(int, input().split()))
ans = 0

same = N // 2
count = 0

for i in range(2, 10 ** 5 + 1):
    count += d.count(i - 1)
    if count == same:
        ans += 1

print(ans)

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

half = d[N // 2 - 1]
nxt = d[N // 2]

if nxt == half:
    print(0)
else:
    print(nxt - (half + 1) + 1)
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
# N = int(input())
S = input()
# N, A, B = map(int, input().split())
# A = list(map(int, input().split()))

for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        print("Bad")
        break
else:
    pirnt("Good")

Fixed submission:
#!/usr/bin/env python3
# N = int(input())
S = input()
# N, A, B = map(int, input().split())
# A = list(map(int, input().split()))

for i in range(len(S) - 1):
    if S[i] == S[i + 1]:
        print("Bad")
        break
else:
    print("Good")
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
card = False
for _ in range(M):
    L, R = map(int, input().split())
    if card is not False:
        card = card & set([i for i in range(L, R + 1)])
    else:
        card = set([i for i in range(L, R + 1)])
print(len(card))

Fixed submission:
N, M = map(int, input().split()) 
left = 1
right = N
for _ in range(M):
    L, R = map(int, input().split())
    if left < L:
        left = L
    if R < right:
        right = R
    if left > right:
        print(0)
        exit()
print(right - left + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
heapq.heapify(A)
BC = []
for _ in range(M):
    BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x: x[1], reverse=True)
for b, c in BC:
    for _ in range(b):
         my_min = heapq.heappop(A)
         if c > my_min:
             heapq.heappush(A, c)
         else:
              heapq.heappush(A, my_min)

print(sum(A))

Fixed submission:
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
heapq.heapify(A)
BC = []
for _ in range(M):
    BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x: x[1], reverse=True)

card = []
for b, c in BC:
    for _ in range(b):
         my_min = heapq.heappop(A)
         if c > my_min:
             heapq.heappush(A, c)
         else:
              heapq.heappush(A, my_min)
              break

print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
BC = []
for _ in range(M):
    BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x: x[1], reverse=True)
for b, c in BC:
    index = bisect.bisect_left(A, c)
    replace = 0
    if index > 0:
        for _ in range(N - index, N):
            A.insert(index, c)
            replace += 1
            if replace == b:
                break

print(sum(A[::-1][:N]))

Fixed submission:
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = sorted(A)
heapq.heapify(A)
BC = []
for _ in range(M):
    BC.append(list(map(int, input().split())))
BC = sorted(BC, key=lambda x: x[1], reverse=True)

card = []
for b, c in BC:
    for _ in range(b):
         my_min = heapq.heappop(A)
         if c > my_min:
             heapq.heappush(A, c)
         else:
              heapq.heappush(A, my_min)
              break

print(sum(A))
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())

A = sorted(list(map(int, input().split())))[::-1]
B = sorted(list(map(int, input().split())))[::-1]
C = sorted(list(map(int, input().split())))[::-1]

A_B = []
for a in A:
    for b in B:
        A_B.append(a + b)

A_B = sorted(A_B)

def bin_search(mid):
    res = 0
    idx = 0
    ans = []
    for c in C:
        while idx < len(A_B):
            if c + A_B[idx] >= mid:
                res += len(A_B) - idx
                ans += [i + c for i in A_B[idx:]]
                break
            else:
                idx += 1
    
    return res, ans

ok = 0
ng = pow(10, 10) * 3 + 1

while ok + 1 < ng:
    mid = (ok + ng) // 2
    res, ans = bin_search(mid)
    if res >= K:
        ok = mid
    else:
        ng = mid

res, ans = bin_search(ok)
for a in sorted(ans)[::-1][:K]:
    print(a)

Fixed submission:
X, Y, Z, K = map(int, input().split())

A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))[::-1]

A_B = []
for a in A:
    for b in B:
        A_B.append(a + b)

A_B = sorted(A_B)

def bin_search(mid):
    res = 0
    idx = 0
    ans = [] 
    for c in C:
        while idx < len(A_B):
            if c + A_B[idx] >= mid:
                res += len(A_B) - idx
                ans.append((c, idx))
                break
            else:
                idx += 1

    return res, ans

ok = 0
ng = pow(10, 10) * 3 + 1

while ok + 1 < ng:
    mid = (ok + ng) // 2
    res, ans = bin_search(mid)
    if res >= K:
        ok = mid
    else:
        ng = mid

res, ans = bin_search(ok)

tmp_ans = []
for c, idx in ans:
    for i in range(idx, len(A_B)):
        tmp_ans.append(A_B[i] + c)
for ans in sorted(tmp_ans)[::-1][:K]:
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import re
S = input()
raw = len(S)
prev = len(S)
while True:
    S = re.sub(r"(10)+", "", S)
    S = re.sub(r"(01)+", "", S)
    if prev > len(S):
        prev = len(S)
    else:
        break
print(raw - len(S))


Fixed submission:
import re
S = input()
num_1 = S.count("1")
num_0 = S.count("0")
print(min(num_0, num_1) * 2)

Buggy python submission (verdict: Time Limit Exceeded):
S = [s for s in input()]
ans = 0
i = 1
while len(S) > 1 and i < len(S):
    if S[i] == S[i - 1]:
        i += 1
    else:
        S.pop(i)
        S.pop(i - 1)
        ans += 2
        i = 1
print(ans)        


Fixed submission:
import re
S = input()
num_1 = S.count("1")
num_0 = S.count("0")
print(min(num_0, num_1) * 2)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
raw = len(S)
prev = len(S)
while True:
    S = S.replace("10", "")
    S = S.replace("01", "")
    if prev > len(S):
        prev = len(S)
    else:
        break
print(raw - len(S))

Fixed submission:
import re
S = input()
num_1 = S.count("1")
num_0 = S.count("0")
print(min(num_0, num_1) * 2)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))
h.insert(0, float("inf"))

dp = [float("inf")] * (N + 1)
dp[1] = 0

for i in range(2, N + 1):
    for k in range(1, K + 1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]))
        else:
            break

print(dp[N])

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
h.insert(0, float("inf"))

dp = [float("inf")] * (N + 1)
dp[1] = 0

for i in range(2, N + 1):
    for k in range(1, K + 1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]))
        else:
            break

print(dp[N])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))
h.insert(0, float("inf"))

dp = [float("inf")] * (N + 1)
dp[1] = 0

for i in range(2, N + 1):
    for k in range(1, K + 1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]))

print(dp[N])

Fixed submission:
N, K = map(int, input().split())
h = list(map(int, input().split()))
h.insert(0, float("inf"))

dp = [float("inf")] * (N + 1)
dp[1] = 0

for i in range(2, N + 1):
    for k in range(1, K + 1):
        if i - k >= 0:
            dp[i] = min(dp[i], dp[i - k] + abs(h[i - k] - h[i]))
        else:
            break

print(dp[N])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
items = [[0, 0]]
for _ in range(N):
    items.append(list(map(int, input().split())))

dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(W + 1):
        if j - items[i][0] >= 0:
            dp[i][j] = max(dp[i - 1][j - items[i][0]] + items[i][1], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(max(dp[N]))

Fixed submission:
N, W = map(int, input().split())
items = [[0, 0]]
for _ in range(N):
    items.append(list(map(int, input().split())))

dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(W + 1):
        if j - items[i][0] >= 0:
            dp[i][j] = max(dp[i - 1][j - items[i][0]] + items[i][1], dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(max(dp[N]))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

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

def main():
    x = M // N
    a_N = M - (N - 1) * x
    a_i = x
    for i in range(1, a_i + 1)[::-1]:
        if a_N % i == 0:
            print(i)
            exit()
        else:
            a_N += (N - 1)
    print(1)

if __name__ == "__main__":
    main()

Fixed submission:
#!/usr/bin/env python3

N, M = map(int, input().split())
from fractions import gcd

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

def main():
    x = M // N
    divisors = sorted(make_divisors(M))
    ok = 0
    ng = len(divisors) - 1
    if divisors[ng] <= x:
        print(divisors[ng])
        exit()
    while ok + 1 < ng:
        c = (ok + ng) // 2
        if divisors[c] <= x:
            ok = c
        else:
            ng = c
    print(divisors[ok])

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
mod = pow(10, 9) + 7
d = []
d.append([1 for _ in range(M + 1)])
d[0][0] = 0

for i in range(0, N - 1):
    d.append([])
    for j in range(M + 1):
        d[i + 1].append(sum([d[i][int(j / k)] for k in range(1, j + 1) if j % k == 0]) % mod)
   
print(d[-1][-1])

Fixed submission:
import collections
N, M = map(int, input().split())
mod = pow(10, 9) + 7

def prime_factorize(K):
    ans = []
    i = 2
    while i ** 2 <= K:
        if K % i == 0:
            K //= i
            ans.append(i)
        else:
            i += 1
    if K != 1:
        ans.append(K)
    
    return ans

def combination(N, r):
    ans = N
    for i in range(1, r):
        ans *= ((N - i) % mod) * pow(i + 1, mod - 2, mod)
        ans %= mod
    
    return ans

prime_nums = dict(collections.Counter(prime_factorize(M)))

ans = 1
for num in prime_nums.values():
    ans *= combination(N - 1 + num, num)
    ans %= mod

print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import fractions
import functools
N, X = map(int, input().split())
x = np.array(sorted(list(map(int, input().split()))))
x =  np.insert(x, np.where(x > X)[0], X) if len(np.where(x > X)) > 0 else np.insert(x, -1, X)
x = np.diff(x)
print(functools.reduce(fractions.gcd, x))

Fixed submission:
import numpy as np
import fractions
import functools
N, X = map(int, input().split())
x = np.array(sorted(list(map(int, input().split()))))
x =  np.insert(x, np.where(x > X)[0][0], X) if len(np.where(x > X)[0]) > 0 else np.append(x, X)
x = np.diff(x)
print(functools.reduce(fractions.gcd, x))

Buggy python submission (verdict: Runtime Error):
import numpy as np
import fractions
import functools
N, X = map(int, input().split())
x = np.array(sorted(list(map(int, input().split()))))
x = np.insert(x, np.where(x > X)[0], X)
x = np.diff(x)
print(functools.reduce(fractions.gcd, x))

Fixed submission:
import numpy as np
import fractions
import functools
N, X = map(int, input().split())
x = np.array(sorted(list(map(int, input().split()))))
x =  np.insert(x, np.where(x > X)[0][0], X) if len(np.where(x > X)[0]) > 0 else np.append(x, X)
x = np.diff(x)
print(functools.reduce(fractions.gcd, x))