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):
def cmb(n, r, mod):
    p, q = 1, 1
    for i in range(r):
        p *= n - i
        p %= mod
        q *= i + 1
        q %= mod
    
    return p * pow(q, mod - 2, mod)


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

print((pow(2, N, MOD) - cmb(N, a, MOD)-cmb(N, b, MOD)-1) % MOD)

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


def choose(x, y):
    v = 1
    for i in range(0, y):
        v = (v * (x - i) * pow(i + 1, m - 2, m)) % m
    return v


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

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()

nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']



show_flg = False


def modinv(a):
    return pow(a, MOD-2, MOD)


def cmb(n, r):
    p = 1
    c = 1
    for i in range(r):
        p *= (n - i)
        c *= (i + 1)
        p = p % MOD
        c = c % MOD
    return p * modinv(c) % MOD


def main():
    n, a, b = MI()
    first = cmb(n, a)
    second = cmb(n, b)
    ans = pow(2, n, MOD) - 1
    print((ans - first - second) % MOD)


if __name__ == '__main__':
    main()

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

Solution (Python):
import math
def main():
    m = (10 ** 9) + 7
    n, a, b = map(int, input().split())

    a_k = math.factorial(a)
    b_k = math.factorial(b)

    
    a_k = pow(a_k, m - 2, m)
    b_k = pow(b_k, m - 2, m)

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

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

    n_C_a = a_k * n_a
    n_C_b = b_k * n_b

    n_C_a = n_C_a % m
    n_C_b = n_C_b % m

    p = pow(2, n, m)

    print((p - n_C_a - n_C_b - 1)%m)
    return 0


if __name__ == '__main__':
    main()

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

MOD = (10**9 + 7)
from functools import reduce
from operator import mul

def mulMOD(x,y):
    return x*y%MOD

def nCr(n,r):
    num = reduce(mulMOD, range(n, n - r, -1))
    den = reduce(mulMOD, range(1, r + 1))
    return num * pow(den, MOD - 2, MOD) % MOD

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

Solution (Python):
n,a,b=map(int,input().split())
N=2*10**5+1
mod=10**9+7
inv_l=[0,1]
for i in range(2,N):
    inv_l+=[inv_l[mod%i]*(mod-int(mod/i))%mod]
def nCr(n,r):
    ret=1
    for i in range(r):
        ret=ret*(n-i)%mod*inv_l[i+1]%mod
    return ret
ans=1
double=2
n_=n
while n_:
    if n_%2==1:
        ans=ans*double%mod
    n_//=2
    double=double*double%mod
ans=(ans-nCr(n,a)-nCr(n,b)-1)%mod
print(ans)

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


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


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()

nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']



show_flg = False


def f(n):
    r = (n - 2)
    m = (4 * (1 - pow(2, r, MOD))) // (1 - 2)
    return (3 + m) % MOD


def modinv(a):
    return pow(a, MOD-2, MOD)


def cmb(n, r):
    p = 1
    c = 1
    for i in range(r):
        p *= (n - i)
        c *= (i + 1)
        p = p % MOD
        c = c % MOD
    return p * modinv(c) % MOD


def main():
    n, a, b = MI()
    first = cmb(n, a)
    second = cmb(n, b)
    ans = f(n)
    print((ans - first - second) % MOD)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n,a,b = map(int,input().split())
    MOD = 10**9 +7
    s = pow(2,n,MOD)-1
    P_ni = 1
    F_i = 1

    for i in range(1,b + 1):
        P_ni=P_ni*(n-i+1)%MOD
        F_i=F_i* i % MOD
        if i == a or i == b:
            s-=P_ni*pow(F_i,MOD-2,MOD)
    print(s%MOD)

if __name__=='__main__':
    main()

Solution (Python):
import sys
import heapq
import copy
import numpy as np
from collections import deque

md=10**9+7

def modinv(a,m):
    return pow(a,m-2,m)

def modFact(n,k):
    ret=1
    for i in range(k):
        enum=(n-i)%md
        denum=modinv(i+1,md)

        ret=(ret*(enum*denum)%md)%md
    
    return (ret+md)%md
        

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

print((pow(2,n,md)-1-modFact(n,a)-modFact(n,b)+md)%md)

Solution (Python):
def main():
    n,a,b = map(int,input().split())
    MOD = 10**9 +7
    s = pow(2,n,MOD)-1
    P_ni = 1
    F_i = 1


    for i in range(1,b + 1):
        P_ni=P_ni*(n-i+1)%MOD
        F_i=F_i* i % MOD
        if i == a or i == b:
            s-=P_ni*pow(F_i,MOD-2,MOD)



    print(s%MOD)

if __name__=='__main__':
    main()

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

Solution (Python):
mod=10**9+7
n,a,b=map(int,input().split())
pows=[2]
for _ in range(40):
  pows.append((pows[-1]**2)%mod)
ans=1
flag=format(n,'b')
if len(flag)<31:
  flag=(31-len(flag))*'0'+flag
flag=flag[::-1]
for i in range(31):
  if flag[i]=='1':
    ans*=pows[i]
    ans%=mod
ans-=1
rfacts=[pow(1,mod-2,mod)%mod,pow(1,mod-2,mod)%mod]
for i in range(2,2*(10**5)+1):
  rfacts.append((rfacts[-1]*pow(i,mod-2,mod))%mod)
if n<=2*10**5:
  fact=1
  for i in range(2,n+1):
    fact*=i
    fact%=mod
  ans-=(fact*rfacts[a]*rfacts[n-a])%mod
  ans%=mod
  ans-=(fact*rfacts[b]*rfacts[n-b])%mod
  ans%=mod
else:
  fact1=1
  for i in range(n,n-a,-1):
    fact1*=i
    fact1%=mod
  ans-=(fact1*rfacts[a])%mod
  ans%=mod
  fact2=1
  for i in range(n,n-b,-1):
    fact2*=i
    fact2%=mod
  ans-=(fact2*rfacts[b])%mod
  ans%=mod
print(ans)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, a, b = MAP()

def power(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x % mod
    elif y % 2 == 0:
        return power(x, int(y/2)) ** 2 % mod
    else:
        return power(x, int((y-1)/2)) ** 2 * x % mod
ans = power(2, n) - 1
    
a_max = 2 * 10 ** 5

fact = [1] * (a_max + 2)

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

def C(n, a):
    tmp = 1
    for i in range(n, n-a, -1):
        tmp = (tmp * i) % mod
    return tmp * power(fact[a], mod - 2)

print((ans - C(n, a) - C(n, b)) % mod)

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

Solution (Python):

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

mod = 10**9 + 7


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 power(x, mod-2)

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


ans = power(2, n) - 1

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

Solution (Python):
import sys, math

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

n, a, b = read_int()
M = pow(10, 9) + 7
sys.setrecursionlimit(300000)

def solve():
    ans = (pow(2, n, M) - 1) - kai(n, 0, a) * pow(kai(a, 0, a), M - 2, M) - kai(n, 0, b) * pow(kai(b, 0, b), M - 2, M)
    return ans % M

def kai(n, i, m):
    if i == m:
        return 1
    return (n * kai(n - 1, i + 1, m)) % M

if __name__ == "__main__":
    print(solve())

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

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

res = pow(2, n, MOD) - 1

dpa = {}
dpb = {}
factriala = 1
factrialb = n
for i in range(1, max(a, b)+1):
  if i in [a, b]:
    dpb[i] = factrialb
  factriala *= i
  factriala %= MOD
  factrialb *= n-i
  factrialb %= MOD
  if i in [a, b]:
    dpa[i] = factriala

def ncr_count(r):
  return dpb[r] * pow(dpa[r], MOD-2, MOD)

res = res - ncr_count(a) - ncr_count(b)

print(res%MOD)

Solution (Python):
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

n, a, b = read_int()
M = pow(10, 9) + 7
sys.setrecursionlimit(300000)
comk = [1 for _ in range(b + 2)]
def solve():
    ans = (pow(2, n, M) - 1) - kai(n, 0, a) * pow(kai(a, 0, a), M - 2, M) - kai(n, 0, b) * pow(kai(b, 0, b), M - 2, M)
    return ans % M

def kai(n, i, m):
    if i == m:
        return 1
    return (n * kai(n - 1, i + 1, m)) % M

if __name__ == "__main__":
    print(solve())

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

MOD = 10**9+7

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

ans = pow(2, N, MOD) - modcmb(N, a, MOD) - modcmb(N, b, MOD) - 1
print(ans % MOD)

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def inv(x):
    return pow(x, MOD-2, MOD)

def nPk(n,k):
    x = 1
    for a in range(n-k+1, n+1):
        x = x * a % MOD
    return x

def nCk(n,k):
    return nPk(n,k) * inv(kaijo[k])

MOD = 10**9+7

kaijo = [0] * 400020
kaijo[0] = 1
for i in range(1, len(kaijo)):
    kaijo[i] = kaijo[i-1] * i % MOD









n,a,b = get_nums_l()

nCa = nCk(n,a)
nCb = nCk(n,b)
ans = pow(2, n, MOD) - 1 - nCa - nCb
print(ans % (10**9 + 7))

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

mod = 10**9 + 7


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 power(x, mod-2)

mod_table = [-1] * (b+1)
mod_table[1] = 1
for i in range(2, b+1):
    mod_table[i] = (mod_table[i - 1] * (i)) % mod

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


ans = power(2, n) - 1

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

Solution (Python):



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


def solve(*args: str) -> str:
    n, a, b = map(int, args[0].split())
    mod = 10**9+7
    return str((pow(2, n, mod) - 1 - ncr(n, a, mod) - ncr(n, b, mod)) % mod)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

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


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

    return rtn


ans = (pow(2, n, MOD) - 1 - modcmb(n, a, MOD) - modcmb(n, b, MOD)) % MOD
print(ans if ans >= 0 else ans + MOD)

Solution (Python):
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
f = c = 1
l = iter((a,b))
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    a = b
    r -= c * pow(f, M - 2, M)
print(r % M)

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     


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

comb = [0 for _ in range(2*10**5 + 2)]
comb[0] = 1

for i in range(2*10**5+1):
    comb[i]

def NCMMod(n, a):
    cur = n
    for i in range(2, a+1):
        cur = cur * (n-i+1) // i
    return cur % mod


fac = [-1] * (10**7+1)
finv = [-1] * (10**7+1)
inv = [-1] * (10**7+1)

fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

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

def main():
    n, a, b = LI()
    comb[1] = n
    n_pow = power_func(2, n, mod)
    for i in range(2, 2*10**5+1):
        comb[i] = comb[i-1] * (n-i+1) * inv[i] % mod
    ans = n_pow - 1
    ans %= mod
    ans = ans - comb[a] - comb[b]
    ans %= mod
    print(ans)

main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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


def countComb(n, r, MOD=1e9 + 7):
    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 = pow(2, n, MOD) - 1

for k in [a, b]:
    ans -= countComb(n, k, MOD)

ans %= MOD

print(ans)

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

Solution (Python):
from math import factorial
 
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
c = 1
for i in range(b):
  c = c * (n - i) % M
  if i + 1 == a:
    r -= c * pow(factorial(a) % M, M - 2, M)
    a = b
print(r % M)

Solution (Python):
from math import factorial
 
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
c = 1
for i in range(b):
  c = c * (n - i) % M
  if i + 1 == a:
    r -= c * pow(factorial(a), M - 2, M)
    a = b
print(r % M)

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

Solution (Python):










import math
import statistics
import string

def intinput():
    return int(input())

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

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

def repeatsurplus(x,y,z): 
    ret = 1
    m = y
    tmp = x
    for i in range(100000):
        if m == 1:
            ret = (ret * tmp) % z
            break
        if m % 2 == 1:
            ret = (ret * tmp) % z
        m = m // 2
        tmp = (tmp * tmp) % z
    return(ret)

def factorialsurplus(x,y,z): 
    ret = 1
    for i in range(x, y+1):
        ret = (ret * i) % z
    return(ret)
    
    
    
n,a,b = splitintinput()
de = 10 ** 9 + 7
ans = repeatsurplus(2,n,de) - 1
ansa = factorialsurplus(n-a+1, n, de) * repeatsurplus(factorialsurplus(1, a, de), de-2, de)
ansb = factorialsurplus(n-b+1, n, de) * repeatsurplus(factorialsurplus(1, b, de), de-2, de)
print((ans-ansa-ansb+2*de)%de)

Solution (Python):
def cmd(n, r, D):
    r = min(r, n-r)
    upper = 1
    lower = 1
    counter = 1
    while counter <= r:
        upper = (upper * (n - counter +1)) % D
        lower = (lower * counter) % D
        counter = counter + 1
    return (upper * pow(lower, D - 2, D)) % D

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

N = pow(2, n, D)
P = cmd(n, a, D)
Q = cmd(n, b, D)
Ans = (N - 1 - P - Q) % D
print(Ans)

Solution (Python):
def d_bouquet(MOD=10**9 + 7):
    from functools import reduce
    N, A, B = [int(i) for i in input().split()]

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

    return (pow(2, N, MOD) - 1 - (comb(N, A) + comb(N, B))) % MOD

print(d_bouquet())

Solution (Python):
MOD = 10**9+7
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

def cmb(n,k,p):
    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

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


total = power_func(2,n,MOD)-1
print((total-cmb(n,a,MOD)-cmb(n,b,MOD))%MOD)

Solution (Python):




def modcmb(n,r,mod):
    upper=1
    for i in range(n-r+1,n+1,1):
        upper=(upper*i)%mod
    rfrac=1
    for i in range(1,r+1,1):
        rfrac=(rfrac*i)%mod
    pwrfrac=pow(rfrac,mod-2,mod)
    return (upper*pwrfrac)%mod

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

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

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

mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def com(n,k,mod=10**9+7):
    u = 1
    s = 1
    for i in range(n,n-k,-1):
        u = u*i % mod
    for i in range(k,0,-1):
        s = s*i % mod
    return u * modinv(s)

c = pow(2,n,mod)
c -= 1
c -= com(n,a)
c -= com(n,b)
print(c%mod)

Solution (Python):
def loop_pow(x,n,mod):
    if n==0:
        return 1
    if n%2==0:
        t=loop_pow(x,n//2,mod)
        return (t*t)%mod
    return x*loop_pow(x,n-1,mod)%mod

def com(N,K,mod):
    n=N
    k=K
    up=1
    down=1
    for _ in range(K):
        up*=n
        up%=mod
        n-=1
    for _ in range(K):
        down*=k
        down%=mod
        k-=1
    down=loop_pow(down,10**9+5,mod)
    return up*down%mod

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

if __name__=="__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





n,a,b=mii()

if n==2 and a==1 and b==2:
    print(0)
    exit()


def p_f(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
def nCk(n, k, mod=10 ** 9 + 7):
    if n < k:
        return 0
    k = min(k, n - k)
    numer = 1
    for x in range(n - k + 1, n + 1):
        numer = (numer * x) % mod
    denom = 1
    for x in range(1, k + 1):
        denom = (denom * x) % mod
    return numer * pow(denom, mod - 2, mod) % mod
 

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, a, b = MAP()

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

ans = power(2, n)-1

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

def C(n, a):
	tmp = 1
	for i in range(n, n-a, -1):
		tmp = (tmp*i)%mod
	return tmp*power(fact[a], mod-2)

print((ans-C(n, a)-C(n, b))%mod)

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

Solution (Python):
def loop_pow(x,n,mod):
    if n==0:
        return 1
    if n%2==0:
        t=loop_pow(x,n//2,mod)
        return (t*t)%mod
    return x*loop_pow(x,n-1,mod)

def com(N,K,mod):
    n=N
    k=K
    up=1
    down=1
    for _ in range(K):
        up*=n
        up%=mod
        n-=1
    for _ in range(K):
        down*=k
        down%=mod
        k-=1
    down=loop_pow(down,10**9+5,mod)
    return up*down%mod

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

if __name__=="__main__":
    main()

Solution (Python):
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

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

def comb(n, r, p):
    ret = 1
    while 1:
        if (r == 0):
            break
        N = n % p
        R = r % p
        if N < R:
            return 0
        for i in range(R):
            ret = ret * (N-i) % p
        imul = 1
        for i in range(R):
            imul = imul * (i+1) % p
        ret = ret * modinv(imul, p) % p
        n //= p
        r //= p
    return ret

mod = 10 ** 9 + 7
N, A, B = map(int, input().split())
tmp = (2 ** N - 1) % mod 
a = comb(N, A, mod)
b = comb(N, B, mod)
print(((tmp + mod) - a - b ) % mod)

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

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

MOD = 1000000007


def combination(n, r):
    r = min(r, n - r)

    num = 1
    den = 1

    for i in range(1, r + 1):
        num = (num * (n + 1 - i)) % MOD
        den = (den * i) % MOD

    return num * pow(den, MOD - 2, MOD) % MOD


def 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


s = func(2, n, MOD) - 1
xa = combination(n, a)
xb = combination(n, b)

p = (s - xa - xb) % MOD

if p < 0:
    print(p + MOD)
else:
    print(p)

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

def combMod(n, r, p):
    numer = 1
    denom = 1
    for i in range(1, r+1):
        numer = numer * (n-r+i) % p
        denom = denom * i % p
    return numer * pow(denom, p-2, p) % p

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

if __name__ == '__main__':
    resolve()

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

mod=10**9+7

J=pow(2,n,mod)
def find_power(n,mod):
    
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n):
    
    powlist=find_power(n,10**9+7)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist

C=find_inv_power(2*10**5+100)
if  True:
    c=1
    for i in range(a):
        c*=(n-i)
        c=c%mod
    c=c*C[a]
    c=c%mod
    d=1
    for i in range(b):
        d*=(n-i)
        d=d%mod
    d=d%mod
    d=d*C[b]
    print((J-c-d-1)%mod)

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

p = 10**9 + 7

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

ans = pow(2, n, p) - 1 - cmb(n, a, p) - cmb(n, b, p)

print(ans%p)

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

Solution (Python):
from sys import setrecursionlimit

setrecursionlimit(2 * 10 ** 9)

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

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


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


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


print(int(ans % mod))

Solution (Python):
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 ==a or i + 1 == b:
    r -= c * pow(f, M - 2, M)
print(r % M)

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

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

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):
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if a != i + 1 != b:
    continue
  r -= c * pow(f, M - 2, M)
print(r % M)