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

Solution in Rust (1.42.0) (judge verdict: Accepted)

#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(dead_code)]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        cmp::max($x, max!($($y),+))
    };
}

macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($y: expr),+) => {
        cmp::min($x, min!($($y),+))
    };
}

macro_rules! abs {
    ($x:expr, $y:expr) => {
        cmp::max($x, $y) - cmp::min($x, $y)
    };
}

const MOD: usize = 1_000_000_000 + 7;

struct BinCoeff {
    size: usize,
    fac: Vec<usize>,
    finv: Vec<usize>,
    inv: Vec<usize>,
}

impl BinCoeff {
    fn new(size: usize) -> BinCoeff {
        if size > 500_000 {
            panic!("Too large BinCoeff!!!")
        }
        let size = size + 1;
        let fac = vec![0; size];
        let finv = vec![0; size];
        let inv = vec![0; size];
        let mut bincoeff = BinCoeff {
            size,
            fac: fac,
            finv: finv,
            inv: inv,
        };
        bincoeff.com_init();
        bincoeff
    }

    fn com_init(&mut self) {
        let fac = &mut self.fac;
        let finv = &mut self.finv;
        let inv = &mut self.inv;
        let size = self.size;
        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;
        for i in 2..size {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }

    fn bin_coeff(&mut self, n: usize, k: usize) -> usize {
        if k > n / 2 {
            self.bin_coeff(n, n - k)
        } else {
            if n < self.size {
                self.fac[n] * (self.finv[k] * self.finv[n - k] % MOD) % MOD
            } else {
                let mut fac = 1usize;
                for i in 0..k {
                    fac *= n - i;
                    fac %= MOD;
                }
                fac * self.finv[k] % MOD
            }
        }
    }
}

struct UnionFind {
    par: Vec<usize>,
}

impl UnionFind {
    fn new(size: usize) -> UnionFind {
        UnionFind {
            par: (0..size).collect::<Vec<usize>>(),
        }
    }

    fn root(&mut self, node: usize) -> usize {
        let parent = self.par[node];
        if parent == node {
            parent
        } else {
            let parent = self.root(parent);
            self.par[node] = parent;
            parent
        }
    }

    fn unite(&mut self, a: usize, b: usize) {
        let root_a = self.root(a);
        let root_b = self.root(b);
        self.par[root_b] = root_a;
    }

    fn is_same(&mut self, a: usize, b: usize) -> bool {
        let root_a = self.root(a);
        let root_b = self.root(b);
        root_a == root_b
    }
}

// must input n <= m
fn gcd(n: usize, m: usize) -> usize {
    if n == 0 {
        m
    } else {
        gcd(m % n, n)
    }
}

fn printer<T, U>(mut array: T)
where
    T: Iterator<Item = U>,
    U: fmt::Display + Copy,
{
    if let Some(a) = array.next() {
        print!("{}", a);
    }
    for a in array {
        print!(" {}", a);
    }
    println!()
}

fn sieve_of_eratosthenes(max: usize) -> Vec<usize> {
    let mut candidates = vec![true; max + 1];
    candidates[0] = false;
    candidates[1] = false;
    let mut num = 2;
    for num in 2..=(max as f64).sqrt().floor() as usize {
        if candidates[num] {
            let prime = num;
            for not_prime in (2 * prime..=max).step_by(prime) {
                candidates[not_prime] = false;
            }
        }
    }
    candidates
        .iter()
        .enumerate()
        .filter(|&(_num, &is_p)| is_p)
        .map(|(num, _is_p)| num)
        .collect::<Vec<_>>()
}

fn factorize(num: usize) -> HashMap<usize, usize> {
    if num < 2 {
        return HashMap::new();
    }

    let mut remain = num;
    let mut factor = HashMap::new();
    let primes = sieve_of_eratosthenes((num as f64).sqrt().floor() as usize);
    for &p in primes.iter() {
        if remain < p {
            break;
        }
        if remain % p == 0 {
            let entry = factor.entry(p).or_insert(0);
            while remain % p == 0 {
                remain /= p;
                *entry += 1;
            }
        }
    }
    if remain != 1 {
        factor.insert(remain, 1);
    }
    factor
}

use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufRead, Read};
use std::{cmp, fmt, iter, usize};

fn maker(x: usize, y: usize, size: usize) -> Vec<usize> {
    if size == 1 {
        if x == y {
            vec![x]
        } else {
            vec![]
        }
    } else if size == 2 {
        vec![x * 10 + y]
    } else if size == 3 {
        (0..10).map(|z| x * 100 + z * 10 + y).collect()
    } else if size == 4 {
        (0..100).map(|z| x * 1000 + z * 10 + y).collect()
    } else if size == 5 {
        (0..1000).map(|z| x * 10000 + z * 10 + y).collect()
    } else if size == 6 {
        (0..10000).map(|z| x * 10000 + z * 10 + y).collect()
    } else {
        vec![]
    }
}

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }
    let mut ans = 1usize;
    let mut base = 1usize;
    for _ in 0..100_000 {
        base <<= 1;
        base %= MOD;
    }
    let div = n / 100_000;
    let rem = n % 100_000;
    for _ in 0..div {
        ans *= base;
        ans %= MOD;
    }
    for _ in 0..rem {
        ans <<= 1;
        ans %= MOD;
    }
    ans = (MOD + ans - 1) % MOD;

    let mut coef_gen = BinCoeff::new(max!(a, b));
    let aa = coef_gen.bin_coeff(n, a);
    ans = (MOD + ans - aa) % MOD;
    let bb = coef_gen.bin_coeff(n, b);
    ans = (MOD + ans - bb) % MOD;
    println!("{}", ans);
}