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

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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

ng = 0
ok = 10 ** 9

# able(X) を、すべての丸太を X 以下の長さに切れる場合 1 , そうでない場合 0 を返す関数とする
# 二分探索によって、able(X) が 1 に切り替わる X 点を見つける


def able(x):
    count = 0
    for i in range(N):
        if A[i] % x:
            count += A[i] // x
        else:
            count += A[i] // x - 1

    if count <= K:
        return True
    else:
        return False


while ok - ng > 1:
    mid = ng + (ok - ng) // 2
    if able(mid):
        ok = mid
    else:
        ng = mid

print(ok)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

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

left = 0
right = 10 ** 9

# able(X) を、すべての丸太を X 以下の長さに切れる場合 1 , そうでない場合 0 を返す関数とする
# 二分探索によって、able(X) が 1 に切り替わる X 点を見つける


def able(x):
    count = 0
    for i in range(N):
        if A[i] % x:
            count += A[i] // x
        else:
            count += A[i] // x - 1

    if count <= K:
        return True
    else:
        return False


while left < right:
    mid = left + (right - left) // 2
    if able(mid):
        right = mid
    else:
        left = mid + 1

print(left)
Problem p02622 (python)

Fixed submission:
S = input()
T = input()
 
leng = len(S)
count = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count += 1
 
print(count)

Buggy submission (verdict: Runtime Error):
S, T = input().split()

leng = len(S)
count = 0
for i in range(len(S)):
  if S[i] != T[i]:
    count += 1

print(count)
Problem p02659 (python)

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

A = int(A)
B_float = int(B[2:])
B_int = int(B[0]) * 100

res = A * (B_int + B_float) // 100

print(int(res))

Buggy submission (verdict: Runtime Error):
A, B = input().split()

A = int(A)
B_float = int(B[2:])
B_int = int(B[0]) * 100

res = A * B // 100

print(int(res))
Problem p02695 (python)

Fixed submission:
N, M, Q = map(int, input().split())
 
A = []
B = []
C = []
D = []
 
for i in range(Q):
    a, b, c, d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)
 
 
def dfs(nums):
 
    if len(nums) == N + 1:
        score = 0
        for j in range(Q):
            if nums[B[j]] - nums[A[j]] == C[j]:
                score += D[j]
        return score
 
    max_score = 0
    for i in range(nums[-1], M+1):
        new_nums = nums + [i]
        max_score = max(max_score, dfs(new_nums))
 
    return max_score
 
nums = [1]
res = dfs(nums)
print(res)

Buggy submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())

A = []
B = []
C = []
D = []

for i in range(Q):
    a, b, c, d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)


def dfs(nums):

    if len(nums) == N + 1:
        score = 0
        for j in range(Q):
            if nums[B[j]] - nums[A[j]] == C[j]:
                score += D[j]
        return score

    max_score = 0
    for i in range(nums[-1], M+1):
        new_nums = nums + [i]
        max_score = max(max_score, dfs(new_nums))

    return max_score

nums[1]
res = dfs(nums)
print(res)
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())

if W >= S:
  print('unsafe')
else:
  print('safe')

Buggy submission (verdict: Runtime Error):
S = input()
leng = len(S)

count = [0] * 2019
count[0] = 1

for i in range(leng):
    remainder = int(S[i:]) % 2019
    count[remainder] += 1

res = 0
for cnt in count:
    res += cnt * (cnt - 1) // 2
    
print(res)
Problem p02711 (python)

Fixed submission:
N = input()

flag = False

for char in N:
  if char == '7':
    print('Yes')
    flag = True
    break

if flag == False:   
  print('No')

Buggy submission (verdict: Runtime Error):
N = input()

for char in N:
  if char = '7':
    print('Yes')

print('No')
Problem p02726 (python)

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


counts = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        # i -> x 直接
        d1 = abs(j-i)
        # i -> X -> Y -> j
        d2 = abs(i-X) + abs(Y-j) + 1

        d = min(d1, d2)
        counts[d] += 1


for i in range(1, N):
    print(counts[i])

Buggy submission (verdict: Runtime Error):
N, X, Y = map(int, input().split())

counts = [0] * N
for i in range(1, N):
    for j in range(i+1, N+1):
        # i -> x 直接
        d1 = abs(j-i)
        # i -> X -> Y -> j
        d2 = abs(i-X) + abs(Y-j) + 1

        d = min(d1, d2, d3)
        counts[d] += 1


for i in range(1, N):
    print(counts[i])
Problem p02862 (python)

Fixed submission:
import sys

X, Y = map(int, input().split())
mod = 10 ** 9 + 7

# if (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
if (X + Y) % 3 != 0:
    # 整数解がない場合
    print(0)
    sys.exit()


m = (2 * X - Y) // 3
n = (2 * Y - X) // 3

if m < 0 or n < 0:
    print(0)
    sys.exit()

u = m + n
fact = [1] * (u+1)

for i in range(1, u+1):
    fact[i] = (fact[i-1] * i) % mod

fact_inv1 = pow(fact[n], mod-2, mod)
fact_inv2 = pow(fact[m], mod-2, mod)

res = (((fact[u] * fact_inv1) % mod) * fact_inv2) % mod

print(res)

Buggy submission (verdict: Runtime Error):
import sys

X, Y = map(int, input().split())
mod = 10 ** 9 + 7

if (2 * X - Y) % 3 != 0:
    # 整数解がない場合
    print(0)
    sys.exit()


m = (2 * X - Y) // 3
n = (2 * Y - X) // 3

u = m + n
fact = [1] * (u+1)

for i in range(1, u+1):
    fact[i] = (fact[i-1] * i) % mod

fact_inv1 = pow(fact[n], mod-2, mod)
fact_inv2 = pow(fact[m], mod-2, mod)

res = (((fact[u] * fact_inv1) % mod) * fact_inv2) % mod

print(res)
Problem p02688 (python)

Fixed submission:
import numpy as np

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

A = np.zeros(N, dtype=int)

for _ in range(K):
    input()
    for i in input().split():
        A[int(i) - 1] += 1

ans = 0
for i in A:
    if i == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
 
A = np.zeros(N, dtype=int)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())
 
A = np.zeros(N, dtype=int)
 
for _ in range(K):
    input()
    for i in input().split():
        A[int(i) - 1] += 1
 
ans = 0
for i in A:
    if i == 0:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, K = map(int, input().split())

A = np.zeros(N, dtype=int)

for _ in range(K):
    input()
    for i in input().split():
        A[int(i) - 1] += 1

ans = 0
for i in A:
    if i == 0:
        ans += 1
print(ans)
Problem p02711 (python)

Fixed submission:
N = input()
ans = "No"
for i in N:
    if i == "7":
        ans = "Yes"

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S = input()
r = 0
g = 0
b = 0
for i in range(N):
    if S[i] == "R":
        r += 1
    elif S[i] == "G":
        g += 1
    else:
        b += 1
ans = r * g * b

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        x = j + j - i
        if S[i] != S[j] and x <= N - 1:
            if S[i] != S[x] and S[x] != S[j]:
                ans -= 1

print(ans)
Problem p02623 (python)

Fixed submission:
from bisect import bisect_right


def solve():
    N, M, K = map(int, input().split())

    A = map(int, input().split())
    B = map(int, input().split())

    sum_as = [0] * (N+1)
    sum_bs = [0] * (M+1)

    for i, a in enumerate(A):
        sum_as[i+1] = sum_as[i] + a

    for i, b in enumerate(B):
        sum_bs[i+1] = sum_bs[i] + b
    sum_bs = sum_bs[1:]

    answer = 0
    for i, sa in enumerate(sum_as):
        remain = K - sa
        if remain < 0:
            continue
        
        idx = bisect_right(sum_bs, remain)
        answer = max(answer, i + idx)

    return answer


def main():
    print(solve())


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
# import sys
# readline = sys.stdin.readline
# generator = (readline().strip() for _ in range(N))

# N, M = map(int, input().split())
# As = list(map(int, input().split()))
# queries = (input() for _ in range(N))


def solve():
    N, M, K = map(int, input().split())

    As = list(map(int, input().split()))
    Bs = list(map(int, input().split()))

    def dfs(n, m, total, count):
        if total > K:
            return count - 1

        if n == N and m == M:
            return count

        if n < N:
            c1 = dfs(n+1, m, total + As[n], count+1)
        else:
            c1 = count

        if m < M:
            c2 = dfs(n, m+1, total + Bs[m], count+1)
        else:
            c2 = count

        return max(c1, c2)

    return dfs(0, 0, 0, 0)


def main():
    print(solve())


if __name__ == "__main__":
    main()
Problem p02679 (python)

Fixed submission:
from sys import stdin
from collections import defaultdict
from math import gcd


def main():
    MOD = 1000000007

    N, *AB = map(int, stdin.buffer.read().split())

    d = defaultdict(int)
    n_zeros = 0

    for a, b in zip(AB[::2], AB[1::2]):
        if a == 0 and b == 0:
            n_zeros += 1
            continue

        g = gcd(a, b)
        a, b = a // g, b // g

        if a * b > 0 or b == 0:
            c = (abs(a), abs(b))
        else:
            c = (-abs(a), -abs(b))

        d[c] += 1

    ans = 1
    n_not_paired = 0
    for ab, n in d.items():
        ab_pair = (-ab[1], -ab[0])
        if ab_pair in d:
            if ab[0] > 0:
                m = d[ab_pair]
                ans = ans * (pow(2, n, MOD) + pow(2, m, MOD) - 1) % MOD
        else:
            n_not_paired += n

    ans = (ans * pow(2, n_not_paired, MOD) + n_zeros - 1) % MOD
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from sys import stdin
from collections import defaultdict
from math import gcd


def main():
    MOD = 1000000007

    N, *AB = map(int, stdin.buffer.read().split())

    d = defaultdict(int)
    n_zeros = 0

    for a, b in zip(AB[::2], AB[1::2]):
        if a == 0 and b == 0:
            n_zeros += 1
            continue

        g = gcd(a, b)
        a, b = a // g, b // g

        if a * b > 0 or b == 0:
            c = (abs(a), abs(b))
        else:
            c = (-abs(b), -abs(a))

        d[c] += 1

    ans = 1
    n_not_paired = 0
    for ab, n in d.items():
        ab_pair = (-ab[1], -ab[0])
        if ab_pair in d:
            if ab[0] > 0:
                ans = ans * (pow(2, n, MOD) + pow(2, m, MOD) - 1) % MOD
        else:
            n_not_paired += n

    ans = (ans * pow(2, n_not_paired, MOD) + n_zeros - 1) % MOD
    print(ans)


if __name__ == '__main__':
    main()
Problem p02685 (python)

Fixed submission:
def inverse_mod(a, mod=10**9+7):
    """ Calculate inverse of the integer a modulo mod.
    """
    return pow(a, mod-2, mod)


def combination_mod(n, r, mod=10**9+7):
    """ Calculate nCr modulo mod.
    """

    r = min(r, n-r)
    numerator = denominator = 1
    for i in range(r):
        numerator = numerator * (n - i) % mod
        denominator = denominator * (i + 1) % mod

    return numerator * inverse_mod(denominator, mod) % mod


def create_inverses_table(n, mod=10**9+7):
    """ Create table for inverses of the integers 0 to n modulo mod.
    """

    inv_table = [0] + [1] * n
    for x in range(2, n+1):
        inv_table[x] = -(mod//x) * inv_table[mod % x] % mod

    return inv_table


def solve():
    n_blocks, n_colors, n_max_pairs = map(int, input().split())

    if n_colors == 1:
        return int(n_blocks - n_max_pairs == 1)

    mod = 998244353

    inverses = create_inverses_table(max(n_colors, n_max_pairs), mod)

    e1 = n_colors * pow(n_colors-1, n_blocks-1, mod) % mod
    e2 = 1
    total = e1 * e2

    for k in range(1, n_max_pairs+1):
        e1 = e1 * inverses[n_colors - 1] % mod
        e2 = e2 * (n_blocks - k) * inverses[k] % mod
        total += e1 * e2
        total %= mod

    return total


def main():
    print(solve())


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def inverse_mod(a, mod=10**9+7):
    """ Calculate inverse of the integer a modulo mod.
    """
    return pow(a, mod-2, mod)


def combination_mod(n, r, mod=10**9+7):
    """ Calculate nCr modulo mod.
    """

    r = min(r, n-r)
    numerator = denominator = 1
    for i in range(r):
        numerator = numerator * (n - i) % mod
        denominator = denominator * (i + 1) % mod

    return numerator * inverse_mod(denominator, mod) % mod


def create_inverses_list(n, mod):
    """ Create list of inverses of the integers 0 to n modulo mod.
    """
    
    inv_list = [1] * (n+1)
    for x in range(n+1):
        inv_list[x] = (-(mod//x) * inv_list[mod % x]) % mod
    
    return inv_list


def main():
    n_blocks, n_colors, n_max_pairs = map(int, input().split())
    mod = 998244353

    inverses = create_inverses_list(n_max_pairs, mod)
    
    e1 = n_colors * pow(n_colors-1, n_blocks-1, mod)
    e2 = 1
    total = e1 * e2 % mod

    for k in range(1, n_max_pairs+1):
        e1 = e1 * inverses[n_colors - 1] % mod
        e2 = e2 * (n_blocks - k) % mod * inverses[k] % mod
        total += e1 * e2 % mod
        total %= mod

    print(total)


if __name__ == "__main__":
    main()
Problem p02831 (python)

Fixed submission:
import sys
from fractions import gcd


def main():
    # input = sys.stdin.readline

    a, b = map(int, input().split())

    answer = a * b / gcd(a, b)
    print(int(answer))


if __name__ == '__main__':
    main()

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

def main():
    # input = sys.stdin.readline

    a, b = map(int, input().split())

    answer = a * b / math.gcd(a, b)
    print(int(answer))


if __name__ == '__main__':
    main()
Problem p02933 (python)

Fixed submission:
def A():
    stdin = lambda: map(int, input().split())
    a = int(input())
    s = input()

    if a >= 3200:
        answer = s
    else:
        answer = 'red'
    print(answer)


if __name__ == '__main__':
    A()

Buggy submission (verdict: Runtime Error):
    a = int(input())
    s = input()
    
    if a >= 3200:
        answer = s
    else:
        answer = 'red'
    print(answer)
Problem p02935 (python)

Fixed submission:
def C():
    N = int(input())
    values = list(map(int, input().split()))

    values = sorted(values, reverse=True)
    weights = [(1/2)**(i+1) for i in range(N-1)] + [(1/2)**(N-1)]

    total_value = sum([values[i]*weights[i] for i in range(N)])

    print(total_value)


if __name__ == '__main__':
    C()

Buggy submission (verdict: Runtime Error):
def C():
    N = int(input())
    values = list(map(int, input().split()))

    values = values.sort()
    total_value = [values[i]*((1/2)**i) for i in range(N)]    
    
    print(total_value)

    
if __name__ == '__main__':
    C()
Problem p02987 (python)

Fixed submission:
def code_for_A(S, test=None):

    if not test:
        S = input()

    condition = 0
    for s in S:
        condition += S.count(s) != 2

    if condition:
        answer = 'No'
    else:
        answer = 'Yes'

    print(answer)

code_for_A(None, 0)

Buggy submission (verdict: Runtime Error):
def code_for_A(S, test=None):

    if not test:
        S = input()

    condition = 0
    for s in S:
        condition += S.count(s) != 2

    if condition:
        answer = 'No'
    else:
        answer = 'Yes'

    print(answer)

code_for_A(,1)
Problem p03041 (python)

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

S = input()

K -= 1
replaced_S = S[:K] + S[K].lower() + S[K+1:]

print(replaced_S)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())

S = input()

K += 1
replaced_S = S[:K] + S[K].lower() + S[K+1:]

print(replaced_S)
Problem p03042 (python)

Fixed submission:
def can_be_month(n):
    if 0 < int(n) < 13:
        return True
    return False


S = input()

if can_be_month(S[:2]) and can_be_month(S[2:]):
    print('AMBIGUOUS')
elif can_be_month(S[:2]):
    print('MMYY')
elif can_be_month(S[2:]):
    print('YYMM')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
def can_be_month(n):
    if 0 < n < 13:
        return True
    return False


S = input()

if not S:
    print('NA')
elif can_be_month(S[:2]) and can_be_month(S[2:]):
    print('AMBIGUOUS')
elif can_be_month(S[:2]):
    print('MMYY')
elif can_be_month(S[2:]):
    print('YYMM')
Problem p03104 (python)

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

def xor(n):
    m = n+1
    return m//2%2 + n*(m%2)

print(xor(B)^xor(A-1))

Buggy submission (verdict: Runtime Error):
A,B = map(int,input().split())
L = list(range(A,B+1))

ans = 0
for l in L:
    ans = ans^l

print(ans)
Problem p03135 (python)

Fixed submission:
T,X = map(int, input().split())

print(T/X+0.000001)

Buggy submission (verdict: Runtime Error):
X,T = map(int, input().split(' '))

print(f'{T/X/1.0}000')

Buggy submission (verdict: Runtime Error):
X,T = map.(int, input().split(' '))

input(T/X)
Problem p03137 (python)

Fixed submission:
N,M = list(map(int, input().split(' ')))
Xs = list(map(int, input().split(' ')))

Xs.sort()
L=[]
for i in range(M-1):
  L.append(Xs[i+1]-Xs[i])
  
L.sort()
result = sum(L[:1-N]) if N>1 else sum(L)

print(result)

Buggy submission (verdict: Runtime Error):
N,M = list(map(int, input().split(' ')))
Xs = list(map(int, input().split(' ')))

Xs.sort()
L=[]
for i in range(M-1):
  L.append(Xs[i+1]-Xs[i])
  
L.sort()
print(sum(L[1-N]))
Problem p03208 (python)

Fixed submission:
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

def solve(N,K,trees):
    trees.sort()

    diffs = []
    for i,h in enumerate(trees[:N-K+1]):
        min_h = h
        max_h = trees[i+K-1]
        #print(min_h,max_h)
        diffs.append(max_h-min_h)

    print(min(diffs))
    return

solve(N,K,trees)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

def solve(N,K,trees):
    trees.sort()

    diffs = []
    for i,h in enumerate(trees[:N-K+1]):
        min_h = h
        max_h = trees[i+K-1]
        print(min_h,max_h)
        diffs.append(max_h-min_h)

    print(min(diffs))
return

solve(N,K,trees)

Buggy submission (verdict: Runtime Error):
N,K = map(int, input().split())
trees = [int(input()) for _ in range(N)]

trees.sort()

diffs = []
for i,h in trees[:N-K]:
  min_h = h
  max_h = trees[i+K]
  diffs.append(max_h-min_h)

print(min(diffs))
Problem p03221 (python)

Fixed submission:
N,M = map(int, input().split())
citys = [list(map(int,input().split()))+[i] for i in range(M)]

citys.sort(key = lambda x:x[1])
nums = [0]*(N+1)
states = [None]*M

for p,y,i in citys:
    nums[p] += 1
    states[i] = [str(p), str(nums[p])]

for s in states:
    print(s[0].zfill(6)+s[1].zfill(6))

Buggy submission (verdict: Runtime Error):
N,M = map(int, input().split())
citys = [list(map(int,input().split()))+[i] for i in range(M)]

citys.sort(key = lambda x:x[1])
nums = [0]*(N+1)
states = [None]*(N+1)

for p,y,i in citys:
    nums[p] += 1
    states[i] = [str(p), str(nums[p])]

for s in states:
    print(s[0].zfill(6)+s[1].zfill(6))
Problem p03317 (python)

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

idx = As.index(min(As))
left = idx

n_l = (left + k - 2) // (k - 1)

right = n - ((n_l) * (k-1)) - 1

n_r = (right + k - 2) // (k - 1)

print(n_l + n_r)

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

idx = As.index(i)
left = idx
right = n - idx - 1

n_l = (left + k - 1) // (k - 1)
n_r = (right + k - 1) // (k - 1)

print(n_l + n_r)
Problem p02711 (python)

Fixed submission:
n = int(input())
first = n // 100
second = (n % 100) // 10
third = (n % 10)

if (first == 7 or second == 7 or third == 7):
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = input()
first = n // 100
second = (n % 100) // 10
third = (n % 10)

if (first == 7 or second == 7 or third == 7):
  print('YES')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n = input()
first = n // 100
second = (n % 100) // 10
third = (n % 10)

if (first == 7 || second == 7 || third == 7):
  print('YES')
else:
  print('No')
Problem p02712 (python)

Fixed submission:
n = int(input())
i = 1
result = 0
while (i <= n):
  if (i % 3 != 0 and i % 5 != 0):
    result += i
  i += 1
print(result)

Buggy submission (verdict: Runtime Error):
n = input()
i = 1
result = 0
while (i <= n):
  if (i % 3 != 0 and i % 5 != 0):
    result += i
  i += 1
print(result)

Buggy submission (verdict: Runtime Error):
n = input()
i = 1
result = 0
while (i <= n):
  if (i % 3 == 0 || i % 5 == 0):
    result += i
print(result)
Problem p02990 (python)

Fixed submission:
from scipy.misc import comb

def f2(n, k):
    return comb(n+k-1, k-1, exact=True)

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)


if __name__ == "__main__":
    N, K = map(int, input().split())

    blue = K
    red = N - K

    for i in range(1, K+1):
        blue = f(K, i)
        red = f2(N-K-(i-1), i+1)
        ans = blue * red
        print(int(ans % 1000000007))

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

def f2(n, k):
    return comb(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)


if __name__ == "__main__":
    N, K = map(int, input().split())

    blue = K
    red = N - K

    for i in range(1, K+1):
        blue = f(K, i)
        red = f2(N-K-(i-1), i+1)
        ans = blue * red
        print(int(ans % 1000000007))

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

def f2(n, k):
    return comb(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)


if __name__ == "__main__":
    N, K = map(int, input().split())

    blue = K
    red = N - K

    for i in range(1, K+1):
        blue = f(K, i)
        red = f2(N-K-(i-1), i+1)
        ans = blue * red
        print(int(ans % 1000000007))
Problem p03774 (python)

Fixed submission:
import math

INF = 1001001001

def resolve():
  n, m = map(int, input().split())
  s = []
  c = []

  for i in range(n):
    a, b = map(int, input().split())
    s.append([a, b])

  for i in range(m):
    a, b = map(int, input().split())
    c.append([a, b])

  for a in s:
    ans = 0
    dist = INF
    for i in range(m):
      if abs(a[0] - c[i][0]) + abs(a[1] - c[i][1]) < dist:
        dist = abs(a[0] - c[i][0]) + abs(a[1] - c[i][1])
        ans = i+1
    print(ans)
  return

if __name__ == "__main__":
  resolve()

Buggy submission (verdict: Runtime Error):
from a import resolve

import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 2
2 0
0 0
-1 0
1 0"""
        output = """2
1"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 4
10 10
-10 -10
3 3
1 2
2 3
3 5
3 5"""
        output = """3
1
2"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 5
-100000000 -100000000
-100000000 100000000
100000000 -100000000
100000000 100000000
0 0
0 0
100000000 100000000
100000000 -100000000
-100000000 100000000
-100000000 -100000000"""
        output = """5
4
3
2
1"""
        self.assertIO(input, output)

if __name__ == "__main__":
    unittest.main()