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):
N,a,b=map(int,input().split())
MOD=10**9+7
def comb(n,k):
  tmp=1
  for i in range(n-k+1,n+1):
    tmp*=i
    tmp%=MOD
  for i in range(1,k+1):
    tmp*=pow(i,MOD-2,MOD)
    tmp%=MOD
  return tmp
ans = pow(2,N,MOD) - 1 - comb(N,a) - comb(N,b)
print(ans%MOD)

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

Solution (Python):



from functools import reduce
mod = 10**9+7

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


def nCk(n, k):
    numer = reduce(lambda x, y: (x * y) % mod, range(n, n - k, -1))
    denom = reduce(lambda x, y: (x * y) % mod, range(1, k + 1))
    return numer * pow(denom, mod - 2, mod) % mod


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

Solution (Python):
from math import factorial

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


def sq(a, b, mod):
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer


mod = 10 ** 9 + 7

s = pow(2, n, mod) - 1 - nCk(n, a, mod) - nCk(n, b, mod)

s = (s + mod) % mod

print(s)

Solution (Python):
mod = 10**9+7
N, A, B = [int(i) for i in input().split()]


def ncr(n, r):
    r = min(r, n-r)
    res = 1
    m = n
    for _ in range(r):
        res *= m
        res %= mod
        m -= 1
    m = r
    for _ in range(r):
        res *= pow(m, mod-2, mod)
        res %= mod
        m -= 1
    return res


print((pow(2, N, mod)-1-ncr(N, A)-ncr(N, B)) % mod)

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

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


def power(x, y, z):
    if x == 1 or y == 0:
        return 1
    a = power(x, y // 2, z)
    a = (a * a) % z
    if y % 2 == 1:
        a = (a * x) % z
    return a


def choose(n, r, z):
    x = 1
    y = 1

    for i in range(min(r, n - r)):
        x = (x * (n - i)) % z
        y = (y * (i + 1)) % z

    y = power(y, z - 2, z)
    return (x * y) % z


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

print(ans)

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


def power(x, y, z):
    if y == 0:
        return 1
    a = power(x, y // 2, z)
    a = (a * a) % z
    if y % 2 == 1:
        a = (a * x) % z
    return a


def choose(n, r, z):
    x = 1
    y = 1

    for i in range(min(r, n - r)):
        x = (x * (n - i)) % z
        y = (y * (i + 1)) % z

    y = power(y, z - 2, z)
    return (x * y) % z


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

print(ans)

Solution (Python):
MOD = 10**9 + 7

class ModInt:
    def __init__(self, x):
        if isinstance(x, ModInt):
            self.x = x.x
        else:
            self.x = x % MOD
    
    
    def __str__(self):
        return str(self.x)
    
    def __int__(self):
        return self.x
    
    __index__ = __int__
    
    
    __repr__ = __str__

    
    def __add__(self, other):
        return ModInt(self.x + ModInt(other).x)
    
    def __sub__(self, other):
        return ModInt(self.x - ModInt(other).x)

    def __mul__(self, other):
        return ModInt(self.x * ModInt(other).x)
    
    
    def __truediv__(self, other):
        
        return ModInt(self.x * pow(ModInt(other).x, MOD - 2, MOD))

    
    def __floordiv__(self, other):
        return self.x // ModInt(other).x

    
    def __pow__(self, other):
        return ModInt(pow(self.x, ModInt(other).x, MOD))

    
    __radd__ = __add__

    def __rsub__(self, other):
        return ModInt(other - self.x)
    
    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return ModInt(other * pow(self.x, MOD - 2, MOD))

    def __rfloordiv__(self, other):
        return ModInt(other // self.x)
    
    
    def __rpow__(self, other):
        return ModInt(pow(other, self.x, MOD))
    
    
    def __lt__(self, other):
        return self.x < ModInt(other).x
    
    def __gt__(self, other):
        return self.x > ModInt(other).x

    def __le__(self, other):
        return self.x <= ModInt(other).x
    
    def __ge__(self, other):
        return self.x >= ModInt(other).x
    
    def __eq__(self, other):
        return self.x == ModInt(other).x
    
    def __ne__(self, other):
        return self.x != ModInt(other).x

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

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

ans = 2 ** n

ans = ans - comb(n, a)
ans = ans - comb(n, b)
ans = ans - 1

print(ans)

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

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

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

ans = pow(2,n,mod) - 1 - da - db
print(ans % mod)

Solution (Python):
from math import factorial

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

mod = 10**9+7

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

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

Solution (Python):


from functools import *
import sys
sys.setrecursionlimit(100000)



def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())
mod = 10**9+7


def factorial(n):
    fact = 1
    for integer in range(1, n + 1):
        fact *= integer
    return fact


def cmb2(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    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])

    return int(result)

    return count


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
    
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 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 modpow(a, n, mod):
    res = 1
    while n > 0:
        

        if n & 1:
            res = res*a % mod
        a = a*a % mod
            
        n>>=1

    return res


n,a,b=acinput()





c=combination(n,min(n,n-a))+combination(n,min(b,n-b))



print((modpow(2,n,mod)-c-1)%mod)

Solution (Python):
MOD = 10 ** 9 + 7

def inverse(a, p):
    return pow(a, p-2, p)

def nCr(n, r, p = MOD):
    x, y = 1, 1
    for i in range(r):
        x = (x * (n - i)) % p
        y = (y * (i + 1)) % p
    return x * inverse(y, p) % p

n, a, b = map(int, input().split())
ans = pow(2, n, MOD) - 1

print(((ans - nCr(n, a) - nCr(n, b)) % MOD))

Solution (Python):
n,a,b=map(int,input().split())
mod=10**9+7
n_max=2*(10**5+1)
F,FI=[0]*(n_max+1),[0]*(n_max+1)
F[0],FI[0]=1,1
for i in range(n_max):
  F[i+1]=(F[i]*(i+1))%mod
FI[n_max-1]=pow(F[n_max-1],mod-2,mod)
for i in reversed(range(n_max-1)):
  FI[i]=(FI[i+1]*(i+1))%mod
ans=pow(2,n,mod)
c=1
for i in range(b):
  c=(c*(n-i))%mod
  if i==a-1:
    c1=c
c2=c
c1=(c1*FI[a])%mod
c2=(c2*FI[b])%mod
print((ans-c1-c2-1)%mod)

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

def main():
    mod = 10**9+7
    n,a,b=map(int,input().split())
    f=1
    fa=0
    for i in range(1,b+1):
        f=(f*(n-i+1)*pow(i,mod-2,mod))%mod
        if i==a:
            fa=f
    ans=(pow(2,n,mod)-fa-f-1)%mod
    print(ans)

if __name__ == '__main__':
    main()

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

factorial = [1]
for i in range(1, N+1):
    factorial.append((factorial[i-1]*i)%mod)

p_list = [n%mod]
for i in range (1,N+1):
    p_list.append((p_list[i-1]*(n-i))%mod)
    
x = pow(2,n,mod)-1
ya = pow(factorial[a],10**9+5,mod)
yb = pow(factorial[b],10**9+5,mod) 

print ((x-p_list[a-1]*ya-p_list[b-1]*yb)%mod)

Solution (Python):
import sys


def input():
    return sys.stdin.readline()[:-1]


def comb(n, k):
    nCk = 1
    MOD = 10**9+7

    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    for i in range(1, k+1):
        nCk *= pow(i, MOD-2, MOD)
        nCk %= MOD
    return nCk


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


if __name__ == "__main__":
    main()

Solution (Python):
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def inv_mod(a, N):
    """
    Fermatの小定理より(Nが素数のときしか使えない)
    aの逆元 ax = 1 (mod N)を満たすx = a^(N-2) mod Nを返す。
    O(log N)
    """

    def bpm(x, y, N):
        """
         Bisection power method : 二分累乗法
         O(log y)でx^(y) mod N を求める。
        """
        ans = 1
        x %= MOD
        digit = int((math.log(y, 2) // 1 + 1))  
        for i in range(digit):
            if (y >> i) & 1 == 1:
                ans *= x
                ans %= MOD
            x **= 2
            x %= MOD
        return ans

    return bpm(a, N - 2, N)


def bpm(x, y, N):
    """
     Bisection power method : 二分累乗法
     O(log y)でx^(y) mod N を求める。
    """
    ans = 1
    x %= MOD
    digit = int((math.log(y, 2) // 1 + 1))  
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


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

nCa = 1
nCb = 1

inv_list = [1]  
for i in range(max(a, b)):
    inv_list.append(int(MOD - inv_list[(MOD % (i + 2)) - 1] * (MOD // (i + 2)) % MOD))

for i in range(a):
    nCa *= inv_list[i]
    nCa %= MOD
    nCa *= n - i
    nCa %= MOD

for i in range(b):
    nCb *= inv_list[i]
    nCb %= MOD
    nCb *= n - i
    nCb %= MOD

print((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)

Solution (Python):
from functools import reduce

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


def F(n,r):
    
    numerator = reduce(lambda x,y: x * y % MOD, range(n,n-r,-1))
    
    denominator = reduce(lambda x,y: x * y % MOD, range(1,r+1))
    return numerator * pow(denominator, MOD - 2, MOD) % MOD


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

print(ans)

Solution (Python):
def mcomb(n, k):
    a = 1
    b = 1
    for i in range(k):
        a *= n - i
        a %= 1000000007
        b *= i + 1
        b %= 1000000007
    return a * pow(b, 1000000005, 1000000007) % 1000000007


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

result = pow(2, n, 1000000007) - 1
result -= mcomb(n, a)
result + 1000000007
result %= 1000000007
result -= mcomb(n, b)
result + 1000000007
result %= 1000000007
print(result)

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

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

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

Solution (Python):
import sys
from io import StringIO
import unittest
import math

mod = 10**9+7

def pow_mod(a, b, mod):
    x = 1
    while b > 0:
        if b & 1:
            x = (x*a)%mod
        a = (a**2)%mod
        b //= 2
 
    return x

def modinv(a, mod):
    return pow_mod(a, mod-2, mod)

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

    for i in range(1,r+1):
        combsum = (combsum * inv[i])%mod

    return combsum

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

a=min([a,n-a])
b=min([b,n-b])

maxab=max([a,b])

inv=[modinv(i,mod) for i in range(0,maxab+2)]

def resolve():

    ptn = pow_mod(2,n,mod)
    ptn -= 1

    comba=comb(n,a,mod)
    combb=comb(n,b,mod)

    ptn = (ptn-comba-combb)%mod

    print(ptn)

    return 

resolve()

Solution (Python):

from math import factorial
MOD = int(1e9+7)
INF = int(1e9)

def comb(n, m, mod):
    comb_a = 1
    for i in range(m):  
        comb_a *= (n-i)
        comb_a %= mod
    comb_b = factorial(m)%mod
    comb_b = pow(comb_b, mod-2, mod)
    return (comb_a * comb_b) % mod
    
def main():
    n, a, b = map(int, input().split())
    print((pow(2, n, MOD)-1-comb(n, a, MOD)-comb(n, b, MOD))%MOD)
main()

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

mod = 10**9 + 7

import time
start = time.time()



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



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

modinv_table = [-1] * (b+1)
for i in range(1, b+1):
    modinv_table[i] = modinv(i)

end = time.time()


def binomial_coefficients2(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table[i + 1]
        ans %= mod
    return ans


ans = power(2, n) - 1

ans -= (binomial_coefficients2(n, a) + binomial_coefficients2(n, b))
print(ans % mod)

Solution (Python):
def comb(n, k):
    nCk = 1
    MOD = 10**9+7

    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD

    for i in range(1, k+1):
        nCk *= pow(i, MOD-2, MOD)
        nCk %= MOD
    return nCk


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

Solution (Python):
m=10**9+7
n,a,b=map(int,input().split())
s=r=1
for i in range(b):s+=r*(i==a);r=r*(n-i)*pow(i+1,m-2,m)%m
print((pow(2,n,m)-s-r)%m)

Solution (Python):
import sys
readline = sys.stdin.readline
read = sys.stdin.read
n,a,b = [int(i) for i in read().split()]

MOD = 10**9+7
ans = pow(2,n,MOD)-1


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        

ans -= choose(n,a)
ans -= choose(n,b)
print(ans%MOD)

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

mod = 10**9 + 7

def comb(n:int,k:int,MOD:int):
    """return nCk (mod MOD)
    """
    nCk = 1
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD
    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk

all = pow(2,n,mod)-1
comb_a = comb(n,a,mod)
comb_b = comb(n,b,mod)
answer = (all -comb_a -comb_b) % mod

print(answer)

Solution (Python):
import numpy as np
n, a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
MOD = 10**9 + 7
v = pow(2, n, MOD) - 1


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5 + 1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n - 1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n - 1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv



fact, fact_inv = make_fact(2 * 10**5 + 1, MOD)

a_fact = fact[a]
b_fact = fact[b]

n_fact = [n % MOD] * (b + 1)
for i in range(1, b + 1):
    n_fact[i] = (n_fact[i - 1] * (n - i)) % MOD
an_fact = n_fact[a - 1]
bn_fact = n_fact[b - 1]


def f(a, b, MOD):
    a, b = int(a), int(b)
    return (a % MOD * pow(b, MOD - 2, MOD)) % MOD


ca = f(an_fact, a_fact, MOD)
cb = f(bn_fact, b_fact, MOD)

print((v - ca - cb) % MOD)

Solution (Python):
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def inv_mod(a, N):
    """
    Fermatの小定理より(Nが素数のときしか使えない)
    aの逆元 ax = 1 (mod N)を満たすx = a^(N-2) mod Nを返す。
    O(log N)
    """

    def bpm(x, y, N):
        """
         Bisection power method : 二分累乗法
         O(log y)でx^(y) mod N を求める。
        """
        ans = 1
        x %= MOD
        digit = int((math.log(y, 2) // 1 + 1))  
        for i in range(digit):
            if (y >> i) & 1 == 1:
                ans *= x
                ans %= MOD
            x **= 2
            x %= MOD
        return ans

    return bpm(a, N - 2, N)


def bpm(x, y, N):
    """
     Bisection power method : 二分累乗法
     O(log y)でx^(y) mod N を求める。
    """
    ans = 1
    x %= MOD
    digit = int((math.log(y, 2) // 1 + 1))  
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


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

nCa = 1
nCb = 1

inv_list = []

for i in range(max(a, b)):
    inv_list.append(inv_mod(i + 1, MOD))

for i in range(a):
    nCa *= inv_list[i]
    nCa %= MOD
    nCa *= n - i
    nCa %= MOD

for i in range(b):
    nCb *= inv_list[i]
    nCb %= MOD
    nCb *= n - i
    nCb %= MOD

print((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)

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

Solution (Python):

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

mod=10000*100000+7
def mpow(a,b,m=100000*10000+7):
  ret=1
  while b>0:
    if b&1:
      ret=(ret*a)%m
    a=(a*a)%m
    b>>=1
  return ret
def nCr(n,r):
  num=1
  for i in range(n-r+1,n+1):
    num=(num*i)%mod
  den=1
  for i in range(1,r+1):
    den=(den*i)%mod
  den=mpow(den,mod-2)
  return (num*den)%mod
ans=mpow(2,n)-1
if ans<0:
  ans+=mod
ans-=nCr(n,a)
if ans<0:
  ans+=mod
ans-=nCr(n,b)
if ans<0:
  ans+=mod
print(ans)

Solution (Python):
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def inv_mod(a, N):
    """
    ユークリッドの互除法より
    aの逆元 ax = 1 (mod N)を満たすxを返す。
    O(log a)
    """

    def extgcd(a, b):
        """
        Extended Great Common Divisor
        ax + by = gcd(a, b) = dを満たすx, y, dを返す。
        """
        d = fractions.gcd(a, b)
        if b == 0:
            return 1, 0, a
        else:
            q, r = divmod(a, b)
            x, y, d = extgcd(b, r)
            s, t = y, x - q * y
            return s, t, d

    return extgcd(a, N)[0]


def bpm(x, y, N):
    """
     Bisection power method : 二分累乗法
     O(log y)でx^(y) mod N を求める。
    """
    ans = 1
    x %= MOD
    digit = int((math.log(y, 2) // 1 + 1))  
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


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

nCa = 1
nCb = 1

inv_list = []

for i in range(max(a, b)):
    inv_list.append(inv_mod(i + 1, MOD))

for i in range(a):
    nCa *= inv_list[i]
    nCa %= MOD
    nCa *= n - i
    nCa %= MOD

for i in range(b):
    nCb *= inv_list[i]
    nCb %= MOD
    nCb *= n - i
    nCb %= MOD

print((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)

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

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

def f(x, y, MOD):
  out=1
  for i in range(x, x-y, -1):
    out=out*i%MOD
  return out

p=[0, 1]+[0]*(2*10**5-1)
for i in range(2, 2*10**5+1, 1):
  p[i]=p[i-1]*i%MOD
  
q=[0]*(2*10**5)+[pow(p[-1], MOD-2, MOD)]
for i in range(2*10**5, 0, -1):
  q[i-1]=q[i]*i%MOD

ans=(pow(2, n, MOD)-1-(f(n, a, MOD)*q[a])%MOD-(f(n, b, MOD)*q[b])%MOD)%MOD
print(ans)

Solution (Python):
n, a, b = map(int, input().split())
mod = 10**9 + 7
def inv(a, p):
    return pow(a, p-2, p)

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

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

Solution (Python):
from math import factorial

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

mod = 10**9 + 7

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

def ncr(n, r):
    x = 1
    y = 1
    for i in range(r):
        x *= (n-i)
        y *= (i+1)
        x %= mod
        y %= mod
    return (x * pow(y, 10**9+5)) % mod

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

print(ans if ans >= 0 else ans + mod)

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


class ModInt:
    def __init__(self, num, mod):
        self.num = num
        self.mod = mod

    def __str__(self):
        return str(self.num)

    def __repr__(self):
        return "ModInt(num: {}, mod: {}".format(self.num, self.mod)

    def __add__(self, other):
        ret = self.num + other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __sub__(self, other):
        ret = self.num - other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def __mul__(self, other):
        ret = self.num * other.num
        ret %= self.mod
        return ModInt(ret, self.mod)

    def pow(self, times):
        pw = pow(self.num, times, self.mod)
        return ModInt(pw, self.mod)

    def inverse(self):
        return self.pow(self.mod - 2)

    def __truediv__(self, other):
        num = self * other.inverse()
        return ModInt(num, self.mod)


class CombinationSmall:
    def __init__(self, n, k, mod):
        self.n = n
        self.k = k
        self.mod = mod
        self.fact = [ModInt(1, mod)]
        self.inverse = [ModInt(1, mod)]
        for i in range(1, k + 1):
            self.fact.append(self.fact[-1] * ModInt(n - i + 1, mod))
            self.inverse.append(self.inverse[-1] * ModInt(i, mod).inverse())

    def comb(self, k):
        if k > self.k:
            return ModInt(0, self.mod)

        return self.fact[k] * self.inverse[k]


comb = CombinationSmall(n, min(n, 2 * 10 ** 5), mod)

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

print(ans)

Solution (Python):
n,a,b=map(int,input().split())
MOD=10**9+7
def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p
print((pow(2,n,MOD)-comb(n,a)-comb(n,b)-1)%MOD)

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

def factorial(n,m):
    
    f = [1,1]
    for i in range(2,n+1):
        f.append(f[-1]*i % m)
    
    g = [1]
    for i in range(n):
        g.append(pow(f[i+1],m-2,m))
    return f,g

f, g = factorial(2*10**5+1,mod)

div_a = g[a]
"""
for i in range(n,n-a-1,-1):
    div_a *= i
    div_a %= mod
"""
for i in range(1,a+1):
    div_a *= n - i + 1
    div_a %= mod


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


mx = pow(2, n, mod)
mx += mod*3
print((mx - 1 - div_a - div_b)%mod)

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

def factorial(n,m):
    
    f = [1,1]
    for i in range(2,n+1):
        f.append(f[-1]*i % m)
    
    g = [1]
    for i in range(n):
        g.append(pow(f[i+1],m-2,m))
    return f,g

f, g = factorial(2*10**5+1,mod)

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


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


mx = pow(2, n, mod)
mx += mod*3
print((mx - 1 - div_a - div_b)%mod)

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

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

nca=comb(n,a,mod)
ncb=comb(n,b,mod)

ans=pow(2,n,mod)
ans=(ans-((nca+ncb)%mod+1))%mod
print(ans)

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

def comb(n,r,mod):
    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

nca=comb(n,a,mod)
ncb=comb(n,b,mod)

ans=pow(2,n,mod)
ans=(ans-((nca+ncb)%mod+1))%mod
print(ans)

Solution (Python):
n,a,b = map(int,input().split())
inf = 10**9 +7
ans = pow(2,n,inf)-1
def conbi(n,k):
  if n-k < k:
    k = n-k
  x = 1
  y = 1
  for i in range(k):
    x *= n-i
    x = x%inf
    y *= i+1
    y = y%inf
  ans = x* pow(y,inf-2,inf)%inf
  return ans
ans  -= conbi(n,a) + conbi(n,b)
ans = ans%inf
print(ans)

Solution (Python):
n,a,b=map(int, input().split())
def comb(n, r,mod):
  r=min(r,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
mod=10**9+7
if n==2:
    print(0)
else:
    print((pow(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod))%mod)

Solution (Python):
def solve():

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

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

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

            
            
            
            
        return x * pow(y, mod-2, mod)%mod

    
    sigma_nCi = pow(2, n, mod)
    
    nCa = combination(n, a, mod)
    nCb = combination(n, b, mod)

    ans = sigma_nCi - 1 - nCa - nCb

    
    print(ans%mod)

if __name__ == '__main__':
    solve()

Solution (Python):
N, A, B = map(int, input().split())
mo = 1000000007
A_val = 1
for i in range(A):
    A_val = ((A_val * (N - i) * pow(i+1, mo-2, mo))) % mo
B_val = 1
for i in range(B):
    B_val = ((B_val * (N - i) * pow(i+1, mo-2, mo))) % mo
    
ans = (pow(2, N, mo) - 1 - A_val - B_val) % mo
print(ans)

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

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

count = pow(2, n, mod) - 1 - comb[a] - comb[b]
print(count % mod)

Solution (Python):
import math


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 comb(n,k):
    nCk = 1
    
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= mod

    
    for i in range(1,k+1):
        nCk *= pow(i,mod-2,mod)
        nCk %= mod
    return nCk

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



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

print(ans%mod)

Solution (Python):
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)

Solution (Python):
import math


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 comb(n,k):
    nCk = 1
    
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= mod

    
    for i in range(1,k+1):
        nCk *= pow(i,mod-2,mod)
        nCk %= mod
    return nCk

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



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

print(ans%mod)

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

def fermat(n, r, law):
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % law
        y = y * (i + 1) % law

    ans = x * pow(y, law - 2, law) % law
    return ans

print((pow(2,n,law)- fermat(n,a,law)-fermat(n,b,law)-1)%law)

Solution (Python):
def main():
    from math import factorial
    n, a, b = map(int, input().split())
    p = 1000000007

    
    n_all = pow(2, n, p) -1

    
    a_comb = 0      
    a_comb_x = 1    
    a_comb_y = 1    
    for i in range(n, n-a ,-1):
        a_comb_x *= i
        a_comb_x %= p
    a_comb_y = factorial(a)
    a_comb_y = pow(a_comb_y, p-2,p)
    a_comb = (a_comb_x * a_comb_y) % p

    b_comb = 0      
    b_comb_x = 1    
    b_comb_y = 1    
    for i in range(n, n-b ,-1):
        b_comb_x *= i
        b_comb_x %= p
    b_comb_y = factorial(b)
    b_comb_y = pow(b_comb_y, p-2,p)
    b_comb = (b_comb_x * b_comb_y) % p

    
    r = n_all - a_comb
    if r < 0:
        r += p
    r -= b_comb
    if r < 0:
        r += p
    print(r)

main()