Problem p02768 (python)

Fixed submission:
def pow(a,b,c):
    ans = 1
    while b > 0:
        if b & 1:
            ans = ans*a % c
        a = a*a % c
        b = b >> 1
    return ans
def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(n-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num*pow(den,c-2,c) % c
mod = 10**9+7
n,a,b = map(int,input().split())
ans  = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod
if ans < 0:
    ans = ans + mod
print(ans)

Buggy submission (verdict: Runtime Error):
def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(n-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num*pow(den,-1,c) % c
mod = 10**9+7
n,a,b = map(int,input().split())
ans  = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod
if ans < 0:
    ans = ans + mod
print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
      return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
ans = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod 
if ans < 0:
  ans += mod
print(ans)

Buggy submission (verdict: Runtime Error):

from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
      return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
ans = pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod 
if ans < 0:
  ans += mod
  print(ans)

Buggy submission (verdict: Runtime Error):
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
      return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
print(pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1)

Buggy submission (verdict: Runtime Error):
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
print(pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1)

Buggy submission (verdict: Runtime Error):
# sys.setrecursionlimit(100000)
n,a,b = map(int,input().split())
mod = 10**9+7
count = 0
def cmb(n,r):
  if n == 0 or n == r: return 1
  if r == 1: return n
  return cmb(n-1,r) + cmb (n-1,r-1)
for i in range(1,n+1):
  if i != a and i != b:
    count += cmb(n,i)
print(count % mod)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
mod = 10**9+7
count = 0
def cmb(n,r):
  if n == 0 or n == r: return 1
  if r == 1: return n
  return cmb(n-1,r) + cmb (n-1,r-1)
for i in range(1,n+1):
  if i != a and i != b:
    count += cmb(n,i)
print(count % mod)