Problem p02990 (python)

Fixed submission:
n,k=map(int,input().split())
dp=[[0 for i in range(k+1)] for j in range(n+1)]
for i in range(n+1):
  dp[i][0]=1
dp[1][1]=1
for i in range(2,n+1):
  for j in range(1,k+1):
    dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
dp=[[0 for i in range(k+1)] for j in range(n+1)]
a=n-r
if r>=a:
  r=a
for i in range(n+1):
  dp[i][0]=1
dp[1][1]=1
for i in range(2,n+1):
  for j in range(1,k+1):
    dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
flag=0
dp=[[0 for i in range(k+1)] for j in range(n+1)]
if k==0 or n==k:
  dp[n][k]==1
  flag=1
if flag==0 and (k==1 or k==n-1):
  dp[n][k]==n
if flag==0:
  a=n-r
  if r>=a:
    r=a
  for i in range(n+1):
    dp[i][0]=1
  dp[1][1]=1
  for i in range(2,n+1):
    for j in range(1,k+1):
      dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
dp=[[0 for i in range(k+1)] for j in range(n+1)]
if k==0 or n==k:
  dp[n][k]==1
if k==1 or k==n-1:
  dp[n][k]==n
a=n-r
if r>=a:
  r=a
for i in range(n+1):
  dp[i][0]=1
dp[1][1]=1
for i in range(2,n+1):
  for j in range(1,k+1):
    dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
dp=[[0 for i in range(k+1)] for j in range(n+1)]
if k==0 or n==k:
  dp[n][k]==1
if k==1 or k==n-1:
  dp[n][k]==n
a=n-r
if r>=a:
  r=a
for i in range(n+1):
  dp[i][0]=1
dp[1][1]=1
for i in range(2,n+1):
  for j in range(1,k+1):
    dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
dp=[[0 for i in range(k+1)] for j in range(n+1)]
if k==0 or n==k:
  dp[n][k]==1
if k==1 or k==n-1:
  dp[n][k]==n
a=n-r
if r>=a:
  r=a
for i in range(n+1):
  dp[i][0]=1
dp[1][1]=1
for i in range(2,n+1):
  for j in range(1,k+1):
    dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
for i in range(1,k+1):
  ans=dp[n-k+1][i]*dp[k-1][i-1]
  while ans>10**9+7:
    ans%=10**9+7
  print(ans)

Buggy submission (verdict: Runtime Error):
def ncr(n,r):
  if r==0 or n==r:
    return 1
  if r==1 or r==n-1:
    return n
  if r>=n-r:
    r=n-r
  dp=[[0 for i in range(r+1)] for j in range(n+1)]
  for i in range(n+1):
    dp[i][0]=1
  dp[1][1]=1
  for i in range(2,n+1):
    for j in range(1,r+1):
      dp[i][j]=dp[i-1][j-1]+dp[i-1][j]
  return dp[n][r]

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

Buggy submission (verdict: Runtime Error):
from math import factorial
n,k=map(int,input().split())
INF=1000000007
for i in range(1,k+1):
  ans=int(factorial(n-k+1)//factorial(i)//factorial(n-k+1-i)*factorial(k-1)//factorial(k-i)//factorial(i-1))
  while ans>INF:
    ans=ans%INF
  print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n,k=map(int,input().split())
INF=1000000007
for i in range(1,k+1):
  ans=int(comb(n-k+1,i,exact=True)*comb(k-1,i-1,exact=True))
  while ans>INF:
    ans=ans%INF
  print(ans)