Problem p02990 (python)

Fixed submission:
from math import factorial
import sys

sys.setrecursionlimit(2000)
mod = 10**9+7
n, k = map(int, input().split())

memo = {}
def combination(n,k):
  if n < k:
    return 0
  return factorial(n)//factorial(k)//factorial(n-k)
  if n / 2 < k:
    k = n - k
  if n in memo and k in memo[n]:
    return memo[n][k]
  v = 0
  if k == 0:
    v = 1
  elif k == 1:
    v = n
  else:
    v = combination(n-1,k) + combination(n-1,k-1)
  return memo.setdefault(n, {}).setdefault(k, v)

for i in range(1, k + 1):
  print(combination(n-k+1,i)*combination(k-1,i-1)%mod)

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

sys.setrecursionlimit(2000)
mod = 10**9+7
n, k = map(int, input().split())

memo = {}
def combination(n,k):
  return factorial(n)//factorial(k)//factorial(n-k)
  if n < k:
    return 0
  if n / 2 < k:
    k = n - k
  if n in memo and k in memo[n]:
    return memo[n][k]
  v = 0
  if k == 0:
    v = 1
  elif k == 1:
    v = n
  else:
    v = combination(n-1,k) + combination(n-1,k-1)
  return memo.setdefault(n, {}).setdefault(k, v)

for i in range(1, k + 1):
  print(combination(n-k+1,i)*combination(k-1,i-1)%mod)

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

sys.setrecursionlimit(2000)
n, k = map(int, input().split())

memo = {}
def combination(n,k):
  if n / 2 < k:
    k = n - k
  if (n,k) in memo:
    return memo[(n,k)]
  elif n < k:
    return memo.setdefault((n,k), 0)
  elif k == 0:
    return memo.setdefault((n,k), 1)
  elif k == 1:
    return memo.setdefault((n,k), n)
  else:
  	return memo.setdefault((n,k), combination(n-1,k) + combination(n-1,k-1))

for i in range(1, k + 1):
  print(combination(n-k+1,i)*combination(k-1,i-1)%(10**9+7))

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

sys.setrecursionlimit(2000)
n, k = map(int, input().split())

memo = {}
def combination(n,k):
  if (n,k) in memo:
    return memo[(n,k)]
  elif n < k:
    return memo.setdefault((n,k), 0)
  elif k == 0:
    return memo.setdefault((n,k), 1)
  elif k == 1:
    return memo.setdefault((n,k), n)
  else:
  	return memo.setdefault((n,k), combination(n-1,k) + combination(n-1,k-1))

for i in range(1, k + 1):
  print(combination(n-k+1,i)*combination(k-1,i-1)%(10**9+7))

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

memo = {}
def combination(n,k):
  return memo.setdefault((n,k), factorial(n)//factorial(k)//factorial(n-k))

n, k = map(int, input().split())
for i in range(1, k + 1):
  print(combination(n-k+1,i)*combination(k-1,i-1)%(10**9+7))

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

memo = {}
def combination(n,k):
  return memo.setdefault((n,k), int(factorial(n)/(factorial(k)*factorial(n-k))))

n, k = map(int, input().split())
for i in range(1, k + 1):
  print((combination(n-k+1,i)*combination(k-1,i-1))%(10**9+7))

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

memo = {}
def combination(n,k):
  return memo.setdefault((n,k), int(factorial(n)/(factorial(k)*factorial(n-k))))

n, k = map(int, input().split())
for i in range(1, k + 1):
  print(combination(n-k+1,i)*combination(k-1,i-1)%(10**9+7))