qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n,a,b = map(int,input().split())

mod = 10**9 + 7

def comb_mod(n, r, mod):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fac.append(fac[-1] * i % mod)
            inv.append(-inv[mod % i] * (mod // i) % mod)
            finv.append((finv[-1] * inv[-1]) % mod)
        return int(fac[n] * finv[r] * finv[n - r] % mod)

m = pow(2,n,mod) - 1

import math
def perm(n,r):
    return (math.factorial(n)//math.factorial(n-r))

s = perm(n,a) * pow(math.factorial(a),mod-2,mod)
# print(s)

t = perm(n,b) * pow(math.factorial(b),mod-2,mod)
# print(t)

ans = m - s - t

print(ans%mod)

Fixed code:
n,a,b = map(int,input().split())

mod = 10**9 + 7

def comb(n,k,mod):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%mod
    for i in range(2,k+1):
        inv[i]=mod-inv[mod%i]*(mod//i)%mod
        ans=ans*(n-k+i)*inv[i]%mod
    return ans

def comb_mod(n, r, mod):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fac.append(fac[-1] * i % mod)
            inv.append(-inv[mod % i] * (mod // i) % mod)
            finv.append((finv[-1] * inv[-1]) % mod)
        return int(fac[n] * finv[r] * finv[n - r] % mod)

m = pow(2,n,mod) - 1

import math
def perm(n,r):
    return (math.factorial(n)//math.factorial(n-r))

s = comb(n,a,mod)
# print(s)

t = comb(n,b,mod)
# print(t)

ans = m - s - t

print(ans%mod)
Buggy code:
n, a, b = map(int,input().split())
mod = 10**9+7
total = pow(2, n, mod) - 1
print(total)
def c(n, r):
    p, q = 1, 1
    for i in range(r):
        p *= (n-i)%mod
        q *= (i+1)%mod
    return p * pow(q, mod-2, mod)%mod

print((total - c(n, a) - c(n, b))%mod)

Fixed code:
n, a, b = map(int,input().split())
mod = 10**9+7
total = pow(2, n, mod) - 1
def c(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q, mod-2, mod)%mod

print((total - c(n, a) - c(n, b))%mod)
Buggy code:
n, a, b = map(int,input().split())
mod = 10 ** 9 + 7

def permutation(n,r):
    perm = 1
    for integer in range(n-r+1, n+1):
        perm *= integer
    return perm

def RepeatSquaring(x, n, m):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = (ans*x)%m
    x = (x*x)%m
    n = n >> 1
  return ans

def cmb(n, r, mod):
    nume = permutation(n,r)
    deno = permutation(r,r)
    return (nume * RepeatSquaring(deno, mod-2, mod)) % mod

ans = RepeatSquaring(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)

print(ans)

Fixed code:
n, a, b = map(int,input().split())
mod = 10 ** 9 + 7

def permutation(n,r,mod):
    perm = 1
    for integer in range(n-r+1, n+1):
        perm *= integer
        perm %= mod
    return perm

def RepeatSquaring(x, n, m):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = (ans*x)%m
    x = (x*x)%m
    n = n >> 1
  return ans

def cmb(n, r, mod):
    nume = permutation(n,r,mod)
    deno = permutation(r,r,mod)
    return (nume * RepeatSquaring(deno, mod-2, mod)) % mod

ans = (RepeatSquaring(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)) % mod

print(ans)
Buggy code:
n,a,b = map(int,input().split())
def cmb(n, r, mod):
    x = 1 
    y = 1
    for i in range(r):
        x = x*(n-i)%(mod)
    for i in range(1,r+1):
        y = y*i%(mod)
    return x * pow(y,mod-2,mod) %mod

v = int(pow(2,n,10**9+7)-1-cmb(n,a,10**9+7)-cmb(n,b,10**9+7))
print(v)

Fixed code:
mod = 10**9+7
n,a,b = map(int, input().split())
r = pow(2, n, mod) - 1

def cmb(n,k):
    x,y = 1,1
    for i in range(k):
        x = x * (n-i) % mod
        y = y * (k-i) % mod
    return x * pow(y, mod-2, mod) % mod

ans = r - cmb(n,a) - cmb(n,b)
ans = ans % mod
print(ans)
Buggy code:
n,a,b = map(int,input().split())
mod = 10**9+7
def combination(N,K):
    bunsi = 1
    bunbo = 1
    for i in range(K):
        bunsi = bunsi*(N-i)%mod
        bunbo = bunbo*(i+1)%mod
    return bunsi*pow(bunbo,mod-2,mod)%mod
all_num = (2**n-1)%mod
ans = all_num-combination(n,a)-combination(n,b)
print(ans%mod)

Fixed code:
n,a,b = map(int,input().split())
mod = 10**9+7
def combination(N,K):
    bunsi = 1
    bunbo = 1
    for i in range(K):
        bunsi = bunsi*(N-i)%mod
        bunbo = bunbo*(i+1)%mod
    return bunsi*pow(bunbo,mod-2,mod)%mod
all_num = pow(2,n,mod)-1
ans = all_num-combination(n,a)-combination(n,b)
print(ans%mod)
Buggy code:
n, a, b = list(map(int, input().split()))

p = 10**9 + 7

def pow_mod(n, m, p):
  if m == 0:
    return 1
  elif m % 2 == 0:
    nm2p = pow_mod(n, m//2, p)
    return (nm2p * nm2p) % p
  elif m % 2 == 1:
    return (pow_mod(n, m-1, p) * (n % p)) % p

tot = 2 ** n - 1

def compute_ncr_mod(n, r, p):
  n_factorial = 1
  for i in range(n, n-r, -1):
    n_factorial *= i
  r_factorial = 1
  for i in range(r, 0, -1):
    r_factorial *= i
  ncr_modp = ((n_factorial % p) * pow_mod(r_factorial, p-2, p)) % p
  return ncr_modp

print(tot - compute_ncr_mod(n, a, p) - compute_ncr_mod(n, a, b))

Fixed code:
import math

n, a, b = list(map(int, input().split()))

p = 10**9 + 7

def pow_mod(n, m, p):
  if m == 0:
    return 1
  elif m % 2 == 0:
    nm2p = pow_mod(n, m//2, p)
    return (nm2p * nm2p) % p
  elif m % 2 == 1:
    return (pow_mod(n, m-1, p) * (n % p)) % p

def compute_ncr_mod(n, r, p):
  r = min(n-r, r)
  n_factorial = 1
  r_factorial = 1
  for i in range(1, r+1):
    n_factorial *= n-i+1
    n_factorial %= p
    r_factorial *= i
    r_factorial %= p
  ncr_modp = (n_factorial * pow_mod(r_factorial, p-2, p)) % p
  return ncr_modp

print((pow_mod(2, n, p) - 1 - compute_ncr_mod(n, a, p) - compute_ncr_mod(n, b, p)) % p)
Buggy code:
import math


n,a,b=map(int,input().split())
mod=10**9+7

c1=1
c2=1

for i in range(n-a+1,n+1):
    c1*=i
    c1%=mod
for j in range(1,a+1):
    c1*=pow(j,mod-2,mod)
    c1%=mod
    
for i in range(n-b+1,n+1):
    c2*=i
    c2%=mod
for j in range(1,b+1):
    c2*=pow(j,mod-2,mod)
    c2%=mod

ans=pow(2,n,mod)-1
print(ans-c1-c2)


Fixed code:
import math


n,a,b=map(int,input().split())
mod=10**9+7

c1=1
c2=1

for i in range(n-a+1,n+1):
    c1*=i
    c1%=mod
for j in range(1,a+1):
    c1*=pow(j,mod-2,mod)
    c1%=mod
    
for i in range(n-b+1,n+1):
    c2*=i
    c2%=mod
for j in range(1,b+1):
    c2*=pow(j,mod-2,mod)
    c2%=mod

ans=pow(2,n,mod)-1

print((ans-c1-c2)%mod)
Buggy code:
#input
n, a, b = map(int, input().split())

#output
mod = pow(10, 9) + 7

def cmb(n, r):
    res = 1
    fac = 1
    for i in range(r):
        res *= (n-i) % mod
        fac *= (i+1) % mod
    return res*pow(fac, mod-2, mod) % mod

answer = (pow(2, n, mod) - 1 - cmb(n, a) - cmb(n, b)) % mod
print(answer)

Fixed code:
#input
n, a, b = map(int, input().split())

#output
mod = pow(10, 9) + 7

def cmb(n, r):
    res = 1
    fac = 1
    for i in range(r):
        res *= (n-i)
        res %= mod
        fac *= (i+1)
        fac %= mod
    return res*pow(fac, mod-2, mod) % mod

answer = pow(2, n, mod) - 1 - cmb(n, a) - cmb(n, b)
print(answer % mod)
Buggy code:
LARGE = 10 ** 9 + 7


def solve(n, a, b):

    pow_ab = [1] * (b + 1)
    for i in range(b):
        pow_ab[i + 1] = pow_ab[i] * (i + 1)
    pow_ab_inv = [1] * (b + 1)
    pow_ab_inv[-1] = pow(pow_ab[-1], LARGE - 2, LARGE)
    for i in range(b - 1, 0, -1):
        pow_ab_inv[i] = pow_ab_inv[i + 1] * (i + 1) % LARGE

    res_all = pow(2, n, LARGE) - 1
    res_ab = 1
    for i in range(a):
        res_ab *= (n - i)
    res_all -= res_ab * pow_ab_inv[a]
    for i in range(a, b):
        res_ab *= (n - i)
    res_all -= res_ab * pow_ab_inv[b]
    return res_all % LARGE


def main():
    n, a, b = map(int, input().split())
    res = solve(n, a, b)
    print(res)


def test():
    assert solve(4, 1, 3) == 7
    assert solve(1000000000, 141421, 173205) == 34076506


if __name__ == "__main__":
    test()
    main()


Fixed code:
LARGE = 10 ** 9 + 7


def solve(n, a, b):

    pow_ab = [1] * (b + 1)
    for i in range(b):
        pow_ab[i + 1] = pow_ab[i] * (i + 1) % LARGE
    pow_ab_inv = [1] * (b + 1)
    pow_ab_inv[-1] = pow(pow_ab[-1], LARGE - 2, LARGE)
    for i in range(b - 1, 0, -1):
        pow_ab_inv[i] = pow_ab_inv[i + 1] * (i + 1) % LARGE

    res_all = pow(2, n, LARGE) - 1
    res_ab = 1
    for i in range(a):
        res_ab *= (n - i)
        res_ab %= LARGE
    res_all -= res_ab * pow_ab_inv[a]
    for i in range(a, b):
        res_ab *= (n - i)
        res_ab %= LARGE
    res_all -= res_ab * pow_ab_inv[b]
    return res_all % LARGE


def main():
    n, a, b = map(int, input().split())
    res = solve(n, a, b)
    print(res)


def test():
    assert solve(4, 1, 3) == 7
    assert solve(1000000000, 141421, 173205) == 34076506


if __name__ == "__main__":
    test()
    main()
Buggy code:
import sys

def comb(n, r, revfact, mod):
    ans = 1
    if r > n // 2: r = n - r
    for i in range(r):
        ans *= (n - i)
        ans %= mod
        ans *= revfact[i + 1]
        ans %= mod
    return ans

def solve():
    input = sys.stdin.readline
    n, a, b = map(int, input().split())
    mod = 7 + 10 ** 9
    total = (pow(2, n, mod) - 1) % mod
    fact = [1] * (b + 2)
    revfact = [1] * (b + 2)
    for i in range(1, b + 2):
        fact[i] = (i * fact[i-1]) % mod
    revfact[b + 1] = pow(fact[b + 1], mod - 2, mod)
    for i in reversed(range(1, b + 1)):
        revfact[i] = ((i + 1) * revfact[i + 1]) % mod

    print((total - comb(n, a, revfact, mod) - comb(n, b, revfact, mod)) % mod)


    return 0

if __name__ == "__main__":
    solve()

Fixed code:
import sys

def comb(n, r, revfact, mod):
    ans = 1
    for i in range(r):
        ans *= (n - i)
        ans %= mod
        ans *= revfact[i + 1]
        ans %= mod
    return ans

def solve():
    input = sys.stdin.readline
    n, a, b = map(int, input().split())
    mod = 7 + 10 ** 9
    total = (pow(2, n, mod) - 1) % mod
    rev = [1] * (b + 2)
    for i in range(1, b + 2):
        rev[i] = pow(i, mod - 2, mod)

    print((total - comb(n, a, rev, mod) - comb(n, b, rev, mod)) % mod)


    return 0

if __name__ == "__main__":
    solve()
Buggy code:
N, A, B = map(int, input().split())

MOD = 10 ** 9 + 7

def comb(n, k, mod):
    a = b = 1
    for i in range(1,k+1):
        b *= i
        b %= mod
        a *= n
        a %= mod
        n -= 1
    return a/b//1

ret = pow(2, N, MOD) - 1 - comb(N,A,MOD) - comb(N,B,MOD)
ret %= MOD
if ret < 0:
    ret += MOD
print(ret)


Fixed code:
N, A, B = map(int, input().split())
MOD = 10 ** 9 + 7

def calc_inv(n, k, mod):
    a = 1
    b = 1
    for i in range(1,k+1):
        a *= i
        a %= mod
        b *= n
        n -= 1
        b %= mod
    return b * pow(a, mod-2, mod) % mod

ret = pow(2, N, MOD) - 1 - calc_inv(N,A,MOD) - calc_inv(N,B,MOD)
ret %= MOD
if ret < 0:
    ret += MOD
print(int(ret))
Buggy code:
def cmb(n, k, mod):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % mod

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % mod

    return (numerator * pow(denominator, mod-2, mod)) % mod


def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x


n, a, b = map(int, input().split())
mod = 10**9 + 7
print((pow_k(2, n) % mod - cmb(n, a, mod) - cmb(n, b, mod) - 1) % mod)


Fixed code:
def cmb(n, k, mod):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % mod

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % mod

    return (numerator * pow(denominator, mod-2, mod)) % mod


def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x


def myPow(x, n, m):
    if(n == 0):
        return 1
    if(n % 2 == 0):
        return myPow(x * x % m, n / 2, m)
    else:
        return x * myPow(x, n - 1, m) % m


n, a, b = map(int, input().split())
mod = 10**9 + 7
print((myPow(2, n, mod) - cmb(n, a, mod) - cmb(n, b, mod) - 1) % mod)
Buggy code:
import math
import sys
sys.setrecursionlimit(int(10**9))

mod = 10**9 + 7

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y/2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def fact(n):
    if n == 1: 
        return 1
    else:
        return (fact(n-1)*n)%mod

def comb(n, k):
    ans = 1
    for i in range(k):
        ans = (ans * (n-i)//(i+1)) % mod
    return ans % mod

n, a, b = map(int, input().split())

ans = power(2, n)%mod - comb(n,a) - comb(n,b) - 1
print(ans % mod)

Fixed code:
import math
import sys
sys.setrecursionlimit(int(10**9))

mod = 10**9 + 7

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y/2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def fact(n):
    if n == 1: 
        return 1
    else:
        return (fact(n-1)*n)%mod

def comb(n, k):
    ans = 1
    for i in range(k):
        ans *= (n-i)
        ans //= i+1
    return ans % mod

n, a, b = map(int, input().split())
now = 1
for i in range(a):
    now = (now*(n-i))%mod
cnka = (now * power(math.factorial(a),mod-2) )% mod
for i in range(a,b):
    now = (now*(n-i))%mod
cnkb = (now * power(math.factorial(b),mod-2) )% mod

ans = power(2, n)%mod - cnka - cnkb - 1
print(ans % mod)
Buggy code:
import sys,collections,math
input = sys.stdin.readline

n,a,b = list(map(int,input().split()))
m = 10**9+7
ans = pow(2,n,m)


la  = 1
laa = 1
for i in range(n,n-a,-1):
    la = la*i
for i in range(1,a+1):
    laa = laa*i

lb  = 1
lbb = 1
for i in range(n,n-b,-1):
    lb = lb*i
for i in range(1,b+1):
    lbb = lbb*i

la = (la*pow(laa,10**9+5,m))%m
lb = (lb*pow(lbb,10**9+5,m))%m

print((ans-la-lb-1)%m)


Fixed code:
import sys,collections,math
input = sys.stdin.readline

n,a,b = list(map(int,input().split()))
m = 10**9+7
ans = pow(2,n,m)


la  = 1
laa = 1
for i in range(n,n-a,-1):
    la = (la*i)%m
for i in range(1,a+1):
    laa = (laa*i)%m

lb  = 1
lbb = 1
for i in range(n,n-b,-1):
    lb = (lb*i)%m
for i in range(1,b+1):
    lbb = (lbb*i)%m

la = (la*pow(laa,10**9+5,m))%m
lb = (lb*pow(lbb,10**9+5,m))%m

print((ans-la-lb-1)%m)
Buggy code:
m=10**9+7
n,a,b=map(int,input().split())

def comb(n,r,m):
    x,y=1,1
    for i in range(r):
        x*=n-1
        y*=n+1
        x%=m
        y%=m
    return int(x * pow(y, m-2, m))
ans = pow(2, n, m)-comb(n, a, m) - comb(n, b, m)
print(ans%m)

Fixed code:
m=10**9+7
n,a,b=map(int,input().split())

def comb(n,r,m):
    x,y=1,1
    for i in range(r):
        x*=n-i
        y*=i+1
        x%=m
        y%=m
    return int(x * pow(y, m-2, m))
ans = pow(2, n, m)-1-comb(n, a, m) - comb(n, b, m)
print(ans%m)
Buggy code:
import math

MOD = 10 ** 9 + 7


def cmb(n, r):
    total = 1
    for i in range(r):
        total *= (n - i) % MOD
    return total * pow(math.factorial(r), MOD - 2, MOD) % MOD


def calc(n, r):
    ret = 1
    for i in range(r):
        ret = ret * (n - i) % MOD
    return ret * pow(factorial(r), MOD - 2, MOD) % MOD


if __name__ == '__main__':
    n, a, b = list(map(int, input().split(" ")))

    total = pow(2, n, MOD)
    a_total = calc(n, a)
    b_total = calc(n, b)
    print((total - a_total - b_total - 1) % MOD)

Fixed code:
import math

MOD = 10 ** 9 + 7


def cmb(n, r):
    total = 1
    for i in range(r):
        total *= (n - i) % MOD
    return total * pow(math.factorial(r), MOD - 2, MOD) % MOD


def calc(n, r):
    ret = 1
    for i in range(r):
        ret = ret * (n - i) % MOD
    return ret * pow(math.factorial(r), MOD - 2, MOD) % MOD


if __name__ == '__main__':
    n, a, b = list(map(int, input().split(" ")))

    total = pow(2, n, MOD)
    a_total = calc(n, a)
    b_total = calc(n, b)
    print((total - a_total - b_total - 1) % MOD)
Buggy code:
n, a, b = map(int,input().split())
mod7 = 10 ** 9 + 7
def power(a,b,mod):
    p = 1
    q = a
    while b != 0:
        if b % 2 == 1:
            p = (p * q) % mod
        q = (q * q) % mod
        b = b // 2
    return p

def fact(n, mod):
    p = 1
    for i in range(1,n+1):
        p = (p * i) % mod
    return p

def divi(a,b,mod):
    p = (power(b, mod-2, mod) * a) % mod
    return p

def combi(n,a,mod):
    inv_af = power(fact(a,mod),mod-2,mod)
    p = 1
    for i in range(a):
        p = (p * (n-i)) % mod
    return inv_af * p % mod
    
Answer = power(2, n, mod7) - combi(n, a, mod7) - combi(n, b , mod7) - 1
print(Answer)

Fixed code:
n, a, b = map(int,input().split())
mod7 = 10 ** 9 + 7
def power(a,b,mod):
    p = 1
    q = a
    while b != 0:
        if b % 2 == 1:
            p = (p * q) % mod
        q = (q * q) % mod
        b = b // 2
    return p

def fact(n, mod):
    p = 1
    for i in range(1,n+1):
        p = (p * i) % mod
    return p


def combi(n,a,mod):
    inv_af = power(fact(a,mod),mod-2,mod)
    p = 1
    for i in range(a):
        p = (p * (n-i)) % mod
    return inv_af * p % mod

Answer = (power(2, n, mod7) - combi(n, a, mod7) - combi(n, b, mod7) - 1) % mod7
print(Answer)
Buggy code:
n,a,b=map(int,input().split())
M=10**9+7
sum=pow(2,n,M)-1
def inverse(number,mod):
    m=mod-2
    mod2=""
    while m!=0:
        if m%2==0:
            mod2="0"+mod2
        else:
            mod2="1"+mod2
        m=m//2
    two=[]
    for i in range(len(mod2)):
        if mod2[len(mod2)-1-i]=="1":
            two.append(i)
    ret=1
    for i in two:
        v=i
        retsub=number
        while v>0:
            retsub=retsub**2
            retsub=retsub%mod
            v-=1
        ret*=retsub
    ret=ret%mod
    return ret
def cal(num,r,mod):
    ret1=1
    for i in range(0,r):
        ret1*=(num-i)
        ret1%=mod
    r_factorial=1
    for i in range(1,r+1):
        r_factorial*=i
        r_factorial%=M
    ret2=inverse(r_factorial,mod)
    ret=(ret1*ret2)%mod
    return ret

print(sum-cal(n,a,M)-cal(n,b,M))


Fixed code:
n,a,b=map(int,input().split())
M=10**9+7
sum=pow(2,n,M)-1
def inverse(number,mod):
    m=mod-2
    mod2=""
    while m!=0:
        if m%2==0:
            mod2="0"+mod2
        else:
            mod2="1"+mod2
        m=m//2
    two=[]
    for i in range(len(mod2)):
        if mod2[len(mod2)-1-i]=="1":
            two.append(i)
    ret=1
    for i in two:
        v=i
        retsub=number
        while v>0:
            retsub=retsub**2
            retsub=retsub%mod
            v-=1
        ret*=retsub
    ret=ret%mod
    return ret
def cal(num,r,mod):
    ret1=1
    for i in range(0,r):
        ret1*=(num-i)
        ret1%=mod
    r_factorial=1
    for i in range(1,r+1):
        r_factorial*=i
        r_factorial%=M
    ret2=inverse(r_factorial,mod)
    ret=(ret1*ret2)%mod
    return ret

ans=sum-cal(n,a,M)-cal(n,b,M)
print(ans%M)
Buggy code:
mod = 10**9 + 7
n, a, b = map(int, input().split())
ans = pow(2, n, mod)-1

# a
x = 1
for i in range(n - a + 1, n + 1):
    x *= i
y = 1
for i in range(1, a + 1):
    y *= i

a_ans = x*pow(y, mod-2, mod)

x = 1
for i in range(n - b + 1, n + 1):
    x *= i
y = 1
for i in range(1, b + 1):
    y *= i
b_ans = x*pow(y, mod-2, mod)
print((ans - a_ans - b_ans) % mod)


Fixed code:
mod = 10**9 + 7
n, a, b = map(int, input().split())
ans = pow(2, n, mod)-1

# a
x = 1
for i in range(n - a + 1, n + 1):
    x = (x*i) % mod
y = 1
for i in range(1, a + 1):
    y = (y*i) % mod

a_ans = x*pow(y, mod-2, mod)

x = 1
for i in range(n - b + 1, n + 1):
    x = (x*i) % mod
y = 1
for i in range(1, b + 1):
    y = (y*i) % mod
b_ans = x*pow(y, mod-2, mod)
print((ans - a_ans - b_ans) % mod)
Buggy code:
n,a,b = map(int,input().split())
mod = 10**9+7

def comb(N,x):
  numerator = 1
  for i in range(N-x+1,N+1):
    numerator = numerator *i%mod
  denominator = 1
  for j in range(1,x+1):
    denominator = denominator *i%mod
  d = pow(denominator,mod-2,mod)
  return (numerator*d)%mod
al = pow(2,n,mod)-1
ac =comb(n,a)
bc =comb(n,b)
print((al-ac-bc)%mod)

Fixed code:
n,a,b = map(int,input().split())
mod = 10**9+7

def comb(N,x):
  numerator = 1
  for i in range(N-x+1,N+1):
    numerator = numerator *i%mod
  denominator = 1
  for j in range(1,x+1):
    denominator = denominator *j%mod
  d = pow(denominator,mod-2,mod)
  return (numerator*d)%mod
al = pow(2,n,mod)-1
ac =comb(n,a)
bc =comb(n,b)
print((al-ac-bc)%mod)
Buggy code:
N,A,B = map(int,input().split())

ans = 0 
mod = 7+10**9

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

def combi(n,k):
  N = 1
  mK = 1
  mN_K = 1
  for i in range(1,n+1):
    N = (N*i)%mod
  for i in range(1,k+1):
    mK = (mK * expo(i,mod-2))%(mod)
  for i in range(1,n-k+1):
    mN_K = (mN_K*expo(i,mod-2))%mod
  return (((N*mK)%mod)*mN_K)%mod

print(expo(2,N)-1-combi(N,A)-combi(N,B))

Fixed code:
N,A,B = map(int,input().split())

ans = 0 
mod = 7+10**9

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

def combi(n,k):
  N = 1
  K = 1
  for i in range(n-k+1,n+1):
    N = (N*i)%mod
  for i in range(1,k+1):
    K = (K * i)%mod
  return (N*expo(K,mod-2))%mod

print((expo(2,N)-1-combi(N,A)-combi(N,B))%mod)
Buggy code:
import math
n,a,b=map(int,input().split())

count=0
mod=1000000007

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
    return x*pow(y,mod-2,mod)%mod

count+=pow(2,n,mod)
#print(count)
count-=1
count-=C(n,a)
#print(count)
count-=C(n,b)

print(max(0,(count)%mod))

Fixed code:
import math
n,a,b=map(int,input().split())

count=0
mod=1000000007

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
        x%=mod
        y%=mod
    return x*pow(y,mod-2,mod)%mod

count+=pow(2,n,mod)
#print(count)
count-=1
count-=C(n,a)
#print(count)
count-=C(n,b)

print(max(0,(count)%mod))
Buggy code:
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
def comb(x,y):
    child = 1
    mother = 1
    for i in range(y):
        child *= x-i
        mother *= i+1
    return child * pow(mother,mod-2,mod)
ans = pow(2,n,mod)  - comb(n,a) - comb(n,b) - 1
print(int(ans%mod))

Fixed code:
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
def comb(x,y):
    child = 1
    mother = 1
    for i in range(y):
        child = child * (x-i)%mod
        mother = mother * (i+1)%mod
    return child * pow(mother,mod-2,mod) % mod
ans = pow(2,n,mod) - 1
ans -= comb(n,a)
ans %= mod
ans -= comb(n,b)
ans %= mod
print(ans)
Buggy code:
def choose(n,r):
    res = 1
    fac = 1
    for i in range(r):
        res *= n-i
        res %= MOD
        fac *= i+1
        fac %= MOD
    return res*pow(fac,MOD-2,MOD)%MOD        

n,a,b = list(map(int,input().split()))
t=0
ans = pow(2,n)-1
MOD = 10**9+7

ans -= choose(n,a)
ans -= choose(n,b)

ans = ans % MOD
print(int(ans))

Fixed code:
def choose(n,r):
    res = 1
    fac = 1
    for i in range(r):
        res *= n-i
        res %= MOD
        fac *= i+1
        fac %= MOD
    return res*pow(fac,MOD-2,MOD)%MOD        

n,a,b = list(map(int,input().split()))
MOD = 10**9+7
t=0
ans = pow(2,n,MOD)-1


ans -= choose(n,a)
ans -= choose(n,b)

ans = ans % MOD
print(int(ans))
Buggy code:
n, a, b = map(int, input().split())

MOD = 10 ** 9 + 7

def comb(n, r):
    fn = 1
    finv_r = 1
    for i in range(r):
        fn *= n - i
        finv_r *= pow(i+1, MOD-2, MOD)

    return fn * finv_r % MOD
    

ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
ans %= MOD
print(ans)


Fixed code:
n, a, b = map(int, input().split())

MOD = 10 ** 9 + 7

def comb(n, r):
    ret = 1
    for i in range(r):
        ret *= n - i
        ret %= MOD
    for i in range(r):
        ret *= pow(i+1, MOD-2, MOD)
        ret %= MOD

    return ret % MOD
    

ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
ans %= MOD
print(ans)