Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = [int(i) for i in input()]

cnt_arr = [0]
idx = 0
cnt_seq_0 = 1
cnt_seq_1 = 0
cnt_seq_0_arr = []
cnt_seq_1_arr = []
idx_seq_0 = []

prev = 1
for i, s_i in enumerate(S):
    if s_i == 0:
        if prev == 0:
            cnt_seq_0 += 1
        elif prev == 1:
            cnt_seq_1_arr.append(cnt_seq_1)
            cnt_seq_1 = 1
        if prev != 0:
            idx_seq_0.append(i)
        if i == len(S) - 1:
            cnt_seq_0_arr.append(cnt_seq_0)
            cnt_seq_1_arr.append(0)
    elif s_i == 1:
        if prev == 1:
            cnt_seq_1 += 1
        elif prev == 0:
            cnt_seq_0_arr.append(cnt_seq_0)
            cnt_seq_0 = 1
        if i == len(S) - 1:
            cnt_seq_1_arr.append(cnt_seq_1)
    prev = s_i

r_cnt = {}

import heapq
sum_arr = []

if len(cnt_seq_0_arr) == 0:
    print(len(cnt_seq_1_arr))
else:
    sum_0 = cnt_seq_1_arr[0]
    for i in range(K):
        sum_0 += cnt_seq_0_arr[i] + cnt_seq_1_arr[i + 1]

    heapq.heappush(sum_arr, -sum_0)
    sum_i = sum_0

    for i in range(0, len(cnt_seq_0_arr) - K):
        sum_i += -cnt_seq_0_arr[i] - cnt_seq_1_arr[i] + cnt_seq_0_arr[i + K] + cnt_seq_1_arr[i + K + 1]
        heapq.heappush(sum_arr, -sum_i)

    print(-heapq.heappop(sum_arr))

Fixed submission:
N, K = map(int, input().split())
S = [int(i) for i in input()]

now = 1
cnt = 0
nums = []
for i in range(N):
    if S[i] == now:
        cnt += 1
    else:
        nums.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    nums.append(cnt)

if len(nums) % 2 == 0:
    nums.append(0)

add = 2 * K + 1

# Calculate cumulative sums
cum_sum = [0]
for i in range(0, len(nums)):
    cum_sum.append(cum_sum[i] + nums[i])

# Solve
ans = 0
for i in range(0, len(nums), 2):
    l = i
    r = min(i + add, len(nums))
    ans = max(ans, cum_sum[r] - cum_sum[l])

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

AB = []
for i, a in enumerate(A):
    for j, b in enumerate(B):
        AB.append(a + b)

AB.sort(reverse=True)

ABC = []
for i, ab in enumerate(AB[:K+1]):
    for j, c in enumerate(C):
        ABC.append(ab + c)

ABC.sort(reverse=True)

for i in range(K):
    print(ABC[i])

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


A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ABC = []

for i, a in enumerate(A):
    for j, b in enumerate(B):
        if (i + 1) * (j + 1) > K:
            break
        for k, c in enumerate(C):
            if (i + 1) * (j + 1) * (k + 1) > K:
                break
            ABC.append(a + b + c)

ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
s = input()

golems = [1 for _ in range(N)]

index_table = {}
for i, c in enumerate(s):
    if c in index_table:
        index_table[c].append(i)
    else:
        index_table[c] = [i]

for i in range(Q):
    t_i, d_i = input().split()
    if t_i not in index_table:
        continue
    indexes = index_table[t_i]
    if indexes is not None and len(indexes) > 0:
        for index in indexes:
            golem_num = golems[index]
            golems[index] = 0
            if d_i == 'L' and index != 0:
                golems[index - 1] += golem_num
            elif d_i == 'R' and index != N - 1:
                golems[index + 1] += golem_num

count = 0
for i, g in enumerate(golems):
    count += g

print(count)

Fixed submission:
N, Q = map(int, input().split())
s = input()

t = []
d = []
for i in range(Q):
    t_i, d_i = input().split()
    t.append(t_i)
    d.append(d_i)


def calc_group(n):
    for i in range(Q):
        if s[n] == t[i]:
            if d[i] == 'L':
                n -= 1
                if n == -1:
                    return -1
            elif d[i] == 'R':
                n += 1
                if n == N:
                    return 1
    return 0


l = -1
r = N
n = (l + r) // 2
while l != n:
    if calc_group(n) == -1:
        l = n
    else:
        r = n
    n = (l + r) // 2
l_max = l

l = -1
r = N
n = (l + r) // 2
while l != n:
    if calc_group(n) == 1:
        r = n
    else:
        l = n
    n = (l + r) // 2
r_min = r

if r_min == l_max:
    count = 0
else:
    count = r_min - l_max - 1
print(count)
Buggy python submission (verdict: Runtime Error):
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]
INF = 10 ** 9


def bsearch(n, arr):
    l = 0
    r = len(arr)
    m = (l + r) // 2
    while l != m:
        if n <= arr[m]:
            r = m
        else:
            l = m
        m = (l + r) // 2
    return l


s = [-INF] + s + [INF]
t = [-INF] + t + [INF]

for i, x_i in enumerate(x):
    sa = bsearch(x_i, s)
    ta = bsearch(x_i, t)
    lmin = INF
    for si in range(sa, sa + 2):
        for ti in range(ta, ta + 2):
            l = min(abs(x_i - s[si]) + abs(s[si] - t[ti]), abs(x_i - t[ti]) + abs(t[ti] - s[si]))
            lmin = min(l, lmin)
    print(lmin)

Fixed submission:
A, B, Q = map(int, input().split())
s = [int(input()) for _ in range(A)]
t = [int(input()) for _ in range(B)]
x = [int(input()) for _ in range(Q)]


def bsearch(n, arr):
    l = 0
    r = len(arr)
    m = (l + r) // 2
    while l != m:
        if n <= arr[m]:
            r = m
        else:
            l = m
        m = (l + r) // 2
    if r < len(arr) and abs(arr[l] - n) > abs(arr[r] - n):
        return r
    else:
        return l


def bsearch_l(n, arr):
    l = 0
    r = len(arr)
    m = (l + r) // 2
    while l != m:
        if n <= arr[m]:
            r = m
        else:
            l = m
        m = (l + r) // 2
    return l


def calc_distance(x, l, c, near_idx):
    ret = abs(x - l)
    if c == 's':
        next_l = t[near_idx]
    else:
        next_l = s[near_idx]
    ret += abs(next_l - l)
    return ret


st = []
for i, s_i in enumerate(s):
    t_i = bsearch(s_i, t)
    st.append((s_i, 's', t_i))

for i, t_i in enumerate(t):
    s_i = bsearch(t_i, s)
    st.append((t_i, 't', s_i))

st = sorted(st)
starr = sorted(s + t)

ans_list = []
for i, x_i in enumerate(x):
    st_i = bsearch_l(x_i, starr)
    l, c, near_idx = st[st_i]
    ans = calc_distance(x_i, l, c, near_idx)
    if st_i < len(st) - 1:
        l, c, near_idx = st[st_i + 1]
        ans = min(ans, calc_distance(x_i, l, c, near_idx))
    ans_list.append(ans)

for i, ans in enumerate(ans_list):
    print(ans)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def gcd_arr(a):
    ans = a[0]
    for i, a_i in enumerate(a):
        ans = gcd(ans, a_i)
    return ans

print(gcd_arr(A))

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

ans = 10 ** 10
while min(A) != ans:
    ans = min(A)
    for i, a_i in enumerate(A):
        if a_i > ans:
            A[i] = a_i % ans
            if A[i] == 0:
                del A[i]

print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
INF = 10 ** 9


def matchnum(n):
    table = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    return table[n - 1]


# dp[n] : n本使った時の桁数
dp = [0] + [-INF for _ in range(N)]
for i in range(N + 1):
    for j, a_j in enumerate(A):
        if i - matchnum(a_j) >= 0:
            dp[i] = max(dp[i], dp[i - matchnum(a_j)] + 1)

l = dp[N]
m = N
ans = []
A = sorted(A, reverse=True)
while m > 0:
    for i, a_i in enumerate(A):
        if dp[m - matchnum(a_i)] == l - 1:
            ans.append(str(a_i))
            m -= matchnum(a_i)
            l -= 1
            break
print(''.join(ans))

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
INF = 10 ** 9


def matchnum(n):
    table = [2, 5, 5, 4, 5, 6, 3, 7, 6]
    return table[n - 1]


# dp[n] : n本使った時の桁数
dp = [0] + [-INF for _ in range(N)]
for i in range(N + 1):
    for j, a_j in enumerate(A):
        if i - matchnum(a_j) >= 0:
            dp[i] = max(dp[i], dp[i - matchnum(a_j)] + 1)

l = dp[N]
m = N
ans = []
A = sorted(A, reverse=True)
while m > 0:
    for i, a_i in enumerate(A):
        if m - matchnum(a_i) >= 0 and dp[m - matchnum(a_i)] == l - 1:
            ans.append(str(a_i))
            m -= matchnum(a_i)
            l -= 1
            break
print(''.join(ans))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

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

td = []
for _ in range(N):
    t, d = map(int, input().split())
    td.append((t, d))

td.sort(reverse=True, key=lambda x: x[1])

g1 = [0] * (N + 1)
g0 = []
sumt = 0
for i in range(K):
    t, d = td[i]
    if g1[t] == 0:
        g1[t] = d
        sumt += 1
    elif g1[t] < d:
        heapq.heappush(g0, g1[t])
        g1[t] = d
    else:
        heapq.heappush(g0, d)

ans = sum(g1) + sum(g0) + sumt * sumt
for i in range(K, N):
    t, d = td[i]
    if g1[t] == 0 and len(g0) > 0:
        g1[t] = d
        heapq.heappop(g0)
        sumt += 1
        newans = sum(g1) + sum(g0) + sumt * sumt
        ans = max(ans, newans)

print(ans)

Fixed submission:
import heapq

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

td = []
for _ in range(N):
    t, d = map(int, input().split())
    td.append((t, d))

td.sort(reverse=True, key=lambda x: x[1])

g1 = [0] * (N + 1)
g0 = []
sumt = 0
for i in range(K):
    t, d = td[i]
    if g1[t] == 0:
        g1[t] = d
        sumt += 1
    elif g1[t] < d:
        heapq.heappush(g0, g1[t])
        g1[t] = d
    else:
        heapq.heappush(g0, d)

sumg1 = sum(g1)
sumg0 = sum(g0)
ans = sumg1 + sumg0 + sumt * sumt
for i in range(K, N):
    t, d = td[i]
    if g1[t] == 0 and len(g0) > 0:
        g1[t] = d
        sumg1 += d
        sumg0 -= heapq.heappop(g0)
        sumt += 1
        newans = sumg1 + sumg0 + sumt * sumt
        ans = max(ans, newans)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = 10 ** 12

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

print(dp[N - 1])

Fixed submission:
import numpy as np

N, K = map(int, input().split())
h = np.array(list(map(int, input().split())))
INF = 10 ** 12

dp = np.array([0] + [INF for _ in range(N - 1)], dtype=np.int64)
for i in range(1, N):
    dp[i] = np.min(dp[max(0, i-K):i] + np.abs(h[i] - h[max(0, i-K):i]))

print(dp[N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
INF = -10 ** 12

# 重さW以下の時の価値の最大値
dp = [[0 for _ in range(W + 1)] for _ in range(N)]

for i in range(0, N):
    w, v = map(int, input().split())
    for j in range(W + 1):
        if j - w >= 0:
            dp[i][j] = max(dp[i - 1][j - w] + v, dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[N - 1][W])

Fixed submission:
import numpy as np

N, W = map(int, input().split())
INF = -10 ** 12

# 重さW以下の時の価値の最大値
dp = np.zeros((N, W + 1), dtype=np.int64)

for i in range(0, N):
    w, v = map(int, input().split())
    dp[i][:w] = dp[i-1][:w]
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)

print(dp[N - 1][W])

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
INF = -10 ** 12

# 重さW以下の時の価値の最大値
dp = [[0 for _ in range(W + 1)] for _ in range(N + 1)]

for i in range(1, N + 1):
    w, v = map(int, input().split())
    for j in range(W + 1):
        if j - w >= 0:
            dp[i][j] = max(dp[i - 1][j - w] + v, dp[i - 1][j])
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[N][W])

Fixed submission:
import numpy as np

N, W = map(int, input().split())
INF = -10 ** 12

# 重さW以下の時の価値の最大値
dp = np.zeros((N, W + 1), dtype=np.int64)

for i in range(0, N):
    w, v = map(int, input().split())
    dp[i][:w] = dp[i-1][:w]
    dp[i][w:] = np.maximum(dp[i-1][w:], dp[i-1][:-w] + v)

print(dp[N - 1][W])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

for h in range(1, 3501):
    for n in range(h, 3501):
        p = N * h * n
        q = 4 * h * n - N * h - N * n
        if q > 0 and p % q == 0:
            w = int(p / q)
            print(str(h) + ' ' + str(n) + ' ' + str(w))
            exit()

Fixed submission:
N = int(input())

for h in range(1, 3501):
    for n in range(h, 3501):
        q = 4 * h * n - N * h - N * n
        if q <= 0:
            continue
        p = N * h * n
        if p >= q and p % q == 0:
            w = int(p / q)
            print(str(h) + ' ' + str(n) + ' ' + str(w))
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
N, A, B, C, D = map(int, input().split())

B = B - A
A = 0

dp = {}
dp[1] = {}
dp[1][A] = True
for i in range(2, N + 1):
    dp[i] = {}
    for n in dp[i - 1]:
        for x in range(C, D + 1):
            dp[i][n + x] = True
            dp[i][n - x] = True

if B in dp[N]:
    print('YES')
else:
    print('NO')

Fixed submission:
N, A, B, C, D = map(int, input().split())

# k : count of plus
diff = B - A

is_ok = False
for k in range(N - 1):
    min = k * C - (N - 1 - k) * D
    max = k * D - (N - 1 - k) * C
    if min <= diff and diff <= max:
        is_ok = True
        break

if is_ok:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

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

def com(n, k):
    if n == 0 or k == 0:
        return 1
    return int(reduce(mul, range(n + 1 - k, n + 1)) / reduce(mul, range(1, k + 1)))

idx_list = [-1] * (n + 2)
l = 0
r = 0
for i, a_i in enumerate(a):
    if idx_list[a_i] < 0:
        idx_list[a_i] = i
    else:
        l = idx_list[a_i]
        r = n - i
        break

for k in range(1, n + 2):
    m = k - 1
    dup = 0
    for l_n in range(0, m + 1):
        r_n = m - l_n
        if l_n > l or r_n > r:
            continue
        l_c = com(l, l_n)
        r_c = com(r, r_n)
        dup += l_c * r_c
    ans = (com(n + 1, k) - dup) % (10 ** 9 + 7)
    print(ans)

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

b = []
if n % 2 == 0:
    for i in reversed(range(1, n, 2)):
        b.append(str(a[i]))
    for i in range(0, n, 2):
        b.append(str(a[i]))
else:
    for i in reversed(range(0, n + 1, 2)):
        b.append(str(a[i]))
    for i in range(1, n, 2):
        b.append(str(a[i]))

ans = ' '.join(b)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

def set_enable_goal(cur_node, back_paths, enable_goal):
    if cur_node in back_paths:
        for next_node in back_paths[cur_node]:
            if enable_goal[next_node - 1] == 0:
                enable_goal[next_node - 1] = 1
                set_enable_goal(next_node, back_paths, enable_goal)


N, M = map(int, input().split())
MIN = float('-inf')
INF_LIMIT = -MIN

back_paths = {}
all_paths = {}
for i in range(M):
    a, b, c = map(int, input().split())
    if a in all_paths:
        all_paths[a].append((b, c))
    else:
        all_paths[a] = [(b, c)]

    if b in back_paths:
        back_paths[b].append(a)
    else:
        back_paths[b] = [a]


# path cut
enable_goal= [0 for i in range(N)]
enable_goal[N - 1] = 1
set_enable_goal(N, back_paths, enable_goal)

for a, paths in all_paths.items():
    if not enable_goal[a - 1]:
        all_paths[a] = []
    else:
        valid_paths = []
        for b, c in paths:
            if enable_goal[b - 1]:
                valid_paths.append((b, c))
        all_paths[a] = valid_paths


scores = [MIN for i in range(N)]
scores[0] = 0

is_inf = False
for n in range(N):
    for a in range(1, M + 1):
        if a in all_paths:
            for b, c in all_paths[a]:
                scores[b - 1] = max(scores[b - 1], scores[a - 1] + c)

# loop check
if not is_inf:
    prev_score = scores[N - 1]
    for a in range(1, M + 1):
        if a in all_paths:
            for b, c in all_paths[a]:
                scores[b - 1] = max(scores[b - 1], scores[a - 1] + c)
    if prev_score != scores[N - 1]:
        is_inf = True


if is_inf:
    print('inf')
else:
    print(scores[N - 1])

Fixed submission:
A, B, C = map(int, input().split())

if C >= A and C <= B:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

nlist = []
for i in range(N):
    a, b = map(int, input().split())
    if len(nlist) == 0:
        nlist.append((a, b))
    else:
        for i, (na, nb) in enumerate(nlist):
            if a <= na:
                nlist.insert(i, (a, b))
                break
            elif i == len(nlist) - 1:
                nlist.insert(i + 1, (a, b))
                break

cur_pos = 0
for a, b in nlist:
    cur_pos += b
    if cur_pos >= K:
        print(a)
        break

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

dic = {}
for i in range(N):
    a, b = map(int, input().split())
    if a in dic:
        dic[a] += b
    else:
        dic[a] = b
keys = list(dic.keys())
keys.sort()

cur_pos = 0
for key in keys:
    b = dic[key]
    cur_pos += b
    if cur_pos >= K:
        print(key)
        break
Buggy python submission (verdict: Runtime Error):
r = input()
print(3*r**2)

Fixed submission:
r = int(input())

print(3*r**2)
Buggy python submission (verdict: Runtime Error):
import numpy as np

n = int(input())
jobs = [list(map(int, input().split())) for i in range(n)]

jobs.sort(key=lambda x:x[1])

flg = True

a = np.array(jobs)[:,0]
b = np.array(jobs)[:,1]

sum = np.add.accumulate(a)
if sum(sum > b):
    print('No')
else:
    print('Yes')

Fixed submission:
from operator import itemgetter

n = int(input())
jobs = [list(map(int, input().split())) for i in range(n)]

jobs.sort(key=itemgetter(1))

flg = True
sum = 0
for a, b in jobs:
    sum += a
    if sum > b:
        flg = False
        break

if flg:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
n, d = input().split()
n=int(n)
d=int(d)
sum=0
count=0
while 1:
  sum=sum+2*d+1
  count+=1
    break
print(count)

Fixed submission:
n, d = input().split()
n=int(n)
d=int(d)
sum=0
count=0
while 1:
  sum=sum+2*d+1
  count+=1
  if sum>=n:
    break
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
for j in range(n):
  if m < li[j]:
    print(m)
  else:
    buf=li.pop(j)
    print(max(li))
    li.insert(j,buf)

Fixed submission:
n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
m2 = sorted(li)[-2]

for j in range(n):
  if m == li[j]:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Runtime Error):
n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
for j in range(n):
  if m < li[j]:
    print(m)
  else:
    buf=li.pop(j)
    print(max(li))

Fixed submission:
n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
m2 = sorted(li)[-2]

for j in range(n):
  if m == li[j]:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Runtime Error):
n = input()
    n = int(n)

    li = [int(input()) for i in range(n)]
    m = max(li)
    for j in range(n):
      if m < li[j]:
        print(m)
      else:
        print(max(li))

Fixed submission:
n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
m2 = sorted(li)[-2]

for j in range(n):
  if m == li[j]:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
for j in range(n):
  buf = li.pop(j)
  if buf<m:
    print(m)
  else:
  	print(max(li))
  li.insert(j,buf)


Fixed submission:
n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
m2 = sorted(li)[-2]

for j in range(n):
  if m == li[j]:
    print(m2)
  else:
    print(m)

Buggy python submission (verdict: Time Limit Exceeded):
n = input()
n = int(n)

li = [int(input()) for i in range(n)]

for j in range(n):
  buf = li.pop(j)
  print(max(li))
  li.insert(j,buf)


Fixed submission:
n = input()
n = int(n)

li = [int(input()) for i in range(n)]
m = max(li)
m2 = sorted(li)[-2]

for j in range(n):
  if m == li[j]:
    print(m2)
  else:
    print(m)
Buggy python submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(n-2):
  if ((p[i]>p[i+1]) and (p[i+1]>p[i+2]) and (p[i]>p[i+2])) or ((p[i]<p[i+1]) and (p[i+1]<p[i+2]) and (p[i]<p[i+2])):
    count += 1
print(count)

Fixed submission:
s = input()
result = 0
count = 0
for i in s:
  if s.count(i) == 2:
    result = 0
    count+=1
  else:
    count = 5
    break
if result == 1 or count > 4:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

n, k = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 1000000007


def combination(x, y):
    return factorial(x) // (factorial(x-y) * factorial(y))


for i in range(1, k+1):
    blue = combination(k-1, i-1)
    red = combination(n-k+1, i)
    ans = blue * red
    print(ans % MOD)


Fixed submission:
from sys import stdin
from math import factorial

n, k = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 1000000007


def combination(x, y):
    return factorial(x) // (factorial(x-y) * factorial(y))


for i in range(1, k+1):
    if n - k + 1 < i:
        ans = 0
    else:
        blue = combination(k-1, i-1)
        red = combination(n-k+1, i)
        ans = blue * red
    print(ans % MOD)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from math import factorial

n, k = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 1000000007


def combination(x, y):
    return factorial(x) // (factorial(x-y) * factorial(y))


def f2(n, k):
    return combination(n+k-1, k-1)


def f(n, k):
    if n < k:
        return 0
    if n == 0 and k == 0:
        return 1
    if k < 1:
        return 0
    return f2(n-k, k)


for i in range(1, k+1):
    blue = f(k, i)
    red = f2(n-k-(i-1), i+1)
    ans = blue * red
    print(ans % MOD)


Fixed submission:
from sys import stdin
from math import factorial

n, k = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 1000000007


def combination(x, y):
    return factorial(x) // (factorial(x-y) * factorial(y))


for i in range(1, k+1):
    if n - k + 1 < i:
        ans = 0
    else:
        blue = combination(k-1, i-1)
        red = combination(n-k+1, i)
        ans = blue * red
    print(ans % MOD)

Buggy python submission (verdict: Time Limit Exceeded):
from sys import stdin

n, k = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 1000000007

c = [[0 for i in range(4005)] for j in range(4005)]
c[0][0] = 1
for i in range(4000):
    for j in range(i+1):
        c[i+1][j] += c[i][j]
        c[i+1][j+1] += c[i][j]


def combination(x, y):
    return c[x][y]


def f2(n, k):
    return combination(n+k-1, k-1)


def f(n, k):
    if n < k:
        return 0
    if n == 0 and k == 0:
        return 1
    if k < 1:
        return 0
    return f2(n-k, k)


for i in range(1, k+1):
    blue = f(k, i)
    red = 0
    red += f(n-k, i-1)
    red += f(n-k, i)
    red += f(n-k, i)
    red += f(n-k, i+1)
    ans = blue * red
    print(ans % MOD)


Fixed submission:
from sys import stdin
from math import factorial

n, k = [int(x) for x in stdin.readline().rstrip().split()]
MOD = 1000000007


def combination(x, y):
    return factorial(x) // (factorial(x-y) * factorial(y))


for i in range(1, k+1):
    if n - k + 1 < i:
        ans = 0
    else:
        blue = combination(k-1, i-1)
        red = combination(n-k+1, i)
        ans = blue * red
    print(ans % MOD)