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


def modcmb(n, k, mod):
    k = min(k, n-k)
    rtn = n
    for i in range(1, k):
        rtn = (rtn * ((n-i) % mod) * pow(i+1, mod-2, mod)) % mod

    return rtn


ans = (pow(2, n, MOD) - 1 - modcmb(n, a, MOD) - modcmb(n, b, MOD)) % MOD
print(ans if ans >= 0 else ans + MOD)

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

tw = [[1] for i in range(10)]
for i in range(9):
    tw[0].append(tw[0][-1] * 2)
for i in range(1,10):
    for j in range(10):
        if j == 0:
            tw[i].append((tw[i-1][-1] * tw[i-1][1])%mod)
        else:
            tw[i].append((tw[i][-1]*tw[i][1])%mod)

for i in range(len(nn)):
    if i == 0:
        co *= tw[i][int(nn[i])]
    else:
        co = (co * tw[i][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)

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b = map(int,input().split())
    MOD = (10**9)+7
    s = pow(2,n,MOD)
    u = 1
    bb = 1


    for i in range(1,(max(a,b) + 1)):
        u*=(n-i+1)%MOD
        bb*= i % MOD
        if i == a or i == b:
            s-=u*pow(bb,MOD-2,MOD)



    print(s%MOD)
#


if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import factorial

M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
c = 1
for i in range(b):
  c = c * (n - i) % M
  if i + 1 == a:
    a = b
    r -= c * pow(factorial(a), M - 2, M)
print(r % M)

Submission status: Wrong Answer

Solution code:
def loop_pow(x,n,mod):
    if n==0:
        return 1
    if n%2==0:
        t=loop_pow(x,n//2,mod)
        return (t*t)%mod
    return x*loop_pow(x,n-1,mod)%mod

def com(N,K,mod):
    n=N
    k=K
    up=1
    down=1
    for _ in range(K):
        up*=n
        up%=mod
        n-=1
    for _ in range(K):
        down*=k
        down%=mod
        k-=1
    down=loop_pow(down,10**9+5,mod)
    return up*down%mod

def main():
    N,a,b=map(int,input().split())
    mod=10**9+7
    t=loop_pow(2,N,mod)-1-com(N,a,mod)-com(N,b,mod)
    print(t)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

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


def modcmb(n, k, mod):
    rtn = n
    for i in range(1, k):
        rtn = (rtn * ((n-i) % mod) * pow(i+1, mod-2, mod)) % mod

    return rtn


ans = pow(2, n, MOD) - 1 - modcmb(n, a, MOD) - modcmb(n, b, MOD)
print(ans if ans >= 0 else ans + MOD)

Submission status: Wrong Answer

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


def modcmb(n, k, mod):
    rtn = n
    for i in range(1, k):
        rtn = (rtn * (n-i) * pow(i+1, mod-2, mod)) % mod

    return rtn


ans = pow(2, n, MOD) - 1 - modcmb(n, a, MOD) - modcmb(n, b, MOD)
print(ans if ans >= 0 else ans + MOD)

Submission status: Wrong Answer

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

MOD = 1000000007

def combination(n, r):
    r = min(r, n - r)

    num = 1
    den = 1

    for i in range(1, r + 1):
        num = (num * (n + 1 - i)) % MOD
        den = (den * i) % MOD

    return num * pow(den, MOD - 2, MOD) % MOD


def 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


s = func(2, n, MOD) - 1
xa = combination(n, a)
xb = combination(n, b)

p = (s - xa - xb)

if p < 0:
    print(p + MOD)
else:
    print(p)

Submission status: Wrong Answer

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


def modcmb(n, k, mod):
    k = min(k, n-k)
    rtn = n
    for i in range(1, k):
        rtn = (rtn * (n-i) * pow(i+1, mod-2, mod)) % mod

    return rtn


ans = pow(2, n, MOD) - 1 - modcmb(n, a, MOD) - modcmb(n, b, MOD)
print(ans if ans >= 0 else ans + MOD)

Submission status: Wrong Answer

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

p = 10**9 + 7

def cmb(n, r, p):
    x = 1
    y = 1
    for i in range(r):
        x = x*(n-i) % p
        y = y*(r-i) % p
    return x*pow(y, p-2, p) % p

ans = pow(2, n, p) - 1 - cmb(n, a, p) - cmb(n, b, p)

if ans < 0:
    print(int(ans)+p)
else:
    print(int(ans))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
MOD = 10**9+7
 
 
def modpow(a, n, mod):
    rtn = 1
    while n > 0:
        if n & 1:
            rtn = (rtn * a) % mod
        a = (a*a) % mod
        n >>= 1
    return rtn
 
 
def modcmb(n, k, mod):
    rtn = n
    for i in range(1, k):
        rtn = (rtn * (n-i) * modpow(i+1, mod-2, mod)) % mod
 
    return rtn
 
 
ans = modpow(2, n, MOD) - 1 - modcmb(n, min(a,n-a), MOD) - modcmb(n, min(b, n-b), MOD)
print(ans if ans >= 0 else ans + MOD)

Submission status: Wrong Answer

Solution code:
def loop_pow(x,n,mod):
    if n==0:
        return 1
    if n%2==0:
        t=loop_pow(x,n//2,mod)
        return (t*t)%mod
    return x*loop_pow(x,n-1,mod)

def com(N,K,mod):
    n=N
    k=K
    up=1
    down=1
    for _ in range(K):
        up*=n
        up%=mod
        n-=1
    for _ in range(K):
        down*=k
        down%=mod
        k-=1
    down=loop_pow(down,10**9+5,mod)
    return up*down%mod

def main():
    N,a,b=map(int,input().split())
    mod=10**9+7
    t=loop_pow(2,N,mod)-1-com(N,a,mod)-com(N,b,mod)
    while t<0:
        t+=10**9+7
    print(t)
    
if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

mod=10**9+7

J=pow(2,n)%mod
def find_power(n,mod):
    # 0!からn!までのびっくりを出してくれる関数(ただし、modで割った値に対してである）
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(mod)
    return powlist

def find_inv_power(n):
    #0!からn!までの逆元を素数10**9+7で割ったあまりリストを作る関数
    powlist=find_power(n,10**9+7)
    check=powlist[-1]
    first=1
    uselist=[0]*(n+1)
    secondlist=[0]*30
    secondlist[0]=check
    secondlist[1]=check**2
    for i in range(28):
        secondlist[i+2]=(secondlist[i+1]**2)%(10**9+7)
    a=format(10**9+5,"b")
    for j in range(30):
        if a[29-j]=="1":
            first=(first*secondlist[j])%(10**9+7)
    uselist[n]=first
    for i in range(n,0,-1):
        uselist[i-1]=(uselist[i]*i)%(10**9+7)
    return uselist

C=find_inv_power(2*10**5+100)
if  True:
    c=1
    for i in range(a):
        c*=(n-i)
        c=c%mod
    c=c*C[a]
    c=c%mod
    d=1
    for i in range(b):
        d*=(n-i)
        d=d%mod
    d=d%mod
    d=d*C[b]
    print((J-c-d)%mod)

Submission status: Wrong Answer

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


def modpow(a, n, mod):
    rtn = 1
    while n > 0:
        if n & 1:
            rtn = (rtn * a) % mod
        a = (a*a) % mod
        n >>= 1
    return rtn


def modcmb(n, k, mod):
    rtn = n
    for i in range(1, k):
        rtn = (rtn * (n-i) * modpow(i+1, mod-2, mod)) % mod

    return rtn


ans = modpow(2, n, MOD) - 1 - modcmb(n, a, MOD) - modcmb(n, b, MOD)
print(ans if ans >= 0 else ans + MOD)

Submission status: Wrong Answer

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

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

    #X//Y
    X=1
    Y=1
    for i in range(r):
        X*=(n-r)
        X%=mod
        Y*=(r+1)
        Y%=mod
        
    Y=pow(Y,mod-2,mod)
    return (X*Y)%mod
        
        


allp=pow(2,n,mod)-1
ans=(allp-cmb(n,a,mod)-cmb(n,b,mod))%mod
if n==2:
    ans=0

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin


def cmb_prepare(n, p=10**9+7):
    fact = [0 for i in range(n+1)]
    factinv = [0 for i in range(n+1)]
    inv = [0 for i in range(n+1)]

    # init
    fact[0], fact[1] = 1, 1
    factinv[0], factinv[1] = 1, 1
    inv[0], inv[1] = 0, 1

    for i in range(2, n + 1):
        fact[i] = (fact[-1] * i) % p
        inv[i] = (-inv[p % i] * (p // i)) % p
        factinv[i] = (factinv[-1] * inv[-1]) % p
    return fact, factinv


def cmb(n, r, fact, factinv, p=10**9+7):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p


# not AC
def get_result(data):
    n, a, b = data[0]
    fact, factinv = cmb_prepare(n)
    mod = 10**9 + 7
    out = ((2 ** n - 1) % mod - cmb(n, a, fact, factinv) - cmb(n, b, fact, factinv)) % mod
    return out

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)

Submission status: Wrong Answer

Solution code:
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    r -= c * pow(f, M - 2, M)
print((r - c * pow(f, M - 2, M) % M))

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
for i in range(2, MAX):
    fac[i] = fac[i - 1] * 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 main():
    n, a, b = i2nn()
    all_C = (pow(2, n, MOD) - 1) % MOD
    P_a, P_b = getP(n, a, b)
    C_a = (P_a * pow(fac[a], MOD-2, MOD)) % MOD
    C_b = (P_b * pow(fac[b], MOD-2, MOD)) % MOD
    print(all_C, P_a, P_b)
    print((MOD + all_C - C_a - C_b) % MOD)
    return

main()

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
n,a,b=map(int,input().split())
sum = 0
for i in range(n//2+1):
    sum += comb(n,i)
    print(comb(n,i))
    
print((sum*2-comb(n,n//2)-comb(n,a)-comb(n,b)-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
import sys,math

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]


def main():
	n,a,b = MI()
	mod = 10 ** 9 + 7

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

	ans = pow(2,n,mod) - f(n,a,mod) - f(n,b,mod) - 1
	ans += mod if ans < 0 else 0
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
M = 10**9 + 7
n, a, b = map(int, input().split())
r = (pow(2, n, M) - 1) % M
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    r = (r - c * pow(f, M - 2, M)) % M
print((r - c * pow(f, M - 2, M) % M))

Submission status: Wrong Answer

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

n, a, b= [int(x) for x in stdin.readline().rstrip().split()]

combi = 1
wari = (10 ** 9) + 7

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

for i in range(1,n):
  if i == a or i == b:
    continue
  combi = combi + combinations_count(n, i) % wari

print(combi)

Submission status: Wrong Answer

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

mod = 10**9 + 7
res = (2**n - 1) % mod

def cmb(n, r, mod):
    r = min(n-r, r)
    if r == 0:
        return 1
    over, under = 1, 1
    for i in range(1, r+1):
        over = over * (n-i+1) % mod
        under = under * i % mod
    inv = pow(under, mod-2, mod)
    return over * inv % mod


A = cmb(n, a, mod)
B = cmb(n, b, mod)

print((res - A - B - 1) % mod)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
m = 10**9+7
def cmb(r):
    N = 1
    R = 1
    for i in range(r):
        N = N*(n - i) % m
        R = R*(i+1) % m
    return N*pow(R, m-2, m)%m

ans = pow(2, n, m) - ((cmb(a) + cmb(b) + 1)%m)
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
mod = 10**9 + 7
a = min(a, n-a)
b = min(b, n-b)
com = [1] * (max(a, b) + 1)
for i in range(1,len(com)):
    com[i] = (com[i-1] * pow(i, mod-2, mod) * (n-i+1)) % mod
print(pow(2, n, mod) - 1 - com[a] - com[b])

Submission status: Wrong Answer

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

def cmb(n, r, mod):
    r = min(n-r, r)
    if r == 0:
        return 1
    over, under = 1, 1
    for i in range(1, r+1):
        over = over * (n-i+1) % mod
        under = under * i % mod
    inv = pow(under, mod-2, mod)
    return over * inv % mod

res -= cmb(n,a,mod)
res -= cmb(n,b,mod)

print(res // mod)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
mod=10**9+7
ans=pow(2,n,mod)-1
p=1
for i in range(a):
    p*=n-i
    p*=pow(i+1,mod-2,mod)
    p%=mod
for i in range(b):
    p*=n-i
    p*=pow(i+1,mod-2,mod)
    p%=mod
print((ans-p)%mod)

Submission status: Wrong Answer

Solution code:
import math
a, b, c = map(int,input().split())
 
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

g = 2**a-combinations_count(a,b)-combinations_count(a,c)
g = g % (10**9 +7)
print(g)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int, input().split())
 
def comb(n, r,MOD):
    p, q = 1, 1
    for i in range(r):
        p = p * (n-i) % MOD
        q = q * (i+1) % MOD
    return p * pow(q, MOD-2, MOD) % MOD

mod=10**9+7

if n==2:
    print(0)
else:
    print(pow(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod))

Submission status: Wrong Answer

Solution code:
import math

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


def cmb(n, r, mod):
    c=1
    for i in range(1, r+1):
        c = (c * (n-i+1) * pow(i, mod-2, mod)) % mod
    return c


mod = 10**9+7

ans = pow(2, n, mod)
ans -= 1
ans -= cmb(n, a, mod)
ans -= cmb(n, b, mod)

if ans < 0:
    print(ans+mod)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
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

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

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

    return K * x % mod

n, a, b = map(int,input().split())
mod = 10**9+7 #出力の制限
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 )


sum_nCr = pow_k(2, n, mod)
# sum_nCr = pow(2, n)
# print("sum is clear")
nCa = 0
if a != 1:
    nCa = cmb(n, a, mod)
# print("nCa is clear")

nCb = cmb(n, b, mod)
# print("nCb is clear")

ans = sum_nCr - (1 + n + nCa + nCb)
ans %= mod
# print("sum = ",sum(nCr))
# print("0 = ",nCr[0])
# print("1 = ",nCr[1])
# print("a = ",nCa)
# print("b = ",nCb)

# print("ans = ",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
  
def comb(n,k):
  k = min(k,n-k)
  fa = 1
  for i in range(n,n-k,-1):
    fa*=i
    fa%=mod
  return fa*pow(fact[k],mod-2,mod)
mi = comb(n,a)+comb(n,b)
mi%=mod
ans-=mi
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
kaijou=[]
kaijou.append(1)
for i in range(n):
    i=i+1
    kaijou.append(kaijou[i-1]*i)

def sel(c):
    global n
    ans=0
    if n>=c>0:
        ans=kaijou[n]/kaijou[c]/kaijou[n-c]
    return ans
yes=0
for i in range(n):
    k=i+1
    if k==a or k==b:
        ku=0
    else:
        yes=yes+sel(k)
sur=10**9+7
print(yes%sur)

Submission status: Wrong Answer

Solution code:
import math
n,a,b = map(int ,input().split())
d= n**2-1

k= math.factorial(n) // (math.factorial(n - a) * math.factorial(a))
p= math.factorial(n) // (math.factorial(n - b) * math.factorial(b))

print((d-(k+p))%(10**9+7))

Submission status: Wrong Answer

Solution code:

import math
import itertools

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    ret = 0
    n_fact = math.factorial(n)
    n_all = 0
    for i in range(n):
        n_all += n_fact / (math.factorial(i) * math.factorial(n - i))
    n_all -= len(list(itertools.combinations(list(range(n)), a)))
    n_all -= len(list(itertools.combinations(list(range(n)), b)))
    x = 10**9 + 7
    ret = n_all % x
    print(ret)

Submission status: Wrong Answer

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

 
def combination(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = (numer*(n1-i)) % mod
        denom = (denom*i) % mod
    return numer * pow(denom, mod-2, mod) % mod

mod=10**9+7

print((pow(2,n,mod) - combination(n,a,mod) - combination(n,b,mod))%mod)

Submission status: Wrong Answer

Solution code:
import math

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

tem = 0
for i in range(1,n):
  if i != a and i != b :
    tem += math.factorial(n) // (math.factorial(n - i) * math.factorial(i))

print(tem % 1000000007)

Submission status: Wrong Answer

Solution code:
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
#dp = [[0] * 4 for i in range(3)] #2次元配列初期化
#dp = [[[0] * 2 for i in range(3)] for j in range(5)]
#(ord('A'))でASCII出力 Aは65
import math
import statistics
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())
n,a,b = splitintinput()
de = 10 ** 9 + 7
le = 2 ** 30 - de
tmp = n
tmpy = 1
ans = 1
ansa = 1
ansb = 1
time = 1
x = []
y = []
for i in range(7, -1, -1):
    if 30 ** i < tmp:
        x.append(tmp//(30**i))
        tmp -= 30 ** i * (tmp//(30**i))
    elif tmp < 30 and i == 0:
        x.append(tmp)
        break
    else:
        x.append(0)
x.reverse()

for i in range(8):
    if i == 0:
        y.append(2)
        tmpy = le
    else:
        y.append(tmpy)
        tmpy = (tmpy * tmpy) % de

for i in range(len(x)):
    if x[i] == 0:
        continue
    for j in range(x[i]):
        ans = ans * y[i] % de

for i in range(n-a+1,n+1):
    ansa = (int(ansa * i / time)) % de
    time += 1

time = 1

for i in range(n-b+1,n+1):
    ansb = (int(ansb * i / time)) % de
    time += 1

print(int(ans - ansa- ansb - 1 + 2 * de) % de)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(300000)

M = 10 ** 9 + 7

def mod_combination(n, r, mod):
    numerator = 1
    for i in range(n-r+1, n+1):
        numerator = (i * numerator) % mod
    denominator = 1
    for i in range(1, r+1):
        denominator = (i * denominator) % mod
    fermat = repeatsquare(denominator, mod-2, mod)
    return (numerator * fermat) % mod

def repeatsquare(N, P, M):
    if (P == 0):
        return 1
    if (P % 2 == 0):
        t = repeatsquare(N, P//2, M)
        return (t ** 2) % M
    return N * repeatsquare(N, P - 1, M)

def solve(n, a, b):

    k = repeatsquare(2, n, M)
    ac = mod_combination(n, a, M)
    ab = mod_combination(n, b, M)

    ans = k - ac - ab - 1
    while ans < 0:
        ans += M
    return ans

if __name__ == "__main__":
    n, a, b = tuple(map(int, input().split(" ")))
    print(solve(n, a, b))

Submission status: Wrong Answer

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

nCk=[1]
for i in range(b+1):
    tuika=nCk[i]*(n-i)/(i+1)
    nCk.append(tuika)
ans=ans-(nCk[a]%MOD)-(nCk[b]%MOD)
print(ans%MOD)

Submission status: Wrong Answer

Solution code:
# coding:utf-8
from functools import lru_cache
# from scipy.special import comb

@lru_cache(maxsize=None)
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

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

if n % 2 == 0:
    for i in range(1, (n//2)+1):
        if (i == a and (n-i) == b) or (i == b and (n-i) == a):
            pass
        elif i == (n//2) or i == a or i == b or (n - i) == a or (n - i) == b:
            ans += int(cmb(n, i))
        else:
            ans += 2 * int(cmb(n, i))
        # print('i = {}'.format(i))
        # print('a = {}, b = {}, (n-i) = {}'.format(a, b, n-i))
        # print('ans = {}'.format(ans))
else:
    for i in range(1, (n//2)+1):
        if (i == a and (n-i) == b) or (i == b and (n-i) == a):
            pass
        elif i == (n//2) or i == a or i == b or (n - i) == a or (n - i) == b:
            ans += int(cmb(n, i))
        else:
            ans += 2 * int(cmb(n, i))
        # print('i = {}'.format(i))
        # print('a = {}, b = {}, (n-i) = {}'.format(a, b, n-i))
        # print('ans = {}'.format(ans))

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

Submission status: Wrong Answer

Solution code:
n,aa,bb=map(int,input().split())
p=10**9+7
nCa=1
nCb=1
a=min(aa,bb)
b=max(aa,bb)
if a>n/2:
    a=n-a
if b>n/2:
    b=n-b
for i in range(1,b+1):
    if i<=a:
        nCa=(n-i+1)*nCa//i
    if i<=b:
        nCb=nCb*(n-i+1)//i
    if nCa>p:
        nCa%=p
    if nCb>p:
        nCb%=p
    if i>a+1 and i>b+1:
        break
ans=pow(2,n,p)-1-nCa-nCb
print(ans%p)

Submission status: Wrong Answer

Solution code:
def comb(a, b, p=10 ** 9 + 7):
    if (b > a - b):
        return comb(a, a - b, p)
    c = d = 1
    for i in range(b):
        c *= (a - i)
        d *= (b - i)
        c %= p
        d %= p
    return c * modpow(d, p - 2, p) % p


def modpow(n, m, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (modpow(n, m, p//2)**2) % m
    return (modpow(n, m, p-1)*n) % m


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


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
ans=2**n-1
n1=1
n2=1
for i in range(a):
    n1*=n-i
    n1//=i+1
for j in range(b):
    n2*=n-i
    n2//=i+1
print(ans-n1-n2)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
ans=2**n
n1=1
n2=1
for i in range(a):
    n1*=n-i
    n1//=i+1
for j in range(b):
    n2*=n-i
    n2//=i+1
print(ans-n1-n2)

Submission status: Wrong Answer

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


def nCr(n, r, mod):
    r = min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n+1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod


ans = pow(2, n, mod)-1-nCr(n, a, mod)-nCr(n, b, mod)
if ans < 0:
    print(ans + mod)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=[int(i) for i in input().split()]
def power(a,n,mod):
    res=1
    while n>0:
        if n&1:
            res=res*a%mod
        a=a*a%mod
        n>>=1
    return res

ans=power(2,n-1,10**9+7)-1
num1=1
num2=1
for i in range(a):
    num1*=(n-i)
    num2*=(i+1)
ans-=num1//num2
ans%=10**9+7
num1=1
num2=1
for i in range(b):
    num1*=(n-i)
    num2*=(i+1)
ans-=num1//num2
print(ans%(10**9+7))

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) - 1 - modBinomial(n, a, p) - modBinomial(n,b,p)
    if ans < 0:
        print(ans+p)
    else:
        print(ans)
    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:
n, a, b = map(int, input().split())
res = 0

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

from functools import lru_cache

@lru_cache(maxsize=1000)
def c(n,k): 
    return 1 if(k<=0 or n<=k) else ( c(n-1, k-1) + c(n-1, k) ) %4

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 )
    
res = 2 ** (n - 1)

res -= cmb(n,a,mod)
res -= cmb(n,b,mod)

print(res)

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(int(r))

Submission status: Wrong Answer

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

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

from functools import lru_cache

@lru_cache(maxsize=1000)
def c(n,k): 
    return 1 if(k<=0 or n<=k) else ( c(n-1, k-1) + c(n-1, k) ) %4

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 )
    
res = 2 * (n - 1)

res -= cmb(n,a,mod)
res -= cmb(n,b,mod)

print(res)