qyliang/CodeNanoFix huggingface dataset:
Buggy code:
def pow_mod(a, n, m): # (a^n) % m
    res = 1
    while n > 0:
        if n % 2 == 1:
            res = (res * a) % m
        a = (a * a) % m
        n = n // 2
    return res

def combi_mod(p, q, m):
    numerator, denominator = 1, 1
    for i in range(1, q+1):
        numerator *= (p - i + 1)
        numerator %= m
        denominator *= i
        denominator %= m
    return numerator * pow_mod(denominator, m-2, m) % m

n, a, b = list(map(int, input().split()))
res = pow_mod(2, n, M) - 1
res -=combi_mod(n, a, M)
if res < 0:
    res += M
res -= combi_mod(n, b, M)
if res < 0:
    res += M
print(res)

Fixed code:
M = pow(10, 9) + 7

def pow_mod(a, n, m): # (a^n) % m
    res = 1
    while n > 0:
        if n % 2 == 1:
            res = (res * a) % m
        a = (a * a) % m
        n = n // 2
    return res

def combi_mod(p, q, m):
    numerator, denominator = 1, 1
    for i in range(1, q+1):
        numerator *= (p - i + 1)
        numerator %= m
        denominator *= i
        denominator %= m
    return numerator * pow_mod(denominator, m-2, m) % m

n, a, b = list(map(int, input().split()))
res = pow_mod(2, n, M) - 1
res -=combi_mod(n, a, M)
if res < 0:
    res += M
res -= combi_mod(n, b, M)
if res < 0:
    res += M
print(res)
Buggy code:
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
n, a, b = [int(x) for x in input().strip().split()]
mod = 10 ** 9 + 7
ans = pow(2, n, mod) - 1

fact = [1] * (n + 1)
for i in range(1, n+1):
    fact[i] = (fact[i-1] * i) % mod

inv = [1] * (n + 1)
inv[-1] = pow(fact[-1], mod-2, mod)
for i in range(1, n+1):
    inv[-1-i] = (inv[-1-i+1] * (n-(i-1))) % mod

ans = (ans - (fact[n] * inv[n-a] * inv[a]) % mod) % mod
ans = (ans - (fact[n] * inv[n-b] * inv[b]) % mod) % mod
print(ans)

Fixed code:
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
n, a, b = [int(x) for x in input().strip().split()]
mod = 10 ** 9 + 7
ans = pow(2, n, mod) - 1

num = 1
den = 1
for i in range(a):
    den = (den * (i+1)) % mod
    num = (num * (n-i)) % mod
ans = (ans - (num * pow(den, mod-2, mod)) % mod ) % mod

for i in range(a, b):
    den = (den * (i+1)) % mod
    num = (num * (n-i)) % mod
ans = (ans - (num * pow(den, mod-2, mod)) % mod ) % mod

print(ans)
Buggy code:
def combination(n,r,mod=10**9+7):
    n1 = n+1
    r = min(r,n-r)
    numer = denom = 1
    for i in range(1,r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom,mod-2,mod) % mod
  
mod = int(1e9+7)
n,a,b= map(int,input().split())
 
S = (pow(2,n)-1)%mod
A = combination(n,a)
B = combination(n,b)
ans = (S-A-B)%mod
 
print(ans)

Fixed code:
def combination(n,r,mod=10**9+7):
    n1 = n+1
    r = min(r,n-r)
    numer = denom = 1
    for i in range(1,r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom,mod-2,mod) % mod
 
mod = int(1e9+7)
n,a,b= map(int,input().split())
 
S = (pow(2,n,mod) - 1)%mod
A = combination(n,a)
B = combination(n,b)
ans = (S-A-B)%mod
 
print(ans)
Buggy code:
mod = 10**9+7

def comb(n, r):
    x = 1
    y = 1
    if n-r<r:
        r = n-r
    for i in range(r):
        x *= n-i
        y *= (i*1)
        x %= mod
        y %= mod
    return x * pow(y, mod-2, mod) % mod

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

print((pow(2, n, mod)-comb(n, a)-comb(n, b)-1)%mod)

Fixed code:
mod = 10**9+7

def comb(n, r):
    x = 1
    y = 1
    if n-r<r:
        r = n-r
    for i in range(r):
        x *= n-i
        y *= (i+1)
        x %= mod
        y %= mod
    return x * pow(y, mod-2, mod) % mod

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

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


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


ans = pow(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)

while ans < 0:
    ans += mod
print(ans)


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


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


ans = pow(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)

while ans < 0:
    ans += mod
print(ans)
Buggy code:
def main():
    n, a, b = map(int, input().split())
    mod = 10**9+7

    nn = n
    ans1 = 1
    while a > 0:
        ans1 = (ans1 * n * pow(a, mod-2, mod)) % mod
        n -= 1
        a -= 1

    ans2 = 1
    n = nn
    while b > 0:
        ans2 = (ans2 * n * pow(b, mod-2, mod)) % mod
        n -= 1
        b -= 1

    print((pow(2, nn)-ans1-ans2-1) % mod)


main()


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

    nn = n
    ans1 = 1
    while a > 0:
        ans1 = (ans1 * n * pow(a, mod-2, mod)) % mod
        n -= 1
        a -= 1

    ans2 = 1
    n = nn
    while b > 0:
        ans2 = (ans2 * n * pow(b, mod-2, mod)) % mod
        n -= 1
        b -= 1

    print((pow(2, nn, mod)-ans1-ans2-1) % mod)


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


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


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


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


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


ans = pow(2, n, mod) - 1
ans = (ans - comb(n, a)) % mod
ans = (ans - comb(n, b)) % mod
print(ans)
Buggy code:
#156D

def comb(n,r,p=7+10**9):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
n,a,b=map(int,input().split())
s=-2+2**n-comb(n,a)-comb(n,b)
print(s%(7+10**9))


Fixed code:
#156D
p=7+10**9
def comb(n,r):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
n,a,b=map(int,input().split())
s=-1+pow(2,n,p)-comb(n,a)-comb(n,b)
print(s%p)
Buggy code:
n,a,b = map(int,input().split())
lim = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

print((pow(2,n,p)-combination(n,a)-combination(n,b)-1) % lim)

Fixed code:
n,a,b = map(int,input().split())
lim = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

print((pow(2,n,lim)-combination(n,a)-combination(n,b)-1) % lim)
Buggy code:
def cmb(n, r):
    if n - r < r:
      r = n - r
    if r == 0: 
      return 1
    if r == 1: 
      return n
    numerator = [] 
    mod = 10**9+7
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= mod

    return result

def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
n, a, b = map(int, input().split())
mod = 10**9+7
ALL = power_func(2,n,mod)-1
A = cmb(n,a)
B = cmb(n, b)
print(ALL,A,B)

Fixed code:
def cmb(n, r):
    if n - r < r:
      r = n - r
    if r == 0: 
      return 1
    if r == 1: 
      return n
    numerator = [] 
    mod = 10**9+7
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= mod

    return result
def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
n, a, b = map(int, input().split())
mod = 10**9+7
ALL = power_func(2,n,mod)-1
A = cmb(n,a)
B = cmb(n, b)
ans = ALL-A-B
while ans < 0:
  ans = mod + ans
print(ans)
Buggy code:
def com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, 1, mod)

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

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

print(int(sum % mod))


Fixed code:
def com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, mod-2, mod)

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

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

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

def kurikaeshi(x, n, mod):
    if n == 1:
        return x%mod
    elif n %2 == 0:
        return kurikaeshi(x, n//2, mod)**2%mod
    elif n %2 == 1:
        return kurikaeshi(x, n//2, mod)**2*x%mod
    
def combination(n, a, mod):
    bunbo = 1
    bunshi = 1
    for i in range(a):
        bunshi *= n-i
        bunbo *= a-i
        
    return bunshi*(kurikaeshi(bunbo, mod-2, mod)%mod)
        
        
mod = 1000000007
answer = kurikaeshi(2, n, mod)
answer -= 1
answer -= combination(n, a, mod)
answer -= combination(n, b, mod)
print(answer%mod)

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

def kurikaeshi(x, n, mod):
    if n == 1:
        return x%mod
    elif n %2 == 0:
        return kurikaeshi(x, n//2, mod)**2%mod
    elif n %2 == 1:
        return kurikaeshi(x, n//2, mod)**2*x%mod
    
    
def combination(n, a, mod):
    bunbo = 1
    bunshi = 1
    for i in range(a):
        bunshi *= n-i
        bunshi = bunshi%mod
        bunbo *= a-i
        bunbo = bunbo%mod
        
    return bunshi*pow(bunbo, mod-2, mod)%mod
        
        
mod = 1000000007
answer = pow(2, n, mod)
answer -= 1
answer -= combination(n, a, mod)
answer -= combination(n, b, mod)
print(answer%mod)
Buggy code:
mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print((al-(acr+bcr))%mod

Fixed code:
mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print( (al-(acr+bcr))%mod )
Buggy code:
n, a, b = map(int, input().split())
mod = 10**9 + 7
a = min(a, n-a)
b = min(b, n-b)
com = [1] * (max(a, b) + 1)
for i in range(1,len(com)):
    com[i] = (com[i-1] * pow(i, mod-2, mod) * (n-i+1)) % mod
print(pow(2, n, mod) - 1 - com[a] - com[b])

Fixed code:
n, a, b = map(int, input().split())
mod = 10**9 + 7
a = min(a, n-a)
b = min(b, n-b)
com = [1] * (max(a, b) + 1)
for i in range(1,len(com)):
    com[i] = (com[i-1] * pow(i, mod-2, mod) * (n-i+1)) % mod
print((pow(2, n, mod) - 1 - com[a] - com[b] + mod) % mod)
Buggy code:
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

def nCk(N, k, mod):
    ret_val = 1
    for i in range(k):
        ret_val *= (N - i)
        ret_val %= mod
        ret_val *= modinv(i + 1, mod)
        ret_val %= mod
    return ret_val


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
all_cnt = pow(2, n, MOD) - 1
a_cnt = nCk(n, a, MOD)
b_cnt = nCk(n, b, MOD)
ans = all_cnt - a_cnt - b_cnt
print(ans　% MOD)


Fixed code:
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

def nCk(N, k, mod):
    ret_val = 1
    for i in range(k):
        ret_val *= (N - i)
        ret_val %= mod
        ret_val *= modinv(i + 1, mod)
        ret_val %= mod
    return ret_val


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
all_cnt = pow(2, n, MOD) - 1
a_cnt = nCk(n, a, MOD)
b_cnt = nCk(n, b, MOD)
ans = all_cnt - a_cnt - b_cnt
while ans < 0:
    ans += MOD
print(ans)
Buggy code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def pow_r(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

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

for i in range(1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

print((pow_r(2, m)-1-mca-mcb) % P)

Fixed code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def pow_r_mod(x, n, mod=10**9+7):
    """
    O(log n)
    """
    if n == 0:
        return 1

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

    return (K * x) % mod

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

for i in range(1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

print((pow_r_mod(2, m)-1-mca-mcb) % P)
Buggy code:
p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=[0]*(k+1)
com[0]=1
for i in range(1, k+1):
  com[i]=((com[i-1]*(n-i+1))*modinv(i,p))%p
print((2**n-1-com[a]-com[b])%p)

Fixed code:
p = 10 ** 9 + 7
n,a,b = map(int,input().split())
k=max(a,b)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
com=[0]*(k+1)
com[0]=1
for i in range(1, k+1):
  com[i]=((com[i-1]*(n-i+1))*modinv(i,p))%p
print((pow(2,n,p)-1-com[a]-com[b])%p)
Buggy code:
def cmb(n,r,mod):
    p,q=1,1
    if r>n/2:
        r=n-r
    for i in range(r):
        p*=n-i
        q*=i+1
    return (p*pow(q,mod-2,mod))%mod
    
n,a,b=map(int,input().split())
mod=10**9+7
v=pow(2,n,mod)-1
print((v-cmb(n,a,mod)-cmb(n,b,mod))%mod)

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

mod = 10 ** 9 + 7

def comb( n, r, mod ):
  c = 1
  m = 1
  r = min( n - r, r )
  for i in range( r ):
    c = c * ( n - i ) % mod
    m = m * ( i + 1 ) % mod
  return c * pow( m, mod - 2, mod ) % mod

N = pow( 2, n, mod )
A = comb( n, a )
B = comb( n, b )
print(( N - A - B ) % mod )

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

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

n = pow( 2, N, MOD ) - 1
a = comb( N, A )
b = comb( N, B )
print(( n - a - b ) % MOD )
Buggy code:
n, a, b = map(int, input().split())
M = 10**9 + 7
total = pow(2, n, M)

def comb(n, k, p):
    if k > n-k:
        return comb(n, n-k, p)
    num, den = 1, 1
    for i in range(k):
        num = num * (n-i) % p
        den = den * (i+1) % p
    return num * pow(den, p-2) % p

print((total - 1 + (M - comb(n,a,M)) + (M - comb(n,b,M))) % M)


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

def comb(n, k, p):
    if k > n-k:
        return comb(n, n-k, p)
    num, den = 1, 1
    for i in range(k):
        num = num * (n-i) % p
        den = den * (i+1) % p
    return num * pow(den, p-2, p) % p

print((total - 1 + (M - comb(n,a,M)) + (M - comb(n,b,M))) % M)
Buggy code:
from functools import reduce

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

MOD = 10**9 + 7


def comb(n, r, mod=float("inf")):
    c = 1
    m = 1
    r = min(n - r, r)
    for i in range(r):
        c = c * (n - i) % mod
        m = m * (i + 1) % mod
    return c * pow(m, mod - 2, mod) % mod


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


Fixed code:
from functools import reduce

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

MOD = 10**9 + 7


def comb(n, r, mod=float("inf")):
    c = 1
    m = 1
    r = min(n - r, r)
    for i in range(r):
        c = c * (n - i) % mod
        m = m * (i + 1) % mod
    return c * pow(m, mod - 2, mod) % mod


print((pow(2, n, MOD) - comb(n, a, MOD) - comb(n, b, MOD) - 1) % MOD)
Buggy code:
import math

z = 10**9 + 7

n, a, b = [int(i) for i in input().split()]

r = pow(2, n, z)

def c(m):
  x = 1
  for i in range(n-m+1, n+1):
    x = x*i % z
  
  return (x * pow(math.factorial(m), z-2, z)) % z

r = (r - c(a) - c(b)) % z

print(r)

Fixed code:
import math

z = 10**9 + 7

n, a, b = [int(i) for i in input().split()]

r = pow(2, n, z) - 1

def c(m):
  x = 1
  for i in range(n-m+1, n+1):
    x = x*i % z
  
  return (x * pow(math.factorial(m), z-2, z)) % z

r = (r - c(a) - c(b)) % z

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

def combination(n, a, mod):
    bunshi = 1
    bunbo = 1
    for i in range(a):
        bunshi *= n-i
        bunshi = bunshi%mod
        bunbo *= a-i
        bunbo = bunbo%mod
    return bunshi*pow(bunbo, mod-2, mod)%mod
mod = 100000007
answer = pow(2, n, mod)
answer -= 1
answer -= combination(n, a, mod)
answer -= combination(n, b, mod)
print(answer%mod)


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

def combination(n, a, mod):
    bunbo = 1
    bunshi = 1
    for i in range(a):
        bunshi *= n-i
        bunshi = bunshi%mod
        bunbo *= a-i
        bunbo = bunbo%mod
        
    return bunshi*pow(bunbo, mod-2, mod)%mod
        
        
mod = 1000000007
answer = pow(2, n, mod)
answer -= 1
answer -= combination(n, a, mod)
answer -= combination(n, b, mod)
print(answer%mod)
Buggy code:
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
total = pow(2, n) - 1

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

a = comb(n, a)
b = comb(n, b)

print((total -a -b) % mod)

Fixed code:
n, a, b = map(int, input().split())
mod = pow(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

a = comb(n, a)
b = comb(n, b)

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

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

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

ans = pow(2,n,mod)-1-minus(a)-minus(b)
while ans<0:
    ans+=mod
print(ans%mod)


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

def minus(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 = pow(2,n,mod)-1-minus(n,a)-minus(n,b)
while ans<0:
    ans+=mod
print(ans)
Buggy code:
import math
l=10**9+7

n,a,b=map(int,input().split())
comb=[1]
for i in range(max(a,b)):
    den=i+1
    num=n-i
    ans=comb[i]*num*pow(den,l-2,l)%l
    comb.append(ans)


print(pow(2,n,l)-1-comb[a]-comb[b])

Fixed code:
import math
l=10**9+7

n,a,b=map(int,input().split())
comb=[1]

for i in range(max(a,b)):
    den=i+1
    num=n-i
    ans=comb[i]*num*pow(den,l-2,l)%l
    comb.append(ans)


print((pow(2,n,l)-1-comb[a]-comb[b])%l)
Buggy code:
def choose(n, r, M):
    x = 1
    y = 1

    for i in range(r):
        x *= (n - i) % M
        y *= (i + 1) % M
    res = x * pow(y, M-2, M) % M
    return res

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

print((pow(2, n, M) - 1 - choose(n, a, M) - choose(n, b, M)) % M)

Fixed code:
def choose(n, r, M):
    x = 1
    y = 1

    for i in range(r):
        x = x * (n - i) % M
        y = y * (i + 1) % M
    res = x * pow(y, M-2, M) % M
    return res

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

print((pow(2, n, M) - 1 - choose(n, a, M) - choose(n, b, M)) % M)
Buggy code:
# -*- coding: utf-8 -*-
N, a, b = map(int, input().split())

def get_combi_mod(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD

ans = 1
mod_case = 1 if N % 1000 != 0 else 0
div_num = 10 ** 9 + 7
for i in range(N // 1000 + mod_case):
    ans = (ans * (2 ** 1000)) % div_num

print((2 ** N - 1 - get_combi_mod(N, a, div_num) - get_combi_mod(N, b, div_num)) % (10 ** 9 + 7))

Fixed code:
# -*- coding: utf-8 -*-
N, a, b = map(int, input().split())

def get_combi_mod(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD

ans = 1
div_num = 10 ** 9 + 7
two_thou = (2 ** 1000) % div_num
for i in range(N // 1000):
    ans = (ans * two_thou) % div_num

ans = (ans * (2 ** (N % 1000))) % div_num
print((ans - 1 - get_combi_mod(N, a, div_num) - get_combi_mod(N, b, div_num)) % (10 ** 9 + 7))