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())
M=10**9+7
sum=pow(2,n,M)-1
def inverse(number,mod):
    m=mod-2
    mod2=""
    while m!=0:
        if m%2==0:
            mod2="0"+mod2
        else:
            mod2="1"+mod2
        m=m//2
    two=[]
    for i in range(len(mod2)):
        if mod2[len(mod2)-1-i]=="1":
            two.append(i)
    ret=1
    for i in two:
        v=i
        retsub=number
        while v>0:
            retsub=retsub**2
            retsub=retsub%mod
            v-=1
        ret*=retsub
    ret=ret%mod
    return ret
def cal(num,r,mod):
    ret1=1
    for i in range(0,r):
        ret1*=(num-i)
        ret1%=mod
    r_factorial=1
    for i in range(1,r+1):
        r_factorial*=i
        r_factorial%=M
    ret2=inverse(r_factorial,mod)
    ret=(ret1*ret2)%mod
    return ret

print(sum-cal(n,a,M)-cal(n,b,M))

Submission status: Wrong Answer

Solution code:

url = "https://atcoder.jp//contests/abc156/tasks/abc156_d"
import math


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


def main():
    n, a, b = list(map(int, input().split()))
    base = 0
    ans = 0
    for i in range(1, (n + 1)):
        if i == 1:
            base = n
        elif i == 2:
            base = combinations_count(n, 2)
        else:
            base = base - (i - 1)

        if i == a or i == b:
            continue
        elif n < i:
            break

        ans += base
        print(i , ans, base)
    print(ans)


def ret_y(a):
    return pow(math.factorial(a), (pow(10, 9) + 7) - 2)

def main2():
    n, a, b = list(map(int, input().split()))
    an = (pow(2, n) - 1) % (pow(10, 9) + 7)
    ans = an - ret_y(a) - ret_y(b)
    print(an)

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




if __name__ == '__main__':
    main2()

Submission status: Wrong Answer

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

count = 2**n % 1000000007 - 1 # 全部
a = (math.factorial(n) / math.factorial(n - a)/math.factorial(a)) % 1000000007
b = (math.factorial(n) / math.factorial(n - b)/math.factorial(b)) % 1000000007

ans = (count - a - b)

print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
n,a,b=map(int,input().split())
sum=0
for i in range(n):
    if i==a or i==b:
        continue
    com=factorial(n)//(factorial(i)*factorial(n-i))
    sum+=com
print(sum%(10**9+7))

Submission status: Wrong Answer

Solution code:
mod=10**9+7
l,a,b=map(int,input().split())
def C(n,k,m):
  for i in range(1,k):
    n*=(n-i)%m
    k*=(k-i)%m
  return (n*pow(k,m-2,m))%m
ans=pow(2,l,mod)
ca=C(l,a,mod)

cb=C(l,b,mod)
print((ans-ca-cb)%mod)

Submission status: Wrong Answer

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

ans=pow(2,l,mod)
ca=C(l,a,mod)
print(ca)
cb=C(l,b,mod)
print(cb)
print((ans-ca-cb)%mod)

Submission status: Wrong Answer

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

ans = -1

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

ans += modpow(2, n, MOD)


def COM(n, k):
    res = 1
    for i in range(1, k+1):
        res = int(res * (n-i+1) / i) % MOD
    return res


ans -= COM(n, a)
ans -= COM(n, b)

print(ans)

Submission status: Wrong Answer

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

ans = -1

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

ans += modpow(2, n, MOD)


def COM(n, k):
    res = 1
    for i in range(1, k+1):
        res = res * (n-i+1) / i % MOD
    return res %MOD


ans -= COM(n, a)
ans -= COM(n, b)

print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


############ ---- Input Functions ---- ############
def in_int():
    return (int(input()))


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


def in_str():
    s = input()
    return (list(s[:len(s) - 1]))


def in_ints():
    return (map(int, input().split()))

mod = 7 + 10**9


n, a, b = in_ints()

import math

def fact(end, start):
    ans  = 1
    for xx in range(start,end+1):
        ans = ((ans%mod) * (xx%mod))%mod

    return ans


ans  = int(pow(2, n , mod))
aa  =fact(n,n-a+1)//fact(a,1)
bb  =fact(n,n-b+1)//fact(b,1)


ans = (2*mod + ans  -aa - bb -1)%mod

print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

def calcp(n,j,mod):
    res = 1
    for i in range(n,n-j,-1):
        res = res * i %mod
    return res

def main():
    n,a,b = list(map(int, input().split()))
    MOD = 10**9+7
    NMAX = 2*10**5

    fact = [0 for i in range(NMAX+5)]
    fact[0] = 1
    invfact = [0 for i in range(NMAX+5)]
    invfact[0] = 1

    for i in range(NMAX):
        fact[i+1] = (fact[i]*(i+1))%(MOD)

    invfact[NMAX] = pow(fact[NMAX], MOD-2, MOD)
    for i in range(NMAX-1,0,-1):
        invfact[i] = (invfact[i+1] * (i+1)) % MOD

    ans = modpow(2,n,MOD)-1

    pa = calcp(n,a,MOD)*invfact[a]%MOD
    pb = calcp(n,b,MOD)*invfact[b]%MOD
    ans = ans - pa - pb;
    if ans < 0:
        ans += MOD
    print(ans)

        

main()

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
mod = 10**9 + 7
aue,bue = 1,1
for i in range(a):
    aue = aue * (n-i) % mod
for i in range(b):
    bue = bue * (n-i) % mod
asita,bsita = 1,1
for i in range(1,a+1):
    asita = asita*i %mod
for i in range(1,b+1):
    bsita = bsita*i %mod
at = aue * pow(asita,mod-2,mod)
bt = bue * pow(bsita,mod-2,mod)

print(at)
ans = (pow(2,n,mod) - 1 -at -bt)%mod
print(ans)

Submission status: Wrong Answer

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

def inv(k):
    return pow(k, mod - 2, mod)

def comb(n, k):
    bunshi = 1
    bunbo = 1
    for i in range(k):
        bunshi = bunshi * (n - i) % mod
        bunbo = bunbo * (i + 1) % mod
    return bunshi * inv(bunbo) % mod

mod = 1000000007
all_num = pow(2, n, mod)

ans = all_num - 1 - comb(n, a) - comb(n, b)
print(ans)

Submission status: Wrong Answer

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

if n-a < a:
    a = n-a
if n-b < b:
    b = n-b
if b < a:
    a, b = b, a

ans = pow(2, n, MOD)-1
X = Y = 1
for i in range(1, b+1):
    Y = Y*i % MOD
    X = X*(n-i+1) % MOD
    if i == a or i == b:
        if a == b:
            ans -= X*pow(Y, MOD-2, MOD)*2
        else:
            ans -= X*pow(Y, MOD-2, MOD)

print(ans % MOD)

Submission status: Wrong Answer

Solution code:
def mpow(a,n,m):
  if n == 0:
    return 1
  elif n == 1:
    return a
  elif n%2==0:
    return (pow(a,n//2,m))**2%m
  else:
    return a*pow(a,n-1,m)%m

n,a,b=map(int,input().split())
mod=1000000007
print((pow(2,n,mod)-1-mpow(n, a, mod)-mpow(n, b, mod))%mod)

Submission status: Wrong Answer

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

for i in range(2, n+1):
    ans += i*(i-1)

ans -= a*(a-1)
ans -= b*(b-1)
ans /=2
print(int(ans % mod))

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


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, readline().split())
mod = 10 ** 9 + 7
print(pow(2, n, mod) - (combination(n, a) % mod + combination(n, b) % mod) % mod - 1)

Submission status: Wrong Answer

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

#2**nをmodしたもの
ans = pow(2, n, mod) - 1

x = 1
for i in range(a):
  x *= n-i
  x %= mod
  x *= pow(i+1, mod-2, mod)
  x %= mod
ans = (ans + mod-x)%mod


for i in range(b):
  x *= n-i
  x %= mod
  x *= pow(i+1, mod-2, mod)
  x %= mod
ans = (ans + mod-x)%mod

print(ans)

Submission status: Wrong Answer

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

#2**nをmodしたもの
ans = pow(2, n, mod) - 1

x = 1
for i in range(a):
  x *= n-i
  x %= mod
  x *= pow(i+1, mod-2, mod)
  x %= mod
  ans = (ans + mod-x)%mod


for i in range(b):
  x *= n-i
  x %= mod
  x *= pow(i+1, mod-2, mod)
  x %= mod
  ans = (ans + mod-x)%mod

print(ans)

Submission status: Wrong Answer

Solution code:
a=pow(2,10**7,10**9+7)
print(a)

Submission status: Wrong Answer

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

C=1
if n!=b:
    out=1
else:
    out=0

for i in range(int(n/2)):
    C=int((C*(n-i)/(i+1))%(10**9+7))
    if i+1!=a and i+1!=b:
        out=int((out+C)%(10**9+7))
        if n-i!=i+2 and n-i-1!=a and n-i-1!=b:
            out=int((out+C)%(10**9+7))
print(out)

Submission status: Wrong Answer

Solution code:
def cumprod(start, stop=None, mod=None):
    res = 1
    for i in range(start, stop):
        if mod:
            res *= i % mod
            res %= mod
        else:
            res *= i
    return res


n, a, b = [int(i) for i in input().split()]

mod = 10**9+7
res = pow(2, n, mod) - 1
comb_a = cumprod(n-a+1, n+1, mod) * pow(cumprod(1, a+1, mod), mod-2, mod) % mod
comb_b = cumprod(n-b+1, n+1, mod) * pow(cumprod(1, b+1, mod), mod-2, mod) % mod
res -= comb_a + comb_b
if res < 0:
    res += mod

print(res)

Submission status: Wrong Answer

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

REC = 0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(n):
    if i != a and i != b:
        REC += combinations_count(n, i)   
print(REC)

Submission status: Wrong Answer

Solution code:
# 乗法のmod逆元 (mod-2乗)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

# nCr mod p
def comb(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 # modinvが必要
    return res
  
def binary(n):
    return bin(n)[2:]

# バイナリ法
def pow_by_binary(a, x, n): # a^x mod n
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * a) % n
    return y
  
n,a,b = [int(i) for i in input().split()]
mod = 10**9+7
ans = pow_by_binary(2,n,mod)-1-comb(n,a,mod)-comb(n,b,mod)
if ans < 0:
  ans += mod
print(ans)

Submission status: Wrong Answer

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

def minus(n,k):
    x,y =1,1
    for i in range(k):
        x*=(n-i)%mod
        y*=(k-i)%mod
    return x*pow(y, mod-2, mod)%mod

ans = pow(2,n,mod)-1-minus(b,a)-minus(b,b)
while ans<0:
    ans+=mod
print(ans)

Submission status: Wrong Answer

Solution code:
N,A,B=map(int,input().split())
MOD=10**9+7

def calculate_combination(n,k):
    x,y=1,1
    for i in range(k):
        x=x*(n-i)%MOD
        y=y*(k-1)%MOD
    return x*pow(y,MOD-2,MOD)%MOD

ans=pow(2,N,MOD)-1-calculate_combination(N,A)-calculate_combination(N,B)
while ans<0:
    ans+=MOD
print(ans)

Submission status: Wrong Answer

Solution code:
def combination(n,r,mod=10**9+7):
    n1 = n+1
    r = 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
 
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
 
mod = int(1e9+7)
n,a,b= map(int,input().split())
 
S = (pow(2,n,mod))%mod
A = combination(n,a)
B = combination(n,b)
ans = (S-A-B)%mod
 
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
mod=7+10**9
ans = pow(2 , n , mod)
def comb(n,c,mod):
  s=1
  t=1
  for i in range(1,c+1):
    s=s*i%mod
  for j in range(n-c+1,n+1):
    t=t*j%mod
  return (t*pow(s,mod-2,mod))%mod

print(ans-1-comb(n,a,mod)-comb(n,b,mod))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
ans = pow(2 , n , 10**9+7)
mod=7+10**9
def comb(n,c,mod):
  s=1
  t=1
  for i in range(1,c+1):
    s=s*i%mod
  for j in range(n-c+1,n+1):
    t=t*j%mod
  return (t*pow(s,mod-2,mod))%mod

print(ans-1-comb(n,a,mod)-comb(n,b,mod))

Submission status: Wrong Answer

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

#制限なしで全ての花束の作り方
wa = pow(2, n, 10 ** 9 + 7) - 1

#a本の花束の作り方
#val1 = comb(n, a, exact=True)
#val2 = comb(n, b, exact = True)

x = 1
y = 1
for i in range(a):
    x = (x * (n-i)) % (10 ** 9 + 7)
    y = (y * (i+1)) % (10 ** 9 + 7)
val1 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)

x = 1
y = 1
for i in range(b):
    x = (x * (n-i)) % (10 ** 9 + 7)
    y = (y * (i+1)) % (10 ** 9 + 7)

val2 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)

ans = wa - val1 - val2
if ans < 0:
    ans += 10 ** 9 + 7
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
s=0
def kumi(x,y):
  k=1
  for i in range(y):
    k=k*(x-i)
  return x
def comb(x,y):
  return (kumi(x,y)//kumi(y,y))
for i in range(1,n+1):
  if i==a or i==b:
    s=s
  else:
    s=s+(comb(n,i)%(10**9+7))
print(s)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
s=0
def kumi(x,y):
  k=1
  for i in range(y):
    k=k*(x-i)
  return x
def comb(x,y):
  return kumi(x,y)//kumi(y,y)
for i in range(1,n+1):
  if i==a or i==b:
    s=s
  else:
    s=s+comb(n,i)
print(s%(10**9+7))

Submission status: Wrong Answer

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

M = pow(2, N,m)

m = 10**9+7
#互いに素なa,bについて、a*x+b*y=1の一つの解
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]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m
  

res = 1
for i in range(N-a+1,N+1):
    res = res*i%m
for i in range(1,a+1):
    res = res*mod_inv(i,m)%m

rs = 1
for i in range(N-b+1,N+1):
    rs = rs*i%m
for i in range(1,b+1):
    rs = rs*mod_inv(i,m)%m

print(M-1-res-rs)

Submission status: Wrong Answer

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

#(a*x)をmで割った余りが1になるようなxを求める
#aで割ったときの余りはa^(-1)をかけた余りと同じ
#逆元a^(-1)を求める
#aとmが互いに素であることが条件

def gyakugen( a, m ):
  b = m
  x, y = 1, 0
  while b>0:
    q = a // b
    a, b = b, a-q*b
    x, y = y, x-q*y
  return x if x>0 else x+m

#nPrをmで割った余りを求める(ただしn<m、mは素数)
import sys
sys.setrecursionlimit(10**9)#再帰の回数の上限を設定

def perm_remainder(n,r,m):
    if r>=1:
        return (perm_remainder(n-1,r-1,m)*n)%m
    else:
        return 1

#nCrをmで割った余りを求める(ただしn<m,mは素数)

def comb_remainder(n,r,m):
    r=min(r,n-r)
    return (perm_remainder(n,r,m)*gyakugen(perm_remainder(r,r,m),m))%m

#(a**n)を素数mで割った余りを求める
#当然aはmで割り切れない整数

def power_remainder(a,n,m):
    a=a%m
    bi=str(format(n,"n"))#2進表現に
    res=1
    for i in range(len(bi)):
        res=(res*res) %m
        if bi[i]=="1":
            res=(res*a) %m
    return res

#2^n-nCa-nCb-1を計算
print(power_remainder(2,n,m)-1-comb_remainder(n,a,m)-comb_remainder(n,b,m))

Submission status: Wrong Answer

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

#　ans = 2**n
na = list(bin(n))
nb = na[3:]
ans = 2
for j in nb:
    if j == '0':
        ans **= 2
    else:
        ans = (ans ** 2) * 2
    ans %= 10**9 + 7

#　数え過ぎたものを引く
def comb(n, r):
    m = 1
    for i in range(1, r+1):
        m *= (n-i+1) / i
        m %= 10**9 + 7
    return m
ans -= comb(n, a) + comb(n, b) + 1
if ans < 0:
    ans += 10**9 + 7

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

Submission status: Wrong Answer

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

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


res = pow(2,n,mod) - 1


comb_a = C(n,a,mod)
comb_b = C(n,b,mod)

print(res-(comb_a+comb_b)%mod)

Submission status: Wrong Answer

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

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


res = pow(2,n,mod) - 1


comb_a = C(n,a,mod)
comb_b = C(n,b,mod)

print(res-(comb_a+comb_b)%mod)

Submission status: Wrong Answer

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

def comb(n, r):
  d = n
  r = min(r, n-r)
  for i in range(1, r):
    d = ((d * (n-i)) // (i+1)) % m
  return d

out = pow(2, n, m) - 1 - comb(n, a) - comb(n, b)

print(out%m)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

INF = float('inf')
MOD = 10 ** 9 + 7


def nCr_mod(n, r):
    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


def main():
    N, A, B = map(int, input().split())
    total = pow(2, N, MOD)
    print(total - nCr_mod(4, 1) - nCr_mod(4, 3) - 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a
  
A=framod(a,p)
B=framod(b,p)

t=1
for i in range(n-(a-1),n+1):
  t = (t*i)%p
#print(t)
C=(t* pow(A,p-2,p))%p

u=1
for j in range(n-(b-1),n+1):
  u = (u*j)%p
#print(t)
D=(u* pow(B,p-2,p))%p

ans= pow(2,n,p)-1 -C -D
print(ans)

Submission status: Wrong Answer

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


def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a
    
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
  
A= comb(n,a,p)
B= comb(n,b,p)

if n>=4:
  print(2**(n-1)-(A+B))
elif n==2:
  print(0)
else:
  if a+b==5:
    print(0)
  else:
    print(2**(n-1)-(A+B))

Submission status: Wrong Answer

Solution code:
mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print(al-(acr+bcr)%mod)

Submission status: Wrong Answer

Solution code:
import math
n,a,b=map(int, input().split())
count=0
for i in range(n):#i+1本の花束の組み合わせ
    # print(i)
    if i+1==a or i+1==b:
        continue
    # print(i)
    count += math.factorial(n)/math.factorial(i+1)/math.factorial(n-(i+1))
print(int(count//(10^9+7)))

Submission status: Wrong Answer

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

def choose(n, m, mod):
    x, y = 1, 1
    for i in range(m):
        x = x * (n - i) % mod
        y = x * (i + 1) % mod
    return x * mod_pow(y, mod - 2, mod) % mod

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

ans = (mod_pow(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)) % mod
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)
m = max(a,b)
X = [0]*(m+1)
Y = [0]*(m+1)
X[0] = 1
X[1] = n
Y[0] = Y[1] = 1

for i in range(1,m):
    X[i] = X[i-1]*(n-i)%mod
    Y[i] = Y[i-1]*(i+1)%mod

a -= 1
b -= 1
ans = (((pow(2,n,mod)-1)%mod-X[a]*pow(Y[a],mod-2,mod)%mod)%mod-X[b]*pow(Y[b],mod-2,mod)%mod)%mod
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)
m = max(a,b)
X = [0]*m
X[0] = n
Y = [0]*m
Y[0] = 1

for i in range(1,m):
    X[i] = X[i-1]*(n-i)%mod
    Y[i] = Y[i-1]*(i+1)%mod

a -= 1
b -= 1
ans = (((pow(2,n,mod)-1)%mod-X[a]*pow(Y[a],mod-2,mod)%mod)%mod-X[b]*pow(Y[b],mod-2,mod)%mod)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import scipy.misc
s = input().split()
n = int(s[0])
a = int(s[1])
b = int(s[2])
ans =0
if n%2 ==0:
    for i in range(int((n+1)/2)):
        if i ==0:
            continue
        ans = ans + scipy.misc.comb(n,i, exact = True)
    ans = ans*2 +scipy.misc.comb(n,int(n/2), exact = True) -scipy.misc.comb(n,a, exact = True) -scipy.misc.comb(n,b, exact = True) +1
else:
    for k in range(int(n/2)):
        if k ==0:
            continue
        ans = ans + scipy.misc.comb(n,k, exact = True)
    ans = ans  -scipy.misc.comb(n,a, exact = True) -scipy.misc.comb(n,b, exact = True) +1

print(int(ans))

Submission status: Wrong Answer

Solution code:
import scipy.misc
s = input().split()
n = int(s[0])
a = int(s[1])
b = int(s[2])
ans =1
for i in range(n):
    if i == a or i == b or i ==0:
        continue
    ans = ans + scipy.misc.comb(n,i, exact = True)
print(int(ans))

Submission status: Wrong Answer

Solution code:
mod = 10**9+7

def comb(n, r):
    x = 1
    y = 1
    if n-r<r:
        r = n-r
    for i in range(r):
        x *= n-i
        y *= (i*1)
        x %= mod
        y %= mod
    return x * pow(y, mod-2, mod) % mod

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

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

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


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


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


p = 10**9+7

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


def main():
    n, a, b = map(int, input().strip().split())    
    # eprint('pow(2,n,p) - cmb(n, a) - cmb(n, b) - 1 ',end=':\n')
    # eprint(pow(2,n,p) - cmb(n, a) - cmb(n, b) - 1)

    # eprint('pow(2,n,p) ',end=':\n')
    # eprint(pow(2,n,p))
    # eprint('cmb(n,a) ',end=':\n')
    # eprint(cmb(n,a))
    # eprint('cmb(n,b) ',end=':\n')
    # eprint(cmb(n,b))

    # if pow(2,n,p) - cmb(n, a) - cmb(n, b) - 1<-1:
    #     print(pow(2,n,p) - cmb(n, a) - cmb(n, b) - 1 + p)
    # elif pow(2,n,p) - cmb(n, a) - cmb(n, b) - 1 == -1:
    #     print(0)
    # else:
    #     print(max( (pow(2,n,p) - cmb(n, a) - cmb(n, b) - 1) , 0 ))

    #
    eprint('pow(2,n,p) ',end=':\n')
    eprint(pow(2,n,p))

    #
    xxx = pow(2,n,p) - cmb(n, a) - cmb(n, b)
    if xxx<0:
        print(xxx-1+p)
    elif xxx == 0:
        print(0)
    else:
        print(xxx-1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
mod = 10**9 + 7
def cmb(n,r,mod):
	a=1
	b=1
	r = min(r,n-r)
	for i in range(r):
		a = a*(n-i)%mod
		b = b*(i+1)%mod
	return a*pow(b,mod-2,mod)%mod

n,a,b = map(int,input().split())
count = 0
all = pow(2,n,mod) - 1
nCa = cmb(n,a,mod)
nCb = cmb(n,b,mod)
ans = all - (nCa + nCb) + mod
print(ans)

Submission status: Wrong Answer

Solution code:
import math
l=10**9+7

n,a,b=map(int,input().split())
comb=[1]
for i in range(max(a,b)):
    den=i+1
    num=n-i
    ans=comb[i]*num*pow(den,l-2,l)%l
    comb.append(ans)


print(pow(2,n,l)-1-comb[a]-comb[b])

Submission status: Wrong Answer

Solution code:
from math import factorial
n,a,b=map(int,input().split())

total=0
for _ in range(n):
    if not _==a and not _==b:
        x=factorial(n)%(10**9+7)
        y=factorial(_)%(10**9+7)
        z=factorial(n-_)%(10**9+7)
        total+=factorial(n)//(factorial(_)*factorial(n-_))
        
print(total)

Submission status: Wrong Answer

Solution code:
from functools import reduce

n,a,b = [int(i) for i in input().split()]
mod = 10**9 + 7
total = (2**n -1)%mod

def f(A):
    num = reduce(lambda x, y: x * y % mod, range(n, n - a, -1))
    den = reduce(lambda x, y: x * y % mod, range(1, a + 1))
    return num * pow(den, mod - 2, mod) % mod

print((total - f(a) - f(b))%mod)

Submission status: Wrong Answer

Solution code:

N,a,b = map(int,input().split())
Sum = pow(2, N, 10**9+7)-1
MOD = 10**9 + 7
def comb(n,k, mod):
    m = 1#分子
    l = 1#bunnbo
    for i in range(k):
        m *= (n-i)
        l *= (i + 1)
        m %= mod
    return m * pow(l, mod-2, mod) % mod

Sum = pow(2, N, 10**9+7) -1 - comb(N, a, MOD) - comb(N, b, MOD)
print(pow(2, N, 10**9+7), comb(N, a, MOD), comb(N, b, MOD))
Sum = Sum % (10**9+7)
print(Sum)

Submission status: Wrong Answer

Solution code:
import math
N,a,b = map(int,input().split())
Sum = pow(2, N, 10**9+7)-1
def comb(n,k):
    m = n#分子
    l = 1 #bunnbo
    for i in range(k):
        m *= m-i
        l *= i+1
    return m * pow(l, 10**9+5, 10**9+7)

Sum = pow(2, N, 10**9+7) -1 - comb(N,a) - comb(N,b) 
Sum %= 10**9+7
print(Sum)

Submission status: Wrong Answer

Solution code:
import math
N,a,b = map(int,input().split())
Sum = pow(2, N, 10**9+7)-1
def comb(n,k):
    m = n#分子
    l = 1 #bunnbo
    for i in range(k):
        m *= m-i
        l *= i+1
    return m / pow(l, 10**9+5, 10**9+7)

Sum = pow(2, N, 10**9+7) -1 - comb(N,a) - comb(N,b) 
Sum %= 10**9+7
print(Sum)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


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

    all_case = pow(2, n, mod) - 1
    nCa = conbination(n, a, mod)
    nCb = conbination(n, b, mod)
    result = all_case - nCa - nCb
    if result < 0:
        result = result + mod
    print(result)


def conbination(n, r, mod):
    a = 1
    b = 1
    for i in range(1, r + 1):
        # print(a, b, i)
        a = (a * (n - i + 1)) % mod
        b = (b * i) % mod
    b = pow(b, mod - 2, mod)

    return (a * b) % mod


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


def comb(N, A):
    x = 1
    for i in range(A):
        x *= N
        N -= 1
        x %= MOD
    y = 1
    for i in range(A):
        y *= A
        A -= 1
        y %= MOD
    return x*pow(y, MOD-2, MOD) % MOD


N, A, B = map(int, input().split())
MOD = 10**9+7
print(pow(2, N, MOD)-1-comb(N, A)-comb(N, B))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-


N, A, B = map(int, input().split())
MOD = 10**9+7
print(pow(2, N, MOD)-1)

Submission status: Wrong Answer

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

p = 10**9+7

def f(x, n, p):
    print(x, n, p)
    if n == 1:
        return x % p
    if n % 2 == 1:
        return (x * f(x, n-1, p)) % p
    y = f(x, n//2, p)
    return (y**2) % p

def ff(n, m):
    x = 1
    for i in range(n-m+1, n+1):
        x *= i
        x %= p
    return x

res = f(2, n, p) - 1
res -= (ff(n, a) * f(ff(a, a), p-2, p)) % p
res -= (ff(n, b) * f(ff(b, b), p-2, p)) % p

while res < 0:
    res += p

print(res)

Submission status: Wrong Answer

Solution code:
import math #階乗を計算するために必要
def combinations_count(n, r):
    return math.factorial(n)//math.factorial(n-r)*math.factorial(r) #intを返すように//で演算

n, a, b=map(int, input().split())
com_sum=0
for i in range(1, n+1): #range(start, stop)で start ≦ i < stopの連番が生成
    com_sum+=combinations_count(n, i) 
com_sum-=combinations_count(n, a)+combinations_count(n, b)
print(com_sum%((10**9)+7))

Submission status: Wrong Answer

Solution code:
import sys 
stdin = sys.stdin

nm = lambda: map(int, stdin.readline().split())

n,a,b = nm()
mod = 10**9 + 7
s = pow(2,n,mod) - 1

def fur(n,r):
  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

print((s - fur(n,a) - fur(n,b)) % mod)

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


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


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x

def cmb(n,r):
    temp1=1
    temp2=1
    for i in range(n-r+1,n+1):
        temp1*=i
    for i in range(1,r+1):
        temp2*=i
    return temp1//temp2


def main():
    n, a, b = map(int, input().strip().split())
    p=10**9+7
    print((n**2 - cmb(n,a) - cmb(n,b) -1) % p )


if __name__ == '__main__':
    main()