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:
from functools import lru_cache

n, a, b = [int(item) for item in input().split()]
total_comb = 0

@lru_cache(maxsize=None)
def my_comb(n, r):
    if r == 1:
        return n
    if n == 2:
        return 2   
    return my_comb(n-1, r-1) * n / r

total_comb -= my_comb(n, a)
total_comb -= my_comb(n, b)

# print(total_comb)

def bin(N):
    res = ''
    while N >= 2:
        if N == 2:
            res += '10'
        res += str(N%2)
        N = N//2

    return res[::-1]

temp_num = n - 1
temp_index = bin(temp_num)
# print(temp_index)
for i, v in enumerate(reversed(temp_index)):
    if v == '1':
        total_comb += my_comb(n + i, 2*i + 1)
    
    total_comb %= (10**9 + 7)


print(int(total_comb + 1))

Submission status: Runtime Error

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

P = 10**9 + 7
N = 2*10**5+2

f = [1]
for i in range(1, N):
  f.append(f[i-1]*i%P)

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

def comb(n,r):
  return ((f[n]*modinv(n-r, P))%P*modinv(r, P))%P

#print(a,b)
#print((n*modinv(n,P))%P)
#print(comb(n,b))

ans = ((n%P)*(n%P) - comb(n,a) - comb(n,b))%P - 1
print(int(ans))

Submission status: Runtime Error

Solution code:
n, a, b  = map(int,input().split())
ans = 0
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
N = ** 6
mod = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

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

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

Submission status: Runtime Error

Solution code:
print(2**30%10**9+7)
mod=10**9+7
p=73741831
n,a,b=map(int,input().split())

x=1
n1=(n)//30
n2=(n)%30
for i in range(n1):
  x=(x*p)%mod
for i in range(n2):
  x=(x*2)%mod
x=(x-1)%mod
#print(x)

mod = 10**9+7 #出力の制限
N = 2*(10**5)
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=1
for i in range(a):
  A=(A*(n-i))%mod
for i in range(a):
  A=(A*g2[i]*g2[n-i])%mod
  
B=1
for i in range(b):
  B=(B*(n-i))%mod
for i in range(b):
  B=(B*g2[i]*g2[n-i])%mod
  
print((x-A-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 * pow(i,MOD-2,MOD)

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,MOD-2,MOD)
    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[len(t)-i-1] == 1:
        x0 *= 2
        x0 = x0 % MOD
print ((x0 - x1 - x2 - 1) % MOD)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
n, a, b = map(int, input().split())

MOD = 10**9 + 7
C = [n]

bunsi = n-1
bunbo = 2
#for i in range(1, n-1):
m = min(2*10**5, n)
for i in range(1, m):
    C.append(C[i-1]*(bunsi/bunbo))
    bunsi -= 1
    bunbo += 1

#C.append(1)
ans = 2**n
'''
if n % 2 == 1:
    ans = 2*sum(C[0:n//2]) + 1
else:
    ans = 2*sum(C[0:n//2-1]) + C[n//2-1] + 1

if a > n//2:
    a = n - a

if b > n//2:
    b = n - b
ans -= C[a-1] + C[b-1]
print(C)
print(ans)

print(C[0:n//2-1])
print(C[n//2-1])

print(int(ans) % MOD)
'''

print(ans - C[a-1] - C[b-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 #出力の制限
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))

Submission status: Runtime Error

Solution code:

import math
import itertools

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    ret = 0
    n_all = 0
    for i in range(n):
        n_all += len(list(itertools.combinations(list(range(n)), i)))
    for j in range(a):
        n_all -= len(list(itertools.combinations(list(range(n)), j)))
    for k in range(b):
        n_all -= len(list(itertools.combinations(list(range(n)), k)))
    x = 10**9 + 7
    ret = n_all % x
    print(ret)

Submission status: Runtime Error

Solution code:
from scipy.special import comb


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


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

Submission status: Runtime Error

Solution code:
from numba import jit

@jit
def main():
    mod = 10**9+7 #出力の制限
    N = 10**10
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    s = list(map(int, input().split()))
    n = s[0]
    a = s[1]
    b = s[2]
    ans = 0
    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 )

    for i in range(n):
        if i+1 == a or i+1 == b:
            continue
        else:
            if ( i+1<0 or i+1>n ):
                ans += 0
                continue
            i = min(i+1, n-i-1)
            ans +=  g1[i+1] * g2[i+1] * g2[n-i-1] % mod
    return ans
ans = main()
print(ans)

Submission status: Runtime Error

Solution code:
#coding:utf-8

MOD = 1000000007
import math

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):
    return math.fractual(n) * pow( math.fractual(r), mod-2, mod) * pow( math.fractual(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 mypow(x, n, m):
    if n == 0:
        return 1
    if n % 2 == 0:
        return mypow(mul(x, x) % m, n / 2, m)
    else:
        return mul(x, mypow(x, n - 1, m) % m)

def main():
    n, a, b = map(int, input().split())
    sumv = 1
    sumv = mypow(2, n, MOD)
    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:
nCr = {}
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,r,mod)
n,a,b=input().split(' ')
n=int(n)
a=int(a)
b=int(b)
A=1
j=1
A=cmb(n,a)
A=A%1000000007
B=cmb(n,b)
B=B%1000000007
N2=n//1000
N1=n%1000
TTh=860192575
C=1
for i in range(N2):
    C*=TTh
    C=C%1000000007
for i in range(N1):
    C*=2
    C=C%1000000007

C+=1000000007*2
C-=A+B+1
C=C%1000000007
print(C)

Submission status: Runtime Error

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

ans = (pow(2, N, mo) - 1 - hanaya(N, A)- hanaya(N, B)) % mo
print(int(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**5
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 )

allsum = (n * n - 1) % mod
allsum -= cmb(n, a, mod)
allsum -= cmb(n, b, mod)

print(int(allsum))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
# coding: utf-8

# from math import factorial as fact

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

table = {}


def cnk(n, k):
    # return fact(n) // (fact(k) * fact(n-k))
    table = {}
    if k < n-k:
        k = n-k
    # print(k)

    up = 1
    for i in range(k+1, n+1):
        up *= i
    down = 1

    # k!の計算
    if k in table.keys():
        down = table[k]
    else:
        if len(table.keys()) > 0:
            start = max(table.keys())
            down = table[start]  # start!
        else:
            start = 0
            down = 1

        # down <- k!
        for i in range(start+1, k+1):
            down *= i
            if i not in table.keys():
                table[i] = down

    # print(up, down, table)
    return up // table[n-k]


# print(cnk(4, 1))
# print(cnk(n, b))
print((2**n) - 1 - (cnk(n, a) + cnk(n, b)) % (10**9 + 7))

Submission status: Runtime Error

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

ans = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    tp = 1
    for j in range(n, n - i, -1):
        tp *= j
    for j in range(2, i + 1):
        tp /= j
    ans += tp
ans = round(ans % (10**9 + 7))
print(ans)

Submission status: Runtime Error

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


def comb(n, r):
    c = [[0]*(n+1) for i in range(n+1)]

    if r == 0 or r == n:
        return 1
    for i in range(0,n+1):
        c[i][0] = 1
    for j in range(0,r+1):
        c[0][j] = 0
    
    for i in range(n+1):
        for j in range(r+1):
            if i == j:
                c[i][j] = 1
            elif j > i:
                c[i][j] = 0
            else:
                c[i][j] = c[i-1][j-1] + c[i-1][j]
     
    return c
ans =0
for ii in range(1,n+1):
    if ii != a and ii != b:
        ans += c[n][ii]  
print(ans)

Submission status: Runtime Error

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

MAX_NUM = 10**6 + 1
MOD = 10**9+7

n = n%MOD

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
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

def pow_by_iter(a, x, n):
  acc = a
  for i in range(a, x):
    acc = (acc*a)%n
    return acc

ans = pow_by_iter(2, n, MOD)

ans = ans - (combinations(n, a) + combinations(n, b)) - 1
print(ans%MOD)

Submission status: Runtime Error

Solution code:
import math
import numpy as np
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n, a, b = input().split()
n = int(n)
a = int(a)
b = int(b)
linn = np.linspace(1,n,n)
nn = np.ones(n)*n
nlinn = np.array(list(map(combinations_count, nn, linn)))
nlinn = np.sum(nlinn) - combinations_count(n, a) - combinations_count(n, b)
print(nlinn)

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split(' '))
count=0
import math
fac= math.factrial(a)
def com(n, r):
    return fac // (math.factorial(n - r) * math.factorial(r))

for i in range(1,a+1):
    count+=com(a,i)
count-=com(a,b)
count-=com(a,c)
print(int(count)%(10**9+7))

Submission status: Runtime Error

Solution code:
n,a,b=map(int, input().split())
f_num=0
if n==2:
    print('0')
else:
    from scipy.special import comb
    for i in range(1,n+1):
        if i!=a and i!=b:
            f_num+=comb(n,i,exact=True)
    print(f_num%(10**9+7))

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 = 2*10**5
M = 10**9
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 )

# for i in range(N+1, )

# 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

A = mod_cmb_k(n,a,mod)
B = mod_cmb_k(n,b,mod)
ans = 2**n-1-A-B
print(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 = map(int,input().split())
ans = 0

for i in range(1,n+1):
    if (i!=a) and (i!=b):
        ans += cmb(n, i,mod)
        
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 )
    
A=cmb(n,a,mod)
B=cmb(n,b,mod)
    
def pos(x, n, m):
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res
    
C=pos(2,n,mod)

if n==2:
    print(0)
else:
    print((C-1-A-B)%mod)

Submission status: Runtime Error

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 
import resource

resource.setrlimit(resource.RLIMIT_DATA, (-1, -1))

def combMod(n, r, p):
    fact = [0] * (n+1)
    fact[0] = fact[1] = 1
    factinv = [0] * (n+1)
    factinv[0] = factinv[1] = 1
    inv = [0] * (n+1)
    inv[1] = 1
    for i in range(2, n+1):
        fact[i] = (fact[i-1] * i) % p
        inv[i] = (-inv[p % i] * (p // i)) % p
        factinv[i] = (factinv[i-1] * inv[i]) % p
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    # print(fact)
    # print(factinv)
    return fact[n] * factinv[r] * factinv[n-r] % p

def resolve():
    n, a, b = map(int, input().split())
    mod = 10**9+7
    print((pow(2, n, mod) - 1) - (combMod(n, a, mod) + combMod(n, b, mod)))
    # print(combMod(n, a, mod))
    # print(combMod(n, b, mod))

if __name__ == '__main__':
    resolve()

Submission status: Runtime Error

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

ans = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    tp = 1
    for j in range(n, n - i, -1):
        tp *= j
    for j in range(2, i + 1):
        tp /= j
    ans += tp
    print(i, tp)
ans = round(ans % (10**9 + 7))
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())

p = 10 ** 9 + 7

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

Submission status: Runtime Error

Solution code:
from operator import mul
from functools import reduce

n, a, b= [int(x) for x in stdin.readline().rstrip().split()]

combi = 0
wari = (10 ** 9) + 7

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

for i in range(1,n+1):
  if i == a or i == b:
    continue
  combi = combi + combinations_count(n, i)

print(combi % wari)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = 0
MAX = 500000000
fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [0, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = -inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def neko(n, r):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


if n % 2:
    for i in range((n + 1) // 2):
        ans += neko(n, i) * 2 % mod
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))
else:
    for i in range(n // 2):
        ans += neko(n, i) * 2 % mod
    ans += neko(n, n // 2)
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))

Submission status: Runtime Error

Solution code:
N, A, B = map(int, input().split())
mo = 10 ** 9 + 7
from functools import lru_cache
@lru_cache(maxsize=10000000)
def hanaya(n, x):
    if x == 1:
        return n
    else:
        return int(((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())

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 )
    
print(max(0,pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-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 )

mod = 10**9 + 7 
r = 0
ans = 1
for  i in range(1,N):
        ans *= 2
        if r > 30:
            ans %= (10**9 +7)
            r = 0
        r += 1
ans = ans % (10^9 + 7)
ans = ans - (cmb(n,a,mod)+cmb(n,b,mod)+1)
print(ans)

Submission status: Runtime Error

Solution code:
import itertools
n,a,b = map(int,input().split())
ans = 0
for i in range(1,len(n)+1)
if i == a or i == b:
  continue
else:
  ans += len(list(itertools.combinations(n,i)))
print(ans)

Submission status: Runtime Error

Solution code:
from functools import lru_cache

n, a, b = [int(item) for item in input().split()]
total_comb = 0

# @lru_cache(maxsize=None)
def my_comb(n, r):
    if n == 1 or r == 1:
        return 1
    
    return my_comb(n-1, r-1) * n / r

total_comb -= my_comb(n, a)
total_comb -= my_comb(n, b)

# print(total_comb)

def bin(N):
    res = ''
    while N >= 2:
        if N == 2:
            res += '10'
        res += str(N%2)
        N = N//2

    return res[::-1]

temp_num = n - 1
temp_index = bin(temp_num)
# print(temp_index)
for i, v in enumerate(reversed(temp_index)):
    if v == '1':
        total_comb += my_comb(n + i, 2*i + 1)
    
    total_comb %= (10**9 + 7)


print(int(total_comb + 1))

Submission status: Runtime Error

Solution code:
def mpow(x: int, k: int, MOD=1000000007) -> int:
    """
    x^kのmodを返します
    """
    res = 1
    y = x
    while (k):
        if(k % 2 == 1):
            res = (res * y) % MOD
        y = (y ** 2) % MOD
        k = k // 2
    return res
'''
def cmb(n, x, mod=10**9+7):
    # nCx
    # 組み合わせ
    # ex) combination(5, 2) = 10
    factorial = [1] * (n+1)
    t = 1
    for i in range(1, n+1):
        t = (t * i) % mod
        factorial[i] = t
    tmp = factorial[n]
    tmp = (tmp * pow(factorial[x], mod-2, mod)) % mod
    tmp = (tmp * pow(factorial[n-x], mod-2, mod)) % mod
    return tmp
'''
mod = 10**9+7 #出力の制限

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

print(mpow(2,10**9))

num = 1000000000 + 7

MAX_NUM = N
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 cmb(n,k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

#print(mpow(2,N))

print(mpow(2,N)- cmb(N, a) - cmb(N, b) -1)

Submission status: Runtime Error

Solution code:
n,a,b=map(int, input().split())
f_num=0
if n==2:
    print('0')
else:
    from scipy.special import comb
    for i in range(1,n+1):
        if i!=a and i!=b:
            f_num+=cmb(n,i,exact=True)
    print(f_num%(10**9+7))

Submission status: Runtime Error

Solution code:
import math

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

dp = [0]*n

for i in range(1,n):
  if i == 1:
    dp[1] = n
    list.append(n)
  else:
    dp[i] = dp[i-1]*(n-i)
    list.append(dp[i]//i)

sum_list = sum(list)
print(sum_list)

ans = sum_list - (dp[a]//a)-(dp[b]//b)

print(ans if ans <= 10**9+7 else ans%(10**9+7))

Submission status: Runtime Error

Solution code:
M,A,B = [int(x) for x in 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 = 200000
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 binary(n):
    return bin(n)[2:]


def pow_by_binary_exponentiation(a, x, n): # a^x mod n
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * a) % n
    return y
d = pow_by_binary_exponentiation(2,M,mod)-1
    
d1 = cmb(M,A,mod)
d2 = cmb(M,B,mod)
print((d-d1-d2)%mod)

Submission status: Runtime Error

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

dp = [0] * (n + 1)
dp[0] = 1
prime = 10 ** 9 + 7
ans = 0
for i in range(1, n + 1):
    ue = n - i + 1
    shita = i
    if shita < ue:
        dp[i] = (dp[i - 1] * ue) // shita
    else:
        # break
        dp[i] = dp[n - i]

for i in range(1, n + 1):
    if i != a and i != b:
        ans += dp[i] % prime

# print(dp)
print(ans)

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 int(((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:
from functools import lru_cache

@lru_cache(maxsize=1000000)
def fact(n):
  if n <= 1:
    return 1
  return fact(n-1)

def comb(n,r):
    return fact(n) // fact(n-r) // fact(r)

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

ans = (2 ** n - 1) - comb(n, a) - comb(n, b)
ans = ans % (10 ** 9 + 7)
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 )

mod = 10**9 + 7 
r = 0
ans = 1
for  i in range(1,N):
        ans *= 2
        if r > 30:
            ans %= (10**9 +7)
            r = 0
        r += 1
ans = ans % (10^9 + 7)
ans = ans - (cmb(n,a,mod)+cmb(n,a,mod)+1)
print(-(ans))

Submission status: Runtime Error

Solution code:

import numpy as np


N,A,B = map(int,input().split())
i =np.arange(1,N+1,1)
a=0
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)]
for j in range(N):

	if i[j] != A and i[j] != B:
		a +=cmb(N,i[j])
		
a %= 10**9+7	
print(a)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
n, a, b = [int(x) for x in input().strip().split()]
mod = 10 ** 9 + 7
ans = pow(2, n, mod) - 1

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

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

ans = (ans - (fact[n] * inv[n-a] * inv[a]) % mod) % mod
ans = (ans - (fact[n] * inv[n-b] * inv[b]) % mod) % mod
print(ans)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
mod = 10**9 + 7
ans = 0
MAX = 500000
fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [0, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = -inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def neko(n, r):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


if n % 2:
    for i in range((n + 1) // 2):
        ans += neko(n, i) * 2 % mod
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))
else:
    for i in range(n // 2):
        ans += neko(n, i) * 2 % mod
    ans += neko(n, n // 2)
    ans -= neko(n, a)
    ans -= neko(n, b)
    print(max(ans - 1, 0))

Submission status: Runtime Error

Solution code:
from scipy.special import comb
import sys

sys.setrecursionlimit(10 ** 9)

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


def my_pow(x, n):
    # //----  初期条件
    if n == 0:
        return 1     # // 初期条件 F(0)＝1
    elif n == 1:
        return x          # // 初期条件 F(1)＝x
    #  //----  漸化式
    elif n % 2 == 0:                # // nの奇遇で場合分け
        return my_pow(x, n / 2) ** 2         # // 偶数のとき  F(x, n)＝sq(F(x, n/2))
    else:
        return x * my_pow(x, (n - 1) / 2) ** 2   # // 奇数のとき  F(x, n)＝x*sq(F(x, n/2))


X = my_pow(2, N) - comb(N, a, exact=True) - comb(N, b, exact=True) - 1

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

Submission status: Runtime Error

Solution code:
import sys
from io import StringIO
import unittest

import math

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**5)*2
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 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
        x = x%mod #
        n //= 2

    return K * x

def resolve():

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

    ptn = pow_k(2,n)
    ptn -= 1


    comba=cmb(n,a,mod)
    combb=cmb(n,b,mod)

    ptn -= (comba+combb)
    ptn = ptn%mod

    print(ptn)

    return 

resolve()

Submission status: Runtime Error

Solution code:
import math
n, a, b = map(int, input().split())
x = 1
my_list = [0] * n

for i in range(n):
    x = x * (n - i) // (i + 1)
    my_list[i] = x

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

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

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
l=[0]*n
l[0]=n

d1=n
e1=1

for i in range(1,n):
  d2=d1*(n-i)
  e2=e1*(i+1)
  l[i]=d2//e2
  d1=d2
  e1=e2
del l[a-1]
del l[b-2]
k=sum(l)
print(k%(10**9 +7))