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: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )


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


def f(p):
    if p == 0:
        return ModInt(1)
    if p % 2 == 0:
        t = f(p // 2)
        return t * t
    return 2 * f(p // 2)


nC = [ModInt(1)]
for i in range(1, 200005):
    nC.append(nC[-1] * (n - i + 1) / i)
# print(nC[-10:])

print((f(n) - nC[a] - nC[b]))

Submission status: Wrong Answer

Solution code:
import math
lists = list(map(int, input().split()))
n = lists[0]
a,b = lists[1],lists[2]
skip_num = [a,b]
r = 0
for i in range(1,n+1):
    if i not in skip_num:
        print(i)
        r = r + (math.factorial(n)/(math.factorial(n-i)*math.factorial(i)))
print(r)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
ans=2**n-1
x=1
y=1
i=0
while a:
	i+=1
	x*=(n-i+1)
	y*=i
	a=a-1
ans1=x/y
x=1
y=1
i=0
while b:
	i+=1
	x*=(n-i+1)
	y*=i
	b=b-1
ans2=x/y
ans=ans-ans1-ans2
ans%=100000007
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
from itertools import accumulate
from operator import mul
from collections import deque
import copy

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

nums = [i for i in range(1,n + 1)]
fact = deque([1] + list(accumulate(nums,mul)))
fact2 = copy.deepcopy(fact)
N = fact[-1]

ans = 0

for i in range(0,n + 1):
  r = fact.popleft()
  k = fact2.pop()
  if i != a and i != b and i > 1:
    ans += int(N / (r * k)) % mod

print(ans)

Submission status: Wrong Answer

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


def ncr(n, r):
    res = 1
    for i in range(1, r + 1):
        res = res * (n - i + 1) // i
        res %= 10 ** 9 + 7
    return res


def myPow2(a, n):
    x = 1
    while n > 0:
        if n & 1:
            x = x * a
            x %= 10 ** 9 + 7
        a = a * a
        a %= 10 ** 9 + 7
        n >>= 1
    return x


av = ncr(n, a)
bv = ncr(n, b)
ans = myPow2(2, n) - 1
x = ans - av - bv
if x < 0:
    x += 10 ** 9 + 7
print(x % (10 ** 9 + 7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

n, a, b = map(int,input().split())
if n == 2:
  print(0)
else:
  total = 2 ** n -1
  total  = total 
  print(total % (10 ** 9 + 7)-cmb(n,a,10**9+7) -cmb(n,a,10**9+7))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
a, b = min(a, n-a), min(b, n-b)
ans = pow(2, n, 1000000007) - 1

temp1, temp2, count = 1, 1 ,0
for i in range(min(a, b)):
    temp1 *= n - i
    temp2 *= i + 1
    if temp1 >= 1000000007:
        temp1 %= 1000000007
        count += 1
if a == b:
    ans -= 2 * (temp1 + (100000007 * count) // temp2) % 1000000007
    if ans < 0:
        print(ans + 1000000007)
    else:
        print(ans)
else:
    ans -= (temp1 + (100000007 * count) // temp2) % 1000000007
    if ans < 0:
        ans += 1000000007
    for i in range(min(a, b), max(a, b)):
        temp1 *= n - i
        temp2 *= i + 1
        if temp1 >= 1000000007:
            temp1 %= 1000000007
            count += 1
    ans -= (temp1 + (100000007 * count) // temp2) % 1000000007
    if ans < 0:
        print(ans + 1000000007)
    else:
        print(ans)

Submission status: Wrong Answer

Solution code:
import math

n,a,b = map(int,input().split())
r = sum([math.factorial(n) // (math.factorial(n - i) * math.factorial(i)) for i in range(1,(n+2)//2)])
d = math.factorial(n) // (math.factorial(n - a) * math.factorial(a))
d += math.factorial(n) // (math.factorial(n - b) * math.factorial(b))
d += math.factorial(n) // (math.factorial(n - (n+1)//2) * math.factorial((n+1)//2))
r = 2*r + 1 -d

if r<0:
    r += 10**9 + 7
else:
    r %= 10**9 + 7
    
print(r)

Submission status: Wrong Answer

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

sum = 2**n
sum = sum - math.factorial(n)/math.factorial(n-a)/math.factorial(a)
sum = sum - math.factorial(n)/math.factorial(n-b)/math.factorial(b)

print(round(sum%mom))

Submission status: Wrong Answer

Solution code:
n,a,b = [int(x) for x in input().split()]

INF = (10**9 + 7)


if n == 2:
    print(0)
else:
    ans = (2 ** n -1) - (2**a - 1) - (2 ** b - 1)
    print(ans % INF)

Submission status: Wrong Answer

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

ntmp = n
nottmp = 1
tmpin = [1, 1]

result = 0
N = n // 2
if n % 2 != 0:
    result += 1
for i in range(N):
    tmpin[0] *= ntmp
    tmpin[1] *= nottmp
    if nottmp != a and nottmp != b:
        result += ((tmpin[0] // tmpin[1]) * 2)
    else:
        result += (tmpin[0] // tmpin[1])
    ntmp -= 1
    nottmp += 1
    

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

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1
fact = [1]*(2*10**5+1)
for i in range(2,2*10**5+1):
  tmp = fact[i-1]*i
  tmp %= mod
  fact[i]=tmp
x = n-a
y = n-b
a = min(a,x)
b = min(b,y)
fa = 1
for i in range(n,n-a,-1):
  fa*=i
  fa%=mod
a_mi = fa
fa = 1
for i in range(n,n-b,-1):
  fa*=i
  fa%=mod
b_mi = fa
ans-=(((a_mi*pow(fact[a],mod-2,mod))%mod)+((b_mi*pow(fact[b],mod-2,mod))%mod))%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def combinations_count(m, r):
    return math.factorial(m) // (math.factorial(m - r) * math.factorial(r))

j = 0
sum = 0

while j <= n :

    if(j != a and j != b) :
        c = combinations_count(n, j)
        
    sum = sum + c
    c = 0

    j = j + 1

sum = sum - 1

if sum != 0 : 
    ans = sum
else :
    ans = 0

ans = ans / (10^9 + 7)

print(ans)

Submission status: Wrong Answer

Solution code:
#!python3.4
# -*- coding: utf-8 -*-
# abc156/abc156_d
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

MAX = 2 * 10**5 + 10
MOD = 10**9 + 7

fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [1, 1] + [0] * MAX

for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD

def getP(n, a, b):
    _n = n
    for i in range(1, a):
        _n = (_n * (n - i)) % MOD
    P_a = n
    for i in range(a, b):
        _n = (_n * (n - i)) % MOD
    P_b = _n
    return (P_a, P_b)

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 main():
    n, a, b = i2nn()
    all_C = power_func(2, n, MOD) - 1
    P_a, P_b = getP(n, a, b)
    C_a = (P_a * finv[a]) % MOD
    C_b = (P_b * finv[b]) % MOD
    print((all_C - C_a - C_b) % MOD)
    return

main()

Submission status: Wrong Answer

Solution code:
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
n,a,b=map(int,input().split())
res=0
for i in range(n):
    if i == a or i == b:
        continue
    res += combination(n, i)
print (res)

Submission status: Wrong Answer

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: Wrong Answer

Solution code:
import math
a = input().split()
a=[int(i) for i in a]
b=a[0]
d=a[1]
e=a[2]
f=0
def c(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
f=(b**2-1-c(b,d)-c(b,e))%(10**9+7)
print(f)

Submission status: Wrong Answer

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

def comb(n,k,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=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


c=1
d=0
mod=10**9+7
for _ in range(n):
    c=c*2
    d+=1
    if d>30:
        d=0
        c=c%mod
c=c%mod

c-=comb(n,a,mod)+comb(n,b,mod)

if c<0:
    c+=mod

print(c)

Submission status: Wrong Answer

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


def ncr(n, r):
    res = 1
    for i in range(1, r + 1):
        res = res * (n - i + 1) // i
        res %= 10 ** 9 + 7
    return res


def myPow2(a, n):
    x = 1
    while n > 0:
        if n & 1:
            x = x * a
            x %= 10 ** 9 + 7
        a = a * a
        a %= 10 ** 9 + 7
        n >>= 1
    return x


av = ncr(n, a)
bv = ncr(n, b)
ans = myPow2(2, n) - 1
print(av, bv, ans)
x = ans - av - bv
if x < 0:
    x += 10 ** 9 + 7
print(x % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,a,b = map(int,input().split())
    def bigcomb(n,r):
        r = min(r,n-r)
        ans = 1
        for i in range(1,r+1):
            ans *= (n-i+1)/i
            ans %= Mod
        return int(ans)
    i1 = bigcomb(n,a)
    i2 = bigcomb(n,b)
    print(i1,i2)
    def pow(x, i):
        ans = 1
        while(i > 0):
            if(bin(i & 1) == bin(1)):
                ans = ans*x
                ans %= Mod
            x = x*x
            i = i >> 1
        return ans
    ans = pow(2,n)

    print(ans - i1 - i2 - 1)
#endline===============================================
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def cmb(n, r, p):
  a=1
  for i in range(r):
    a*=n
    a%=mod
    n-=1
  b=1
  for i in range(1,r+1):
    b*=i
    b%=mod

  inv_b=mod_inv(b,mod)
  # print(a,inv_b)
  return a*inv_b

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

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

    return (K * x)%mod

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,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def main():
  n,a,b=LI()
  if n==2:
    if a!=b:
      return 0
    else:
      return 1

  ans=pow_k(2,n)

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

  if ans<0:
    ans+=mod

  return ans-1

# main()
print(main())

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def modInverse(a, p):
    return pow(a, p-2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % p

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p

def solve(n: int, a: int, b: int):
    p = 10**9+7
    ans = pow(2, n, p) - modBinomial(n, a, p) - modBinomial(n,b,p)
    if ans < 0:
        ans += p
    if ans < 0:
        print(0)
    else:
        print(ans-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# ABC 156 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nms = lambda: map(str, input().split())
nl = lambda: list(map(int, input().split()))
# def factorial_mod(n, mod):
#     a = 1
#     for i in range(1, n + 1):
#         a *= i
#         a %= mod
#     return a
# def comb_mod(n, k, mod):
#     if k > n or k < 0:
#         return 0
#     fact_n = factorial_mod(n, mod)
#     fact_k = factorial_mod(k, mod)
#     fact_n_k = factorial_mod(n - k, mod)
#     return (fact_n * pow(fact_k, mod - 2, mod) * pow(fact_n_k, mod - 2, mod)) % mod
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 spow(x, n,mod):
    ans = 1
    while(n > 0):
        if(bin(n & 1) == bin(1)):
            ans = ans*x%mod
        x = x*x%mod
        n = n >> 1 #ビットシフト
    return ans
n,a,b=nm()
MOD = 10**9 + 7
cn=spow(2,n,MOD)
ca=cmb(n,a)
cb=cmb(n,b)

Submission status: Wrong Answer

Solution code:
import sys
from functools import reduce
from operator import mul

input = sys.stdin.readline

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 main():
    N, a, b = map(int, input().split())
    MOD = 10 ** 9 + 7

    base = 2
    n = N
    while True:
        if n % 2 != 0:
            base *= 2
            break
        n //= 2
        base *= 2

    ans_ = base ** n

    x = cmb(N, a)
    y = cmb(N, b)

    print((ans_-x-y-1) % MOD)





main()

Submission status: Wrong Answer

Solution code:
def comb(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
def cmb(n, r):
    if n - r < r:
      r = n - r
    if r == 0: 
      return 1
    if r == 1: 
      return n
    numerator = [] 
    mod = 10**9+7
    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 power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
n, a, b = map(int, input().split())
mod = 10**9+7
ALL = power_func(2,n,mod)-1
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 
if n > 10**3:
  A = cmb(n, a) % mod
  B = cmb(n, b) % mod
else:
  for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (int(mod/i)) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
  A = comb(n,a,mod)
  B = comb(n,b,mod)
ans = ALL-A-B
if ans < 0:
  ans = mod + ans
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1
fact = [1]*(2*10**5+1)
for i in range(2,2*10**5+1):
  tmp = fact[i-1]*i
  tmp %= mod
  fact[i]=tmp
x = n-a
y = n-b
a = min(a,x)
b = min(b,y)
fa = 1
for i in range(n,n-a,-1):
  fa*=i
  fa%=mod
a_mi = fa
fa = 1
for i in range(n,n-b,-1):
  fa*=i
  fa%=mod
b_mi = fa
print(a,b,a_mi,b_mi)
ans-=(((a_mi*pow(fact[a],mod-2,mod))%mod)+((b_mi*pow(fact[b],mod-2,mod))%mod))%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

mod = 10**9+7 #出力の制限
N = 10**5 * 2
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
def p(n,r):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r] % mod

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)

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n,a,b = m()

nn = str(n)

co = 1

for i in range(len(nn)-1,-1,-1):
    if i == 0:
        co *= 2**int(nn[i])
    else:
        co = (co * 1024 * 2**int(nn[i]))%mod
        co = co % mod

aaa = 1
bbb = 1
for i in range(min(a,n-a)):
    aaa *= (n-i)
    aaa %= mod
    aaa *= g2[i+1]
    aaa %= mod
for i in range(min(b,n-b)):
    bbb *= (n-i)
    bbb %= mod
    bbb *= g2[i+1]
    bbb %= mod


print((co - aaa - bbb - 1)%mod)