Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
K, N = map(int, input().split())
A = map(int, input().split())
dist = 0
for a in A:
    dist |= 1 << a
dist = format(dist, "0%db" % K)
d = dist.index("1")
ans = 0
count = 0
for i in range(K):
    if dist[(d + i) % K] == "1":
        ans = max(ans, count)
        count = 0
    else:
        count += 1
ans = max(ans, count)
print(K - ans - 1)

Fixed submission:
K, N = map(int, input().split())
A = map(int, input().split())
dist = [0] * K
for a in A:
    dist[a] = 1
d = dist.index(1)
ans = 0
count = 0
for i in range(K):
    if dist[(d + i) % K] == 1:
        ans = max(ans, count)
        count = 0
    else:
        count += 1
ans = max(ans, count)
print(K - ans - 1)
Buggy python submission (verdict: Runtime Error):

from collections import Counter
from scipy.special import comb
import numpy as np
N = int(input())
A = list(map(int, input().split()))

total = 0
answers = np.array([0] * (N + 1))
for number, appearance in Counter(A).items():
    flat = comb(appearance, 2, exact=True)
    minus_one = comb(appearance - 1, 2, exact=True)
    total += flat
    answers[number] = minus_one - flat
answers += total

print(*answers[A], sep="\n")


Fixed submission:
from collections import Counter
from scipy.misc import comb
import numpy as np
N = int(input())
A = list(map(int, input().split()))

total = 0
answers = np.array([0] * (N + 1))
for number, appearance in Counter(A).items():
    flat = comb(appearance, 2, exact=True)
    minus_one = comb(appearance - 1, 2, exact=True)
    total += flat
    answers[number] = minus_one - flat
answers += total

print(*answers[A], sep="\n")
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
ans = [None] * N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] in [None, c]:
        ans[s - 1] = c
    else:
        print(-1)
        quit()

ans = "".join(map(lambda i, n :str(n) if n else "0" if i else "1", enumerate(ans)))
if N > 1 and ans[0] == "0":
    print(-1)
    quit()

print(ans)


Fixed submission:
N, M = map(int, input().split())
ans = [None] * N
for _ in range(M):
    s, c = map(int, input().split())
    if ans[s - 1] in [None, c]:
        ans[s - 1] = c
    else:
        print(-1)
        quit()

ans = "".join(map(lambda pair :str(pair[1]) if pair[1] != None else "0" if pair[0] or N == 1 else "1", enumerate(ans)))
if N > 1 and ans[0] == "0":
    print(-1)
    quit()

print(ans)
Buggy python submission (verdict: Runtime Error):
from math import log, ceil
print(ceil(int(log(*map(int, input().split())) - 0.001) + 0.001))

Fixed submission:
N, R = map(int, input().split())
print(R + max(0, 100 * (10 - N)))
Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb

N = input()
K = int(input())

L = len(N)

if N.count("0") > L - K:
    integer = int(N)
    N = str(integer - integer % 10 - 1)

L = len(N)

if L < K:
    print(0)
    quit()

M = ["0"] * L
count = 0
for i in range(L):
    count += bool(int(N[i]))
    M[i] = N[i]
    if count == K:
        M = "".join(M)
        break

index = 0
ans = 0
while index < L:
    if int(M[index]):
        n = L - index - 1
        k = K - index
        digit = (int(M[index]) - 1)
        ans += comb(n, k, exact=True) * 9 ** k + \
               digit * comb(n, k - 1, exact=True) * 9 ** (k - 1)
    index += 1

print(ans + 1)


Fixed submission:
from scipy.misc import comb

N = input()
K = int(input())

L = len(N)

if N.count("0") > L - K:
    integer = int(N)
    N = str(integer - integer % 10 - 1)

L = len(N)

if L < K or N[0] == "-":
    print(0)
    quit()

M = ["0"] * L
count = 0
for i in range(L):
    count += bool(int(N[i]))
    M[i] = N[i]
    if count == K:
        M = "".join(M)
        break

index = 0
ans = 0
count = 0
while index < L:
    if int(M[index]):
        count += 1
        n = L - index - 1
        k = K - count + 1
        digit = int(M[index]) - (count != K)
        ans += comb(n, k, exact=True) * 9 ** k + \
               digit * comb(n, k - 1, exact=True) * 9 ** (k - 1)
    index += 1

print(int(ans))

Buggy python submission (verdict: Runtime Error):
from scipy.misc import comb

N = input()
K = int(input())

L = len(N)

if N.count("0") > L - K:
    integer = int(N)
    N = str(integer - integer % 10 - 1)

M = ["0"] * L
count = 0

for i in range(L):
    count += bool(int(N[i]))
    M[i] = N[i]
    if count == K:
        M = "".join(M)
        break

index = 0
ans = 0
while index < L:
    if int(M[index]):
        n = L - index - 1
        k = K - index
        digit = (int(M[index]) - 1)
        ans += comb(n, k, exact=True) * 9 ** k + \
               digit * comb(n, k - 1, exact=True) * 9 ** (k - 1)
    index += 1

print(ans + 1)

Fixed submission:
from scipy.misc import comb

N = input()
K = int(input())

L = len(N)

if N.count("0") > L - K:
    integer = int(N)
    N = str(integer - integer % 10 - 1)

L = len(N)

if L < K or N[0] == "-":
    print(0)
    quit()

M = ["0"] * L
count = 0
for i in range(L):
    count += bool(int(N[i]))
    M[i] = N[i]
    if count == K:
        M = "".join(M)
        break

index = 0
ans = 0
count = 0
while index < L:
    if int(M[index]):
        count += 1
        n = L - index - 1
        k = K - count + 1
        digit = int(M[index]) - (count != K)
        ans += comb(n, k, exact=True) * 9 ** k + \
               digit * comb(n, k - 1, exact=True) * 9 ** (k - 1)
    index += 1

print(int(ans))
Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
ATK, MP = zip(*(tuple(map(int, input().split())) for _ in range(N)))
MAX_ATK = max(ATK)
table = [0] * (H + MAX_ATK)
for damage in range(1, H + 1):
    table[damage] = min(table[damage - ATK[magic]] + MP[magic] for magic in range(N))
print(table[H])


Fixed submission:
H, N = map(int, input().split())
ATK, MP = zip(*(tuple(map(int, input().split())) for _ in range(N)))
MAX_ATK = max(ATK)
table = [0] * (H + MAX_ATK)
for damage in range(1, H + 1):
    table[damage] = min(table[damage - ATK[magic]] + MP[magic] for magic in range(N))
print(table[H])

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())
ATK, MP = zip(*(tuple(map(int, input().split())) for _ in range(N)))
table = [[float("inf")] * (H + 1) for _ in range(N + 1)]
table[0][0] = 0
for magic in range(N):
    for damage in range(H + 1):
        now = table[magic][damage]
        table[magic + 1][damage] = min(now, table[magic + 1][damage])
        table[magic][min(H, damage + ATK[magic])] = min(now + MP[magic], table[magic][min(H, damage + ATK[magic])])

print(table[N - 1][H])


Fixed submission:
H, N = map(int, input().split())
ATK, MP = zip(*(tuple(map(int, input().split())) for _ in range(N)))
MAX_ATK = max(ATK)
table = [0] * (H + MAX_ATK)
for damage in range(1, H + 1):
    table[damage] = min(table[damage - ATK[magic]] + MP[magic] for magic in range(N))
print(table[H])
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p), ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))


Fixed submission:
N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p) - 1, ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M = map(int, input().split())
accepted = np.array([0] * N, dtype=np.int32)
penalties = np.array([0] * N, dtype=np.int32)
for _ in range(M):
    p, ac = [func(c) for func, c in zip([lambda n: int(n) - 1, lambda s: s == "AC"], input().split())]
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), accepted.dot(penalties))


Fixed submission:
N, M = map(int, input().split())
accepted = [0] * N
penalties = [0] * N
for _ in range(M):
    p, ac = input().split()
    p, ac = int(p) - 1, ac == "AC"
    accepted[p] |= ac
    penalties[p] += not accepted[p]
print(sum(accepted), sum(p for ac, p in zip(accepted, penalties) if ac))
Buggy python submission (verdict: Runtime Error):
from math import gcd
a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))


Fixed submission:
from fractions import gcd
a, b = map(int, input().split())
print(int(a * b / gcd(a, b)))
Buggy python submission (verdict: Runtime Error):
import numpy as np
from math import log
N = int(input())
if N % 2:
    print(0)
    quit()
print(((N // 2) // np.array([5**i for i in range(1, int(log(N // 2, 5)) + 1)], np.int64)).sum())


Fixed submission:
N = int(input())
if N % 2 == 0:
    total = 0
    temp = (N // 2) // 5
    total += temp
    while temp:
        temp //= 5
        total += temp
    print(total)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
MOD = 10**9 + 7
n = int(input())
array = np.array([list(map(int, format(num, "060b")))[::-1] for num in map(int, input().split())], dtype="int64")
sum_ = 0
for idx, column in enumerate(array.T):
    n_ones = column.sum()
    sum_ += ((n_ones * (n - n_ones)) % MOD) * ((2 ** idx) % MOD) % MOD
    sum_ %= MOD
print(sum_)

Fixed submission:
import numpy as np
MOD = 10**9 + 7
n = int(input())
A = np.array(list(map(int, input().split())))

answer = 0
for i in range(60):
    n_ones = np.count_nonzero(A & 1)
    answer += 2 ** i * (n - n_ones) * n_ones
    A >>= 1

print(answer % MOD)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
def bfs(graph, N, start):
    colors = [dict() for _ in range(N)]
    visited = [0] * N
    visited[start] = 1
    que = deque([start])
    while que:
        node = que.popleft()
        # do_something(node)
        color = 1
        for n in graph[node]:
            if not visited[n]:
                visited[n] = 1
                while color in colors[node].values():
                    color += 1
                colors[node][n] = color
                colors[n][node] = color
                que.append(n)
    return colors

N = int(input())
graph = [[] for _ in range(N)]
inputs = tuple(tuple(map(lambda n: int(n) - 1, input().split())) for _ in range(N - 1))
counts = [0] * N
for i, j in inputs:
    graph[i].append(j)
    graph[j].append(i)
    counts[i] += 1
    counts[j] += 1
colors = bfs(graph, N, 0)
print(max(counts))
for i, j in inputs:
    print(colors[i][j])

Fixed submission:
from collections import deque
def color_available(unavailable, K):
    idx = 0
    L = len(unavailable)
    unavailable = sorted(unavailable)
    for color in range(K):
        if idx < L and color == unavailable[idx]:
            idx += 1
        else:
            yield color

def bfs(graph, N, K, start):
    colors = [dict() for _ in range(N)]
    visited = [0] * N
    visited[start] = 1
    que = deque([start])
    while que:
        node = que.popleft()
        gen = color_available(colors[node].values(), K)
        color = 1
        for n in graph[node]:
            if not visited[n]:
                visited[n] = 1
                color = next(gen)
                colors[node][n] = color
                colors[n][node] = color
                que.append(n)
    return colors

N = int(input())
graph = [[] for _ in range(N)]
inputs = tuple(tuple(map(lambda n: int(n) - 1, input().split())) for _ in range(N - 1))
counts = [0] * N
for i, j in inputs:
    graph[i].append(j)
    graph[j].append(i)
    counts[i] += 1
    counts[j] += 1
K = max(counts)
colors = bfs(graph, N, K, 0)
print(K)
for i, j in inputs:
    print(colors[i][j] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

N, M = map(int, input().split())
S = input()[::-1]

stack = deque([[0, M + 1]])
now = 0
while stack:
    now, d = stack.pop()
    d -= 1
    if not d:
        continue
    if now + d >= N:
        stack.append([now, d - (now + d - N)])
        print(*map(lambda s: s[1], reversed(stack)))
        quit()
    stack.append([now, d])
    if S[now + d] == "0":
        stack.append([now + d, M + 1])
print(-1)


Fixed submission:
N, M = map(int, input().split())
S = list(map(int, reversed(input())))
now = 0
ans = []
while now + M < N:
    last = now
    now += M
    while S[now]:
        now -= 1
    if last == now:
        print(-1)
        break
    ans.append(now - last)
else:
    print(*reversed(ans + [N - now]))
Buggy python submission (verdict: Runtime Error):
from statistics import mean
from itertools import combinations
dist = lambda p1, p2: ((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2) ** (1 / 2)

N = int(input())
P = (tuple(map(int, input().split())) for _ in range(N))

distances = (dist(*combination) for combination in combinations(P, 2))
total_distance = (sum(distance) for distance in combinations(distances, N - 1))
print(mean(total_distance))

Fixed submission:
from itertools import combinations
dist = lambda p1, p2: ((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2) ** (1 / 2)

N = int(input())
P = (tuple(map(int, input().split())) for _ in range(N))

distances = (dist(*combination) for combination in combinations(P, 2))
total_distance = tuple(sum(distance) for distance in combinations(distances, N - 1))
print(sum(total_distance) / len(total_distance))

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import mean
from itertools import combinations
dist = lambda p1, p2: ((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2) ** (1 / 2)

N = int(input())
P = (tuple(map(int, input().split())) for _ in range(N))

distances = (dist(*combination) for combination in combinations(P, 2))
total_distance = (sum(distance) for distance in combinations(distances, N - 1))
print(mean(total_distance))

Fixed submission:
from itertools import combinations
dist = lambda p1, p2: ((p2[0] - p1[0]) ** 2 + (p2[1] - p1[1]) ** 2) ** (1 / 2)

N = int(input())
P = (tuple(map(int, input().split())) for _ in range(N))

distances = (dist(*combination) for combination in combinations(P, 2))
total_distance = tuple(sum(distance) for distance in combinations(distances, N - 1))
print(sum(total_distance) / len(total_distance))
Buggy python submission (verdict: Time Limit Exceeded):
N, T = map(int, input().split())
table = [[0] * (N + 1) for _ in range(T + 1)]
dish = sorted((tuple(map(int, input().split())) for _ in range(N)), key=lambda t: t[0])
for t in range(T + 1):
    for n in range(N):
        minutes_to_take, deliciousness = dish[n]
        now = table[t][n]
        if t < T:
            table[min(T, t + minutes_to_take)][n + 1] = max(table[min(T, t + minutes_to_take)][n + 1], now + deliciousness)
        if n < N:
            table[t][n + 1] = max(table[t][n + 1], now)
print(max(table[t][N] for t in range(T + 1)))

Fixed submission:
N, T = map(int, input().split())
table = [[0] * (N + 1) for _ in range(T + 1)]
dish = sorted((tuple(map(int, input().split())) for _ in range(N)), key=lambda t: t[0])
for t in range(T + 1):
    for n in range(N):
        minutes_to_take, deliciousness = dish[n]
        now = table[t][n]
        if t < T:
            table[min(T, t + minutes_to_take)][n + 1] = max(table[min(T, t + minutes_to_take)][n + 1], now + deliciousness)
        if n < N:
            table[t][n + 1] = max(table[t][n + 1], now)
print(max(table[t][N] for t in range(T + 1)))
Buggy python submission (verdict: Runtime Error):
num = int(input())
print(min(i + num // i - 2 for i in range(1, int(num ** (1 / 2))) if not num % i))

Fixed submission:
num = int(input())
print(min(i + num // i - 2 for i in range(1, int(num ** (1 / 2)) + 1) if not num % i))
Buggy python submission (verdict: Runtime Error):
print(degrees(atan(2 * (a ** 2 * b - x) / a ** 3)) if x >= a ** 2 * b / 2 else degrees(atan(a * b ** 2 / x / 2)))


Fixed submission:
from math import atan, degrees
a, b, x = map(int, input().split())
print(degrees(atan(2 * (a ** 2 * b - x) / a ** 3)) if x >= a ** 2 * b / 2 else degrees(atan(a * b ** 2 / x / 2)))
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect
N = int(input())
sides = sorted(map(int, input().split()))

ans = 0
for i in range(1, N - 1):
    for j in range(i + 1, N + 1):
        ans += N - j - bisect(sides, sides[-i] - sides[-j], hi=N-j)
print(ans)


Fixed submission:
from bisect import bisect
N = int(input())
sides = sorted(map(int, input().split()))

ans = 0
for i in range(1, N - 1):
    for j in range(i + 1, N + 1):
        ans += N - j - bisect(sides, sides[-i] - sides[-j], hi=N-j)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect
N = int(input())
sides = sorted(map(int, input().split()))
print(sum(sum(N - j - bisect(sides, sides[-i] - sides[-j], hi=N-j) for j in range(i + 1, N + 1)) for i in range(1, N - 1)))


Fixed submission:
from bisect import bisect
N = int(input())
sides = sorted(map(int, input().split()))

ans = 0
for i in range(1, N - 1):
    for j in range(i + 1, N + 1):
        ans += N - j - bisect(sides, sides[-i] - sides[-j], hi=N-j)
print(ans)

Buggy python submission (verdict: Runtime Error):
from bisect import bisect
N = int(input())
sides = sorted(map(int, input().split()))
print(sum(N - j - bisect(sides, sides[-i] - sides[-j], hi=N-j) for j in range(i + 1, N + 1) for i in range(1, N - 1)))


Fixed submission:
from bisect import bisect
N = int(input())
sides = sorted(map(int, input().split()))

ans = 0
for i in range(1, N - 1):
    for j in range(i + 1, N + 1):
        ans += N - j - bisect(sides, sides[-i] - sides[-j], hi=N-j)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
INF = 10 ** 7
N, M = map(int, input().split())
L = 1 << N
table = [[INF] * L for _ in range(M + 1)]
table[0][0] = 0
for m in range(M):
    cost, _ = map(int, input().split())
    match = reduce(lambda a, b: a | b, (1 << shamt for shamt in map(lambda n: int(n) - 1, input().split())))
    for l in range(L):
        now = table[m][l]
        if l and not now:
            continue
        table[m + 1][l] = min(now, table[m + 1][l])
        table[m + 1][l | match] = min(now + cost, table[m + 1][l | match])
print(table[M][L - 1] if table[M][L - 1] != INF else -1)

Fixed submission:
from functools import reduce
INF = 10 ** 7
N, M = map(int, input().split())
L = 1 << N
keys = [0] * M
for m in range(M):
    cost, _ = map(int, input().split())
    match = reduce(lambda a, b: a | b, (1 << shamt for shamt in map(lambda n: int(n) - 1, input().split())))
    keys[m] = cost, match
table = [[INF] * L for _ in range(M + 1)]
table[0][0] = 0
for m in range(M):
    cost, match = keys[m]
    for l in range(L):
        now = table[m][l]
        if l and not now:
            continue
        table[m + 1][l] = min(now, table[m + 1][l])
        table[m + 1][l | match] = min(now + cost, table[m + 1][l | match])
print(table[M][L - 1] if table[M][L - 1] != INF else -1)
Buggy python submission (verdict: Runtime Error):
from itertools import accumulate
N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
visited = [0] * N
children = [0] * N
count = 0
order = [0] * N
def dfs_recursive(edge):
    global count
    visited[edge] = 1
    order[edge] = count
    count += 1
    child = edge
    for e in graph[edge]:
        if not visited[e]:
            child = dfs_recursive(e)
    children[edge] = child
    return child
for _ in range(N - 1):
    a, b = map(lambda n: int(n) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
dfs_recursive(0)
imos = [0] * (N + 1)
for _ in range(Q):
    p, x = map(int, input().split())
    root = p - 1
    root_idx = order[root]
    child = children[root]
    child_idx = order[child]
    imos[root_idx] += x
    imos[child_idx + 1] -= x
ans = list(accumulate(imos))
ans.pop()
print(*ans)

Fixed submission:
from collections import deque
def dfs(graph, N, start, points):
    visited = [0] * N
    visited[start] = 1
    stack = deque([(start, points[start])])
    ret = [0] * N
    while stack:
        edge, point = stack.pop()
        ret[edge] = point
        for e in graph[edge]:
            if not visited[e]:
                visited[e] = 1
                stack.append((e, point + points[e]))
    return ret

N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(lambda n: int(n) - 1, input().split())
    graph[a].append(b)
    graph[b].append(a)
points = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    points[p - 1] += x
print(*dfs(graph, N, 0, points))
Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right
s, t = open(0).read().split()
S, T = set(s), set(t)
if T & S != T:
    print(-1)
    quit()
d, l = dict(), dict()
for idx, c in enumerate(s):
    d[c] = d.get(c, []) + [idx]
    l[c] = l.get(c, 0) + 1
prev = -1
loop = 0
for c in t:
    idx = bisect_right(d[c], prev)
    if idx >= l[c]:
        loop += 1
        prev = d[c][0]
    else:
        prev = d[c][idx]
print((loop) * len(s) + prev + 1)

Fixed submission:
from bisect import bisect_right
s = tuple(map(lambda c: ord(c) - ord("a"), input()))
t = tuple(map(lambda c: ord(c) - ord("a"), input()))
S, T = set(s), set(t)
if T & S != T:
    print(-1)
    quit()
d, l = [[] for _ in range(26)], [0] * 26
for idx, c in enumerate(s):
    d[c].append(idx)
    l[c] += 1
prev = -1
loop = 0
for c in t:
    idx = bisect_right(d[c], prev)
    if idx >= l[c]:
        loop += 1
        prev = d[c][0]
    else:
        prev = d[c][idx]
print((loop) * len(s) + prev + 1)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right
s, t = open(0).read().split()
S, T = set(s), set(t)
if T & S != T:
    print(-1)
    quit()
d, l = dict(), dict()
for idx, c in enumerate(s):
    d[c] = d.get(c, []) + [idx]
    l[c] = l.get(c, 0) + 1
prev = -1
loop = 0
for c in t:
    idx = bisect_right(d[c], prev)
    if idx >= l[c]:
        loop += 1
        prev = d[c][0]
    else:
        prev = d[c][idx]
print((loop) * len(s) + prev + 1)

Fixed submission:
from bisect import bisect_right
s = tuple(map(lambda c: ord(c) - ord("a"), input()))
t = tuple(map(lambda c: ord(c) - ord("a"), input()))
S, T = set(s), set(t)
if T & S != T:
    print(-1)
    quit()
d, l = [[] for _ in range(26)], [0] * 26
for idx, c in enumerate(s):
    d[c].append(idx)
    l[c] += 1
prev = -1
loop = 0
for c in t:
    idx = bisect_right(d[c], prev)
    if idx >= l[c]:
        loop += 1
        prev = d[c][0]
    else:
        prev = d[c][idx]
print((loop) * len(s) + prev + 1)
Buggy python submission (verdict: Runtime Error):
N = int(input())
boxes = [0] * (N + 1)
ans = tuple(n for n, digit in reversed(tuple(enumerate(map(int, input().split()), 1))) if (sum(d for d in boxes[n::n]) & 1 != digit and (boxes.__setitem__(n, 1) or 1)))
print(f"{len(ans)}\n", *ans)

Fixed submission:
N = int(input())
A = reversed(tuple(enumerate(map(int, input().split()), 1)))

boxes = [0] * (N + 1)
ans = []

for n, digit in A:
    put = sum(d for d in boxes[n::n]) & 1 != digit
    if put:
        boxes[n] = 1
        ans.append(n)

print(len(ans))
if ans:
    print(*ans)
Buggy python submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7
FACT_MAX = 2000
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD

N, K = map(int, input().split())
for i in range(1, K + 1):
    print(comb(N - K + 1, i) * comb(K - 1, i - 1) % MOD)

Fixed submission:
MOD = 10 ** 9 + 7
FACT_MAX = 2001
fact = [1] * FACT_MAX
for i in range(1, FACT_MAX):
    fact[i] = fact[i - 1] * i % MOD
def comb(n, r):
    return 0 if n < r else fact[n] * pow(fact[n - r], MOD - 2, MOD) * pow(fact[r], MOD - 2, MOD) % MOD

N, K = map(int, input().split())
for i in range(1, K + 1):
    print(comb(N - K + 1, i) * comb(K - 1, i - 1) % MOD)