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



Sample input:
4 1 3


Sample output:
7

Submission status: Runtime Error

Solution code:
import numpy as np
from scipy.special import comb

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

count = (2**n - 1) - comb(n, a, exact=True) - comb(n, b, exact=True)
print(count % 1000000007)

Submission status: Runtime Error

Solution code:
class ModTools:
    def __init__(self, MAX, MOD):
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        inverse = [1] * MAX
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse

    def nCr(self, n, r):
        if n < r: return 0
        r = min(r, n-r)
        numerator = self.fact[n]
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

N, a, b = map(int,input().split())
mod = 10**9+7
fact = ModTools(N, mod)
sum = 1
for i in range(N) :
    sum = (sum * 2) % mod

sum = (sum - fact.nCr(N,a) - fact.nCr(N,b) - 1) % mod
print(sum)

Submission status: Runtime Error

Solution code:
import itertools
from math import factorial
from scipy.special import comb

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

counter = 0
UpperLimit = n//2
if n%2 == 0:
    for r in range(UpperLimit):
        counter += comb(n, r, exact = True)
    counter *= 2
    counter += comb(n, UpperLimit, exact = True)
    counter -= 1
else:
    for r in range(UpperLimit+1):
        counter += comb(n, r, exact = True)
    counter *= 2
    counter -= 1

counter -= factorial(n) // (factorial(n - a) * factorial(a))
counter -= factorial(n) // (factorial(n - b) * factorial(b))

print(counter%(10**9+7))

Submission status: Runtime Error

Solution code:
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
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
	fact.append((fact[-1] * i) % p)
	inv.append((-inv[p % i] * (p // i)) % p)
	factinv.append((factinv[-1] * inv[-1]) % p)


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

Submission status: Runtime Error

Solution code:
i = list(map(int, input().split()))
import math
ans=0
answ=0
def combinations_count(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if i[0]%2=1:
  for k in range(i[0]/2):
    if i[1]=k or i[2]=k or i[0]-k=i[1] or i[0]-k=i[2]:
      answ+=(combinations_count(i[0], k)%(10**9+7))
	else:
      answ+=(combinations_count(i[0], k)%(10**9+7))
else:
  for k in range(i[0]/2+1):
    if i[1]=k or i[2]=k or i[0]-k=i[1] or i[0]-k=i[2] or k=i[0]//2:
      answ+=(combinations_count(i[0], k)%(10**9+7))
    else:
      answ+=(combinations_count(i[0], k)%(10**9+7))
neo=(2*ans)+answ
while neo>=10**9+7:
  neo=neo%(10**9+7)
print(neo)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
if n == 2:
    ans = 0
else:
    X = [0]*n
    X[0] = n
    X[n-1] = n
    if n % 2 == 0:
        for i in range(1,n//2):
            X[i] = (X[i-1] * (n-i) // (i+1)) % (10**9 + 7)
            X[n-i-1] = (X[i-1] * (n-i) // (i+1)) % (10**9 + 7)
    else:
        for i in range(1,n//2):
            X[i] = (X[i-1] * (n-i) // (i+1)) % (10**9 + 7)
            X[n-i-1] = (X[i-1] * (n-i) // (i+1)) % (10**9 + 7)
        X[n//2] = (X[n//2 - 1] * (n - n//2 + 1) // (n//2)) % (10**9 + 7)
    X.append(1)
    X[a] = 0
    X[b] = 0
    print(X)
    ans = 0
    for i in range(1,n+1):
        ans += X[i]
        ans %= 10**9 + 7
print(ans)

Submission status: Runtime Error

Solution code:
n=list(map(int, input().split()))
import math
#(math.factorial(5))
a=list(range(0,n[0]))
a.remove(n[1])
a.remove(n[2])
B=[math.factorial(n[0])/math.factorial(i)/math.factorial(n[0]-i) for i in a]
C=sum(B)
D=C%(10**9+7)
print(int(C))

Submission status: Runtime Error

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

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

fac = [0]*(n+1)
fac[0] = 1
fac[1] = 1
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod

c = 0
if n % 2 == 0:
    for i in range(1,n//2 ):
        c += ( fac[n] * modinv(fac[i]) )%mod * modinv(fac[n-i]) % mod
    c *= 2
    c += ( fac[n] * modinv(fac[n//2]) )%mod * modinv(fac[n-n//2]) % mod
    c -= ( fac[n] * modinv(fac[a]) )%mod * modinv(fac[n-a]) % mod
    c -= (fac[n] * modinv(fac[b])) % mod * modinv(fac[n-b]) % mod
    c += 1
    c = c % mod
else:
    for i in range(1, n // 2 + 1):
        c += (fac[n] * modinv(fac[i])) % mod * modinv(fac[n - i]) % mod
    c *= 2
    c -= (fac[n] * modinv(fac[a])) % mod * modinv(fac[n - a]) % mod
    c -= (fac[n] * modinv(fac[b])) % mod * modinv(fac[n - b]) % mod
    c += 1
    c = c % mod

print(c)

Submission status: Runtime Error

Solution code:
from scipy.special import comb
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def combi(n,k,p):
    if n<0 or k<0 or n<k:
        return 0
    if n==0 or k==0:
        return 1
    a=factorial(n) %p
    b=factorial(k) %p
    c=factorial(n-k) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
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
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p
def modisisuu(a,n,p):
    bi=str(format(n,"b"))
    #print(bi)
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res
def do():
    mod=10**9+7
    n,a,b=INTM()
    ct=modisisuu(2,n,mod)
    #print(ct)
    ct=(ct-1-comb(n,a,mod)-comb(n,b,mod))%mod
    print(ct)
if __name__ == '__main__':
    do()

Submission status: Runtime Error

Solution code:
import operator as op
from functools import reduce

a = input().split()
for i in range(len(a)):
    a[i] = int(a[i])

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom

s = 0
for i in range(1, a[0] + 1):
    if i != a[1] and i != a[2]:
        s += ncr(a[0], i)

print(int(s) % (10**9 + 7))

Submission status: Runtime Error

Solution code:
from scipy.special import comb
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def combi(n,k,p):
    if n<0 or k<0 or n<k:
        return 0
    if n==0 or k==0:
        return 1
    a=factorial(n) %p
    b=factorial(k) %p
    c=factorial(n-k) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
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
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p
def modisisuu(a,n,p):
    bi=str(format(n,"b"))
    #print(bi)
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res
def do():
    mod=10**9+7
    n,a,b=INTM()
    ct=modisisuu(2,n,mod)
    #print(ct)
    ct=(ct-1-comb(n,a,mod)-comb(n,b,mod))%mod
    print(ct)1000000000 141421 173205
if __name__ == '__main__':
    do()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
from collections import deque, defaultdict
import bisect

def comb_mod(n, r, MOD=10**9+7):
    if n < 0 or r < 0 or n < r:
        return 0

    factrial = [1] * (n+1)
    for k in range(1, n+1):
        factrial[k] = (factrial[k-1] * k) % MOD

    fact_inv = [1] * (n+1)
    fact_inv[n] = pow(factrial[n], MOD - 2, MOD)
    for k in range(n-1, -1, -1):
        fact_inv[k] = (fact_inv[k+1] * (k+1)) % MOD

    return (factrial[n] * fact_inv[r] * fact_inv[n-r]) % MOD


def main():
    #N = int(input())
    #Xs = list(map(int, input().split()))
    n, a, b = map(int, input().split())
    mod = 10**9 + 7

    result = 2 ** n % mod - comb_mod(n, a) - comb_mod(n, b) % mod - 1
    result = int(result % mod)

    print(result)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def modinv(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return lastx % (10**9+7)

MOD=10**9+7
am=[2]
for i in range(50):
    am.append((am[-1]**2)%MOD)
fr=[1]
for i in range(1,2*(10**5)):
    fr.append((fr[-1]*i)%MOD)

n,a,b=map(int,input().split())
a=min(a,n-a)
b=min(b,n-b)
s=bin(n)[2::][::-1]

ans=1
for i in range(len(s)):
    if s[i]=="1":
        ans*=am[i]
        ans%=MOD

for x in [a,b]:
    tmp=1
    for i in range(n-x+1,n+1):
        tmp=(tmp*i)%MOD
    tmp*=modinv(fr[x],MOD)
    ans=(ans-tmp)%MOD

ans=(ans-1)%MOD
print(ans)

Submission status: Runtime Error

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

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

fac = [0]*(n+1)
fac[0] = 1
fac[1] = 1
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod

c = 0
if n % 2 == 0:
    for i in range(1,n//2 ):
        c += ( fac[n] * modinv(fac[i]) )%mod * modinv(fac[n-i]) % mod
        c = c % mod
    c *= 2
    c += ( fac[n] * modinv(fac[n//2]) )%mod * modinv(fac[n-n//2]) % mod
    c -= ( fac[n] * modinv(fac[a]) )%mod * modinv(fac[n-a]) % mod
    c -= (fac[n] * modinv(fac[b])) % mod * modinv(fac[n-b]) % mod
    c += 1
    c = c % mod
else:
    for i in range(1, n // 2 + 1):
        c += (fac[n] * modinv(fac[i])) % mod * modinv(fac[n - i]) % mod
        c = c % mod
    c *= 2
    c -= (fac[n] * modinv(fac[a])) % mod * modinv(fac[n - a]) % mod
    c -= (fac[n] * modinv(fac[b])) % mod * modinv(fac[n - b]) % mod
    c += 1
    c = c % mod

print(c)

Submission status: Runtime Error

Solution code:
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 )

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

Submission status: Runtime Error

Solution code:
from itertools import combinations

n, a, b = map(int, input().split())
count, ls = 0, [*range(1, n + 1, 1)]
for x in range(1, n+1):
    if x == a or x == b:
        continue
    else:
        count += len(list(combinations(ls, x)))%(10**9 + 7)

print(count)

Submission status: Runtime Error

Solution code:
class Factorial:
    def __init__(self, n, mod=10**9+7):
        self.fac = [0] * (n+1)
        self.ifac = [0] * (n+1)
        self.fac[0] = 1
        self.ifac[0] = 1
        self.mod = mod
        modmod = self.mod - 2
        for i in range(n):
            self.fac[i+1] = self.fac[i] * (i+1) % self.mod
            self.ifac[i+1] = self.ifac[i] * pow(i+1, modmod, self.mod) % self.mod

    def comb(self, n, r):
        if n == 0 and r == 0:
            return 1
        if n < r or n < 0:
            return 0
        tmp =  self.ifac[n-r] * self.ifac[r] % self.mod
        return tmp * self.fac[n] % self.mod

    def perm(self, n, r):
        if n == 0 and r == 0:
            return 1
        if n < r or n < 0:
            return 0
        return (self.fac[n] * self.ifac[n-r]) % self.mod


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

fact = Factorial(N)
sum = 1
for i in range(N) :
    sum = (sum * 2) % mod

sum = (sum - fact.comb(N,a) - fact.comb(N,b) - 1) % mod
print(sum)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
mod = 10**9+7
ans = 2**n-1%mod
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

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 )
a = 0
a += cmb(n,b,mod) 
a += cmb(n,b,mod) 
print((ans-a)%mod)

Submission status: Runtime Error

Solution code:
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 c(n,k): 
  return 1 if(k<=0 or n<=k) else ( c(n-1, k-1) + c(n-1, k) ) %4

def make_comb_dp(n):
    dp = [[0] * (n + 1) for i in range(n + 1)]
    for i in range(n + 1):
        dp[i][0] = 1
        dp[i][i] = 1
    for i in range(2, n + 1):
        for j in range(1, i):
            dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]
    return dp
    
dp = make_comb_dp(n)
soko = (sum(dp[n]))
ans = soko - 1 - dp[n][a] - dp[n][b]
print(ans % mod)






# def c(n,k): 
#   return 1 if(k<=0 or n<=k) else c(n-1, k-1) + c(n-1, k)

# for i in range(10):
#   print([c(i,j) for j in range(i+1)])


# MAX = 510000
# fac = [0] * MAX
# finv = [0] * MAX
# inv = [0] * MAX

# # // テーブルを作る前処理
# MOD = mod
# def COMinit():
#     fac[0] = fac[1] = 1
#     finv[0] = finv[1] = 1
#     inv[1] = 1
#     # for (i = 2; i < MAX; i++){
#     for i in range(2, MAX):
#         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 C(n, k):
#     if (n < k):
#         return 0
#     if (n < 0 or k < 0):
#         return 0
#     else:
#         print(1)
#         return fac[n] * (finv[k] * finv[n - k] % mod) % mod
# print(C(173205, 141421))

Submission status: Runtime Error

Solution code:
from scipy.misc as scm

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

t = 0
for i in range(1, n+1, 1):
    if i == a or i == b:
        continue
    t += scm.comb(n, i, exact=True)

print(t)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
ans=2**n
n1=1
n2=1
for i in range(1,1+a):
    n1 = n1 * (n - i + 1) / i
    n1%=10**9+7
for j in range(1,1+b):
    n2 = n2 * (n - j + 1) /j
    n2%=10**9+7
ans-=n1+n2
ans=ans%(10**9+7)
print(int(ans-1))

Submission status: Runtime Error

Solution code:
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


n,a,b = map(int,input().split())
s = (10**7)+7
sum = 0
for i in range(n):
    if(i+1 != a and i+1 != b):
        sum = sum + cmb(n,i+1)
    if(sum > s):
        sum = sum - s
print(sum)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

for i in range(2, n + 1):
    if i not in [a, b]:
        ans += comb(n, i, exact=True)

print(ans % mod)

Submission status: Runtime Error

Solution code:
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 )

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

Submission status: Runtime Error

Solution code:
import sys
import math

input = sys.stdin.readline
sys.setrecursionlimit(20000)

div = 10**9 + 7


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


def f(n):
    if n == 1:
        return 1
    return f(n-1) * 2 + 1


def main():
    n, a, b = map(int, input().split())
    score = f(n)
    score -= combination(n, a)
    score -= combination(n, b)
    print(score)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
class Factorial:
    def __init__(self, n, mod=10**9+7):
        self.fac = [0] * (n+1)
        self.ifac = [0] * (n+1)
        self.fac[0] = 1
        self.ifac[0] = 1
        self.mod = mod
        modmod = self.mod - 2
        for i in range(n):
            self.fac[i+1] = self.fac[i] * (i+1) % self.mod
            self.ifac[i+1] = self.ifac[i] * pow(i+1, modmod, self.mod) % self.mod

    def comb(self, n, r):
        if n == 0 and r == 0:
            return 1
        if n < r or n < 0:
            return 0
        tmp =  self.ifac[n-r] * self.ifac[r] % self.mod
        return tmp * self.fac[n] % self.mod

    def perm(self, n, r):
        if n == 0 and r == 0:
            return 1
        if n < r or n < 0:
            return 0
        return (self.fac[n] * self.ifac[n-r]) % self.mod

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

fact = Factorial(N)
sum = 0
for i in range(N) :
    sum = (sum + fact.comb(N,i)) % mod

sum = (sum - fact.comb(N,a) - fact.comb(N,b)) % mod
print(sum)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

t = 0
for i in range(1, n+1, 1):
    if i == a or i == b:
        continue
    t += comb(n, i, exact=True)

print(t)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

n, a, b = map(int,input().split())
total_num = 0
for i in range(n):
    if i != a and i != b:
        total_num += comb(n, i, exact=True) % (10 ^ 9 + 7)
print(total_num)

Submission status: Runtime Error

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

cnt=1
for i in range(1,n + 1):
    cnt*=i
    if i == a:
        af = cnt
    elif i == n-a:
        anf = cnt
    elif i == b:
        bf = cnt
    elif i == n-b:
        bnf = cnt
    elif i == n:
        nf=cnt
        break

ans = 2 ** n - (nf//af//anf) - (nf//bf//bnf)-1
print(int(ans % (10**9+7)))

Submission status: Runtime Error

Solution code:
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 )

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

mod = 10**9+7 #出力の制限

flowers = list(range(n))
sum = 0
for i in range(1, n + 1):
  if i == a or i == b:
    continue;
  sum = sum + cmb(n, i, mod)

print(sum % (10**9 + 7))

Submission status: Runtime Error

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,a,b = inpl()
def calc(N,x):
    ret = 1
    for i in range(N-x+1,N+1):
        ret *= i
        ret %= mod

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

    return ret%mod

ans = pow(2,N,mod)-1 - calc(a) - calc(b)
print(ans%mod)

Submission status: Runtime Error

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

cnt=1
for i in range(n + 1):
    cnt*=i
    if i == a:
        af = cnt
    elif i == n-a:
        anf = cnt
    elif i == b:
        bf = cnt
    elif i == n-b:
        bnf = cnt
    elif i == n:
        nf=cnt
        break

ans = 2 ** n - (nf//af//anf) - (nf//bf//bnf)-1
print(int(ans % (10**9+7)))

Submission status: Runtime Error

Solution code:
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

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

    return K * x

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

mod = 10 ** 9 + 7


import numpy as np
 
def prepare(n, MOD):
    nrt = int(n ** 0.5) + 1
    nsq = nrt * nrt
    facts = np.arange(nsq, dtype=np.int64).reshape(nrt, nrt)
    facts[0, 0] = 1
    for i in range(1, nrt):
        facts[:, i] = facts[:, i] * facts[:, i - 1] % MOD
    for i in range(1, nrt):
        facts[i] = facts[i] * facts[i - 1, -1] % MOD
    facts = facts.ravel().tolist()
 
    invs = np.arange(1, nsq + 1, dtype=np.int64).reshape(nrt, nrt)
    invs[-1, -1] = pow(facts[-1], MOD - 2, MOD)
    for i in range(nrt - 2, -1, -1):
        invs[:, i] = invs[:, i] * invs[:, i + 1] % MOD
    for i in range(nrt - 2, -1, -1):
        invs[i] = invs[i] * invs[i + 1, 0] % MOD
    invs = invs.ravel().tolist()
 
    return facts, invs


facts, invs = prepare(n, mod)

def comb(n, r, mod):
    return facts[n] * invs[r] % mod * invs[n-r] % mod

nca = comb(n, a, mod)#factorial(n) // factorial(a) // factorial(n-a)
ncb = comb(n, b, mod)#factorial(n) // factorial(b) // factorial(n-b)

ans = pow_k(2, n)

ans -= 1 + nca + ncb
ans %= mod
print(ans)

Submission status: Runtime Error

Solution code:
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])

    return result

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

flowers = list(range(n))
sum = 0
for i in range(1, n + 1):
  if i == a or i == b:
    continue;
  sum = sum + cmb(n, i)

print(sum % (10**9 + 7))

Submission status: Runtime Error

Solution code:
N,A,B = map(int,input().split())
mod = 10**9+7
X = 200000
inv_t = [0]+[1]
for i in range(2,X):
  inv_t += [inv_t[mod % i] * (mod - int(mod / i)) % mod]

def fast_mod_pow(x, n, mod):
    r = 1
    while n>0:
        if n&1:
            r = (r * x) % mod
        x = (x * x) % mod
        n >>= 1
    return r

def comb(n,k):
    value = 1
    for i in range(n-k+1,n+1):
        value *= i
        value %= mod
    for i in range(1,k+1):
        value *= inv_t[i]
        value %= mod
    return value

ans = fast_mod_pow(2,N,mod)-1
ans -= comb(N,A)
ans -= comb(N,B)
print(ans%mod)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
from scipy.special import comb
f=0
for i in range(1,n+1):
    if i==a or i==b:
        continue
    else:
        f+=comb(n, i, exact=True)%1000000007
print(f)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
m = 10**9+7
from functools import lru_cache

@lru_cache(maxsize=1000)
def c(n,k): 
  return 1 if(k<=0 or n<=k) else (c(n-1, k-1) + c(n-1, k))%m

l = [c(n,j) for j in range(n+1)]
print(sum(l)-(l[a]+l[b]+1))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
nca = len(list(itertools.combinations(range(n), a)))
ncb = len(list(itertools.combinations(range(n), b)))
# answer = 2**n - 1 - nca - ncb
# print(answer % (10**9 + 7))
print((2**n - 1 - nca - ncb) % (10**9 + 7))

Submission status: Runtime Error

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

def c(n,k): 
  return 1 if(k<=0 or n<=k) else (c(n-1, k-1) + c(n-1, k))%m

l = [c(n,j) for j in range(n+1)]
print(sum(l)-(l[a]+l[b]+1))

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
n,a,b=map(int,input().split())
INF=10**9+7
def modcomb(n,k,m):
    fac=[0]*(n+1)
    finv=[0]*(n+1)
    inv=[0]*(n+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,n+1):
        fac[i]=fac[i-1]*i%m
        inv[i]=m-inv[m%i]*(m//i)%m
        finv[i]=finv[i-1]*inv[i]%m
    return fac[n]*(finv[k]*finv[n-k]%m)%m
ans=0
ans=(ans-modcomb(n,a,INF)-modcomb(n,b,INF))%INF
ans=(ans+pow(2,n,INF)-1)%INF
print(ans)

Submission status: Runtime Error

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

# 2^n - nCa - nCb
nCa = 1
for i in range(1, a+1):
    nCa *= (n+1 - i) /  i
nCb = 1
for i in range(1, b+1):
    nCb *= (n+1 - i) /  i

retval = 2 ** n - nCa - nCb - 1
print(int(retval))