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 Kotlin (1.3.71) (judge verdict: Accepted)

import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.max
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, a, b) = readLongList()
    // 全部で2のn乗 - 1
    val all = ModInt.valueOf(2).modPow(n) - ModInt.valueOf(1)

    // a個選ぶ
    var aPa = ModInt.valueOf(1)
    for (i in 1L..a) aPa *= ModInt.valueOf(i)

    var nPa = ModInt.valueOf(1)
    for (i in n downTo (n - a + 1)) nPa *= ModInt.valueOf(i)

    var nCa = nPa / aPa

    // b選ぶ
    var bPb = ModInt.valueOf(1)
    for (i in 1L..b) bPb *= ModInt.valueOf(i)

    var nPb = ModInt.valueOf(1)
    for (i in n downTo (n - b + 1)) {
        nPb *= ModInt.valueOf(i)
    }
    var nCb = nPb / bPb

    var ans = all - nCa - nCb
    out.println(ans)

}

/**
 * always positive number (Use for minus)
 */
class ModInt private constructor(val value: Long, val mod: Long) {
    companion object {
        @JvmStatic
        fun valueOf(value: Long, mod: Long = 1000000007L): ModInt {
            var v = value % mod
            if (v < 0) v += mod
            return ModInt(v, mod)
        }
    }

    operator fun unaryMinus() = ModInt(mod - value, mod)

    operator fun plus(other: ModInt): ModInt {
        var value = value + other.value
        if (value >= mod) { value -= mod }
        return ModInt(value, mod)
    }

    operator fun minus(other: ModInt): ModInt {
        var value = value - other.value
        if (value < 0) { value += mod }
        return ModInt(value, mod)
    }

    operator fun times(other: ModInt) = ModInt((value * other.value) % mod, mod)

    operator fun div(other: ModInt): ModInt {
        if (other.value == 0L) throw ArithmeticException("/ by zero")
        val value = (this.value * modInverse(other.value, mod)) % mod
        return ModInt(value, mod)
    }

    override fun toString() = value.toString()

    /** O(log(n)): n >= 0 */
    fun modPow(n: Long) = ModInt(modPow(this.value, n, mod), mod)

    /**  O(log(MOD)) */
    fun inverse() = ModInt(modInverse(this.value, mod), mod)
}

/** O(log(m)) mod <= 2_147_483_648, n >= 0 */
fun modPow(n: Long, m: Long, MOD: Long = (1L shl 31)): Long {
    if (m < 0) throw ArithmeticException("The power of negative exponent is not integer.")
    if (MOD <= 0) throw ArithmeticException("MOD <= 0")

    var ret = 1L
    var x = (n % MOD)
    if (x < 0) x += MOD
    var k = m
    while (k > 0) {
        if ((k and 1L) == 1L) { ret = (ret * x) % MOD }
        x = (x * x) % MOD
        k = k shr 1
    }
    return ret
}

/**
 * O(log(MOD))
 */
fun modInverse(n: Long, mod: Long = 1000000007L): Long {
    var a = n % mod
    if (a < 0) a += mod

    if (a == 0L) throw ArithmeticException("n is not relatively prime to mod")

    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a / b
        a -= t * b
        a = b.also { b = a } // swap(a, b)
        u -= t * v
        u = v.also { v = u } // swap(u, v)
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)