Problem: 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.

Submission attempts (in order):
N, a, b = map(int, input().split())
 
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7 
X = 10**9
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル
 
for i in range( 2, X + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
ax = cmb(N, a, mod)
bx = cmb(N, b, mod)
 
print((pow(2, N) - ax - bx - 1)%mod)

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

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

mod = 10**9+7 
X = 2 * 10**5
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル

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

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print((pow(2, N) - ax - bx - 1)%(10**9 + 7))

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

sum = pow(2, N)

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

mod = 10**9+7 
X = 2 * 10**5
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル

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

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print((sum - ax - bx - 1)%(10**9+7))

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

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

mod = 10**9+7 
X = 2 * (10**5)
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル

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

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print((pow(2, N) - ax - bx - 1)%(10**9 + 7))

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

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

mod = 10**9+7 
X = 2 * (10**5)
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル

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

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print(pow(2, N)%mod - ax - bx - 1)

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
mod = 10**9+7 
X = 2 * 10**5
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル
 
for i in range( 2, X + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
 
ax = cmb(N, a, mod)
bx = cmb(N, b, mod)
 
print((pow(2, N) - ax - bx - 1))

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

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

mod = 10**9+7 
X = 2 * (10**5)
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル

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

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print((pow(2, N) - ax - bx - 1)%mod)

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

sum = pow(2, N)

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

mod = 10**9+7 
#N = 10**4
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル

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

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print((sum - ax - bx - 1)%(10**9+7))

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

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

mod = 10**9+7 
X = 2 * (10**5)
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 計算用テーブル

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

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print((pow(2, N) - ax - bx - 1)%(10**9 + 7))

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

sum = pow(2, N)

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

p = 10 ** 9 + 7
X = 2 * 10 ** 5  
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  
 
for i in range(2, X + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ax = cmb(N, a, mod)
bx = cmb(N, b, mod)

print((sum - ax - bx - 1)%(10**9+7))

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)

Verdicts: Time Limit Exceeded

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Time Limit Exceeded

Runtime Error

Runtime Error

Accepted