Problem:
 Score : 400 points    Problem Statement Akari has n kinds of flowers, one of each kind.  She is going to choose one or more of these flowers to make a bouquet.  However, she hates two numbers a and b , so the number of flowers in the bouquet cannot be a or b .  How many different bouquets are there that Akari can make?  Find the count modulo (10^9 + 7) .  Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.      Constraints  All values in input are integers.  2 \leq n \leq 10^9  1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5)         Input Input is given from Standard Input in the following format:  n  a  b       Output Print the number of bouquets that Akari can make, modulo (10^9 + 7) . (If there are no such bouquets, print 0 .)        Sample Input 1 4 1 3      Sample Output 1 7  In this case, Akari can choose 2 or 4 flowers to make the bouquet.  There are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4 , so there are a total of 7 different bouquets that Akari can make.       Sample Input 2 1000000000 141421 173205      Sample Output 2 34076506  Print the count modulo (10^9 + 7) .

Solution (Python):
class Mint:
    
    MOD = 10**9+7
    
    def __init__(self, x=0):
        self.x = (x%self.MOD + self.MOD) % self.MOD
    
    def __iadd__(self, other):
        self.x += other.x
        if self.x >= self.MOD:
            self.x -= self.MOD
        return self
    
    def __isub__(self, other):
        self.x += self.MOD - other.x
        if (self.x >= self.MOD):
            self.x -= self.MOD
        return self
    
    def __imul__(self, other):
        self.x *= other.x
        self.x %= self.MOD;
        return self;
    
    def __add__(self, other):
        ans = Mint(self.x)
        ans += other
        return ans
        
    def __sub__(self, other):
        ans = Mint(self.x)
        ans -= other
        return ans
    
    def __mul__(self, other):
        ans = Mint(self.x)
        ans *= other
        return ans
    
    def __pow__(self, n):
        if n == 0:
            return Mint(1)
        a = self.__pow__(n >> 1)
        a *= a
        if n&1:
            a *= self
        return a
    
    def inv(self):
        return self**(self.MOD-2)
    
    def __ifloordiv__(self, other):
        self *= other.inv()
        return self
    
    def __floordiv__(self, other):
        ans = Mint(self.x)
        ans //= other
        return ans
        
class Comb:
    
    def __init__(self):
        pass
    
    def comb(self, n, k):
        assert n < Mint.MOD
        if k < 0 or k > n:
            return 0
        numerator = Mint(n-k+1)
        for i in range(n-k+2, n+1):
            numerator *= Mint(i)
        d = Mint(1)
        for i in range(2, k+1):
            d *= Mint(i)
        denominator = d.inv()
        return numerator*denominator            
        

def Main(N, A, B):
    ans = Mint(2)**N-Mint(1)-Comb().comb(N, A)-Comb().comb(N, B)
    return ans.x

def main():
    N, A, B = list(map(int, input().split()))
    print(Main(N, A, B))

if __name__ == '__main__':
    main()

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

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

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

print(ans % mod)

Solution (Python):
def cmb(n, r, mod):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n%mod

    X = Y = 1
    for i in range(n - r + 1, n + 1):
        X *= i
        X %= mod
    for i in range(1, r + 1):
        Y *= i
        Y %= mod
    return (X * RepeatingSquare(Y, mod - 2, mod)) % mod

def RepeatingSquare(n, p, mod):
    if p == 0:
        return 1
    elif p%2 == 0:
        t = RepeatingSquare(n, p//2, mod)
        return (t * t) % mod
    return n * RepeatingSquare(n, p - 1, mod)

def solve(mod):
    n, a, b = [int(_) for _ in input().split()]
    nb = cmb(n, b, mod)
    na = cmb(n, a, mod)
    return RepeatingSquare(2, n, mod) - 1 - na - nb

if __name__ == '__main__':
    MOD = 10 ** 9 + 7
    print(solve(MOD)%MOD)

Solution (Python):

from math import factorial

MOD = 10**9+7

def combination_formula(n, r):
    _max, _min = max(n-r, r), min(n-r, r)
    bunsi, bunbo = 1, 1
    for i in range(_min):
        bunsi *= (n-i)
        bunbo *= (i+1)
        bunsi %= MOD
        bunbo %= MOD
    
    
    bunbo = pow(bunbo, MOD-2, MOD)
    ans = (bunsi*bunbo) % MOD
    return ans

def solve():
    n, a, b = list(map(int, input().split()))
    ans = pow(2, n, MOD)
    ans -= 1  
    ans -= combination_formula(n, a)
    ans -= combination_formula(n, b)
    while ans < 0:
        ans += MOD
    print(ans)


if __name__ == "__main__":
    solve()

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

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

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

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

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

MOD = 1000000007

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

ans = pow(2, n, MOD)
ans -= 1
ans -= comb(n, a)
ans -= comb(n, b)
while ans < 0:
    ans += MOD
print(ans)

Solution (Python):
N,a,b = map(int,input().split())
MOD = 10**9 + 7
c = pow(2,N,MOD) - 1
 
def comb(n,k):
    fac,finv = 1,1
    for i in range(k):
        fac = fac*(n-i)%MOD
        finv = finv*(i+1)%MOD
    return fac * pow(finv,MOD-2,MOD) % MOD

print((c - comb(N,a) - comb(N,b)) % MOD)

Solution (Python):
from math import factorial
n, a, b = map(int, input().split())
mod = 10**9+7

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

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

Solution (Python):
n,a,b = map(int, input().split())
MOD = 10**9 + 7

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


X = pow(2,n,MOD)-1
A = modcomb(n,a,MOD)
B = modcomb(n,b,MOD)
ans = (X-A-B)%MOD
print(ans)

Solution (Python):


def mod_inverse(x, mod):
    return pow(x, mod-2, mod)



def mod_comb(n, k, mod):
    numer, denom = 1, 1
    for i in range(k):
        
        numer = numer * ((n-i) % mod) % mod
        denom = denom * ((i+1) % mod) % mod

    return numer * mod_inverse(denom, mod) % mod


n, a, b = map(int, input().split())
mod = 1000000007
ans = pow(2, n, mod) - 1
ans = (ans - mod_comb(n, a, mod)) % mod
ans = (ans - mod_comb(n, b, mod)) % mod
print( (ans + mod) % mod )

Solution (Python):
n,a,b = map(int,input().split())
mod = pow(10,9)+7
ans = pow(2,n,mod) - 1
anu = 1
ade = 1
bnu = 1
bde = 1
for i in range(max(a,b)):
  if i < a:
    anu = (anu*(n-i))%mod
    ade = (ade*(a-i))%mod
  if i < b:
    bnu = (bnu*(n-i))%mod
    bde = (bde*(b-i))%mod
ade = pow(ade,mod-2,mod)
bde = pow(bde,mod-2,mod)
ans -= (anu*ade)%mod
ans -= (bnu*bde)%mod
print(ans%mod)

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()


def powMod(n,p,m):
  if p==0:
    return 1
  if p%2==0:
    t=powMod(n,p//2,m)
    return t*t%m
  return n*powMod(n,p-1,m)%m


def main():
  n,a,b=LI()

  ans=powMod(2,n,mod)
  ans-=1
  ans%=mod

  pattern_a1=1
  for i in range(a):
    pattern_a1*=n-i
    pattern_a1%=mod
  pattern_a2=1
  for i in range(1,a+1):
    pattern_a2*=i
    pattern_a2%=mod
  pattern_a=pattern_a1*pow(pattern_a2,mod-2,mod)

  pattern_b1=1
  for i in range(b):
    pattern_b1*=n-i
    pattern_b1%=mod
  pattern_b2=1
  for i in range(1,b+1):
    pattern_b2*=i
    pattern_b2%=mod
  pattern_b=pattern_b1*pow(pattern_b2,mod-2,mod)

  ans-=pattern_a
  ans%=mod
  if ans<0:
    ans+=mod
  ans-=pattern_b
  ans%=mod
  if ans<0:
    ans+=mod

  return ans


print(main())

Solution (Python):
n,a,b = (int(x) for x in input().split())
mod = pow(10,9) + 7
ans = pow(2,n,mod) - 1
X = 1
Y = 1
W = 1
Z = 1

if a < b:
    c = a
    a = b
    b = c

for i in range(a):
    if i < a:
        X *= (n-i)
        X %= mod
        Y *= (a-i)
        Y %= mod

    if i < b:
        W *= (n-i)
        W %= mod
        Z *= (b-i)
        Z %= mod
    
Y = pow(Y,mod-2,mod)
ans -= ((X*Y) % mod)
    
Z = pow(Z,mod-2,mod)
ans -= ((W*Z) % mod)
print(ans%mod)

Solution (Python):


class Combination:
    def __init__(self, size, mod=10**9 + 7):
        self.size = size + 2
        self.mod = mod
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % self.mod
            self.inv[i] = -self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % self.mod

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % self.mod

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % self.mod) % self.mod

    def nhr(self, n, r):  
        return self.ncr(n + r - 1, n - 1)

    def factN(self, n):
        if n < 0:
            return 0
        return self.fact[n]

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

def calc(k):
    ret = 1
    for i in range(k):
        ret = ret * (N - i) * pow(i + 1, MOD - 2, MOD) % MOD
    return ret

ans = pow(2, N, MOD) - 1 - calc(A) - calc(B)
print(ans % MOD)

Solution (Python):
import sys


MOD = 1000000007  

def cmb(n, r):
    shi=bo=1
    for i in range(r):
        shi*=(n-i)
        shi%=MOD
        bo*=(r-i)
        bo%=MOD
    return shi*pow(bo,MOD-2,MOD)

def solve(n: int, a: int, b: int):
    print((pow(2,n)-cmb(n,a)-cmb(n,b)-1)%MOD)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  
    a = int(next(tokens))  
    b = int(next(tokens))  
    solve(n, a, b)

if __name__ == '__main__':
    main()

Solution (Python):
n, a, b = [int(x) for x in input().split()]

p = 10 ** 9 + 7


def exp_by_sq(x, n):
    if n == 0:
        exp = 1
    elif n == 1:
        exp = x % p
    elif  n % 2 == 0:
        exp = exp_by_sq(x * x % p, n // 2)
    else:
        exp = x * exp_by_sq(x * x % p, (n - 1) // 2) % p
    return exp % p

def binomial_p(n, k, p):
    '''
    Input: integers n, k such that n >= k >= 0, prime number p
    Output: n choose k mod p
    '''
    k = min(k, n-k)

    if k == 0:
        retval = 1
    elif k == 1:
        retval = n
    else:
        numer = n  
        inv = [0, 1]    
        inv_denom = 1 
        for i in range(2, k + 1):
            numer = numer * (n - i + 1) % p
            inv.append(( inv[p % i] * (p - p//i) ) % p ) 
            inv_denom = inv_denom * inv[-1] % p
        retval = numer * inv_denom % p

    return retval

ans = (exp_by_sq(2, n) - 1 - binomial_p(n, a, p) - binomial_p(n, b, p)) % p

print(ans)

Solution (Python):
def mod_comb(n,k,mod):
    result = 1
    for i in range(n-k+1,n+1):
        result *= i
        result %= mod
    for i in range(1,k+1):
        result *= pow(i,mod-2,mod)
        result %= mod
    return result


def main():
    n,a,b = map(int,input().split())
    mod = 10**9+7
    ans = pow(2,n,mod)-1
    ans = (ans - mod_comb(n,a,mod))%mod
    ans = (ans - mod_comb(n,b,mod))%mod
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):



from operator import mul
from functools import reduce



def main():

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

    def combi(n, r):
        if r < 0 or r > n:
            return 0
        r = min(n - r, r)

        over = 1
        under = 1

        for i in range(n - r + 1, n + 1):
            over = over * i % mod

        for i in range(1, r + 1):
            under = under * i % mod

        return over * modpow(under, mod-2) % mod

    def modpow(n, r):
        if r == 0:
            return 1

        v = modpow(n, r // 2)
        v = v * v % mod
        if r % 2 != 0:
            v = v * n % mod
        return v

    ans = modpow(2, n) - 1
    ans -= combi(n, a)
    ans -= combi(n, b)

    while ans < 0:
        ans += mod

    print(ans)


main()

Solution (Python):


def mod_inverse(x, mod):
    return pow(x, mod-2, mod)



def mod_comb(n, k, mod):
    numer, denom = 1, 1
    for i in range(k):
        
        numer = numer * ((n-i) % mod) % mod
        denom = denom * ((i+1) % mod) % mod

    return numer * mod_inverse(denom, mod) % mod


n, a, b = map(int, input().split())
mod = 1000000007
ans = pow(2, n, mod) - 1
ans = (ans - mod_comb(n, a, mod)) % mod
ans = (ans - mod_comb(n, b, mod)) % mod
print( (ans + mod) % mod )

Solution (Python):
n,a,b=map(int,input().split())
mod=10**9+7
def nCk(n,k):
    x=1
    y=1
    for i in range(k):
        x=(x*(n-i))%mod
        y=(y*(k-i))%mod
    y_inv=pow(y,mod-2,mod)
    return (x*y_inv)%mod

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

Solution (Python):
"""pythonで整数処理"""

def divisors(n):
    """約数の配列を返す"""
    yakusu = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            yakusu.append(i)
            if i * i != n:
                yakusu.append(n // i)
    return yakusu

class ModInt:
    """mod計算を勝手にやってくれるクラス"""
    def __init__(self, x, mod=1000000007):
        self.x = x % mod
        self.mod = mod

    def __repr__(self):
        return str(self.x)

    def __add__(self, other):
        if isinstance(other, self.__class__):
            return self.__class__(self.x + (other.x % self.mod))
        else:
            return self.__class__(self.x + (other % self.mod))

    def __sub__(self, other):
        if isinstance(other, self.__class__):
            return self.__class__(self.x - (other.x % self.mod) if \
                (self.x - (other.x % self.mod)) > 0 else (self.x - (other.x % self.mod)) + self.mod)
        else:
            return self.__class__(self.x - (other % self.mod) if \
                (self.x - (other % self.mod)) > 0 else (self.x - (other % self.mod)) + self.mod)

    def __mul__(self, other):
        if isinstance(other, self.__class__):
            return self.__class__(self.x * (other.x % self.mod))
        else:
            return self.__class__(self.x * (other % self.mod))

    def __truediv__(self, other):
        return self.__class__(self.x * other.inv().x)

    def __pow__(self, other):
        if isinstance(other, self.__class__):
            return self.__class__(pow(self.x, other.x, self.mod))
        else:
            return self.__class__(pow(self.x, other, self.mod))

    def inv(self):
        return self.__class__(pow(self.x, self.mod - 2, self.mod))

def modcomb(n, r, mod=1000000007):
    """
    nCrを返す。
    ModIntが必要。
    1 <= r <= n <= modが必要。
    """
    x = ModInt(1, mod)
    y = ModInt(1, mod)
    for i in range(r):
        x = x * (n - i)
        y = y * (i + 1)
    return x / y
        
n,a,b = map(int,input().split())
print(ModInt(2)**n-modcomb(n,a)-modcomb(n,b)-1)

Solution (Python):
def nck(n, k, mod):
    result = 1
    for i in range(n - k + 1, n + 1):
        result = result * i % mod
    tmp = 1
    for i in range(1, k + 1):
        tmp = tmp * i % mod
    return result * pow(tmp, mod - 2, mod) % mod


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


if __name__ == '__main__':
    main()

Solution (Python):
def combination(n,r):
  n1,r = n+1, 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

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

mod = 10**9+7

all = pow(2,n,mod)-1
exc = (combination(n,a)+combination(n,b))%mod
ret = (all - exc)%mod

print(ret)

Solution (Python):

n,a_,b_=map(int,input().split())
l=[min(a_,n-a_),min(b_,n-b_)]
a,b=min(l),max(l)
mod=10**9+7
def pow_k(x,n):
    k=1
    
    while n>1:
        if n%2==1:
            k*=x
            n-=1
            k=k%mod
        x**=2
        x=x%mod
        n//=2
    
    return (k * x) % mod
    

def modcomb(n,r,mod):
    X, Y =  1, 1
    r = min(r, n-r)
    for i in range(1,r+1):
        X = X * (n-i+1) % mod
        Y = Y * i % mod
    
    return X * pow(Y,mod-2,mod) % mod
ans=pow(2,n,mod)-1-modcomb(n,a,mod)-modcomb(n,b,mod)
print(ans%mod)

Solution (Python):

n,a_,b_=map(int,input().split())
l=[min(a_,n-a_),min(b_,n-b_)]
a,b=min(l),max(l)
mod=10**9+7
def pow_k(x,n):
    k=1
    
    while n>1:
        if n%2==1:
            k*=x
            n-=1
            k=k%mod
        x**=2
        x=x%mod
        n//=2
    
    return (k * x) % mod
    

def modcomb(n,r,mod):
    X, Y =  1, 1
    r = min(r, n-r)
    for i in range(1,r+1):
        X = X * (n-i+1) % mod
        Y = Y * i % mod
    
    return (X * pow_k(Y, mod-2) % mod) % mod
ans=pow_k(2,n)-1-modcomb(n,a,mod)-modcomb(n,b,mod)
print(ans%mod)

Solution (Python):
from functools import reduce
def modcomb(n, k, mod):
    
    
    
    num = reduce(lambda x, y: x * y % mod, range(n, n - k, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, k + 1))
    return num * pow(den, mod - 2, mod) % mod
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
x = pow(2, n, mod)
y = modcomb(n, a, mod)
z = modcomb(n, b, mod)
ans = x - y - z - 1
print(ans % mod)

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

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

mod = 10**9 + 7
all_case = pow(2, n, mod) - 1

print((all_case - cmb_mod(n, a, mod) - cmb_mod(n, b, mod)) % mod)

Solution (Python):
def choose(n, r, mod = 10 ** 9 + 7):
    bumbo = 1
    bunshi = 1
    for i in range(r):
        bunshi =(bunshi *  (n - i)) % mod
        bumbo = (bumbo * (i + 1)) % mod
    return bunshi * pow(bumbo, mod - 2, mod) % mod

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

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


nCa = choose(n, a)
nCb = choose(n, b)
ans -= (nCa + mod) % mod
ans -= (nCb + mod) % mod
ans = (ans + mod) % mod
print(ans)

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


inv = [1] * (2 * (10 ** 5)+1)
for i in range(2, 2 * (10 ** 5)+1):
    inv[i] = -inv[mod % i] * (mod // i)
    inv[i] %= mod


def comb(n, a):
    res = 1
    for i in range(a):
        res *= n - i  
        res *= inv[i + 1]  
        res %= mod  
    return res


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

ans %= mod
if ans < 0:
    ans += mod

print(ans)

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

p = 10 ** 9 + 7
inv = [0] * (b + 1)
inv[1] = 1

for k in range(2, b + 1):
	inv[k] = pow(k, p - 2, p)

com = 1
for i in range(1, a + 1):
	com = (com * (n + 1 - i)) % p * inv[i]

coma = com

for j in range(a + 1, b + 1):
	com = (com * (n + 1 - j)) % p * inv[j]

comb = com

print((pow(2, n, p) - 1 - coma - comb) % p)

Solution (Python):
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(100000)


def read_values():
    return map(int, input().split())


def read_index():
    return map(lambda x: x - 1, map(int, input().split()))


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def functional(N, mod):
    F = [1] * (N + 1)
    for i in range(N):
        F[i + 1] = (i + 1) * F[i] % mod
    return F


def inv(a, mod):
    return pow(a, mod - 2, mod)


def P(a, b, mod):
    res = 1
    for i in range(a, b + 1):
        res *= i
        res %= mod
    return res


def C(a, b, mod):
    return P(a - b + 1, a, mod) * inv(P(1, b, mod), mod) % mod


def main():
    N, A, B = read_values()
    mod = 10 ** 9 + 7 
    res = pow(2, N, mod) - 1

    p1 = P(N - A + 1, N, mod)
    p2 = p1 * P(N - B + 1, N - A, mod) % mod
    p3 = P(1, A, mod)
    p4 = p3 * P(A + 1, B, mod) % mod
    res -= p1 * inv(p3, mod) % mod
    res -= p2 * inv(p4, mod) % mod
    print(res % mod)


if __name__ == "__main__":
    main()

Solution (Python):


import sys

def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    return
    print(*args, **kwargs)


def choose(a, b, mod):
    numer, denomi = 1, 1 
    for i in range(0, b):
        denomi = (denomi * (i + 1)) % mod
        numer = ((a - i) * numer) % mod
    return (numer * pow(denomi, mod - 2, mod)) % mod


def main():
    mod = 1000000007
    n, a, b = read_int_list()
    ans = pow(2, n, mod)
    ans = (ans - 1) % mod  
    ans = (ans - choose(n, a, mod)) % mod
    ans = (ans - choose(n, b, mod)) % mod
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
def modPow(a, n, mod):
  if n == 1:
    return a % mod
  if n%2 == 1:
    return (a * modPow(a, n - 1, mod)) % mod
  t = modPow(a, n / 2, mod)
  return (t * t) % mod

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

  
n, a, b = map(int, input().split())
mod = 10**9+7
ans = modPow(2, n, mod)-1
aa = comb(n, a, mod)
bb = comb(n, b, mod)

print((ans-aa-bb)%mod)

Solution (Python):
n,a,b=map(int,input().split())
m=10**9+7
def com(n,k,m):
  p,q=1,1
  for i in range(n-k+1,n+1):
    p*=i
    p%=m
  for i in range(1,k+1):
    q*=i
    q%=m
  return p*pow(q,m-2,m)%m
ca,cb=com(n,a,m),com(n,b,m)
ans=(pow(2,n,m)-1-ca-cb)%m
print(ans)

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


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

Solution (Python):
MOD = 1000000007


def cal(a, n):
    if n == 1:
        return a
    if n % 2 == 0:
        return (cal(a, n // 2) % MOD) ** 2 % MOD
    else:
        return (cal(a, n - 1) % MOD) * a % MOD


def cal_p(n, r):
    res = 1
    for i in range(r):
        res = res * (n - i) % MOD

    return res


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

all = cal(2, n) - 1
A = cal_p(n, a) * cal(cal_p(a, a), 1000000005) % MOD
B = cal_p(n, b) * cal(cal_p(b, b), 1000000005) % MOD

print((all - A - B) % MOD)

Solution (Python):
def get_exp_mod(base, exp, mod):
    exp_bin = str(format(exp, 'b'))  
    res = 1
    for i in range(len(exp_bin)):
        if exp_bin[-i - 1] == '1':
            res = res * base % mod
        base = base * base % mod  

    return res


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


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



all_case = (get_exp_mod(2, n, mod) - 1) % mod


print((all_case - comb(n, a, mod) - comb(n, b, mod)) % mod)

Solution (Python):
n,a,b = map(int,input().split())
mod = (10**9)+7
max_cate = pow(2, n, mod) - 1
def cmb_mod(n, r, mod):
  numerator = 1
  denominator = 1
  for i in range(r):
    numerator = (numerator * (n - i)) % mod
    denominator = (denominator * (i + 1)) % mod
  return (numerator * pow(denominator,mod-2,mod)) % mod

a_num = cmb_mod(n,a,mod)
b_num = cmb_mod(n,b,mod)
print((max_cate - a_num - b_num)%mod)

Solution (Python):
N ,a,b= list(map(int,input().split(' ')))


M = 10**9+7

def pow(x,n):
    if n==0:
        return 1
    res = pow((x*x)%M,n//2)
    if (n%2)==1:
        res = (res*x)%M
    return res


def power(x,n):
    res = 1
    if(n>0):
        res = power(x,n//2)
        if (n%2)==0:
            res = (res*res)%M
        else:
            res = (((res*res)%M)*x)%M
    return res

def comb(n,a):
    ans = 1
    for i in range(a):
        ans = (ans*(n-i))%M
        ans = (ans*power(i+1,M-2))%M 
    return ans




print((power(2,N)-1-comb(N,a)-comb(N,b))%M)

Solution (Python):
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod) - 1 
mod_inv = [0, 1] + [0] * (b+3)
for i in range(2, b+5):
    mod_inv[i] = - mod_inv[mod % i] * (mod // i) % mod
def comod(n, r, mod):
    ans = 1
    for i in range(r):
        ans *= (n-i) % mod
        ans *= mod_inv[i+1]
        ans %= mod
    return ans
ans -= comod(n,a,mod) + comod(n,b,mod)
print(ans % mod)

Solution (Python):
def modPow(a, n, mod):
  if n == 1:
    return a % mod
  if n%2 == 1:
    return (a * modPow(a, n - 1, mod)) % mod
  t = modPow(a, n / 2, mod)
  return (t * t) % mod

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

  
n, a, b = map(int, input().split())
mod = 10**9+7
ans = modPow(2, n, mod)-1
aa = comb(n, a, mod)
bb = comb(n, b, mod)

print((ans-aa-bb)%mod)

Solution (Python):
n, a, b = map(int, input().split())
p = 10**9+7

max_r = b




def make_mod_inv(l,p): 
    mod_inv = [0, 1] + [0] * (l+3) 
    for i in range(2, l+5):
        mod_inv[i] = -mod_inv[p % i] * (p // i) % p
    return mod_inv

mod_inv = make_mod_inv(max_r,p)

def NCr_mod_p(N, r, p):
    ret = 1
    for i in range(r):
        ret *= (N-i)%p
        ret *= mod_inv[i+1]
        ret %= p
    return ret

ans = pow(2,n,p) - 1 - NCr_mod_p(n,a,p) - NCr_mod_p(n,b,p)
print(ans%p)

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007


def main():
	n,a,b = inputMap()
	

	total = pow(2, n, mod)
	total -= 1
	tmp = combination(n, a, mod)
	if total < tmp:
		total = total + mod - tmp
	else:
		total -= tmp

	tmp = combination(n, b, mod)
	if total < tmp:
		total = total + mod - tmp
	else:
		total -= tmp

	print(total)





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

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

if __name__ == "__main__":
	main()

Solution (Python):

import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

























def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

inf = float('inf')
mod = 1000000007


def main():
	n,a,b = inputMap()
	

	total = pow(2, n, mod)
	total -= 1
	tmp = combination(n, a, mod)
	if total < tmp:
		total = total + 1000000007 - tmp
	else:
		total -= tmp

	tmp = combination(n, b, mod)
	if total < tmp:
		total = total + 1000000007 - tmp
	else:
		total -= tmp

	print(total)



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

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y

if __name__ == "__main__":
	main()

Solution (Python):
n, a, b = map(int, input().split())
p = 10**9+7

max_r = b




def make_inv(m,p): 
    inv = [0, 1] + [0] * m 
    for i in range(2, m+2):
        inv[i] = -inv[p % i] * (p // i) % p
    return inv

inv = make_inv(max_r+3,p)

def NCr_mod_p(N, r, p):
    ret = 1
    for i in range(r):
        ret *= (N-i)%p
        ret *= inv[i+1]
        ret %= p
    return ret

ans = pow(2,n,p) - 1 - NCr_mod_p(n,a,p) - NCr_mod_p(n,b,p)
print(ans%p)

Solution (Python):
N,a,b=map(int,input().split())
mod=10**9+7

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

ans=pow(2,N,mod)-1-C(N,a,mod)-C(N,b,mod)
print(ans%mod)

Solution (Python):


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) + mod - 1 - com[a] - com[b]) % mod)

Solution (Python):
from functools import reduce 
def solve():
    mod = 10 ** 9 + 7
    n, a, b = map(int, input().split())
    all_comb = pow(2, n, mod) - 1

    X = reduce(lambda x,y:x*y%mod, list(range(n-a+1, n+1))) 
    Y = reduce(lambda x,y:x*y%mod, list(range(1,a+1)))
    Y = pow(Y, mod-2, mod)
    a_comb = X * Y % mod

    X = reduce(lambda x,y:x*y%mod, list(range(n-b+1, n+1))) 
    Y = reduce(lambda x,y:x*y%mod, list(range(1,b+1)))
    Y = pow(Y, mod-2, mod)
    b_comb = X * Y % mod

    ans = all_comb - a_comb
    ans %= mod
    ans -= b_comb
    ans %= mod
    print(ans)

if __name__ == '__main__':
    solve()

Solution (Python):


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) + mod - 1 - com[a] - com[b]) % mod)

Solution (Python):
import functools
n, a, b = map(int, input().split())
mod = 10**9+7

def f(n: int, a: int) -> int:
    n = functools.reduce(lambda x, y: x*y%mod, range(n, n-a, -1))
    d = functools.reduce(lambda x, y: x*y%mod, range(1, a+1))
    return n*pow(d, mod - 2, mod)%mod

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

Solution (Python):
from functools import reduce
mod=10**9+7

def f(A):
 dem=reduce(lambda x,y:x*y%mod,range(n,n-A,-1))
 num=reduce(lambda x,y:x*y%mod,range(1,A+1))
 return dem*pow(num,mod-2,mod)%mod

stdin=open(0)
n,a,b=map(int,stdin.read().split())
ans=pow(2,n,mod)-f(a)-f(b)-1
ans%=mod
print(ans)

Solution (Python):
n,a,b = map(int, input().split())
p = 7 + 10**9


def permMOD(MOD, N, R=-1):
    from functools import reduce as r
    if R==-1: R=N
    return r(lambda x,y: x*y%MOD, range(N, N-R, -1))


def combMOD(MOD, N, R):
    return permMOD(MOD, N, R) * pow(permMOD(MOD, R), MOD-2, MOD) % MOD


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