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.15.1) (judge verdict: Accepted)

#![allow(unused)]

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;

//入力マクロここから
//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 $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")
    };
}
//入力マクロここまで

fn mod_pow(a: u64, n: u64, p: u64) -> u64 {
    let mut ans = 1;
    let mut a = a;
    let mut n = n;

    while n > 0 {
        if n & 1 == 1 {
            ans = ans * a % p
        }
        a = a * a % p;
        n >>= 1;
    }

    ans
}

fn math_mod(a: i64, b: i64) -> i64 {
    let r = a % b;
    if r < 0 {
        r + b.abs()
    } else {
        r
    }
}

// ax + by = gcd(a,b)の解 (a,bは整数)(a!=0,b!=0,c!=0),(gcd>0)
//　拡張ユークリッド互除法
fn ext_gcd(a: i64, b: i64) -> (i64, i64) {
    if b == 0 {
        return (if a > 0 { 1 } else { -1 }, 0);
    }

    let (s, t) = ext_gcd(b, a % b);
    (t, s - (a / b) * t)
}

//整数aのmod pにおける逆元
fn inv(a: i64, p: i64) -> i64 {
    let (inv, _) = ext_gcd(a, p);
    math_mod(inv, p)
}

//a / b mod p
//(a * bの逆元) mod p
fn div_mod(a: i64, b: i64, p: i64) -> i64 {
    math_mod(a * inv(b, p), p)
}

//O(k)
fn ncr2(n: u64, k: u64, p: u64) -> u64 {
    if n < k {
        return 0;
    }

    let mut ue = 1;
    let mut sita = 1;

    for i in 1..k + 1 {
        ue *= n - i + 1;
        ue %= p;
        sita *= i;
        sita %= p;
    }

    div_mod(ue as i64, sita as i64, p as i64) as u64
}

fn main() {
    input! {
        n: usize,
        a: usize,
        b: usize,
    }

    let p: u64 = 1_000_000_007;

    let pow = mod_pow(2, n as u64, p);
    let nca = ncr2(n as u64, a as u64, p);
    let ncb = ncr2(n as u64, b as u64, p);

    let ans = {
        let ans = (pow as i64 - 1 - nca as i64 - ncb as i64) % p as i64;
        if ans < 0 {
            ans + p as i64
        } else {
            ans
        }
    };

    println!("{}", ans);
}