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 powmod(x, y, mod):
    if y == 0:
        return 1
    return (((powmod(x, y >> 1, mod) ** 2) % mod) * x ** (y & 1)) % mod


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


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

Solution (Python):
n, a, b = [int(i) for i in input().split()]
mod = 10**9 + 7

total = (2**n - 1) % mod
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

at = combination(n,a)
bt = combination(n,b)

result = total - at - bt
result %= mod
if result < 0:
  result += mod
print(result)

Solution (Python):
mod = int(1e9) + 7
n, a, b = map(int, input().split())

def aaa(base, n):

    ans = 1
    nn = n
    while True:
    
        if nn == 0:
            break
        if nn % 2 == 0:
            base = base ** 2
            base = base % mod + mod
            nn /= 2
        else:
            ans *= base
            ans = ans % mod + mod
            nn -= 1
    return ans

xn = aaa(2, n)

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

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

def div(a, b):
    return mul(a, power(b, mod-2))


def fac(start, length, mod):
    x = 1
    for k in range(start, start + length):
        x *= k
        x %= mod
    return x

aa = fac(n - a + 1 , a, mod)
aaa = fac(1, a, mod)
xa = div(aa, aaa)
if aa == 0:
    if aaa == 0:
        xa = 1


bb = fac(n - b + 1 , b, mod)
bbb = fac(1, b, mod)
xb = div(bb, bbb)
if bb == 0:
    if bbb == 0:
        xb = 1
        

x = xn - xa - xb - 1
x = x % mod
if x < 0:
    x += mod
print(x)

Solution (Python):

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

mod = int(1e9+7)
ans = 1

def calc(n,mod):
  if n>25:
    return ( (calc(n//2,mod) **2 ) * (2 if n%2 == 1 else 1) )% mod
  else:
    return (2**n) % mod
    
ans = calc(n,mod)
  
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
  
a1 = 1
for i in range(1,a+1):
  a1 = int((a1*(n-a+i))*modinv(i,mod))%mod

b1 = 1
for i in range(1,b+1):
  b1 = int((b1*(n-b+i))*modinv(i,mod))%mod
  
print(int((ans-1-b1-a1))%mod)

Solution (Python):

def pow_r(x, n,s):
    """
    O(log n)
    """
    x=x%s
    if n == 0:
        return 1

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

    return K * x%s
n,a,b=map(int,input().split())
s=10**9+7
ma=1
for i in range(a):
    ma*=(n-i)
    ma%=s
ama=ma
for i in range(a,b,1):
    ma*=(n-i)
    ma%=s
bma=ma

mi=1
for i in range(a):
    mi*=(i+1)
    mi%=s
ami=mi
for i in range(a,b,1):
    mi*=(i+1)
    mi%=s
bmi=mi

if n==2:
    print(0)
else:
    print((pow_r(2,n,s)%s-(ama*pow_r(ami,s-2,s)%s+bma*pow_r(bmi,s-2,s)%s)-1)%s)

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

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
mod=10**9+7
      
def cmb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

print( ((2 ** n -1) - cmb(n, a, mod) - cmb(n, b, mod)) %mod)

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

if n == 2:
    print(0)
    exit()

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


def cmb(r, mod):
    if r<0:
        return 0
    return g1[r-1] * g2[r] % mod

mod = 10**9+7 
N = 2 * 10 ** 5
g1 = [n % mod] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
    g1.append((g1[-1] * (n - i + 1)) % mod)
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans -= cmb(a, mod)
ans -= cmb(b, mod)
ans %= mod

print(ans)

Solution (Python):
MOD = 10**9+7
N ,a, b = map(int, input().split())
nCr = 1
A=1
B=1
oa = 1
for r in range(b):
    nCr_1 = nCr * ((N - r) * pow(r + 1,MOD-2,MOD))%MOD
    nCr_1 %= MOD
    nCr = nCr_1
    if r==a-1:
      A = nCr_1
    if r==b-1:
      B = nCr_1
ans = pow(2,N,MOD)-1-A-B
print(ans%MOD)

Solution (Python):
from math import factorial
n, a, b = map(int, input().split())
if n == 2 and a == 1 and b == 2:
    print(0)
    exit()

mod = 10**9 + 7

limit = 0
m = n
while m > 0:
    m //= 2
    limit += 1


def solve(n):
    ans = 1
    p = 2
    for i in range(limit):
        
        if (n >> i) & 1 == 1:
            ans = (ans * p) % mod
        p = (p * p) % mod
    
    return ans

ans = solve(n)









def gcd1(a, b):
    def calc(a, b, first, second):
        if a < b:
            a, b = b, a
        r = a % b
        q = -(a - r)//b
        if r == 0:
            return b, second
        
        first = [x + q * y for (x, y) in zip(first, second)]
        return calc(r, b, second, first)
    first = [1, 0]
    second = [0, 1]
    return calc(a, b, first, second)

def mod_inv(n, mod):
    table = gcd1(n, mod)
    inv = table[1][1]
    if inv < 0:
        inv += mod
    return inv

def cmb(n, r, mod):
    ans = 1
    for i in range(r):
        ans = (ans * n) % mod
        n -= 1
    ans1 = 1
    for i in range(1, r + 1):
        ans1 = (ans1 * i) % mod
    return ans * mod_inv(ans1, mod)












ac = cmb(n, a, mod)
bc = cmb(n, b, mod)


print((mod + ans - ac - bc - 1) % mod)

Solution (Python):

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def main():
  n,a,b=map(int,input().split())
  mod=10**9+7
  cmb_l=[1 for _ in range(b+1)]
  for i in range(b):
    cmb_l[i+1]=(cmb_l[i]*(n-i)%mod*mod_inv(i+1,mod))%mod

  x=cmb_l[a]
  y=cmb_l[b]
  return((2**n-x-y-1) % mod)
print(main())

Solution (Python):
import sys

input=sys.stdin.readline

def facto(x, y, mod):
	re = 1
	for i in range(y, x+1):
		re *= i
		re %= mod
	print(re, file=sys.stderr)
	return re

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    
    return facto(n, n-r+1, mod) * g2[r] % mod
    

mod = 10**9+7 
NN = 2 * 10**5
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, NN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


def main():
	N,A,B=map(int,input().split())
	
	
	
	M = 10**9 + 7
	
	res = pow(2, N, M) - 1
	res = (res+M) % M
	res -= cmb(N, A, M)
	res = (res+M) % M
	res -= cmb(N, B, M)
	res = (res+M) % M
	
	print(res)


main()

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


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

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


def comb(r):
    res = up[r - 1] * pow(down[r - 1], mod - 2, mod) % mod
    return res


ans = (ans - comb(A) + mod) % mod
ans = (ans - comb(B) + mod) % mod
print(ans)

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

fac1 = [n] * (max + 1)
fac2 = [1] * (max + 1)
for i in range(2, max + 1):
    fac1[i] = fac1[i - 1] * (n - i + 1) % mod
    fac2[i] = fac2[i - 1] * i % mod
c = fac1[a] * pow(fac2[a], mod - 2, mod) % mod
d = fac1[b] * pow(fac2[b], mod - 2, mod) % mod

print((pow(2, n, mod) - c - d - 1) % mod)

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

mod = 10**9+7


def inv(a, mod):
    r = [1, 0, a]
    w = [0, 1, mod]
    while w[2] != 1:
        q = r[2]//w[2]
        r_new = [r[0]-q*w[0], r[1]-q*w[1], r[2]-q*w[2]]
        r = w
        w = r_new
    x, y = w[0], w[1]    
    return (mod+x % mod) % mod


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

fact[0] = fact[1] = 1
ifact[0] = ifact[1] = 1

for i in range(2, max_num):
    fact[i] = fact[i-1] * i % mod
    ifact[i] = ifact[i-1] * inv(i, mod) % mod


def comb(x, y):
    tmp = 1
    for i in range(1, y+1):
        tmp *= (n+1-i)
        tmp %= mod
    tmp *= ifact[y]
    tmp %= mod
    return tmp

po = [2]
for i in range(1, 100):
    po.append((po[-1]**2) % mod)

nb = list(bin(n)[2:])[::-1]
n2 = 1

for i in range(len(nb)):
    if nb[i] == '1':
        n2 *= po[i]

n2 %= mod

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

Solution (Python):
n,a,b = map(int,input().split())
mod = 10**9+7
import sys
sys.setrecursionlimit(10**9)
ans = 1
now = n
def power(x, y):
  if   y == 0     : return 1
  elif y == 1     : return x % mod
  elif y % 2 == 0 : return power(x, y//2)**2 % mod
  else            : return power(x, y//2)**2 * x % mod
ans = power(2,n)
com = [0]*(b+1)
com[0]=1
N = b+1
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]
for i in range(1,b+1):
  com[i] = ((com[i-1]*(n-i+1))%mod)*(inv_t[i])%mod
ans -= com[a]+com[b]+1
print(ans%mod)

Solution (Python):
N, A, B = map(int, input().split())

MOD = 10 ** 9 + 7

binary_map = [(1, 2)]

while binary_map[-1][0] < N:
    binary_map.append((binary_map[-1][0]*2, binary_map[-1][1]**2 % MOD))


def modinv(a):
    b = MOD
    u = 1
    v = 0
    while b > 0:
        t = a // b
        a -= t * b
        c = a
        a = b
        b = c

        u -= t * v
        c = u
        u = v
        v = c
    u %= MOD
    if u < 0:
        u += MOD
    return u


def get_exp(mul_num):
    ret = 1
    index = -1
    while mul_num > 0:
        while mul_num < binary_map[index][0]:
            index -= 1
        mul_num -= binary_map[index][0]
        ret = (ret * binary_map[index][1]) % MOD
    return ret


bouquet_max = get_exp(N)

P_table = [N] * B

for i in range(B - 1):
    P_table[i + 1] = (P_table[i] * (N - i - 1)) % MOD

modinvexp_table = [1] * B

for i in range(1, B):
    modinvexp_table[i] = modinvexp_table[i - 1] * modinv(i + 1) % MOD

remove_a = P_table[A - 1] * modinvexp_table[A - 1] % MOD
remove_b = P_table[B - 1] * modinvexp_table[B - 1] % MOD

print((bouquet_max - P_table[A - 1] * modinvexp_table[A - 1] - P_table[B - 1] * modinvexp_table[B - 1] - 1) % MOD)

Solution (Python):
import sys
from pprint import pprint

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    
    return [w[0],w[1]]

  
def mod_inv(a,m):
    if a == 0:
        return 0
    x = extgcd(a,m)[0]
    return (m+x%m)%m


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

if __name__ == '__main__':
    mod = 10**9 + 7
    n, a, b = map(int, sys.stdin.readline().strip().split(" "))
    

    denominator = 1
    numerator = 1
    for i in range(1, a+1):
        
        numerator *= (n-i+1)
        numerator %= mod
        denominator *= i
        denominator %= mod
    
    cmb_a = numerator * mod_inv(denominator, mod)
        
    denominator = 1
    numerator = 1
    for i in range(1, b+1):
        
        numerator *= (n-i+1)
        numerator %= mod
        denominator *= i
        denominator %= mod
    
    cmb_b = numerator * mod_inv(denominator, mod)
        
    
    ans = pow(2, n, mod) - 1 - cmb_a - cmb_b
    print(ans % mod)

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

def cmb(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])
            result %= MOD

    return result%MOD

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

if __name__ == '__main__':
    print(solve()%MOD)

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

p = 10 ** 9 + 7

binom = n 
ans = 0 if a == 1 or b == 1 else n


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


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

    for i in range(2, k + 1):
        numer = numer * (n - i + 1) % p
        inv.append(( inv[p % i] * (p - p//i) ) % p ) 
        invfct_k = invfct_k * inv[-1] % p

    if k == 0:
        return 1
    elif k == 1:
        return n
    else:
        return numer * invfct_k % p

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

print(ans)

Solution (Python):
import math
n,a,b = map(int,input().split())
mod = 10**9+7
k = 2
def Base_10_to_n(X,k):
  if (int(X/k)):
    return Base_10_to_n(int(X/k),k)+str(X%k)
  return str(X%k)
STR = Base_10_to_n(n,k)
ans = 1
cur = 2
for i in range(len(STR)):
    if STR[len(STR)-1-i] == '1':
        ans *= cur
        ans = ans%mod
    cur *= cur
    cur %= mod
    
ans -= 1
ans = ans%mod
L = [a,b]
cur = n
cur2 = n
for i in range(1,a):
    cur *= (n-i)*(pow(i+1, mod-2, mod))
    cur %= mod
for i in range(1,b):
    cur2 *= (n-i)*(pow(i+1, mod-2, mod))
    cur2 %= mod
cur %= mod
cur2 %= mod
ans -= cur
ans -= cur2
if ans < 0:
    while ans < 0:
        ans += mod
print(ans)

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

MOD = 1000000007


def combination(n, r, mod=10 ** 9 + 7):
    n1, r = n + 1, min(r, n - r)
    numer = denom = 1

    for i in range(1, r + 1):
        numer = (numer * (n1 - i)) % mod
        denom = (denom * i) % mod
    return numer * pow(denom, mod - 2, mod) % mod


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):
MAX_NUM = 2 * (10**5)+ 1
MOD = 10**9+7

fac  = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv  = [0 for _ in range(MAX_NUM)]

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

for i in range(2,MAX_NUM):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def combinations(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    res = 1
    for i in range(n, n - k, -1):
      res = (res * i) % MOD

    res = (res * finv[k]) % MOD

    return res

n, a, b = map(int, input().split())
if n == 2:
  print(0)
  exit(0)

sum = pow(2, n, MOD) - 1
sum = (sum - combinations(n, a)) % MOD
sum = (sum - combinations(n, b)) % MOD

print(sum)

Solution (Python):
def f(x,r,p):
  ans=1
  for i in range(r):
    ans=(ans*(x-i))%p
  return ans
def power_func(a,b,p):
  if b==0:
    return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return (d*d)%p
  else:
    return (a*power_func(a,b-1,p))%p
n,a,b=map(int,input().split())
mod=10**9+7
a=min(a,n-a)
b=min(b,n-b)
ca=f(n,a,mod)*power_func(f(a,a,mod),mod-2,mod)
cb=f(n,b,mod)*power_func(f(b,b,mod),mod-2,mod)
ans=(-1+power_func(2,n,mod)-ca-cb)%mod
print(ans)

Solution (Python):
from bisect import bisect_right, bisect_left
from collections import Counter, deque
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import groupby, permutations, combinations, product
from sys import stdin, stderr





def gcd(x, y):
    return x if y == 0 else gcd(y, x % y)





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



def lcm(x, y):
    m = gcd(x, y)
    return (x // m) * (y // m)


def mod_fac(n, r):
    mod = 10 ** 9 + 7
    res = 1
    for i in range(r):
        res = res * (n - i) % mod
    return res


def mod_pow(x, n):
    res = 1
    mod = 10**9 + 7
    while n > 0:
        if n % 2 == 1:
            res *= x
            res %= mod
        x *= x
        x %= mod
        n //= 2
    return res


def mod_comb(n, r):
    r = min(r, n-r)
    mod = 10 ** 9 + 7
    res = mod_fac(n, r)
    return res * mod_pow(mod_fac(r, r), mod - 2) % mod


def main():
    mod = 10**9 + 7
    n, a, b = [int(x) for x in input().split()]
    ret = mod_pow(2, n) - 1
    
    ret -= mod_comb(n, a)
    if ret < 0:
        ret += mod
    ret -= mod_comb(n, b)
    if ret < 0:
        ret += mod
    return ret


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

Solution (Python):
def modpow(a,b,mod):
    ans=1
    a=a%mod
    while b>0:
        if b%2==1:
            ans=(ans*a)%mod
        a=(a**2)%mod
        b=b//2
    return ans

N,A,B=map(int,input().split())

ans=modpow(2,N,10**9+7)-1
c=1
d=1
for i in range(A):
  c=(c*(N-i))%(10**9+7)
for i in range(A):
  d=(d*(i+1))%(10**9+7)
d=modpow(d,10**9+5,10**9+7)
ans-=(c*d)%(10**9+7)
c=1
d=1
for i in range(B):
  c=(c*(N-i))%(10**9+7)
for i in range(B):
  d=(d*(i+1))%(10**9+7)
d=modpow(d,10**9+5,10**9+7)
ans-=(c*d)%(10**9+7)
while ans<0:
  ans+=10**9+7
print(ans)

Solution (Python):



from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe




def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(x):
    print(x,file=sys.stderr)
def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)

def pin(type=int):
    return map(type,input().split())


def modular_w_binary_method (n,m,p):
    ans=1 if n>0 else 0
    while(p>0):
        if p%2==1:
            ans=(ans*n)%m
        n=(n**2)%m
        p//=2
    return ans

"""
    フェルマーの小定理より a**(p)%p==a isTrue
    これを利用すれば a**(p-2)%p==a**(-1) isTrue
    元と逆元とをかけてpで割れば1が余るよ！
"""
def modular_inverse(a,prime):
    return(modular_w_binary_method(a,prime,prime-2))



def conbination(n,a,mod=0):
    
    res=1 
    for s in range(a):
        res=(res*(n-s)*(modular_inverse(s+1,mod)))%mod

        
    return res
"""
"""




bigmod=(10**9)+7



n,a,b=pin()
an=0

allcombination=modular_w_binary_method(2, bigmod,n)
ans= allcombination -1 %bigmod
A=conbination(n,a,bigmod)
B=conbination(n,b,bigmod)
print((ans-A-B)%bigmod)



"""


"""
"""
お前カッコ閉じるの忘れてるだろ
"""

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


mod = 1000000007

inv = [1] * 222222





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

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

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

print(ans)

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

M = 10 ** 9 + 7

def pow2(n):
    pow2s = [2]
    i = 1
    while 2 ** i <= n:
        pow2s.append(pow2s[-1] ** 2 % M)
        i += 1
    r = 1
    for i in range(len(pow2s)):
        if n & (1 << i) != 0:
            r = (r * pow2s[i]) % M
    return r

def fact(n):
    r = 1
    for i in range(1, n + 1):
        r = (r * i) % M
    return r

def inv(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 x0

def comb(n, k):
    r1 = 1
    for i in range(k):
        r1 = r1 * (n - i) % M
    r2 = 1
    for i in range(k):
        r2 = r2 * (i + 1) % M
    return r1 * inv(r2, M) % M
r = pow2(n) - 1 - comb(n, a) - comb(n, b)
while r < 0:
    r += M
print(r)

Solution (Python):
def nCr(n, r):
    mod=10**9+7
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod

def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res

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

ans=(power_func(2,n,10**9+7)-1)-nCr(n,a)-nCr(n,b)

if ans<0:
       while ans<0:
              ans+=10**9+7
       print(ans)
else:
       print(ans)

Solution (Python):

import itertools
import sys
import math

sys.setrecursionlimit(10**9)

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

def main():
    N, a, b = map(int,input().split())

    
    nCa = comb(N,a)
    nCb = comb(N,b)

    _, ans = divmod(2**N-1 - nCa - nCb,10**9+7)
    print(ans)

if __name__ == "__main__":
  main()

Solution (Python):
mod = int(1e9 + 7)
def cmb(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])
            result %= mod

    return result


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

base = 1
waru = 1000
syou = n // waru
amari = n % waru
kakeru = 2**waru % mod
for _ in range(syou):
    base = base * kakeru
    base %= mod
base = base * 2**amari
base %= mod

nca = cmb(n, a%mod)
ncb = cmb(n, b%mod)
answer = (base - 1 - nca - ncb) % mod
print(answer)

Solution (Python):
import math
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y
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 pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = (ans*x)
      ans%=MOD 
    x = (x*x)%MOD
    n = n >> 1 
  return ans
def COMint():
  fac[0]=1
  fac[1]=1
  finv[0]=1
  finv[1]=1
  inv[1]=1
  for i in range(2,N+1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD
def com(n,k):
  if n<k:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
MOD=10**9+7

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,a,b=[int(x) for x in input().split()]
ans1 = pow(2,n)-1
N = n
a1=combination(n,a)
b1 = combination(n,b)
if ans1-a1%MOD-b1%MOD<0:
  print(((ans1-a1%MOD-b1%MOD)%MOD+MOD)%MOD)
else:
  print(ans1-a1%MOD-b1%MOD)

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

MOD = 10**9+7
from math import factorial

class Facts():
    
    
    def __init__(self, max_num=(2 * 10**5) + 1, p=10**9 + 7):
        self.p = p
        self.max_num = max_num
        self.fact = [1] * (self.max_num + 1)
        for i in range(1, self.max_num + 1):
            self.fact[i] = self.fact[i-1] * i
            self.fact[i] %= self.p

    def comb(self, n, k):
        
        if n < 0 or k < 0 or n < k:
            return 0
        if n == 0 or k == 0:
            return 1
        a = n
        for i in range(1, k):
            a *= (n-i)
            a %= MOD

        b = k
        for i in range(1, k):
            b *= (k-i)
            b %= MOD

        return (a*self.power_func(b, self.p-2)) % self.p


    def power_func(self, a, b):
        
        if b == 0:
            return 1
        if b % 2 == 0:
            d = self.power_func(a, b//2)
            return d*d % self.p
        if b % 2 == 1:
            return (a*self.power_func(a, b-1)) % self.p

class FLT:
    
    
    def __init__(self, mod=10**9+7):
        self.mod = mod

    def rep_sqr(self, base, k):
        if k == 0:
            return 1
        elif k % 2 == 0:
            return (self.rep_sqr(base, k // 2) ** 2) % self.mod
        else:
            return (self.rep_sqr(base, k - 1) * base) % self.mod

    def inv(self, a):
        
        return self.rep_sqr(a, self.mod-2)

fact = Facts()
flt = FLT()
a_comb = fact.comb(n, a)
b_comb = fact.comb(n, b)

ans = (flt.rep_sqr(2, n) - 1 - a_comb - b_comb) % MOD
print(ans)

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

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

for i in range(2, max(a,b)+1):
  inv[i] = p - inv[p%i] * (p // i) % p

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

ans = pow(2, n, p) - 1 - com[a] - com[b]

print(ans % p)

Solution (Python):



MAX = 10**9 + 7

def pow_mod_p(n, k, p):
  x = 1
  while k:
    if k % 2 == 1:
      x *= n
      x %= p
    n **= 2
    n %= p
    k >>= 1
  return x

def comb_mod_p(n, k, p):
  x = 1
  for ik in range(k):
    x *= ((n-ik) * pow_mod_p(ik+1, p-2, p))
    x %= p
  return x


def main():
  n, a, b = map(int, input().strip().split())
  sum = pow_mod_p(2, n, MAX) - 1
  sum = sum - comb_mod_p(n, a, MAX) - comb_mod_p(n, b, MAX)
  print(sum % MAX)


if __name__=='__main__':
  main()

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


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


mod = 10**9+7



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

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

sou = pow(2,n,mod) -1
ans = (sou - combination(n, a)-combination(n, b))
if (ans<0):
        ans += mod
if (ans<0):
        ans += mod
print(ans)

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

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

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

ans -= comb(a)
ans -= comb(b)
ans = (ans % mod + mod) % mod

print(ans)

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

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

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

def modpow(a, n, mod):
    res = 1
    while(n>0):
        if(n&1):
            res = res * a % mod
        a = (a**2) % mod
        n >>= 1
    return res

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

N, A, B = [int(i) for i in input().split()]
A = min(A, N-A)
B = min(B, N-B)
ext_A = 1
ext_B = 1
for ind, a in enumerate(range(N, N-A, -1)):
    ext_A *= a
    ext_A *= modinv(ind+1, mod)
    ext_A %= mod

for ind, b in enumerate(range(N, N-B, -1)):
    ext_B *= b
    ext_B *= modinv(ind+1, mod)
    ext_B %= mod

print((modpow(2, N, mod) - 1 -ext_A - ext_B)%mod)

Solution (Python):
n, a, b= [int(i) for i in input().split()]
mod = 10**9 + 7

def nCk(N, K, mod):
  ret = 1  
  for k in range(K):
    ret = (ret *(n - k)) %mod
    
  inv = [1 for _ in range(K+1)]
  finv = [1 for _ in range(K+1)]
  for i in range(2, K+1):
    inv[i] = mod - inv[mod % i] * (mod // i) % mod
    finv[i] =finv[i-1] * inv[i] % mod
    
  return (ret * finv[K]) % mod

def mod_pow(a, n, mod):
  res = 1
  while  n > 0:
    if n & 1:
      res = (res * a ) % mod
    a = a * a  % mod
    n = n >> 1
  return res

print(int(mod_pow(2, n, mod) - nCk(n, a, mod) - nCk(n, b, mod) - 1)%mod)

Solution (Python):
n, a, b = map(int, input().split())
def powermod(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 combimod(n, r, p):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
        a %= p
    b = 1
    for i in range(1, r + 1):
        b *= i
        b %= p
    return (a * powermod(b, p-2, p)) % p
print((powermod(2, n, 1000000007) - combimod(n, a, 1000000007) - combimod(n, b, 1000000007) - 1 + 3000000021) % 1000000007)

Solution (Python):
N,a,b=map(int,input().split())
mod=10**9+7
n=max(a,b)
fra=[1]*(n+2)
inv=[1]*(n+2)
t=1
for i in range(1,n+2):
    t*=i
    t%=mod
    fra[i]=t
t=pow(fra[n+1],mod-2,mod)
for i in range(n+1,0,-1):
    inv[i]=t
    t*=i
    t%=mod
ans=pow(2,N,mod)-1
tmp=inv[a]
for i in range(1,a+1):
    tmp*=(N+1-i)%mod
    tmp%=mod
ans-=tmp
tmp=inv[b]
for i in range(1,b+1):
    tmp*=((N+1-i)%mod)
    tmp%=mod
ans-=tmp
ans%=mod
print(ans)