Buggy python submission (verdict: Time Limit Exceeded):
mod = 7+10**9

def expo(x):
  ans = 1
  n = mod-2
  while n>0:
    if n%2 == 1:
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1
  return ans

#def combi(n,k):
#  return ((fac[n]*(expo_fac[k])%mod)*expo_fac[n-k]%mod)

n,k = map(int,input().split())
fac = [1]+[0]*n
for i in range(1,n+1):
  fac[i] = fac[i-1]*i%mod

expo_fac = [expo(fac[i]) for i in range(n+1)]

ans = 0
for i in range(min(n,k+1)):
  ans = (ans + ((fac[n]*(expo_fac[i])%mod)*expo_fac[n-i]%mod)*((fac[n-1]*(expo_fac[i])%mod)*expo_fac[n-i-1]%mod)%mod)%mod
print(ans)

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

mod = 10**9 + 7
l = 10**7
fac = [1]*l
facr = [1]*l

for i in range(l-1):
    fac[i+1] = fac[i]*(i+1)%mod
facr[l-1] = pow(fac[l-1],mod - 2,mod)
for i in range(1,l)[::-1]:
    facr[i-1] = facr[i]*i%mod

def combi(N,K):
    return fac[N]*facr[N-K]%mod*facr[K]%mod

ans = 1
for i in range(1,min(n,k+1)):
    ans += combi(n,i)*combi(n-1,i)%mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 7+10**9

def expo(x):
  ans = 1
  n = mod-2
  while n>0:
    if n%2 == 1:
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1
  return ans

def combi(n,k):
  return (fac[n]*(expo_fac[k])%mod)*expo_fac[n-k]%mod

n,k = map(int,input().split())
fac = [1]+[0]*n
for i in range(1,n+1):
  fac[i] = fac[i-1]*i%mod

expo_fac = [expo(fac[i]) for i in range(n+1)]

ans = 0
for i in range(min(n,k+1)):
  ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
print(ans)

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

mod = 10**9 + 7
l = 10**7
fac = [1]*l
facr = [1]*l

for i in range(l-1):
    fac[i+1] = fac[i]*(i+1)%mod
facr[l-1] = pow(fac[l-1],mod - 2,mod)
for i in range(1,l)[::-1]:
    facr[i-1] = facr[i]*i%mod

def combi(N,K):
    return fac[N]*facr[N-K]%mod*facr[K]%mod

ans = 1
for i in range(1,min(n,k+1)):
    ans += combi(n,i)*combi(n-1,i)%mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 7+10**9

def expo(x):
  ans = 1
  n = mod-2
  while n>0:
    if n%2 == 1:
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1
  return ans

def combi(n,k):
  return (fac[n]*(expo(fac[k]))%mod)*expo(fac[n-k])%mod

n,k = map(int,input().split())
fac = [1]+[0]*n
for i in range(1,n+1):
  fac[i] = fac[i-1]*i%mod

ans = 0
for i in range(min(n,k+1)):
  ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
print(ans)

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

mod = 10**9 + 7
l = 10**7
fac = [1]*l
facr = [1]*l

for i in range(l-1):
    fac[i+1] = fac[i]*(i+1)%mod
facr[l-1] = pow(fac[l-1],mod - 2,mod)
for i in range(1,l)[::-1]:
    facr[i-1] = facr[i]*i%mod

def combi(N,K):
    return fac[N]*facr[N-K]%mod*facr[K]%mod

ans = 1
for i in range(1,min(n,k+1)):
    ans += combi(n,i)*combi(n-1,i)%mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Runtime Error):
mod = 7+10**9

def expo(x):
  ans = 1
  n = mod-2
  if memo_e[x]:
    return memo_e[x]
  while n>0:
    if n%2 == 1:
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1
  memo_e[x] = ans
  return ans

def combi(n,k):
  return (fac[n]*(expo(fac[k]))%mod)*expo(fac[n-k])%mod

n,k = map(int,input().split())
fac = [1]+[0]*n
for i in range(1,n+1):
  fac[i] = fac[i-1]%mod

memo_e = [0]*(n**n+1)
ans = 0
for i in range(min(n,k+1)):
  ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
print(ans)

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

mod = 10**9 + 7
l = 10**7
fac = [1]*l
facr = [1]*l

for i in range(l-1):
    fac[i+1] = fac[i]*(i+1)%mod
facr[l-1] = pow(fac[l-1],mod - 2,mod)
for i in range(1,l)[::-1]:
    facr[i-1] = facr[i]*i%mod

def combi(N,K):
    return fac[N]*facr[N-K]%mod*facr[K]%mod

ans = 1
for i in range(1,min(n,k+1)):
    ans += combi(n,i)*combi(n-1,i)%mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

mod = 7+10**9

def expo(x,n):
  ans = 1
  while n>0:
    if n%2 == 1:
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1
  return ans

def fac(n):
  if not memo_f[n]:
    memo_f[n] = (n*fac(n-1))%mod
  return memo_f[n]

def combi(n,k):
  return (((fac(n)*(expo(fac(k),mod-2)))%mod)*expo(fac(n-k),mod-2))%mod


n,k = map(int,input().split())
memo_f = [1]+[0]*n

if k == 1:
  ans = combi(n-1,k)*combi(n,k)%mod
elif k >= n:
  ans = 0
  for i in range(n):
    ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
else:
  ans = 0
  for i in range(k+1):
    ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
print(ans)

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

mod = 10**9 + 7
l = 10**7
fac = [1]*l
facr = [1]*l

for i in range(l-1):
    fac[i+1] = fac[i]*(i+1)%mod
facr[l-1] = pow(fac[l-1],mod - 2,mod)
for i in range(1,l)[::-1]:
    facr[i-1] = facr[i]*i%mod

def combi(N,K):
    return fac[N]*facr[N-K]%mod*facr[K]%mod

ans = 1
for i in range(1,min(n,k+1)):
    ans += combi(n,i)*combi(n-1,i)%mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Runtime Error):
mod = 7+10**9

def expo(x,n):
  ans = 1
  while n>0:
    if n%2 == 1:
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1
  return ans

def fac(n):
  if not memo_f[n]:
    memo_f[n] = (n*fac(n-1))%mod
  return memo_f[n]

def combi(n,k):
  return (((fac(n)*(expo(fac(k),mod-2)))%mod)*expo(fac(n-k),mod-2))%mod


n,k = map(int,input().split())
memo_f = [1]+[0]*n

if k == 1:
  ans = combi(n-1,k)*combi(n,k)%mod
elif k >= n:
  ans = 0
  for i in range(n):
    ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
else:
  ans = 0
  for i in range(k+1):
    ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
print(ans)

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

mod = 10**9 + 7
l = 10**7
fac = [1]*l
facr = [1]*l

for i in range(l-1):
    fac[i+1] = fac[i]*(i+1)%mod
facr[l-1] = pow(fac[l-1],mod - 2,mod)
for i in range(1,l)[::-1]:
    facr[i-1] = facr[i]*i%mod

def combi(N,K):
    return fac[N]*facr[N-K]%mod*facr[K]%mod

ans = 1
for i in range(1,min(n,k+1)):
    ans += combi(n,i)*combi(n-1,i)%mod
    ans %= mod
print(ans)

Buggy python submission (verdict: Runtime Error):
mod = 7+10**9

def expo(x,n):
  ans = 1
  if x%2 == 1:
    ans = ans*x
  x = x*x
  n = n >> 1
  return ans

def fac(n):
  if not memo_f[n]:
    return (n*fac(n-1))%mod
  else:
    return memo_f[n]

def combi(n,k):
  return (((fac(n)*(expo(fac(k),mod-2)))%mod)*expo(fac(n-k)))%mod


n,k = map(int,input().split())
memo_f = [1]+[0]*n

if k == 1:
  ans = combi(n-1,k)*combi(n,k)%mod
elif k >= n:
  ans = 0
  for i in range(n):
    ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
else:
  ans = 0
  for i in range(k+1):
    ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
print(ans)

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

mod = 10**9 + 7
l = 10**7
fac = [1]*l
facr = [1]*l

for i in range(l-1):
    fac[i+1] = fac[i]*(i+1)%mod
facr[l-1] = pow(fac[l-1],mod - 2,mod)
for i in range(1,l)[::-1]:
    facr[i-1] = facr[i]*i%mod

def combi(N,K):
    return fac[N]*facr[N-K]%mod*facr[K]%mod

ans = 1
for i in range(1,min(n,k+1)):
    ans += combi(n,i)*combi(n-1,i)%mod
    ans %= mod
print(ans)