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:
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**6
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())
counter = 0
for i in range(1,n+1):
    if ((i != a) and (i != b)):
        counter += cmb(n,i,mod)
print(counter)

Submission status: Runtime Error

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
from operator import mul
from functools import reduce

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

l = [n]*(n)
for r in range(2, n+1):
    val = (n-r+1)/r
    l[r-1] = round(val*(l[r-2]))%div

l[a-1] = 0
l[b-1] = 0

print(sum(l))

Submission status: Runtime Error

Solution code:
list = input().split()
n = int(list[0])
a = int(list[1])
b = int(list[2])

num = 0

for i in range(1, n + 1):
	X = 1
	Y = 1
	if i == a:
		continue
	elif i == b:
		continue
	# 分母
	for j in range(i, 0, -1):
		X *= j
	# 分子
	for j in range(n, n - i, -1):
		Y *= j
	num += (Y / X)

print(int(num % 1000000007))

Submission status: Runtime Error

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
from operator import mul
from functools import reduce

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

l = [n]*(n)
for r in range(2, n+1):
    val = (n-r+1)/r
    l[r-1] = round(val*(l[r-2]))%div

l[a-1] = 0
l[b-1] = 0


print(sum(l))

Submission status: Runtime Error

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

N=collections.deque(list(reversed(range(1,n+1))))
dp_fac=[0]*n
dp_bunbo=[1]*n
for i in range(0,n):
    if i==0:
        dp_bunshi=N[0]%mod
    else:
        dp_bunbo[i]=((i+1)*dp_bunbo[i-1])%mod
        dp_bunshi=(N[i]*dp_bunshi)%mod
    dp_fac[i]=dp_bunshi//dp_bunbo[i]
ans=0
for j in range(0,n):
    if (j+1)==a or (j+1)==b:continue
    ans+=dp_fac[j]
print(ans)

Submission status: Runtime Error

Solution code:
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 #出力の制限
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 )
l = []
for r in range(1, n+1):
    if r != a and r != b:
        l.append(cmb(n,r,mod))

print(sum(l))

Submission status: Runtime Error

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

n_range = [val for val in range(1, n+1) if val not in [a, b]]

ans = 0
for val in n_range:
  a = a
  for i in val:
    a = a * (n - i)
  ans = ans + a

print(ans)

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**6
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())
counter = 0
for i in range(n+1):
    if ((i != a) and (i != b)):
        counter += cmb(n,i,mod)
print(counter-1)

Submission status: Runtime Error

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

def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res
    
if n==2:
    print(0)
else:
    ans=pos(2,n,mod)-1-cmb(n,a,mod)-cmb(n,b,mod)
    print(ans%mod)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

import sys
import math
from scipy.special import comb


debug = False

def log(text):
    if debug:
        print(text)


def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
    
    (n, a, b) = [int(e) for e in lines[0].split(" ")]

    return (n, a, b)


def solve(n, a, b):

    result = int(2**n) - 1 - comb(n, a) - comb(n, b) % int(10**9 + 7)


    return result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()

Submission status: Runtime Error

Solution code:
#coding:utf-8

MOD = 1000000007

def sub(a, b):
    return (a + MOD - b) % MOD

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

def div(a, b):
    return mul(a, pow(b, MOD-2, MOD))

    
def nCr(n, r, mod=MOD):
  	p = min(r, n-r)
    return frac(n) * pow(frac(r), mod-2, mod) * pow(frac(n-r), mod-2, mod) % MOD

def frac(n):
    v = 1
    for i in range(2, n+1):
        v = mul(v, i)
    return v

def main():
    n, a, b = map(int, input().split())
    sumv = 1
    for _ in range(n):
        sumv = mul(sumv, 2)
    sumv = sub(sumv, nCr(n, a, MOD))
    sumv = sub(sumv, nCr(n, b, MOD))
    sumv = sub(sumv, 1)
    print(sumv)

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

from operator import mul
from functools import reduce
from math import factorial

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

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

def combination(n, r):
    res = 1
    for i in range(r):
        res *= (n - i) / (i + 1)
    return int(res)

#def comb(n,k,p):
#  """power_funcを用いて(nCk) mod 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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

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

Submission status: Runtime Error

Solution code:
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
s, _ = prepare(N, MOD)
print((2**N - s[N]//(s[A]*s[N-A]) - s[N]//(s[B] * s[N-B]) - 1) % MOD)

Submission status: Runtime Error

Solution code:
n,a,b=(int(x) for x in input().split())
mod=1000000007
n1=int(n/2)
list=[1]
for i in range(n1):
	k=list[i]*(n-i)/(i+1)
	k%=mod
	list.append(k)
su=sum(list)%mod
su*=2
if n%2==0:
	su-=list[n1]
if 2*a>=n:
	a=n1-(a/2)
if 2*b>=n:
	b=(n1-int(b/2))
su-=list[a]
su-=list[b]
su-=1
print(int(su%mod))

Submission status: Runtime Error

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

n_range = [val for val in rane(1, n+1) if val not in [a, b]]

ans = 0
for val in n_range:
  a = a
  for i in val:
    a = a * (n - i)
  ans = ans + a

print(ans)

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**6
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())
counter = 0
for j in range(n):
    if ((j != a) and (j != b)):
        counter += cmb(n,j,mod)
print(counter)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
d=0
c=[]
for i in range(n):
  if !(i==a or i==b):
    c=str(i)
    
for i in range(len(c)):
  d+=combinations_count(n,int(c[0]))

print(d)

Submission status: Runtime Error

Solution code:
from math import sqrt,factorial
from scipy.special import comb
N,a,b=map(int,input().split())
Nsq=int(sqrt(N))+1
ans=0
for i in range(1,Nsq):
    if N%i==0 and i!=a and i!=b:
        ans+=comb(N,i,exact=True)
print(ans%(10**9+7))

Submission status: Runtime Error

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

def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res
    
if n==2:
    print(0)
else:
    ans=pos(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
    print(ans%mod)

Submission status: Runtime Error

Solution code:
n=list(map(int, input().split()))
import math
#(math.factorial(5))
a=list(range(1,n[0]+1))
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:
from scipy.special import comb
div = 1000000000+7

tmp = raw_input()
t = tmp.split(' ')
n = int(t[0])
a = int(t[1])
b = int(t[2])
ans = 0
for i in range(n):
    if i != a and i != b:
        ans += comb(n, i, exact=True)
        ans = ans % div

print(ans)

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())
counter = 0
for j in range(n):
    if ((j != a) and (j != b)):
        counter += cmb(n,j,mod)
print(counter)

Submission status: Runtime Error

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

def main():
    import itertools as it
    mod = 10**9+7
    N, A, B = map(int, read().split())
    res = 0
    for i in range(1,N+1):
        if i == A or i == B:
            continue
        res = (res + len(list(it.combinations(range(N),i))))%mod
        print(res)
    return

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from scipy import special

n, a, b = map(int, input().split())
ans =0
for i in range(n):
    if a == i or b == i:
        continue
    else:
        ans += special.comb(n, i, True)
print(ans % (10 ** 9 + 7))

Submission status: Runtime Error

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

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

total = 0

for i in range(1, n+1, 1):
  total += comb(n, i, exact = True)

total -= comb(n, a, exact = True)
total -= comb(n, b, exact = True)

print(total)

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
mo = 10 ** 9 + 7
def hanaya(n, x):
    if x == 1:
        return n
    else:
        return ((hanaya(n, x-1))*((n-x+1)/x))%mo

ans = (pow(2, N) - 1 - hanaya(N, A)- hanaya(N, B)) % mo
print(int(ans))

Submission status: Runtime Error

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

#ここから

mod = 10**9+7
MAX_N = 10**9

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%mod)

fact_inv[-1] = pow(fact[-1],mod-2,mod)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%mod

def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

#ここまでパクリ
#https://juppy.hatenablog.com/entry/2018/11/12/%E8%9F%BB%E6%9C%AC_python_nCk_mod_p_%E7%AB%B6%E6%8A%80%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0

ans = 2**n % mod - mod_comb_k(n,a,mod) - mod_comb_k(n,b,mod)
print(ans)

Submission status: Runtime Error

Solution code:

import scipy
n,a,b=map(int,input().split())
l1=[]
l2=[]
l3=[]
for i in range(1,a):
  x=int(scipy.misc.comb(n,i))
  l1.append(x)
for i in range(a+1,b):
  y=int(scipy.misc.comb(n,i))
  l2.append(y)
for i in range(b+1,n):
  z=int(scipy.misc.comb(n,i))
  l3.append(z)
L=sum(l1)+sum(l2)+sum(l3)
print((L+1)%(10**9 + 7))

Submission status: Runtime Error

Solution code:
import operator as op
from functools import reduce
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
n,a,b = [int(x) for x in input().split()]
mod = 10**9+7
print(int((pow(2,n,mod)-1-ncr(n,a)-ncr(n,b))%mod))

Submission status: Runtime Error

Solution code:
import sys
import math
MOD = 10 ** 9 + 7

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
    #[x,y]
    return [w[0],w[1]]

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

input = sys.stdin.readline
n,a,b = map(int,input().split())
x1 = 1

a = min(a,n-a)
b = min(b,n-b)
if a > b:
    a,b = b,a

for i in range(n-a+1,n+1):
    x1 = x1 * i % MOD
for i in range(1,a+1):
    x1 = x1 * mod_inv(i)

x2 = x1
for i in range(n-b+1,n-a+1):
    x2 = x2 * i % MOD
for i in range(a+1,b+1):
    x2 = x2 * mod_inv(i)
    x2 = x2 % MOD

t = []
nn = n
while nn > 0:
    t.append(nn % 2)
    nn //= 2
x0 = 1
for i in range(len(t)):
    x0 = x0 ** 2
    x0 = x0 % MOD
    if t[n-i-1] == 1:
        x0 *= 2
        x0 = x0 % MOD
print ((x0 - x1 - x2 - 1) % MOD)

Submission status: Runtime Error

Solution code:
from scipy.misc import comb


if __name__ == "__main__":
    n, a, b = map(int, input().split())
    ans=0
    if n == 2:
        if (a == 1 and b == 1) or (a == 2 and b == 1):
            print(0)
    else:
        for i in range(1, int(n // 2)):
            cnt=2
            if i == a or i == b:
                cnt -= 1
            if (n - i) == a or (n - i) == b:
                cnt -= 1
            ans += comb(n,i,exact=True)*cnt
        if n%2==0 and (int(n//2) !=a and int(n//2) != b):
            ans += comb(n,int(n//2),exact=True)
        if n != a and n != b:
            ans += 1
        print(ans % (10 ** 9 + 7))

Submission status: Runtime Error

Solution code:

import scipy
n,a,b=map(int,input().split())
l1=[]
l2=[]
l3=[]
for i in range(1,a):
  x=int(scipy.special.comb(n,i))
  l1.append(x)
for i in range(a+1,b):
  y=int(scipy.special.comb(n,i))
  l2.append(y)
for i in range(b+1,n):
  z=int(scipy.special.comb(n,i))
  l3.append(z)
L=sum(l1)+sum(l2)+sum(l3)
print((L+1)%(10**9 + 7))

Submission status: Runtime Error

Solution code:
import numpy as np
n,a,b= map(int,input().split())
from functools import reduce
from fractions import Fraction
nca = (reduce(lambda x,y:x+y, (np.log(n-i)-np.log(i+1) for i in range(a)), 1) )
ncb = (reduce(lambda x,y:x+y, (np.log(n-i)-np.log(i+1) for i in range(b)), 1) )
print(int(2**n - 1 - np.exp(nca) - np.exp(ncb))%(10**9+7))

Submission status: Runtime Error

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

def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res
    
if n==2:
    print(0)
else:
    ans=pos(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
    print(ans)

Submission status: Runtime Error

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

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

    mod = 10**9+7
    ans = pow(2, n, mod)

    facts, inv_fact =  prepare(n, mod)

    ans_1 = facts[n]*inv_fact[a]*inv_fact[n-a]%mod
    ans_2 = facts[n]*inv_fact[b]*inv_fact[n-b]%mod

    ans = ans - ans_1 - ans_2
    ans = ans %mod

    print ans -1

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
c=1
d=1
e=0
f=0
for i in range(n):
    if i+1==a:
        continue
    if i+1==b:
        continue
    for j in range(i+1):
        c*=(n-j)
        d*=(1+j)
    f=(int(c))/(int(d))
    e=e+f
    c=1
    d=1
e=int(e//1)
e=e%(10^9+7)
print(e)

Submission status: Runtime Error

Solution code:
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 
N = 10**6
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 )

def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res
    
if n==2:
    print(0)
else:
    ans=pos(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
    print(ans)

Submission status: Runtime Error

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

import numba


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

cmb = numba.jit(cmb)

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

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

Submission status: Runtime Error

Solution code:
from scipy.special import comb

n, a, b = map(int, input().split())
total = 0
for i in range(1,n+1):
    if i == a or i == b:
        continue
    total += comb(n, i, exact=True)
print(total%(10**9+7))

Submission status: Runtime Error

Solution code:
from scipy.special import comb
n,a,b=map(int,input().split())
l1=[]
l2=[]
l3=[]
for i in range(1,a):
  x=int(comb(n,i))
  l1.append(x)
for i in range(a+1,b):
  y=int(comb(n,i))
  l2.append(y)
for i in range(b+1,n):
  z=int(comb(n,i))
  l3.append(z)
L=sum(l1)+sum(l2)+sum(l3)
print((L+1)%(10**9 + 7))

Submission status: Runtime Error

Solution code:
import sys
from scipy.special import comb


n,a,b=(int(i) for i in input().split())

big = 1000000007

sum = pow(2,n,1000000007)
#print(sum)
sum1 = sum -comb(n%big,a)-comb(n%big,b)-1

#print(sum1)

#sum = sum
ans = sum1 % 1000000007


print(int(ans))

Submission status: Runtime Error

Solution code:
import math
n,a,b=map(int,input().split())
na=1
m=7+10**9
def gyakugen(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[i]-q*w[i],r[2]-q*w[2]]
        r=r2
        w=w2
    return (b+w[0]%b)%b
ans=1
for i in range(n):
    ans*=2
    if ans>=m:
        ans%=m

for i in range(1,n+1):
    na=na*i%m
nb=na
for i in range(1,n-a+1):
    na=na*gyakugen(i,m)%m
for i in range(1,a+1):
    na=na*gyakugen(i,m)%m
for i in range(1,n-b+1):
    nb=nb*gyakugen(i,m)%m
for i in range(1,b+1):
    nb=nb*gyakugen(i,m)%m    
ans=ans-na-nb-1
ans%=m
print(ans)

Submission status: Runtime Error

Solution code:
m = 10**9+7
def power(x,y,m):
    if y==0:
        return 1
    if y==1:
        return x%m
    if y%2==0:
        return power((x*x)%m,y//2,m)
    return ((x%m)*power((x*x)%m,y//2,m))%m
def n_c_r(n,r,m):
  	s = 1
    for i in range(1,n-r+1):
      	s = (s*(r+i)//i)%m
    return s
N,a,b = map(int, input().split())
ans = (((power(2,N,m)+m)%m) -(n_c_r(N,max(N-a,a),m) + n_c_r(N,max(N-b,b),m)))%m
print(ans)

Submission status: Runtime Error

Solution code:
import sys
from scipy.special import comb


n,a,b=(int(i) for i in input().split())

big = 1000000007

sum = pow(2,n,1000000007)
#print(sum)
#sum1 = sum -comb(n%big,a)-comb(n%big,b)-1

#print(sum1)

#sum = sum
ans = sum1 % 1000000007


print(int(ans))

Submission status: Runtime Error

Solution code:
inp = [int(i) for i in input().split()]
n = inp[0]
a = inp[1]
b = inp[2]

# C = {}
# def cmb(n,r):
#   print(n,r)
#   if r==0 or r ==n:
#     return 1
#   if r==1:
#     return n
#   if (n,r) in C:
#     return C[(n,r)]
#   C[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
#   return C[(n,r)]

# 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

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 )

A = cmb(n,a,mod)
B = cmb(n,b,mod)
ans = 2**n-1-A-B
print(ans%(10**9+7))

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>

using namespace ::std;


long long myPow(long long _x, long long _n, long long _m)
{
	long long ret = 1;
	while(0 < _n)
	{
		if((_n % 2) == 0)
		{
			_x = (_x * _x) % _m;
			_n >>= 1;
		}
		else
		{
			ret *= (ret * _x)%_m;
			--_n;
		}
	}
	return ret;
}

std::vector<std::vector<long long>> comb(int n, int r) {
  std::vector<std::vector<long long>> v(n + 1,std::vector<long long>(n + 1, 0));
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int j = 1; j < v.size(); j++) {
    for (int k = 1; k < j; k++) {
      v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
    }
  }
  return v;
}

int main()
{
	long long n, a, b;
    cin >> n >> a >> b;
    long long m = 1000000007;
    long long total = myPow(2, n, m) - 1;
    if(a <= n)
    {
        total -= comb(n,a)[n][a] %m;
    }
    if(b <= n)
    {
        total -= comb(n,b)[n][b] %m;
    }

    total = (total + 2*m)%m;

    cout << total << endl;
}

Submission status: Runtime Error

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

fac1 = [n] * max
fac2 = [1] * max
for i in range(2, max):
    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)

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())
print(int( (2**n - 1 - cmb(n, a) - cmb(n, b)) % (10e9+7) ))

Submission status: Runtime Error

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

dp = [-1] * (n+1)
total = 0

for i in range(0, n+1):
    if(i > 0):
        dp[i] = (i * dp[i - 1]) % divisor
    else:
        dp[0] = 1

def factorial(n):
    return dp[n]

if n > 2:
    for i in range(1, n+1):
        if(i != a and i != b):
            total += dp[n] // (dp[i] * dp[n-i])

else:
    print(0)
    

print(total)

Submission status: Runtime Error

Solution code:
n, a, b = map(int,input().split())
mod = 10**9+7
from fractions import Fraction

def comb(n, k):
    
    if n < 0 or k < 0:
        pdt = 0
    
    else:
        pdt = 1
        for s in range(1, k + 1):
            pdt *= Fraction(n - s + 1, s)
    
    return pdt.numerator
nm = pow(2,n,mod) -1
am = cmb(n,a)%mod
bm = cmb(n,b)%mod
ans = (nm - am - bm)
if ans < 0:
    ans += mod
print(ans)