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:
n,a,b=map(int,input().split())
mod = 1000000007
ans = pow(2,n,mod) - 1

def solve(nu):
    res = 1
    for i in range(nu):
        res *= n-i
    for i in range(nu):
        res/=i+1
    res%=mod
    return res

ans -=solve(a)
ans %= mod
ans -= solve(b)
ans %= mod

print(ans)

Submission status: Runtime Error

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

##############################################
#https://tane-no-blog.com/976/
mod = pow(10, 9) + 7
 
def comb(N, x):
    #n*(n-1)*…*(n-1+1)を計算
    numerator = 1
    for i in range(N-x+1, N+1):
        numerator = numerator * i % mod
    
    #a!を計算 
    denominator = 1
    for j in range(1, x+1):
        denominator = denominator * j % mod
        
    #最後の項 a!**((10**9+7)-2)を計算
    d = pow(denominator, mod-2, mod)
    
    return numerator * d

################################

comb_all = pow(2,n,MOD_BY) - 1 #(2**n) - 1
comb_a = comb(n,a)
comb_b = comb(n,b)

#print(comb_all,comb_a,comb_b)
print((comb_all-comb_a-comb_b)%MOD_BY)

Submission status: Runtime Error

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


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret


N, A, B = map(int, input().split())
MOD = 10**9+7
F = FactMod(N+1, MOD)

print(pow(N, 2, MOD)-1 - F.comb(N, A) - F.comb(N, B))

Submission status: Runtime Error

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

fac = [0 for _ in range(n+1)]
inv = [0 for _ in range(n+1)]
finv = [0 for _ in range(n+1)]

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

p = 10**9 + 7
#p = 31
#inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
for i in range(2,n+1):
    fac[i] = (fac[i-1]*i)%p
    inv[i] = (p - inv[p%i]*int(p/i)%p)%p
    finv[i] = (finv[i-1]*inv[i])%p
    
#print(fac)
#print(inv)
#print(finv)

def cal(m,k):
    return fac[m]*(finv[k]*finv[m-k]%p)%p

ans=pow(2,n,mod) - 1
ans = (ans - cal(n,a) - cal(n,b))%p

if(ans<0):
    ans = -1*ans

print(ans)

Submission status: Runtime Error

Solution code:
import math

MOD = 10 ** 9 + 7


def cmb(n, r):
    total = 1
    for i in range(r):
        total *= (n - i) % MOD
    return total * pow(math.factorial(r), MOD - 2, MOD) % MOD


def calc(n, r):
    ret = 1
    for i in range(r):
        ret = ret * (n - i) % MOD
    return ret * pow(factorial(r), MOD - 2, MOD) % MOD


if __name__ == '__main__':
    n, a, b = list(map(int, input().split(" ")))

    total = pow(2, n, MOD)
    a_total = calc(n, a)
    b_total = calc(n, b)
    print((total - a_total - b_total - 1) % MOD)

Submission status: Runtime Error

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

res = int(2**n-1)
caa = 1
cab = 1
abu = 1
abs = 1
bbu = 1
bbs = 1

for y in range(a):
  abs *= n - y
  abs /= y + 1
  
for z in range(b):
  bbs *= n - z
  bbs /= z + 1

res -= int(abs+bbs)
print(int(res%(10**9+7)))

Submission status: Runtime Error

Solution code:
#coding:utf-8
#!/usr/bin/python

a,b=map(int,raw_input().split())

N=pow(10,9)+7
n=1000000000
#a=141421
#b=173205

def modpow(b,e,m): 

    result=1

    while(e!=0): 
          if(e&1==1): 
             result=(result*b)%m 
          e>>=1
          b=(b*b)%m
    
    return result

def combination(n,r,N):
    bunshi=1
    for i in range(n-r+1,n+1):
        bunshi=(bunshi*i)%N
    bunbo=1
    for i in range(1,r+1):
        bunbo=(bunbo*i)%N
    return bunshi*modpow(bunbo,N-2,N)

#pow(2,n)-nCa-nCb-1
#nCr=n!/((n-r)!*r!)だから
#bunshi=n*n-1*・・・*n-r+1
#bunbo=1*・・・*r
#Nが素数だから、フェルマーの小定理より
#modpow(a,N-1,N)=1
#a*pow(a,N-2)=pow(a,N-1)=1(modN)
#より。aのmodNでの逆元はpow(a,N-2)になる。
#r!の逆元が欲しいから、modpow(bunbo,N-2,N)を掛ける。

print (modpow(2,n,N)-combination(n,a,N)-combination(n,b,N)-1)%N

Submission status: Runtime Error

Solution code:
import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 
if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
def mpow(a,n,mod):
  if n == 0:
    return 1
  elif n == 1:
    return a
  elif n%2==0:
    return (pow(a,n/2,mod))**2%mod
  else:
    return a*pow(a,n-1,mod)%mod
def mfac(l,r,mod):
  ans = l
  for i in reversed(range(r,l)):
    ans *= i
    ans %= mod
  return ans
def mcomb(n,k,mod):
  A = mfac(n,n-k+1)
  B = mfac(k,1)
  B = mpow(B,mod-2,mod)
  return A*B%mod

def main():
  mod = 10**9+7
  n,a,b = map(int,input().split(" "))
  ans = mpow(2,n,mod)-1+mcomb(n,a,mod)-mcomv(n,b,mod)
  ans %= mod
  print(ans)

if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
def modpow(a,n):
    if n==0:
        return 1
    elif n==1:
        return a%mod
    elif n%2==0:
        return (modpow(a,n/2)**2)%mod
    else:
        return (a*modpow(a,n-1))%mod

def modfact(l,r):
    fact=1
    for i in range(l-r+1):
        fact=fact*(r+i)%mod
    return fact

def comb(n,x):
    S=modfact(n,n-x+1)
    fact=modfact(x,1)
    T=modpow(fact,mod-2)
    print(S,fact,T,S*T%mod)
    return S*T%mod

n,a,b=map(int,input().split())
fact=modpow(2,n)
ans=fact-1-comb(n,a)-comb(n,b)
while ans<0:
    ans+=mod
print(ans)

Submission status: Runtime Error

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

def combination(n,x,mod):
    bunbo=1
    bunshi=1
    for i in range(x):
        bunbo*=n-i
        bunshi*=i
        buubo=bunbo%mod
        bunshi=bunshi%mod
    return (bunshi//bunshi)%mod

mod=1000000007
answer=2**n-1
answer-=combination(n,a,mod)
answer-=combination(n,b,mod)
answer=answer%mod
print(answer)

Submission status: Runtime Error

Solution code:
def power_func(a, b, p):
  """a^b mod 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 comb(n, k, p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a = factorial(n) % p
  b = power_func(factorial(k) % p, p-2, p)
  c = power_func(factorial(n-k) % p, p-2, p)
  return (a*b*c)%p
  
n, a, b = map(int, input().split())

MOD = 10**9 + 7


print((pow(2,n,MOD) - 1 - comb(n, a, MOD) - comb(n, b, MOD))

Submission status: Runtime Error

Solution code:
def factorial_mod(a, M):
    ans = 1
    for i in range(a,1,-1):
        ans = (ans * i) % M
    return ans
def test(n, a, M):
    ans = 1
    for i in range(a):
        ans = (ans * (n-i)) % M
    return ans
def combination_mod(n,a,M):
    tmp = factorial_mod(a,M)
    tmp = pow(tmp, M-2, M)
    ans = test(n,a,M) * tmp % M
    return ans
def output(n,a,b):
    M = 10**9+7
    ans = (pow(2,n,M) - 1 - combination_mod(n,a,M) - combination_mod(n,b,M)) % M
    return ans
n, a, b = map(int, input().split())
print(output(a,b,c))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
MOD = 1000000007
l_fac = [0] * (n + 1)
l_finv = [0] * (n + 1)
l_inv = [0] * (n + 1)

def f_comb(m, r):
  if m < r:
  	return 0
  if m < 0 or r < 0:
  	return 0
  return l_fac[m] * (l_finv[r] * l_finv[m - r] % MOD) % MOD

l_fac[0] = l_fac[1] = 1
l_finv[0] = l_finv[1] = 1
l_inv[1] = 1

for i in range(2, n + 1):
  l_fac[i] = l_fac[i - 1] * i % MOD
  l_inv[i] = MOD - l_inv[MOD%i] * (MOD // i) % MOD
  l_finv[i] = l_finv[i - 1] * l_inv[i] % MOD

total = 0
for i in range(1, n + 1):
  if i == a or i == b:
    continue
  total += f_comb(n, i)
  total %= MOD
print(total)

Submission status: Runtime Error

Solution code:
import numpy as np
def comb_mod(n, a, m):
  if a > n:
    return 0
  a = min(a, n-a+1)
  # tbl = [[0]*(a+1) for _ in range(2)]
  tbl = np.zeros((2, a+1), dtype=np.int64)
  tbl[0][0] = 1
  tbl[1][0] = 1
  # for i in tqdm(range(n)):
  for i in tqdm(range(n)):
    # tbl[i%2][0] = 1
    tbl[i%2][1:] = (tbl[(i+1)%2][1:] + tbl[(i+1)%2][:-1]) % m
    # for k in range(min(i+1, len(tbl[i%2]))):
    #   if i == k:
    #     tbl[i%2][k] = 1
    #   elif i < k:
    #     tbl[i%2][k] = 0
    #   elif k == 0:
    #     tbl[i%2][k] = 1
    #   else:
    #     tbl[i%2][k] = (tbl[(i-1)%2][k-1] + tbl[(i-1)%2][k]) % m
  return tbl[(n-1)%2][a]

n, a, b = map(int, input().split(' '))
c = 0
for i in range(1, n+1):
  if i == a or i == b:
    continue
  c += comb_mod(n, i, 1000000007)
print(c)

Submission status: Runtime Error

Solution code:
num_in = list(map(int, input().split()))
n = num_in[0]
a = num_in[1]
b = num_in[2]
result = 0
i = 1

if n <= b:
  print(0)
else:
  if n < 2 * 10 ** 5:
    while i < n:
      result += math.factorial(n) / math.factorial(n - i) / math.factorial(i)
  else:
    while i < 2 * 10 ** 5:
      result += math.factorial(n) / math.factorial(n - i) / math.factorial(i)
  result -= math.factorial(n) / math.factorial(n - a) / math.factorial(a)\
  + math.factorial(n) / math.factorial(n - b) / math.factorial(b)
  print(result % (10 ** 9 + 7))

Submission status: Runtime Error

Solution code:
mod=10**9+7
ors=[n]
rev=[1]

def ie(n,r,mod):
  if r==1:
    return n
  elif r%2==0:
    return (ie(n,r//2,mod)**2)%mod
  else:
    return n*((ie(n,(r-1)//2,mod))**2)%mod
  
for i in range(1,b):
  ors.append(ors[-1]*(n-i)%mod)
  rev.append(rev[-1]*(i+1)%mod)  
N=ie(2,n,mod)
A=ors[a-1]*ie(rev[a-1],mod-2,mod)
B=ors[b-1]*ie(rev[b-1],mod-2,mod)
print((N-A-B-1)%mod)

Submission status: Runtime Error

Solution code:
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
      return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
ans = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod 
if ans < 0:
  ans += mod
print(ans)

Submission status: Runtime Error

Solution code:

from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
      return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
ans = pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod 
if ans < 0:
  ans += mod
  print(ans)

Submission status: Runtime Error

Solution code:
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
      return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
print(pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1)

Submission status: Runtime Error

Solution code:
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
print(pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1)

Submission status: Runtime Error

Solution code:
def pre_cmb_mod(n, mod):
    if n == 0:
        return [1], [1]
    fact = [1, 1]
    inv = [0, 1]
    factinv = [1, 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)
    return fact, factinv


def cmb_mod(n, r, mod, fact, factinv):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % mod
  
  mod = 10**9 + 7
n, a, b = map(int, input().split())

fact, factinv = pre_cmb_mod(n, mod)

result = 0
for r in range(1, n+1):
    if r == a or r == b:
        continue
    result += cmb_mod(n, r, mod, fact, factinv)
    result %= mod

print(result)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
s=0
p=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
 
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return prepare(n,p)[0][n] * prepare(n,p)[1][r] * prepare(n,p)[1][n-r] % p
 
s=(2**n-1)%p-cmb(n,a,p)-cmb(n,b,p)
 
print(s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
mod=10**9+7
if abs(n-m)>1:
    print(0)
    exit()
a,b=[1,1]
for i in range(1,min(n,m)+1):
    a=(a*i)%mod
if n!=m:
    b*=max(n,m)*a
    print((a*b)%mod)
else:
    b=a
    print((2*a*b)%mod)

Submission status: Runtime Error

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

for i in range(1,n+1):
    numerator = (numerator*(n-i+1))%mod
    denominator = (denominator*i)%mod
    if i == a or i == b:
        ans = ans - (numerator*pow(denominator,mod-2,mod))%mod
        if i == b:
            break

print(ans%mod)

Submission status: Runtime Error

Solution code:
mod=10 ** 9 + 7

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

def power(x,n):
    if n==0:
        return 1
    elif n%2==0:
        half=power2(x,n//2)
        return half**2 %mod
    else:
        half=power2(x,(n-1)//2)
        return  half**2 * x %mod

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

ans=(power(2,n) - binomial(n,a) -binomial(n,b))%mod

print(ans)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
mod = 10**9+7
def Pow(a, n):
    if n == 0: return 1
    if n%2 == 0:
        return (Pow(a, n//2))**2%mod
    else:
        return Pow(a, n-1)*a%mod
cnt = Pow(2, n) - 1
x = [0] * (n+1)
for i in range(1,b+1):
    x[i] = Pow(i, mod-2)
cmb = [0] * (n+1)
cmb[1] = n
for i in range(2, b+1):
    cmb[i] = cmb[i-1]*(n-i+1)%mod*x[i]%mod
cnt -= cmb[a]+cmb[b]
print(cnt%mod)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  ll n,a,b; cin >> n >> a >> b;
  ll ans = RS(2,n,M);
  
  //nCa
  ll bunbo=1; ll bunshi=1;
  rep(i,a){
    bunbo = bunbo * (i+1) % M;
    bunshi = bunshi * (n-i) % M;
  }
  ll nCa = bunshi * RS(bunbo,M-2,M) % M;
  //nCb
  bunbo=1; bunshi=1;
  rep(i,b){
    bunbo = bunbo * (i+1) % M;
    bunshi = bunshi * (n-i) % M;
  }
  ll nCb = bunshi * RS(bunbo,M-2,M) % M;
  
  ans -= (nCa+nCb+1)%M;
  if (ans < 0) ans += M;
  cout << ans << "\n";
  return 0;
}

Submission status: Runtime Error

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

def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i 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 *= numerator[k]
            result %= mod
    return int(result)

ans = (pow(2, n, mod)-1-(mod-nCr(n, a))-(mod_nCr(n, b)))%mod
print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
 
/*** Template Begins ***/
 
typedef unsigned long long    ll;
typedef pair<ll,ll>  pll;
typedef pair<ll, pair<int, int> > plll;
typedef vector<long long>  vll;
typedef vector<pll>  vp;
typedef long double ld;
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
// #define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
// #define h 998244353
#define all(a)       (a).begin(),(a).end()
ll power(ll x, ll y, ll p)
{
  ll res = 1;
  x = x % p;
  while (y > 0)
  { 
    if (y & 1) 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  } 
  return res; 
} 
const int MAXN = 1e5+7;

// Debug //
#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
// #define trace6(a, n,i;b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

// Constants //
 
/*** Template Ends ***/
ll ncr(ll n,ll r)
{
  ll i;
  if(n==0 || r==0 || n==r)
    return 1;
  ll num = 1,deno=1;
  for(i=1;i<=r;i++)
  {
    num*=(n-(i-1));
    num%=hell;
    deno*=i;
    deno%=hell;
  }
  num*=power(deno,hell-2,hell);
  num%=hell;
  return num;
}
void solve()
{
  ll n,a,b;
  cin>>n>>a>>b;
  ll sub = ncr(n,a)+ncr(n,b)+1;
  // trace2(ncr(n,a),ncr(n,b) );
  sub%=hell;
  ll ans = power(2,n,hell);
  ans = (ans-sub+hell)%hell;
  cout<<ans;
}
int main()
{ 
  // ios;
  // fxreopen("inputt.txt", "w", stdout);
  ll t;
  // cin >> t;
  t=1;
  while(t--)
    solve();
  return 0;
}

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

s=(2**n-1)%(10**9+7)
x=comb(n,a,exact=True)%(10**9+7)
y=comb(n,b,exact=True)%(10**9+7)

print(s-x-y)

Submission status: Runtime Error

Solution code:
def main():
    n, a, b = map(int, input().split())
    value_max = 2 * (10 ** 5)
    com = [0 for _ in range(value_max + 1)]
    com[1] = n
    mod = 10 ** 9 + 7
    mod_inverse = [pow(i, mod - 2, mod) for i in range(1, value_max + 1)]
    ans = pow(2, n, mod)
 
    # KeyInsight:
    # 全体 - 条件を満たす場合
    # modの世界では割り算の代わりに逆元を使う
    # See:
    # https://www.youtube.com/watch?v=lzAMKPMLdtU&feature=youtu.be
    for i in range(2, min(n, value_max) + 1):
        if (n - i + 1) == 0:
            break
 
        com[i] = com[i - 1] * (n - i + 1)
        com[i] *= mod_inverse[i - 1]
        com[i] %= mod
 
    diff = (com[a] + com[b] + 1) % mod
    print((ans - diff) % mod)
 main()

Submission status: Runtime Error

Solution code:
# from .myutil import Combination


class Combination:
    mod = 0
    N = 0
    g1 = [1, 1]
    g2 = [1, 1]
    inverse = [0, 1]

    def __init__(self, mod=10 ** 9 + 7, N=10 ** 6):
        self.mod = mod
        self.N = N
        for i in range(2, self.N + 1):
            self.g1.append((self.g1[-1] * i) % self.mod)
            self.inverse.append((-self.inverse[self.mod % i] * (self.mod // i)) % self.mod)
            self.g2.append((self.g2[-1] * self.inverse[-1]) % self.mod)

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


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

total = (2 ** n) - comb.cmb(n, a) - comb.cmb(n, b) - 1

print(total)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

Submission status: Runtime Error

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

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result = int(numerator[k]) * result % mod

    return result
  
 def m_power_n_mod(m,n,mod):
    q = 1
    f = m
    while(n > 0):
        c = n % 2
        n = int((n-c)/2)
        q = (q * f**c) % mod
        f = f**2 % mod
    return q
 
print((m_power_n_mod(2,n,mod) - 1 - cmb(n,a)%mod - cmb(n,b)%mod)%mod)

Submission status: Runtime Error

Solution code:
from scipy.misc import comb

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

ret = 0
for i in range(n):
    if i+1 == a : continue
    if i+1 == b : continue
    ret = ret + scipy.special.comb(n, i+1, exact=True)
    if ret > 1000000007 : ret = ret % 1000000007
    if i>10 : break
print(ret)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

ret = 0
for i in range(n):
    if i+1 == a : continue
    if i+1 == b : continue
    ret = ret + comb(n, i+1, exact=True)
    if ret > 1000000007 : ret = ret % 1000000007
print(ret)

Submission status: Runtime Error

Solution code:
# sys.setrecursionlimit(100000)
n,a,b = map(int,input().split())
mod = 10**9+7
count = 0
def cmb(n,r):
  if n == 0 or n == r: return 1
  if r == 1: return n
  return cmb(n-1,r) + cmb (n-1,r-1)
for i in range(1,n+1):
  if i != a and i != b:
    count += cmb(n,i)
print(count % mod)

Submission status: Runtime Error

Solution code:
n,a,b = map(int,input().split())
mod = 10**9+7
count = 0
def cmb(n,r):
  if n == 0 or n == r: return 1
  if r == 1: return n
  return cmb(n-1,r) + cmb (n-1,r-1)
for i in range(1,n+1):
  if i != a and i != b:
    count += cmb(n,i)
print(count % mod)

Submission status: Runtime Error

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

ret = 0
for i in range(n):
    if i+1 == a : continue
    if i+1 == b : continue
    ret = ret + (math.factorial(n) // (math.factorial(n-i-1) * math.factorial(i+1)))
    if ret > 1000000007 : ret - 1000000007
print(ret)

Submission status: Runtime Error

Solution code:
from scipy.special import comb
n, a, b = [int(_) for _ in input().split()]
print(pow(2,n)-1 - special.comb(n, a, True) - special.comb(n, b, True))

Submission status: Runtime Error

Solution code:
MOD = 1000000007

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

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def xgcd(a, b):
	x0, y0, x1, y1 = 1, 0, 0, 1
	while b != 0:
		q, a, b = a // b, b, a % b
		x0, x1 = x1, x0 - q * x1
		y0, y1 = y1, y0 - q * y1
	return a, x0, y0

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def modinv(a, m):
	g, x, y = xgcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def combination(n, r):
	ans = 1
	for i in range(n - r + 1, n + 1):
		ans *= i
		ans %= MOD
	for i in range(1, r + 1):
		ans *= modinv(i, MOD)
		ans %= MOD
	return ans

ans = 0
ans += pow(2, n, MOD)
 - 1
ans += MOD - combination(n, a)
ans += MOD - combination(n, b)
ans %= MOD

print(ans)

Submission status: Runtime Error

Solution code:
import math
N, a, b = map(int,input().split())
p = pow(10,9) + 7
a_c = 1
b_c = 1
a_m = 1
b_m = 1
for i in range(a):
  a_c = a_c * (N-i) % p
  a_m = a_m * (i+1) % p
m_a = a_c * pow(a_m, p-2, p) % p
for j in rnage(b):
  b_c = b_c * (N-j) % p
  b_m = b_m * (j+1) % p
m_b = b_c * pow(b_m,p-2,p) % p
print((pow(2,N, p) - 1 - m_a - m_b) % p)

Submission status: Runtime Error

Solution code:
import math
N, a, b = map(int,input().split())
p = 10 ** 9 +7
a_c = 1
b_c = 1
a_m = 1
b_m = 1
for i in range(a):
  a_c = a_c * (N-i) % p
  a_m = a_m * (i+1) % p
  m_a = a_c * pow(a_m, p-2, p) % p
for j in rnage(b):
  b_c = b_c * (N-j) % p
  b_m = b_m * (j+1) % p
  m_b = b_c * pow(b_m,p-2,p) % p
print((pow(2,N, p) - 1 - m_a - m_b) % p)

Submission status: Runtime Error

Solution code:
import math
N, a, b = map(int,input().split())
p = 10 ** 9 +7
A = math.factorial(a)
B = math.factorial(b)
a_c = 1
b_c = 1
a_m = 1
b_m = 1
for i in range(a):
  a_c = a_c * (N-i) % p
  a_m = a_m * (i+1) % p
  m_a = a_c * pow(a_m, p-2, p) % p
for j in rnage(b):
  b_c = b_c * (N-j) % p
  b_m = b_m * (j+1) % p
  m_b = b_c * pow(b_m,p-2,p) % p
print((pow(2,N, p) - 1 - m_a - m_b) % p)

Submission status: Runtime Error

Solution code:
import math
N, a, b = map(int,input().split())
p = 10 ** 9 +7
A = math.factorial(a)
B = math.factorial(b)
n_c_a = 1
n_c_b = 1
for i in range(a):
  n_c_a *= N-i
for j in rnage(b):
  n_c_b *= N-j
m_a = (n_c_a*pow(A,p-2))% p
m_b = (n_c_b*pow(B,p-2))% p
print((pow(2,N) - 1 - m_a - m_b) % p)

Submission status: Runtime Error

Solution code:
import math
N, a, b = map(int,input().split())
p = 10 ** 9 +7
def fc(t):
  if t == 0:
    return 1
  elif t % 2 == 1:
    return ((fc(t//2)) **2 )* 2
  else:
    return (fc(t//2)) ** 2
A = math.factorial(a)
B = math.factorial(b)
n_c_a = 1
n_c_b = 1
for i in range(a):
  n_c_a *= n-i
for j in rnage(b):
  n_c_b *= n-j
m_a = (n_c_a*pow(A,p-2))% p
m_b = (n_c_b*pow(B,p-2))% p
print((pow(2,N) - 1 - m_a - m_b) % p)

Submission status: Runtime Error

Solution code:
import math
N, a, b = map(int,input().split())
p = 10 ** 9 +7
def fc(t):
  if t == 0:
    return 1
  elif t % 2 == 1:
    return ((fc(t//2)) **2 )* 2
  else:
    return (fc(t//2)) ** 2
A = math.factorial(a)
B = math.factorial(b)
n_c_a = 1
n_c_b = 1
for i in range(a):
  n_c_a *= n-i
for j in rnage(b):
  n_c_b *= n-j
m_a = (n_c_a // A)% p
m_b = (n_c_b // A) % p
print((fc(N) - 1 - m_a - m_b) % p)

Submission status: Runtime Error

Solution code:
import math
N, a, b = map(int,input().split())
p = 10 ** 9 +7
def fc(t,k):
  if t == 0:
    return 1
  elif t % 2 == 1:
    return (fc(t//2,k)) **2 * k
  else:
    return (fc(t//2,k)) ** 2
A = math.factorial(a)
B = math.factorial(b)
n_c_a = 1
n_c_b = 1
for i in range(a):
  n_c_a *= n-i
for j in rnage(b):
  n_c_b *= n-j
m_a = n_c_a // A % p
m_b = n_c_b // A % p
print((fc(N,2) - 1 - m_a - m_b) % p)

Submission status: Runtime Error

Solution code:
import math
N, a, b = map(int,input().split())
p = 10 ** 9 +7
def fc(t,k):
  if t == 0:
    return 1
  elif t % 2 == 1:
    return (fc(t//2,k)) **2 * k
  else:
    return (fc(t//2,k)) ** 2
A = math.factorial(a)
B = math.factorial(b)
n_c_a = 1
n_c_b = 1
for i in range(a):
  n_c_a *= n-i
for j in rnage(b):
  n_c_b *= n-j
m_a = fc(p-2,A) * n_c_a % p
m_b = fc(p-2,B) * n_c_b % p
print((fc(N,2) - 1 - m_a - m_b)%2)

Submission status: Runtime Error

Solution code:
from scipy.special import comb