Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
digit = [0] * 60
for a in A:
  binary = bin(a)[-1:1:-1]
  for j in range(len(binary)):
    digit[j] += int(binary[j])
ans = 0
mod = 10**9+7
for i in range(60):
  ans += digit[i] * (N - digit[i]) * pow(2, i, mod)
  ans %= mod
print(ans)

Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
A = np.array(A, dtype=np.int64)
ans = 0
mod = 10**9+7
i = 1
while i < (1 << 60):
    count = np.count_nonzero(A & i)
    ans += count * (N-count) * i
    ans %= mod
    i <<= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = list(map(int, input().split()))
digit = np.zeros(60)
for a in A:
    binary = np.array(list(map(int, bin(a)[-1:1:-1])))
    digit[0:len(binary)] += binary
ans = 0
mod = 10**9+7
digit = digit * (N - digit) % mod
for i in range(60):
    ans += int(digit[i]) * pow(2, i, mod)
    ans %= mod
print(ans)


Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
A = np.array(A, dtype=np.int64)
ans = 0
mod = 10**9+7
i = 1
while i < (1 << 60):
    count = np.count_nonzero(A & i)
    ans += count * (N-count) * i
    ans %= mod
    i <<= 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
digit = [0] * 60
for a in A:
    binary = bin(a)[-1:1:-1]
    for j in range(len(binary)):
        digit[j] += int(binary[j])
ans = 0
mod = 10**9+7
for i in range(60):
    ans += digit[i] * (N - digit[i]) * pow(2, i, mod)
    ans %= mod
print(ans)


Fixed submission:
import numpy as np

N = int(input())
A = list(map(int, input().split()))
A = np.array(A, dtype=np.int64)
ans = 0
mod = 10**9+7
i = 1
while i < (1 << 60):
    count = np.count_nonzero(A & i)
    ans += count * (N-count) * i
    ans %= mod
    i <<= 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))

B = (np.add.accumulate(A) - np.arange(N+1)) % K

count = [0] * K
ans = 0

for j in range(N+1):
    if j - K >= 0:
        count[B[j-K]] -= 1
    ans += count[B[j]]
    count[B[j]] += 1

print(ans)


Fixed submission:
import numpy as np
from collections import defaultdict

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))

B = (np.add.accumulate(A) - np.arange(N+1)) % K

counter = defaultdict(int)
ans = 0

for j in range(N+1):
    if j - K >= 0:
        counter[B[j-K]] -= 1
    ans += counter[B[j]]
    counter[B[j]] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
A = np.array(list(map(int, input().split())))
A %= K

ans = 0
sum_from_right = np.zeros(N)

for i in range(N):
    sum_from_right[:i+1] += A[i]
    sum_from_right %= K
    ans += i + 1 - np.count_nonzero(sum_from_right[:i+1] - np.arange(i+1, 0, -1))

print(ans)


Fixed submission:
import numpy as np
from collections import defaultdict

N, K = map(int, input().split())
A = np.array([0] + list(map(int, input().split())))

B = (np.add.accumulate(A) - np.arange(N+1)) % K

counter = defaultdict(int)
ans = 0

for j in range(N+1):
    if j - K >= 0:
        counter[B[j-K]] -= 1
    ans += counter[B[j]]
    counter[B[j]] += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, T = map(int, input().split())
AB = []
for i in range(N):
    AB.append(tuple(map(int, input().split())))

AB.sort()

ans = 0
dp = [0] * T

for a, b in AB:
    ans = max(ans, dp[-1] + b)
    for j in range(T-1, -1, -1):
        if j >= a:
            dp[j] = max(dp[j], dp[j-a] + b)

print(ans)


Fixed submission:
import numpy as np

N, T = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]

AB.sort()

ans = 0
dp = [0] * T
dp = np.zeros(T, int)

for a, b in AB:
    ans = max(ans, dp[-1] + b)
    dp[a:] = np.maximum(dp[a:], dp[:-a] + b)
    # for j in reversed(range(a, T)):
    #     dp[j] = max(dp[j], dp[j-a] + b)

print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

l = 0
r = max(a * f for a, f in zip(A, F)) + 1

while l < r:
    m = (l + r) // 2
    if sum(max(a - m // f, 0) for a, f in zip(A, F)) <= K:
        r = m
    else:
        l = m + 1

print(r)

Fixed submission:
A, B = map(int, input().split())
if A > 9 or B > 9:
    print(-1)
else:
    print(A * B)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

l = 0
r = max(a * f for a, f in zip(A, F)) + 1

while l < r:
    m = (l + r) // 2
    if sum(max(a - m // f, 0) for a, f in zip(A, F)) <= K:
        r = m
    else:
        l = m + 1

print(r)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]

l = 0
r = (A * F).max()

while l < r:
    m = (l + r) // 2
    if np.maximum(A - m // F, 0).sum() <= K:
        r = m
    else:
        l = m + 1

print(r)

Buggy python submission (verdict: Runtime Error):
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    F = list(map(int, input().split()))
    A.sort()
    F.sort(reverse=True)
     
    l = 0
    r = max(a * f for a, f in zip(A, F))
     
    while l < r:
        m = (l + r) // 2
        if sum(max(a - m // f, 0) for a, f in zip(A, F)) <= K:
            r = m
        else:
            l = m + 1
     
    print(r)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]

l = 0
r = (A * F).max()

while l < r:
    m = (l + r) // 2
    if np.maximum(A - m // F, 0).sum() <= K:
        r = m
    else:
        l = m + 1

print(r)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort()
F.sort(reverse=True)

l = 0
r = 10**12 + 1

while l < r:
    m = (l + r) // 2
    if sum(max(a - m // f, 0) for a, f in zip(A, F)) <= K:
        r = m
    else:
        l = m + 1

print(r)


Fixed submission:
import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]

l = 0
r = (A * F).max()

while l < r:
    m = (l + r) // 2
    if np.maximum(A - m // F, 0).sum() <= K:
        r = m
    else:
        l = m + 1

print(r)

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))
A.sort(reverse=True)
F.sort()
scores = [x * y for x, y in zip(A, F)]
scores = list(zip(scores, A, F))

while K > 0 and any(s[0] > 0 for s in scores):
    max_score = max(scores)
    index = scores.index(max_score)
    max_score = list(max_score)
    max_score[0] -= max_score[2]
    max_score[1] -= 1
    scores[index] = tuple(max_score)
    K -= 1

print(max(scores)[0])


Fixed submission:
import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)
A.sort()
F.sort()
F = F[::-1]

l = 0
r = (A * F).max()

while l < r:
    m = (l + r) // 2
    if np.maximum(A - m // F, 0).sum() <= K:
        r = m
    else:
        l = m + 1

print(r)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
passages = [[] for i in range(N-1)]
for i in range(M):
    s, t = map(int, input().split())
    passages[s-1].append(t-1)

# no blocking
E = [0] * N
for n, dest in list(enumerate(passages))[::-1]:
    E[n] = sum(E[d] for d in dest) / len(dest) + 1

min_E = E[0]

# with blocking
for n, dest in enumerate(passages):
    if len(dest) == 1:
        continue
    max_E = max(E[d] for d in dest)
    E[n] = ((E[n] - 1) * len(dest) - max_E) / (len(dest) - 1) + 1
    if n > 0:
        for n2, dest2 in list(enumerate(passages))[n-1::-1]:
            E[n2] = sum(E[d2] for d2 in dest2) / len(dest2) + 1
    min_E = min(min_E, E[0])

print(min_E)


Fixed submission:
N, M = map(int, input().split())
passages = [[] for i in range(N-1)]
for i in range(M):
    s, t = map(int, input().split())
    passages[s-1].append(t-1)

prob = [0] * N
prob[0] = 1
for n, dest in enumerate(passages):
    for d in dest:
        prob[d] += prob[n] / len(dest)

# no blocking
E = [0] * N
for n, dest in list(enumerate(passages))[::-1]:
    E[n] = sum(E[d] for d in dest) / len(dest) + 1

min_E = E[0]

# with blocking
for n, dest in enumerate(passages):
    if len(dest) == 1:
        continue
    new_E = ((E[n] - 1) * len(dest) - max(E[d] for d in dest)) / (len(dest) - 1) + 1
    min_E = min(min_E, E[0] - (E[n] - new_E) * prob[n])

print(min_E)

Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy

N, M = map(int, input().split())
passages = [[] for i in range(N-1)]
for i in range(M):
    s, t = map(int, input().split())
    passages[s-1].append(t-1)

# no blocking
E = [0] * N
for n, dest in list(enumerate(passages))[::-1]:
    E[n] = sum(E[d] for d in dest) / len(dest) + 1

min_E = E[0]

# with blocking
inf = 10**5
for n, dest in list(enumerate(passages))[::-1]:
    if len(dest) == 1:
        continue
    max_E = 0
    max_dest = 0
    for d in dest:
        if E[d] > max_E:
            max_E = E[d]
            max_dest = d
    E2 = deepcopy(E)
    E2[n] = ((E[n] - 1) * len(dest) - max_E) / (len(dest) - 1) + 1
    if n > 0:
        for n2, dest2 in list(enumerate(passages))[n-1::-1]:
            E2[n2] = sum(E2[d2] for d2 in dest2) / len(dest2) + 1
    min_E = min(min_E, E2[0])

print(min_E)


Fixed submission:
N, M = map(int, input().split())
passages = [[] for i in range(N-1)]
for i in range(M):
    s, t = map(int, input().split())
    passages[s-1].append(t-1)

prob = [0] * N
prob[0] = 1
for n, dest in enumerate(passages):
    for d in dest:
        prob[d] += prob[n] / len(dest)

# no blocking
E = [0] * N
for n, dest in list(enumerate(passages))[::-1]:
    E[n] = sum(E[d] for d in dest) / len(dest) + 1

min_E = E[0]

# with blocking
for n, dest in enumerate(passages):
    if len(dest) == 1:
        continue
    new_E = ((E[n] - 1) * len(dest) - max(E[d] for d in dest)) / (len(dest) - 1) + 1
    min_E = min(min_E, E[0] - (E[n] - new_E) * prob[n])

print(min_E)
Buggy python submission (verdict: Runtime Error):
N = int(input())
d = map(int, input().split())
print(sum(d[i] * d[j] for j in range(i+1, len(d)) for i in range(len(d))))

Fixed submission:
N = int(input())
d = list(map(int, input().split()))
sum = 0
for i in range(N):
    for j in range(i+1, N):
        sum += d[i] * d[j]
print(sum)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
  for j in range(i+1, N):
    max_len = L[i] + L[j] - 1
    left = j+1
    right = N
    while left < right:
      mid = (left + right) // 2
      if L[mid] < max_len:
        left = mid + 1
      elif L[mid] > max_len:
        right = mid
      else:
        while mid < N - 1 and L[mid] == L[mid]:
          mid += 1
          count += mid - j
          break
    else:
      count += right - j - 1
print(count)

Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
    for j in range(i+1, N):
        max_len = L[i] + L[j]
        count += bisect_left(L, max_len) - j - 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[k] < L[i] + L[j]:
                count += 1
print(count)


Fixed submission:
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
for i in range(N):
    for j in range(i+1, N):
        max_len = L[i] + L[j]
        count += bisect_left(L, max_len) - j - 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
from copy import deepcopy

N, M, L = map(int, input().split())
inf = 10**9 + 1
dist = [[inf] * N for i in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    dist[A-1][B-1] = dist[B-1][A-1] = C

# Floyd-Warshall algorithm
for k in range(N):
    for i in range(N):
        for j in range(i+1, N):
            min_dist = min(dist[i][j], dist[i][k] + dist[k][j])
            dist[i][j] = dist[j][i] = min_dist

refill = [list(map(lambda x: 1 if x <= L else inf, d)) for d in dist]
for k in range(N):
    for i in range(N):
        for j in range(i+1, N):
            min_refill = min(refill[i][j], refill[i][k] + refill[k][j])
            refill[i][j] = refill[j][i] = min_refill

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    print(refill[s-1][t-1] - 1 if refill[s-1][t-1] < inf else -1)


Fixed submission:
from scipy.sparse.csgraph import floyd_warshall
import numpy as np

N, M, L = map(int, input().split())
inf = 10**9 + 1
dist = [[inf] * N for i in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    dist[A-1][B-1] = dist[B-1][A-1] = C

dist = floyd_warshall(dist, directed=False)
dist = np.where(dist <= L, 1, inf)
dist = floyd_warshall(dist, directed=False)
dist = np.where(dist < inf, dist-1, -1)

Q = int(input())
for i in range(Q):
    s, t = map(int, input().split())
    print(int(dist[s-1, t-1]))
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import groupby
N, K = map(int, input().split())
S = [len(list(g)) for k, g in groupby(input())]
i = 0
while i < K and len(S) > 2:
    S.insert(0, S.pop(0) + S.pop(0) + S.pop(0))
    i += 1
if i < K and len(S) == 2:
    S.append(S.pop(0) + S.pop(0))
print(sum(S) - len(S))


Fixed submission:
from itertools import groupby
from collections import deque
N, K = map(int, input().split())
S = [len(list(g)) for k, g in groupby(input())]
S = deque(S)
i = 0
while i < K and len(S) > 2:
    S.append(S.pop() + S.pop() + S.pop())
    i += 1
if i < K and len(S) == 2:
    S.append(S.pop() + S.pop())
print(sum(S) - len(S))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
import sys

sys.setrecursionlimit(300000)

N, Q = map(int, input().split())
tree = defaultdict(list)
counter = [0] * N
for i in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for j in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

visited = [False] * N


def dfs(parent):
    visited[parent] = True
    for child in tree[parent]:
        if not visited[child]:
            counter[child] += counter[parent]
            dfs(child)


dfs(0)
print(' '.join(map(str, counter)))


Fixed submission:
from collections import defaultdict, deque

N, Q = map(int, input().split())
tree = defaultdict(list)
counter = [0] * N
for i in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for j in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

visited = [False] * N

queue = deque()
queue.append(0)
while queue:
    parent = queue.popleft()
    visited[parent] = True
    for child in tree[parent]:
        if not visited[child]:
            counter[child] += counter[parent]
            queue.append(child)

print(' '.join(map(str, counter)))

Buggy python submission (verdict: Runtime Error):
from collections import defaultdict

N, Q = map(int, input().split())
tree = defaultdict(list)
counter = [0] * N
for i in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for j in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

visited = [False] * N


def dfs(parent):
    visited[parent] = True
    for child in tree[parent]:
        if not visited[child]:
            counter[child] += counter[parent]
            dfs(child)


dfs(0)
print(' '.join(map(str, counter)))


Fixed submission:
from collections import defaultdict, deque

N, Q = map(int, input().split())
tree = defaultdict(list)
counter = [0] * N
for i in range(N-1):
    a, b = map(int, input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

for j in range(Q):
    p, x = map(int, input().split())
    counter[p-1] += x

visited = [False] * N

queue = deque()
queue.append(0)
while queue:
    parent = queue.popleft()
    visited[parent] = True
    for child in tree[parent]:
        if not visited[child]:
            counter[child] += counter[parent]
            queue.append(child)

print(' '.join(map(str, counter)))
Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pq = []
for i, b in enumerate(B):
    if A[i] != b:
        heappush(pq, (-b, i))
ans = 0
while pq:
    _, i = heappop(pq)
    B[i] -= B[(i-1) % N] + B[(i+1) % N]
    if B[i] < A[i]:
        ans = -1
        break
    if B[i] > A[i]:
        heappush(pq, (-B[i], i))
    ans += 1
print(ans)

Fixed submission:
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pq = []
for i, b in enumerate(B):
    if A[i] != b:
        heappush(pq, (-b, i))
ans = 0
while pq:
    _, i = heappop(pq)
    s = B[(i-1) % N] + B[(i+1) % N]
    q, r = divmod(B[i] - A[i], s)
    B[i] = A[i] + r
    ans += q
    if q == 0:
        ans = -1
        break
    if B[i] > A[i]:
        heappush(pq, (-B[i], i))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pq = []
for i, b in enumerate(B):
    heappush(pq, (-b, i))
ans = 0
while pq:
    _, i = heappop(pq)
    B[i] -= B[(i-1) % N] + B[(i+1) % N]
    if B[i] < A[i]:
        ans = -1
        break
    if B[i] > A[i]:
        heappush(pq, (-B[i], i))
    ans += 1
print(ans)

Fixed submission:
from heapq import heappush, heappop
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
pq = []
for i, b in enumerate(B):
    if A[i] != b:
        heappush(pq, (-b, i))
ans = 0
while pq:
    _, i = heappop(pq)
    s = B[(i-1) % N] + B[(i+1) % N]
    q, r = divmod(B[i] - A[i], s)
    B[i] = A[i] + r
    ans += q
    if q == 0:
        ans = -1
        break
    if B[i] > A[i]:
        heappush(pq, (-B[i], i))
print(ans)
Buggy python submission (verdict: Runtime Error):
from heapq import heappush, heappop

N, M = map(int, input().split())
salary = [[] for i in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    salary[A].append(B)
queue = []
ans = 0

for i in range(1, M+1):
    for s in salary[i]:
        heappush(queue, -s)
    if queue:
        ans += -heappop(queue)

print(ans)


Fixed submission:
from heapq import heappush, heappop

N, M = map(int, input().split())
salary = [[] for i in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    if A <= M:
        salary[A].append(B)
queue = []
ans = 0

for i in range(1, M+1):
    for s in salary[i]:
        heappush(queue, -s)
    if queue:
        ans += -heappop(queue)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heapify, heappush, heappop

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort()
queue = []
heapify(queue)
ans = 0

for i in range(1, M+1):
    while len(AB) > 0:
        if AB[0][0] <= i:
            heappush(queue, -AB.pop(0)[1])
        else:
            break

    if queue:
        ans += -heappop(queue)

print(ans)


Fixed submission:
from heapq import heappush, heappop

N, M = map(int, input().split())
salary = [[] for i in range(M+1)]
for i in range(N):
    A, B = map(int, input().split())
    if A <= M:
        salary[A].append(B)
queue = []
ans = 0

for i in range(1, M+1):
    for s in salary[i]:
        heappush(queue, -s)
    if queue:
        ans += -heappop(queue)

print(ans)
Buggy python submission (verdict: Runtime Error):
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec() -> Vec<i32> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().unwrap())
        .collect()
}

fn main() {
    let N: usize = read_line().parse().unwrap();
    let H = read_vec();
    let mut prev = 0;
    for h in H {
        if prev < h {
            prev = h - 1;
        } else if prev > h {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


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

N = int(input())
H = list(map(int, input().split()))
prev = -1
for h in H:
    if prev > h:
        print('No')
        exit()
    if prev <= h - 1:
        prev = h - 1
    else:
        prev = h
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
def combination(n, k, mod=10**9+7):
    numer = denom = 1
    for i in range(k):
        numer = (numer * (n-i)) % mod
        denom = (denom * (i+1)) % mod
    return (numer * pow(denom, mod-2, mod)) % mod


N, K = map(int, input().split())
mod = 10**9+7
dp = [[0] * (K+1) for i in range(K+1)]  # the number of ways to split j into i parts
dp[0][0] = 1
for i in range(1, K+1):
    for j in range(1, K+1):
        dp[i][j] = dp[i][j-1] + dp[i-1][j-1]

for i in range(1, K+1):
    print((dp[i][K] * combination(N-K+1, i)) % mod)


Fixed submission:
N, K = map(int, input().split())
mod = 10**9+7
dp = [[0] * (K+1) for i in range(K+1)]  # the number of ways to split j into i parts
dp[0][0] = 1
for i in range(1, K+1):
    for j in range(1, K+1):
        dp[i][j] = dp[i][j-1] + dp[i-1][j-1]

combination = 1
for i in range(1, K+1):
    combination = (combination * (N-K-i+2) * pow(i, mod-2, mod)) % mod
    print((dp[i][K] * combination) % mod)