Buggy python submission (verdict: Runtime Error):

from scipy.misc import comb
# a = comb(n, r)
#a = comb(n, r, exact=True)

N,K= map(int,input().split())
mod = 10**9+7
#def comb(n, k):
#    m = 1
#    if n< k:
#        m= 0
#    if n < 2 * k:
#        k = n - k
#    for i in range(1, k + 1):
#        m = m * (n - i + 1) / i  %mod  
#    return int(m)
#print(comb(1,2))
R = N-K


for i in range(1,K+1):
    # blue
#    if i == 1:
#        b_div = 2
#    else:
#    print(R,i)
    b_div = comb(K-1,i-1)%mod
    # RED
#    if (R+1)<i:
#        print('0')
#    else:
    r_div = comb(R+1,i)%mod
#        if i == K+1:
#            r_div += comb(R+1,i+1)%mod
        
#        print(b_div,r_div)
    print(int(b_div*r_div)%mod)

Fixed submission:



N,K= map(int,input().split())
mod = 10**9+7
def comb(n,k):
  """power_funcを用いて(nCk) mod p を求める"""
  p = 10**9+7
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
R = N-K


for i in range(1,K+1):
    # blue
#    if i == 1:
#        b_div = 2
#    else:
#    print(R,i)
    b_div = comb(K-1,i-1)%mod
    # RED
#    if (R+1)<i:
#        print('0')
#    else:
    r_div = comb(R+1,i)%mod
#        if i == K+1:
#            r_div += comb(R+1,i+1)%mod
        
#        print(b_div,r_div)
    print(int(b_div*r_div)%mod)

Buggy python submission (verdict: Runtime Error):

from scipy.special import comb
# a = comb(n, r)
#a = comb(n, r, exact=True)

N,K= map(int,input().split())
mod = 10**9+7
#def comb(n, k):
#    m = 1
#    if n< k:
#        m= 0
#    if n < 2 * k:
#        k = n - k
#    for i in range(1, k + 1):
#        m = m * (n - i + 1) / i  %mod  
#    return int(m)
#print(comb(1,2))
R = N-K


for i in range(1,K+1):
    # blue
#    if i == 1:
#        b_div = 2
#    else:
#    print(R,i)
    b_div = comb(K-1,i-1)%mod
    # RED
#    if (R+1)<i:
#        print('0')
#    else:
    r_div = comb(R+1,i)%mod
#        if i == K+1:
#            r_div += comb(R+1,i+1)%mod
        
#        print(b_div,r_div)
    print(int(b_div*r_div)%mod)

Fixed submission:



N,K= map(int,input().split())
mod = 10**9+7
def comb(n,k):
  """power_funcを用いて(nCk) mod p を求める"""
  p = 10**9+7
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
R = N-K


for i in range(1,K+1):
    # blue
#    if i == 1:
#        b_div = 2
#    else:
#    print(R,i)
    b_div = comb(K-1,i-1)%mod
    # RED
#    if (R+1)<i:
#        print('0')
#    else:
    r_div = comb(R+1,i)%mod
#        if i == K+1:
#            r_div += comb(R+1,i+1)%mod
        
#        print(b_div,r_div)
    print(int(b_div*r_div)%mod)

Buggy python submission (verdict: Runtime Error):


N,K= map(int,input().split())
mod = 10**9+7
def comb(n, k):
    m = 1
    if n < 2 * k:
        k = n - k
    for i in range(1, k + 1):
        m = m * (n - i + 1) / i    
    return int(m)

R = N-K

for i in range(1,K+1):
    # blue
#    if i == 1:
#        b_div = 2
#    else:
    b_div = comb(K-1,i-1)%mod
    # RED
    r_div = comb(R+1,i)%mod
    if i == K+1:
        r_div += comb(R+1,i+1)%mod
    
#    print(b_div,r_div)
    print((b_div*r_div)%mod)

Fixed submission:



N,K= map(int,input().split())
mod = 10**9+7
def comb(n,k):
  """power_funcを用いて(nCk) mod p を求める"""
  p = 10**9+7
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
R = N-K


for i in range(1,K+1):
    # blue
#    if i == 1:
#        b_div = 2
#    else:
#    print(R,i)
    b_div = comb(K-1,i-1)%mod
    # RED
#    if (R+1)<i:
#        print('0')
#    else:
    r_div = comb(R+1,i)%mod
#        if i == K+1:
#            r_div += comb(R+1,i+1)%mod
        
#        print(b_div,r_div)
    print(int(b_div*r_div)%mod)