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):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

mod = 10**9+7

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

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

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

    return c

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,mod):
  if k>n-k:
    k=n-k
  c=1
  for i in range(n-k+1,n+1):
    c*=i
    c%=mod
  d=1  
  for i in range(1,k+1):
    d*=i
    d%=mod
  return (c*pow(d,mod-2,mod))%mod

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def com_once(n, r, MOD):
    if n < r or n < 0 or r < 0:
        return 0
    r = min(r, n - r)
    numer = denom = 1
    for i in range(r):
        numer = numer * (n - i) % MOD
        denom = denom * (i + 1) % MOD
    return numer * pow(denom, MOD - 2, MOD) % MOD


def main():
    n, a, b = map(int, read().split())

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

    print(ans)
    return


if __name__ == '__main__':
    main()

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

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

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

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

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

    return (c * pow(d, mod-2, mod)) % mod

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

ans %= mod

print(ans)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def mod_com_once(n, r, MOD):
    if n < r or n < 0 or r < 0:
        return 0
    r = min(r, n - r)
    numer = denom = 1
    for i in range(n - r + 1, n + 1):
        numer = numer * i % MOD
    for i in range(1, r + 1):
        denom = denom * i % MOD
    return numer * pow(denom, MOD - 2, MOD) % MOD


def main():
    n, a, b = map(int, read().split())

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

    print(ans)
    return


if __name__ == '__main__':
    main()

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=(2**n-1)%mod
aa=comb(n,a)%mod
bb=comb(n,b)%mod
ans-=aa+bb
print(ans%mod)

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

mod = 10 ** 9 + 7

ans = pow(2, n, mod) - 1
for i in [a, b]:
    num = 1
    den = 1
    for p in range(n, n-i, -1):
        num = num * p % mod
    for q in range(1, i+1):
        den = den * q % mod
    cmb = num * pow(den, mod-2, mod) % mod
    ans -= cmb
    ans %= mod
print(ans)

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

u = [1]
d = [1]
c = [1]
for i in range(1, b+1):
    u.append(u[-1] * (n-i+1) % MOD)
    d.append(d[-1] * i % MOD)
    
    c.append(u[-1] * pow(d[-1], MOD-2, MOD) % MOD)

print((pow(2, n, MOD) - c[a] - c[b] - 1) % MOD)

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

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

mod = 10 ** 9 + 7

def frac_rev(n, r):
  x = 1
  for i in range(n, n-r, -1):
    x = x * i % mod
  return x

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

print(( pow(2, n, mod) - 1 - frac_rev(n, a) * pow(frac(a), mod-2, mod) % mod - frac_rev(n, b) * pow(frac(b), mod-2, mod) % mod) % mod)

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

mod = 10 ** 9 + 7
N = min(n, 2 * 10**5)
fac = [1, 1]
finv = [1, 1]
inv = [0, 1]

def comb(n, r):
  return fac[n] * ( finv[r] * finv[n-r] % mod ) % mod
 
for i in range(2, N + 1):
  fac.append( ( fac[-1] * i ) % mod )
  inv.append( mod - ( inv[mod % i] * (mod // i) % mod ) )
  finv.append( finv[-1] * inv[-1]  % mod )

def frac_rev(n, r):
  x = 1
  for i in range(n, n-r, -1):
    x = x * i % mod
  return x

if n <= 2 * 10**5:
  print(( pow(2, n, mod) - 1 - comb(n, a) -comb(n, b) ) % mod)
else:
  print(( pow(2, n, mod) - 1 - frac_rev(n, a) * finv[a] % mod - frac_rev(n, b) * finv[b] % mod) % mod)

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

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

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

print((M-comb(a)-comb(b))%mod)

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]


def gcd(numbers): return func.reduce(frac.gcd, numbers)
def lcm(numbers): return func.reduce(LCM, numbers)
def inv(a): return pow(a, MOD-2, MOD) 
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans

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

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]


def gcd(numbers): return func.reduce(frac.gcd, numbers)
def lcm(numbers): return func.reduce(LCM, numbers)
def inv(a): return pow(a, MOD-2, MOD) 
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans

n,a,b = imap()
div,mod = divmod(n,10000)
allEvents = (2**10000%MOD)**div%MOD * 2**mod%MOD
ans = allEvents - comb(n,a) - comb(n,b) - 1
ans %= MOD
print(ans)

Solution (Python):
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]


def gcd(numbers): return func.reduce(frac.gcd, numbers)
def lcm(numbers): return func.reduce(LCM, numbers)
def inv(a): return pow(a, MOD-2, MOD) 
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans

n,a,b = imap()
div,mod = divmod(n,10000)
allEvents = (2**10000%MOD)**div%MOD * 2**mod%MOD
ans = allEvents - comb(n,a) - comb(n,b) - 1
ans %= MOD
print(ans)

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]

def lcm(a, b): return a * b // math.gcd(a, b)
def extgcd(a, b):
    if b:
        d, y, x = extgcd(b, a%b)
        y -= (a/b)*x
        return d, x, y
    else:
        return a, 1, 0


sys.setrecursionlimit(1000000)
MOD = 1000000007



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

    a1, a2 = 1, 1
    for i in range(1, a+1):
        a1 = a1 * (n - i + 1) % MOD
        a2 = a2 * i % MOD
    b1, b2 = 1, 1
    for i in range(1, b+1):
        b1 = b1 * (n - i + 1) % MOD
        b2 = b2 * i % MOD
    nca = a1 * pow(a2, MOD-2, MOD) % MOD
    ncb = b1 * pow(b2, MOD-2, MOD) % MOD

    print((pow(2, n, MOD) - 1 - nca - ncb) % MOD)

main()

Solution (Python):
from functools import reduce

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


def comb(N, A, MOD):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD


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

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

def comb(N, A, MOD):
    num = reduce(lambda x, y: x * y % MOD, range(N, N - A, -1))
    den = reduce(lambda x, y: x * y % MOD, range(1, A + 1))
    return num * pow(den, MOD - 2, MOD) % MOD

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

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



fact = {}
fact[n] = n
fact[n - 1] = fact[n] * (n - 1) % MOD

inv_fact = [0] * (max(a, b) + 1)
inv_fact[1] = 1

for i in range(2, max(a, b) + 1):
    fact[n - i] = fact[n - i + 1] * (n - i) % MOD
    inv_fact[i] = inv_fact[i - 1] * pow(i, -1, MOD) % MOD

subtrahend = 1 + fact[n - a + 1] * inv_fact[a] + fact[n - b + 1] * inv_fact[b]
minuend = pow(2, n, MOD)

print((minuend + 2 * MOD - subtrahend) % MOD)

Solution (Python):
from functools import reduce

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

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(lambda x, y: (x * y) % p, range(n, n - r, -1))
    denom = reduce(lambda x, y: (x * y) % p, range(1, r + 1))
    return (numer * pow(denom, p - 2, p)) % p

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

Solution (Python):
n,a,b=map(int,input().split())
MOD=10**9+7
afac=1
for i in range(1,a+1):
  afac=(i*afac)%MOD
afac=pow(afac,MOD-2,MOD)
bfac=1
for i in range(1,b+1):
  bfac=(i*bfac)%MOD
bfac=pow(bfac,MOD-2,MOD)
thing1=1
for i in range(n,n-a,-1):
  thing1=(i*thing1)%MOD
thing2=1
for i in range(n,n-b,-1):
  thing2=(i*thing2)%MOD
print((pow(2,n,MOD)-1-thing1*afac-thing2*bfac)%MOD)

Solution (Python):
class Modulo_Error(Exception):
    pass

class Modulo():
    def __init__(self,a,n):
        self.a=a%n
        self.n=n

    def __str__(self):
        return "{} (mod {})".format(self.a,self.n)

    
    def __pos__(self):
        return self

    def __neg__(self):
        return  Modulo(-self.a,self.n)

    
    def __eq__(self,other):
        if isinstance(other,Modulo):
            return (self.a==other.a) and (self.n==other.n)
        elif isinstance(other,int):
            return (self-other).a==0

    def __neq__(self,other):
        return not(self==other)
    
    
    def __add__(self,other):
        if isinstance(other,Modulo):
            if self.n!=other.n:
                raise Modulo_Error("異なる法同士の演算です.")
            return Modulo(self.a+other.a,self.n)
        elif isinstance(other,int):
            return Modulo(self.a+other,self.n)

    def __radd__(self,other):
        if isinstance(other,int):
            return Modulo(self.a+other,self.n)
        
    
    def __sub__(self,other):
        return self+(-other)

    def __rsub__(self,other):
        if isinstance(other,int):
            return -self+other
        
    
    def __mul__(self,other):
        if isinstance(other,Modulo):
            if self.n!=other.n:
                raise Modulo_Error("異なる法同士の演算です.")
            return Modulo(self.a*other.a,self.n)
        elif isinstance(other,int):
            return Modulo(self.a*other,self.n)
        
    def __rmul__(self,other):
        if isinstance(other,int):
            return Modulo(self.a*other,self.n)
        
    
    def Modulo_Inverse(self):
        x0, y0, x1, y1 = 1, 0, 0, 1
        a,b=self.a,self.n
        while b != 0:
            q, a, b = a // b, b, a % b
            x0, x1 = x1, x0 - q * x1
            y0, y1 = y1, y0 - q * y1

        if a!=1:
            raise Modulo_Error("{}の逆数が存在しません".format(self))
        else:
            return Modulo(x0,self.n)
        
    
    def __truediv__(self,other):
        return self*other.Modulo_Inverse()

    
    def __pow__(self,m):
        u=abs(m)

        r=Modulo(1,self.n)

        while u>0:
            if u%2==1:
                r*=self
            self*=self
            u=u>>1

        if m>=0:
            return r
        else:
            return r.Modulo_Inverse()


M=10**9+7
n,a,b=map(int,input().split())
C=[Modulo(1,M)]*(b+1)

for k in range(1,b+1):
    C[k]=C[k-1]*Modulo(n-(k-1),M)/Modulo(k,M)

print((Modulo(2,M)**n-(C[a]+C[b])-1).a)

Solution (Python):
from math import factorial

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

up=[1]
down=[1]
comb=[1]
for i in range(1,b+1):
    up.append(up[i-1]*(n-i+1)%mod)
    down.append(down[i-1]*i%mod)
    comb.append(up[i]*pow(down[i],mod-2,mod)%mod)

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

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")




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

def cmb(n, r, M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return (g1[n] * g2[r] * g2[n-r]) % M

g1 = [None] * (N+1) 
g2 = [None] * (N+1) 
inverse = [None] * (N+1) 
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 

for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M 
    g2[i] = (g2[i-1] * inverse[i]) % M 

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

    res *= g2[r]
    res %= M
    return res
    
ans = pow(2, n, M) - cmb2(n,a,M) - cmb2(n,b,M) - 1
print(ans%M)

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

def powmod(a,n,m): 
    ans=1
    while n!=0:
        if n&1: ans=ans*a%m
        a=a*a%m
        n>>=1
    return ans%m

def fact(a,b):
    ans=1
    for i in range(a,b+1): ans=ans*i%MOD
    return ans

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

ans=powmod(2,n,MOD)-1
ta1=fact(n-a+1,n)
tb1=fact(n-b+1,n)
ta2=pow(fact(1,a),MOD-2,MOD)
tb2=pow(fact(1,b),MOD-2,MOD)
a=ta1*ta2%MOD
b=tb1*tb2%MOD
print((ans-a-b)%MOD)

Solution (Python):
n,a,b=map(int,input().split())
num9=10**9+7
num2=pow(2,n,num9)-1
def cul(num1,num2):
    num=1
    for i in range(num1-num2+1,n+1):
        num*=i
        num%=num9
    for i in range(1,num2+1):
        num*=pow(i,num9-2,num9)
        num%=num9
    return num
print((num2-cul(n,a)-cul(n,b))%num9)

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

up = 1
bo = 1
for i in range(b):
    up = up*(n-i)%mod
    bo = bo*(i+1)%mod
    if i == a-1:
        acombs = up*pow(bo, mod-2, mod)%mod

bcombs = up*pow(bo, mod-2, mod)%mod

print((ans - acombs - bcombs)%mod)

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

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

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

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

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

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

Solution (Python):
import math
n, a, b = map(int, input().split())
mod = 10**9 + 7
s = pow(2, n, mod) - 1
def cal(n, r):
  p = 1
  q = 1
  for i in range(r):
    p = p*(n-i)%mod
    q = q*(i+1)%mod
  return p*pow(q, mod-2, mod)%mod
print((s - cal(n, a) - cal(n, b))%mod)

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

mod = pow(10,9)+7
ans = pow(2,n,mod)
ans -= 1
def choose(n,k):
    x,y = 1,1
    for i in range(1,k+1):
        x *= (n-i+1)
        x %= mod
        y *= i
        y %= mod
    
    x *= pow(y,mod-2,mod)
    x %= mod
    return x

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

Solution (Python):
from functools import reduce

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

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

    print((ans - comb(n,a,p) - comb(n,b,p)) % p)

def comb(n, r, p):
    r = min(r, n-r)
    if r == 0:
        return 1
    
    num = reduce(lambda x, y: (x * y) % p, range(n, n - r, -1))
    den = reduce(lambda x, y: (x * y) % p, range(1, r + 1))

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

if __name__ == '__main__':
    main()

Solution (Python):

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


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

m = 1000000007

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

Solution (Python):

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


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

m = 1000000007

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

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

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

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

Solution (Python):
def main():
    n, a, b = map(int, input().split())
    p = 10 ** 9 + 7
    r = pow(2, n, p) - 1
    if (n - a) < a:
        a = n - a
    if (n - b) < b:
        b = n - b
    fac_na = 1
    for i1 in range(n, n - a, -1):
        fac_na = (fac_na * i1) % p
    fac_nb = 1
    for i1 in range(n, n - b, -1):
        fac_nb = (fac_nb * i1) % p
    fac_a = 1
    for i1 in range(1, a+1):
        fac_a = (fac_a * i1) % p
    fac_b = 1
    for i1 in range(1, b+1):
        fac_b = (fac_b * i1) % p

    an = fac_na * pow(fac_a, p-2, p)
    bn = fac_nb * pow(fac_b, p-2, p)
    an = an % p
    bn = bn % p
    r -= an
    if r < 0:
        r += p
    r -= bn
    if r < 0:
        r += p
    if r < 0:
        r += p
    print(int(r))


if __name__ == '__main__':
    main()

Solution (Python):
def combination_mod(n, r, mod):
    x = 1
    y = 1

    for i in range(r):
        x *= n - i
        y *= r - i
        x %= mod
        y %= 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) - 1
ans %= mod
ans -= combination_mod(n, a, mod)
ans %= mod
ans -= combination_mod(n, b, mod)
ans %= mod

print(ans)

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

def repeatSquaring(N, P, M):
    if P <= 0:
        return 1
    if (P &0x01) == 0:
        ans = repeatSquaring(N, (P>>1), M)
        return ans*ans % M

    return N*repeatSquaring(N, P-1, M) % M

def seki(aa, bb):
    res = 1
    for k in range(aa, bb+1):
        res *= k
        if res >= modz:
            res %= modz
    return res

def CC(aa, nn):
    ss = repeatSquaring(seki(1, aa), modz - 2, modz)
    return seki(nn-aa + 1, nn)*ss % modz

total = repeatSquaring(2, N, modz) - 1
total -= CC(a, N)
if total < 0: total += modz

total -= CC(b, N)
if total < 0: total += modz

print(int(total))

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

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

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

print((ans - comb(a) - comb(b))%mod)

Solution (Python):
def main():
    from functools import reduce
    def a_comb_mod(n, r):
        mod = 1000000007
        r = min(n-r,r)
        if r == 0: return 1
        numer = reduce(lambda x, y: x * y % mod, range(n, n - r, -1), 1)
        denom = reduce(lambda x, y: x * y % mod, range(1,r + 1), 1)
        denom_inv = pow(denom, mod - 2, mod)
        return numer * denom_inv % mod

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

if __name__ == '__main__':
    main()

Solution (Python):
k = 72
kk = k // 4
K = 1<<k
nu = lambda L: int("".join([hex(K+a)[3:] for a in L[::-1]]), 16)
st = lambda n: hex(n)[2:]
li = lambda s, l, r: [int(a, 16) % P if len(a) else 0 for a in [s[-(i+1)*kk:-i*kk] for i in range(l, r)]]

def grow(d, v, h):
    h += [0] * d
    f = [(-1 if (i+d) % 2 else 1) * fainv[i] * fainv[d-i] % P * h[i] % P for i in range(d+1)]
    nuf = nu(f)
    a = d * inv[v] % P
    t = [1] * (3*d+3)
    for i in range(1, 3*d+3): t[i] = t[i-1] * (a - d + i - 1) % P
    ti = [1] * (3*d+3)
    ti[-1] = pow(t[-1], P-2, P)
    for i in range(1, 3*d+3)[::-1]: ti[i-1] = ti[i] * (a - d + i - 1) % P
    iv = [1] * (3*d+3)
    for i in range(1, 3*d+3):
        iv[i] = ti[i] * t[i-1] % P

    
    g = [inv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = fg[i] * fa[d+i+1] % P * fainv[i] % P

    
    g = [iv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d+1):
        h[i] = h[i] * (fg[i] * t[d+i+1] % P * ti[i] % P) % P

    
    g = [iv[i] for i in range(d+2, 3*d+3)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = h[i+d+1] * (fg[i] * t[2*d+i+2] % P * ti[d+i+1] % P) % P

    return h


def create_table(v):
    s = 1
    X = [1, v+1]
    while s < v:
        X = grow(s, v, X)
        s *= 2

    table = [1]
    for x in X:
        table.append(table[-1] * x % P)
    return table

def fact(i, table):
    a = table[i//v]
    for j in range(i//v*v+1, i+1):
        a = a * j % P
    return a

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

v = 1 << (N.bit_length() + 1) // 2
fa = [1] * (2*v+2)
fainv = [1] * (2*v+2)
for i in range(2*v+1):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(2*v+1)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
inv = [0] * (2*v+2)
for i in range(1, 2*v+2):
    inv[i] = fainv[i] * fa[i-1] % P

T = create_table(v)
C = lambda n, k: fact(n, T) * pow(fact(k, T) * fact(n-k, T), P-2, P) % P
 
print((pow(2, N, P) - 1 - C(N, A) - C(N, B)) % P)

Solution (Python):
k = 72
kk = k // 4
K = 1<<k
nu = lambda L: int("".join([hex(K+a)[3:] for a in L[::-1]]), 16)
st = lambda n: hex(n)[2:]
li = lambda s, l, r: [int(a, 16) % P if len(a) else 0 for a in [s[-(i+1)*kk:-i*kk] for i in range(l, r)]]

def grow(d, v, h):
    h += [0] * d
    f = [(-1 if (i+d) % 2 else 1) * fainv[i] * fainv[d-i] % P * h[i] % P for i in range(d+1)]
    nuf = nu(f)
    a = d * inv[v] % P
    t = [1] * (3*d+3)
    for i in range(1, 3*d+3): t[i] = t[i-1] * (a - d + i - 1) % P
    ti = [1] * (3*d+3)
    ti[-1] = pow(t[-1], P-2, P)
    for i in range(1, 3*d+3)[::-1]: ti[i-1] = ti[i] * (a - d + i - 1) % P
    iv = [1] * (3*d+3)
    for i in range(1, 3*d+3):
        iv[i] = ti[i] * t[i-1] % P

    
    g = [inv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = fg[i] * fa[d+i+1] % P * fainv[i] % P

    
    g = [iv[i] for i in range(1, 2*d+2)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d+1):
        h[i] = h[i] * (fg[i] * t[d+i+1] % P * ti[i] % P) % P

    
    g = [iv[i] for i in range(d+2, 3*d+3)]
    fg = li(st(nuf * nu(g)), d, d * 2 + 1)
    for i in range(d):
        h[i+d+1] = h[i+d+1] * (fg[i] * t[2*d+i+2] % P * ti[d+i+1] % P) % P

    return h


def create_table(v):
    s = 1
    X = [1, v+1]
    while s < v:
        X = grow(s, v, X)
        s *= 2

    table = [1]
    for x in X:
        table.append(table[-1] * x % P)
    return table

def fact(i, table):
    a = table[i//v]
    for j in range(i//v*v+1, i+1):
        a = a * j % P
    return a

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

v = 1 << (N.bit_length() + 1) // 2
fa = [1] * (2*v+2)
fainv = [1] * (2*v+2)
for i in range(2*v+1):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(2*v+1)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
inv = [0] * (2*v+2)
for i in range(1, 2*v+2):
    inv[i] = fainv[i] * fa[i-1] % P

T = create_table(v)
C = lambda n, k: fact(n, T) * pow(fact(k, T) * fact(n-k, T), P-2, P) % P
 
print((pow(2, N, P) - 1 - C(N, A) - C(N, B)) % P)

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

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

print((ans - comb(a) - comb(b))%mod)

Solution (Python):
from functools import reduce

def cmb(n,r,p):
    r = min(n-r,r)
    if r == 0:
        return 1
    num = reduce(lambda x, y: (x*y)%p, range(n,n-r,-1))
    den = reduce(lambda x, y: (x*y)%p, range(1,r+1))
    return (num * pow(den,p-2,p)) % p

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

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

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

print((sum-comb(a)-comb(b))%mod)

Solution (Python):
mod=10**9+7
import math
import sys
from collections import deque
import heapq
import copy
import itertools
from itertools import permutations
from itertools import combinations
import bisect
def mi() : return map(int,sys.stdin.readline().split())
def ii() : return int(sys.stdin.readline().rstrip())
def i() : return sys.stdin.readline().rstrip()
n,a,b=mi()
c=pow(2,n,mod)-1
fact=[1]*(2*10**5+1)
for i in range(1,2*10**5+1):
  fact[i]=(fact[i-1]*i)%mod
def nCk(n,k):
  h=1
  for i in range(k):
    h=(h*(n-i))%mod
  x=h*pow(fact[k],mod-2,mod)
  return(x)
print((c-nCk(n,a)-nCk(n,b))%mod)