Problem p02990 (python)

Fixed submission:
from math import factorial

def cmb(n,k):
    if n < k or n < 0 or k < 0:
        return 0
    return factorial(n)//(factorial(k)*factorial(n-k))

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

for i in range(1, K+1):
    ans = cmb(K-1, i-1) * cmb(N-K+1, i)
    print(ans%(10**9+7))

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

def cmb(n,k):
    if n < k or n < 0 or k < 0:
        return 0
    return int(factorial(n)/(factorial(k)*factorial(n-k)))

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

for i in range(1, K+1):
    ans = cmb(K-1, i-1) * cmb(N-K+1, i)
    print(ans%(10**9+7))

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

def cmb(n,r):
    if n == 0 or r == 0:
        return 1 
    if n < r or r < 0:
        return 0
    return int(factorial(n)/(factorial(r)*factorial(n-r)))

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

blue = K
red = N-K

for i in range(1, blue+1):
    ans = cmb(blue-1, i-1) * cmb(red+1, i)
    print(ans%(10**9+7))

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

def cmb(n,r):
    if n == 0 or r == 0:
        return 1 
    return int(factorial(n)/(factorial(r)*factorial(n-r)))

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

blue = K
red = N-K

for i in range(1, blue+1):
    if blue-1 < i-1:
        print(0)
    else:
        ans = cmb(blue-1, i-1) * cmb(red+1, i)
        print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    if n == 0 or r == 0:
        return 1 
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

blue = K
red = N-K

for i in range(1, blue+1):
    if blue-1 < i-1:
        print(0)
    else:
        ans = cmb(blue-1, i-1) * cmb(red+1, i)
        print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

blue = K
red = N-K

for i in range(1, blue+1):
    if red == 0:
        print(1)
    else:
        ans = cmb(blue-1, i-1) * cmb(red+1, i)
        print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

blue = K
red = N-K

for i in range(1, blue+1):
    ans = cmb(blue-1, i-1) * cmb(red+1, i)
    print(ans%(10**9+7))

Buggy submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


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

blue = K
red = N-K

n = red+1

ans = []
for i in range(1, blue+1):
    if i == 1 or i == blue:
        ans.append(cmb(n, i))
    else:
        tmp = 1
        tmpn = n
        for j in reversed(range(1, i+1)):
            tmp *= cmb(tmpn, 1)
            tmpn -= 1
        ans.append(tmp)

for s in ans:
    print(s%(10**9+7))