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:
def main():
    n, a, b = map(int, input().split())
    p = 10 ** 9 + 7
    r = pow(2, n, p) - 1
    if (n - a) < a:
        a = n - a
    if (n - b) < b:
        b = n - b
    fac_na = 1
    for i1 in range(n, n - a, -1):
        fac_na = (fac_na * i1) % p
    fac_nb = 1
    for i1 in range(n, n - b, -1):
        fac_nb = (fac_nb * i1) % p
    fac_a = 1
    for i1 in range(a+1):
        fac_a = (fac_a * i1) % p
    fac_b = 1
    for i1 in range(b+1):
        fac_b = (fac_b * i1) % p

    an = fac_na * pow(fac_a ,p-2, p)
    bn = fac_nb * pow(fac_b, p-2, p)
    r -= an
    if r < 0:
        r += p
    r -= bn
    if r < 0:
        r += p
    print(int(r))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if n > 0:
  temp = 1
  for i in range(n):
    if i!=a and i!=b:
      temp = temp * (n-i) / (i+1)
      ans += temp
      
ans = ans % (10**9+7)
print(ans)

Submission status: Wrong Answer

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

def repeatSquaring(N, P, M):
    if P <= 0:
        return 1
    if (P &0x01) == 0:
        ans = repeatSquaring(N, (P>>1), M)
        return ans*ans % M

    return N*repeatSquaring(N, P-1, M) % M

def seki(aa, bb):
    res = 1
    for k in range(aa, bb+1):
        res *= k
        if res >= modz:
            res %= modz
    return res

def CC(aa, nn):
    ss = repeatSquaring(seki(1, aa), modz - 2, modz)
    return seki(nn-aa + 1, nn)*ss % modz

total = repeatSquaring(2, N, modz) - 1
total -= CC(a, N)
total -= CC(b, N)
if total < 0: total += modz
print(int(total))

Submission status: Wrong Answer

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

def pow(x, n):
    ans = 1
    while n > 0:
        if n%2 == 1:
            ans *= x
        x *= x
        n >>= 1
    return ans

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

for i in l:
    ref1 = 1
    ref2 = 1
    for j in range(i):
        ref1 = ref1*(n - j)%mod
        ref2 = ref2*(j + 1)%mod
    ans = (ans - ref1/ref2)%mod


while ans < 0:
    ans += mod

print(int(ans))

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

MOD = 10**9 + 7


def comb(n, r, mod=float("inf")):
    c = 1
    m = 1
    r = min(n - r, r)
    for i in range(r):
        c = c * (n - i) % mod
        m = m * (i + 1) % mod
    return c * pow(m, mod - 2, mod) % mod


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

Submission status: Wrong Answer

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

def comb(N,x):
  numerator = 1
  for i in range(N-x+1,N+1):
    numerator = numerator *i%mod
  denominator = 1
  for j in range(1,x+1):
    denominator = denominator *i%mod
  d = pow(denominator,mod-2,mod)
  return (numerator*d)%mod
al = pow(2,n,mod)-1
ac =comb(n,a)
bc =comb(n,b)
print((al-ac-bc)%mod)

Submission status: Wrong Answer

Solution code:
mod = (10 ** 9 + 7)

def comb(n, r):
    p, q = 1, 1

    for i in range(r):
        p = p *(n-i)%mod
        q = q *(i+1)%mod

    return (p / q) % mod

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

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

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

Submission status: Wrong Answer

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

# 1!~n!の計算
f = 1
for i in range(1, n+1):
    f *= i
    f %= mod
# n!^-1の計算
inv = pow(f, mod-2, mod)
for i in range(1, n+1):
    if i != a or i != b:
        ans += inv*i%mod
print(ans)

Submission status: Wrong Answer

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

fac=[]      #fac[n] = (n! mod p)
finv=[]     #finv[n]= ((n!)^-1 mod p)
inv=[]      #inv[n] = finv計算用

#前処理、初期化
def comInit(n,mod):
    fac.append(1)   #fac[0]
    fac.append(1)   #fac[1]
    finv.append(0)  #finv[0]
    finv.append(1)  #finv[1]
    inv.append(0)   #inv[0]
    inv.append(1)   #inv[1]
    for i in range(2,n+1):
        fac.append(fac[-1]*i%mod)
        inv.append(mod - inv[mod%i]*(mod//i)%mod)
        finv.append(finv[-1]*inv[i]%mod)

#二項係数計算
def comCalc(n,k):
    if(n<k):
        return 0
    elif(n<0 or k<0):
        return 0
    else:
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

#x^nを繰り返し二乗法で求める関数
#実際やると大きすぎる数を計算しようとしてエラーになりやすい

#実際に使うときは、MOD=10000007 などの剰余計算を組み込んで使うこと！
def repeated_square(x,n):
    #nを2進数で表して順序反転
    bit_n=bin(n)[2:][::-1]

    ans=1
    ni=x

    if(bit_n[0]=="1"):
        ans*=ni

    for i in range(1,len(bit_n)):
        ni=((ni%MOD)*(ni%MOD))%MOD

        #i桁目が1なら、x^(2^i)を加える
        if(bit_n[i]=="1"):
            ans=((ans%MOD)*(ni%MOD))%MOD

    return ans

comInit(n, MOD)

ans=0
alln=(repeated_square(2, n)-1)%MOD
print((alln-comCalc(n, a)-comCalc(n, b))%MOD)

Submission status: Wrong Answer

Solution code:
def cmb(n,k,p):
    x,y = 1,1
    for i in range(k):
        x = x * (n-i) % p
        y = y * (i+1) % p
    res = x * pow(y,p-2,p) % p
    return res

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

Submission status: Wrong Answer

Solution code:
from functools import reduce
MOD = 10**9 + 7


def cmb(N, 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


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


print((pow(2, n, MOD) - cmb(n, a) - cmb(n, b)) % MOD)

Submission status: Wrong Answer

Solution code:
from functools import reduce
N,a,b = map(int,input().split())
MOD = 10**9+7
def combination(n,r):
    nPr = reduce(lambda x,y: x * y % MOD,range(n,n-r,-1))
    r_fact = reduce(lambda x,y: x * y % MOD,range(1,r+1))
    return nPr * pow(r_fact,MOD-2,MOD) % MOD
result = pow(2,N,MOD) - 1
nashi = combination(N,a) + combination(N,b)
if result - nashi < 0:
    print(result - nashi + MOD)
else:
    print(result - nashi)

Submission status: Wrong Answer

Solution code:
import math


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

c1=1
c2=1

for i in range(n-a+1,n+1):
    c1*=i
    c1%=mod
for j in range(1,a+1):
    c1*=pow(j,mod-2,mod)
    c1%=mod
    
for i in range(n-b+1,n+1):
    c2*=i
    c2%=mod
for j in range(1,b+1):
    c2*=pow(j,mod-2,mod)
    c2%=mod

ans=pow(2,n,mod)-1
print(ans-c1-c2)

Submission status: Wrong Answer

Solution code:
import math


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

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
ans=0
for i in range(int(n/2)):
    ans+=2*combinations_count(n, i)
if n%2==0:
    ans+=combinations_count(n, int(n/2))-1

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

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

Submission status: Wrong Answer

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

def comb(n,r,m):
    x,y=1,1
    for i in range(r):
        x*=n-1
        y*=n+1
        x%=m
        y%=m
    return int(x * pow(y, m-2, m))
ans = pow(2, n, m)-comb(n, a, m) - comb(n, b, m)
print(ans%m)

Submission status: Wrong Answer

Solution code:
n, a, b = (int(i) for i in input().split())  
mod = 1000000007
import math

def combinations_count(n, r):
    if n <= 1:
        return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
lis = [n]
ans = n
bef = n
for i in range(2, math.floor(n/2) + 1):
  add = bef * (bef-1) * (1/i)
  if i == math.floor(n/2) and n % 2 == 0:
    ans *= 2
    ans += add + 1
  elif i == math.floor(n/2) and n % 2 != 0:
    ans += add
    ans *= 2
    ans += 1
  else:
    ans += add
  
  lis.append(add)

  
print(int(ans % mod))
  
### 途中

Submission status: Wrong Answer

Solution code:
def modpow(a, n, p):
    if n == 0:
        return 1
    elif n == 1:
        return a % p
    if n % 2 == 1:
        return (a * modpow(a, n-1, p)) % p
    tmp = modpow(a, n//2, p)
    return (tmp * tmp) % p


def modfactrial(a, p):
    ret = 1
    for i in (a, 1, -1):
        ret = ret * i % p
    return ret


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

    # まずは繰り返し2乗法によって全部の組み合わせを求める
    # すべての組み合わせは、花を選ぶ/選ばないで組み合わせを決めれる

    ans = (modpow(2, n, mod) - 1) % mod

    # a本選んだときの数を引く
    c_a = 1
    for i in range(n, n-a, -1):
        c_a *= i
        c_a %= mod
    c_a *= modpow(modfactrial(a, mod), mod-2, mod)
    ans -= c_a
    ans %= mod

    # b本選んだときの数を引く
    c_b = 1
    for i in range(n, n-b, -1):
        c_b *= i
        c_b %= mod
    c_b *= modpow(modfactrial(b, mod), mod-2, mod)
    ans -= c_b
    ans %= mod

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, a, b = map( int, input().split())
mod = 10 ** 9 + 7
 
def nCr( n, r ):
  f = 1
  inv = 1
  for i in range( min( n - r, r ) + 1 ):
    f = f * ( n - 1 ) % mod
    inv = inv * ( i + 1 ) % mod
  return f * pow( inv, mod - 2, mod ) % mod
 
A = nCr( N, a )
B = nCr( N, b )
N = pow( 2, N, mod )
print( ( N - A - B ) % mod )

Submission status: Wrong Answer

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

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

A = nCr( N, a )
B = nCr( N, b )
N = pow( 2, N, mod )
print( ( N - A - B ) % mod )

Submission status: Wrong Answer

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

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

N = pow( 2, n, mod )
A = nCr( n, a )
B = nCr( n, b )
print( ( N - A - B ) % mod )

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
c=d=1
e=0
m=10**9+7
for i in range(1,n+1):
  if i!=a and i!=b:
    c=(c*(n+1-i))%m
    d=(d*i)%m
    e+=c*pow(d,m-2,m)
print(e)

Submission status: Wrong Answer

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

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

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

lis = list()

lis.append(combinations(n, a))
lis.append(combinations(n, b))

2**n-1 - sum(lis)%mod

Submission status: Wrong Answer

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

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

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

lis = list()

lis.append(combinations(n, a))
lis.append(combinations(n, a))

2**n-1 - sum(lis)%mod

Submission status: Wrong Answer

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000
d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

n, a, b = LI()

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

Submission status: Wrong Answer

Solution code:
from functools import reduce
def cmb(r):
    numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
    denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
    return numerator * pow(denominator, mod - 2, mod) % mod
n,a,b = map(int,(input().split()))
ans=0
mod=10**9+7

ans=pow(2,n,10**9+7)-1
ans-=cmb(a)
ans-=cmb(b)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
import sys 
import math
sys.setrecursionlimit(400000000)
mod=1000000007
n,a,b=map(int,input().split())
def power(x,y):
    count=1
    rem=x
    while 2*count<y:
        x=x**2
        x=x%mod
        count*=2
    res=y-count
    return x*(pow(rem,res))%mod

def nck(x,y):
    sum=1
    for i in range(y):
        sum*=(x-i)/(i+1)
        sum=int(sum)%mod
    return sum

ans=power(2,n)-1-nck(n,a)-nck(n,b)
ans=ans%mod
print(ans%mod)

Submission status: Wrong Answer

Solution code:
from math import factorial
import sys 
import math
sys.setrecursionlimit(400000000)
mod=1000000007
n,a,b=map(int,input().split())
def power(x,y):
    count=1
    rem=x
    while 2*count<y:
        x=x**2
        x=x%mod
        count*=2
    res=y-count
    return x*(pow(rem,res))%mod

def nck(x,y):
    sum=1
    for i in range(y):
        sum*=(x-i)/(i+1)
        sum=sum%mod
    return sum

ans=power(2,n)-1-nck(n,a)-nck(n,b)
if ans<1:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N = 1000000007

def fac(n,r,N):
    ans=1
    for i in range(r):
        ans=ans*(n-i)%N
    return ans

def combi(n,r,N):
    r= min(r, n-r)
    ans = fac(n,r,N)*pow(fac(r,r,N),N-2,N)%N
    return ans

n,a,b = map(int, input().split())
ans = pow(2,n,N)-combi(n,a,N)-combi(n,b,N)-1
if ans<0:
    ans+=N
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n,a,b = list(map(int,sys.stdin.readline().split()))
    mod = 10**9 + 7
    ans = 1
    C = 1
    for i in range(n-1):
        C = C * (n - i) // (i + 1)
        #print("C=",C)
        if not i == a or i == b:
            ans += C
            ans = ans % mod
            #print(ans)
    print(ans)
    
    return 0

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
from collections import defaultdict

def main():
    n,a,b = list(map(int,sys.stdin.readline().split()))
    mod = 10**9 + 7
    ans = 1
    C = 1
    for i in range(n-1):
        C = C * (n - i) // (i + 1)
        #print("C=",C)
        if not i == a or i == b:
            ans += C % mod
            #print(ans)
    print(ans)
    
    return 0

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math

def comb(n, r):
    x = math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
    return x % (pow(10,9)+7)

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

ans = pow(2, n)
ex_a = comb(n, a)
ex_b = comb(n, b)
print(ans-ex_a-ex_b)

Submission status: Wrong Answer

Solution code:
import functools

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

total = pow(2, n, m) -1

def f(n, a, m):
    X = functools.reduce(lambda x,y : (x * y) % m, range(n, n-a, -1))
    Y = functools.reduce(lambda x,y : (x * y) % m, range(1, a+1))
    return  (X * pow(Y, m - 2, m)) % m

# nCa
x = total - f(n, a, m) - f(n, b, m)
if x < 0:
    print(x + m)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
lim = 10**9+7
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * pow(a, mod-2, mod) % mod
    return res

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

Submission status: Wrong Answer

Solution code:
def framod(x,y,p=10**9+7):
  for i in range(x+1,y+1):
    x = (x*i)%p
  return x
    
#########################################

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

ans=0
for i in [a,b]:
  upper = framod(n-i+1,n,p)
  lower = framod(1,i,p)
  ret = (upper*pow(lower,p-2,p))%p
  ans = (ans+ret)%p
print(pow(2,n,p)-ans-1)

Submission status: Wrong Answer

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

mod = 1000000007
def Exp(base,exp):
    outer = 1
    inner = base
    while exp != 1:
        if exp%2==0:
            inner = (inner**2)%mod
            exp/=2
        else :
            outer = (outer*base)%mod
            exp-=1 
    return (inner*outer) %mod


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

ruiseki2 = 1
for i in range(b):
    ruiseki2 = (ruiseki2*(n-i)*pow(i+1, mod-2, mod)) %mod
    
print((Exp(2,n) - ruiseki1 -ruiseki2-1)%mod)

Submission status: Wrong Answer

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

mod = 1000000007
def Exp(base,exp):
    outer = 1
    inner = base
    while exp != 1:
        if exp%2==0:
            inner = (inner**2)%mod
            exp/=2
        else :
            outer = (outer*base)%mod
            exp-=1 
    return (inner*outer) %mod

print(Exp(3,10))

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

ruiseki2 = 1
for i in range(b):
    ruiseki2 = (ruiseki2*(n-i)*pow(i+1, mod-2, mod)) %mod
    
print((Exp(2,n) - ruiseki1 -ruiseki2-1)%mod)

Submission status: Wrong Answer

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

modular = 1000000007

mod_value = pow(2, n, modular)
all_combination_modular = mod_value - 1 if mod_value != 0 else modular - 1

# print(all_combination_modular)

p = 1
q = 1
for i in range(a):
    p = p * (n - i) % modular
    q = q * (i + 1) % modular

mod_a = p * pow(q, modular - 2, modular) % modular

p = 1
q = 1
for i in range(b):
    p = p * (n - i) % modular
    q = q * (i + 1) % modular

mod_b = p * pow(q, modular - 2, modular) % modular

# mod_a = math.factorial(n) * pow(math.factorial(a) * math.factorial(n - a), modular - 2, modular) % modular
# # mod_a = n
# # for i in range(1, a):
# #     mod_a = (mod_a * (n - i) / (1 + i)) % modular
# print(mod_a)
#
# mod_b = math.factorial(n) * pow(math.factorial(b) * math.factorial(n - b), modular - 2, modular) % modular
# # mod_b = n
# # for i in range(1, b):
# #     mod_b = (mod_b * (n - i) / (1 + i)) % modular
# print(mod_b)

result = all_combination_modular - mod_a - mod_b

while True:
    if result <= 0:
        result += modular
    else:
        break
print(result)
# combination_list = [0] * (n + 1)
# combination_list[0] = 1
# previous = 1
# combination = 0
# a_combination = 0
# b_combination = 0
# for i in range(1, n + 1):
#     # combination_list[i] = combination_list[i - 1] * (n + 1 - i) // i
#     previous = previous * (n + 1 - i) // i
#     if i == a:
#         continue
#     if i == b:
#         continue
#     previous %= modular
#     if previous == 0:
#         break
#     print(previous)
#     combination += previous
#
# combination_list[0] = 0
#
# # combination = sum(combination_list) - combination_list[a] - combination_list[b]
# print(combination % modular)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)

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

for i in range(a):
    nca *= (n-i)
    nca *= pow(i+1, mod-2, mod)
    nca %= mod
ncb = 1
for i in range(b):
    ncb *= (n-i)
    ncb *= pow(i+1, mod-2, mod)
    ncb %= mod

nca %= mod
ncb %= mod


ans = pow(2, n, mod) - nca - ncb - 1
if ans >= 0:
    print(ans)
else:
    print(ans + mod)

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7


def f(n, r):
    X = 1
    Y = 1
    for i in range(r):
        X *= n - i    # nCr の分子
        X %= mod
        Y *= i + 1    # nCr の分母
        Y %= mod

    # フェルマーの小定理より (X/Y)%mod = X*Y^(mod - 2) % mod
    return X * pow(Y, mod - 2, mod) % mod


N, A, B = map(int, input().split())
res = pow(2, N, mod) - 1

for i in [A, B]:
    res -= f(N, i)

print(res)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce
import math

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

so=10**9+7

large=(pow(2,n,so))

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

ajogai = kumiawase(n,a) % so
bjogai = kumiawase(n,b) % so
print(large)
print(ajogai)
print(bjogai)
print((large - 1 - ajogai - bjogai + 2*so) % so)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

so=10**9+7

large=(pow(2,n,so))

def kumiawase(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1)) % so
    under = reduce(mul, range(1,r + 1))
    
    return over * pow(under,so-2,so)

ajogai = kumiawase(n,a) % so
bjogai = kumiawase(n,b) % so
print((large - ajogai - bjogai + 2*so) % so)

Submission status: Wrong Answer

Solution code:
n,a,b=(int(i) for i in input().split())
p = 10 ** 9 + 7
def comb(n,k):
    nCk = 1
    MOD = 10**9+7
 
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD
 
    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk
r=pow(2,n,p)-comb(n,a)-comb(n,b)-1
if r<0:
  r+=p
print(r)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
MOD = 10**9+7

# 二分累積法による a^n mod の計算
def modpow(a, n):
    res = 1
    while n > 0:
        if n & 1:
            res = res * a % MOD
        a = a * a % MOD
        n >>= 1
    return res

# nCr mod.p (n <= 10**6)
MAX = 1000010
fac = [0] * MAX 
finv = [0] * MAX
inv = [0] * MAX
def COMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i-1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD//i) % MOD
        finv[i] = finv[i-1] * inv[i] % MOD
# より高速化が必要な場合
def COM(n, k):
    res = 1
    for i in range(k):
        res = res * (n-i) % MOD
    return res * finv[k] % MOD

COMinit()
n, a, b = map(int, input().split())
tot = modpow(2, 10**9) - 1
ans = (tot - COM(n,a) - COM(n,b)) % MOD
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    import numpy as np
    n, a, b = map(int, input().split())
    mod = 10**9+7

    def cumprod(vector, mod=10**9+7):
        a, n = np.array(vector, dtype=np.int64), len(vector)
        nsq = int((n-1)**0.5)+1
        a.resize(nsq, nsq)
        for i in range(1, nsq):
            a[:, i] *= a[:, i-1]
            a[:, i] %= mod
        for i in range(1, nsq):
            a[i] *= a[i-1, -1]
            a[i] %= mod
        a.resize(n)
        return a

    xx = cumprod([i for i in range(n, n-200001, -1)])
    yy = cumprod([i for i in range(200001)])

    ans1 = xx[a]*pow(int(yy[a]), mod-2, mod)
    ans2 = xx[b]*pow(int(yy[b]), mod-2, mod)

    print((pow(2, n, mod)-ans1-ans2-1) % mod)


main()

Submission status: Wrong Answer

Solution code:
from math import factorial
def comb(n,r):
    return  factorial(n) / factorial(r) / factorial(n - r)

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

total = 2**n -1

total-=comb(n,a)
total-=comb(n,b)


print(total%mod)

Submission status: Wrong Answer

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


# 参考：https://qiita.com/MyOden/items/b669bfbf6dbf83242bdf =>フェルマーの小定理を基に演算関数を用意
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


nca = fur(n, a)
ncb = fur(n, b)
ans = ((pow(2, n, mod) - 1) - nca - ncb) % mod

print(ans)

Submission status: Wrong Answer

Solution code:

# 初期入力
n,a,b = (int(x) for x in input().split())
mod =10**9 +7
#
all_n =pow(2,n,mod) -1

#嫌いな数の組み合わせ
dislike_a =1 #掛け算だから初期値１
for i in range(n-a+1,n+1):
    dislike_a *=i
for i in range(1,a+1):
    dislike_a *= pow(i,mod-2,mod)
    dislike_a %=mod
dislike_b =1 #掛け算だから初期値１
for i in range(n-a+1,n+1):
    dislike_b *=i
for i in range(1,a+1):
    dislike_b *= pow(i,mod-2,mod)
    dislike_b %=mod

ans = all_n -dislike_a -dislike_b
print(ans)

Submission status: Wrong Answer

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


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


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

Submission status: Wrong Answer

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


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


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

Submission status: Wrong Answer

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


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


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

Submission status: Wrong Answer

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

def comb(n, r):
    n_p, r_inv, nr_inv = 1, 1, 1
    for i in range(1, n+1):
        n_p *= i % mod
    for i in range(1, r+1):
        r_inv *= pow(i, mod-2, mod) % mod
    for i in range(1, n-r+1):
        nr_inv *= pow(i, mod-2, mod) % mod
    return (n_p * r_inv % mod) * nr_inv % mod


ans = 0
for i in range(n):
    if i == a:
        ans = (ans - comb(n, a)) % mod
    elif i == b:
        ans = (ans - comb(n, b)) % mod
    else:
        ans = (ans + comb(n, i)) % mod
print(ans % mod)

Submission status: Wrong Answer

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

akai=1
nakai=n
bkai=1
nbkai=n
for i in range(2,a+1):
  akai=(akai%mod)*(i%mod)
  nakai=(nakai%mod)*((n-i+1)%mod)
for i in range(2,b+1):
  bkai=(bkai%mod)*(i%mod)
  nbkai=(nbkai%mod)*((n-i+1)%mod)
akai=akai%mod
bkai=bkai%mod
nakai=nakai%mod
nbkai=nbkai%mod
nakai=nakai*pow(akai,mod-2,mod)
nbkai=nbkai*pow(bkai,mod-2,mod)
print((pow(2,n,mod)-nakai-nbkai)%mod)

Submission status: Wrong Answer

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

fac=[]      #fac[n] = (n! mod p)
finv=[]     #finv[n]= ((n!)^-1 mod p)
inv=[]      #inv[n] = finv計算用

#前処理、初期化
def comInit(n,mod):
    fac.append(1)   #fac[0]
    fac.append(1)   #fac[1]
    finv.append(0)  #finv[0]
    finv.append(1)  #finv[1]
    inv.append(0)   #inv[0]
    inv.append(1)   #inv[1]
    for i in range(2,n+1):
        fac.append(fac[-1]*i%mod)
        inv.append(mod - inv[mod%i]*(mod//i)%mod)
        finv.append(finv[-1]*inv[i]%mod)

#二項係数計算
def comCalc(n,k):
    if(n<k):
        return 0
    elif(n<0 or k<0):
        return 0
    else:
        return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

comInit(n, MOD)

ans=0
alln=((2**n)-1)%MOD
print((alln-comCalc(n, a)-comCalc(n, b))%MOD)

Submission status: Wrong Answer

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

def comb(n,r,mod=10**9+7):
    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

ans = pow(2,n,10**9+7)-1 - comb(n,a) - comb(n,b)
if ans < 0: ans += 10**9+7
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int,input().split())
print((n**2 - math.factorial(n)/(math.factorial(a)*math.factorial(n-a)) - math.factorial(n)/(math.factorial(b)*math.factorial(b-a)))%(10**9+7))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
def cmb(n, r, mod):
    x = 1 
    y = 1
    for i in range(r):
        x = x*(n-i)%(mod)
    for i in range(1,r+1):
        y = y*i%(mod)
    return x * pow(y,mod-2,mod) %mod

v = int(pow(2,n,10**9+7)-1-cmb(n,a,10**9+7)-cmb(n,b,10**9+7))
print(v)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
def cmb(n, r, mod):
    x = 1 
    y = 1
    for i in range(r):
        x = x*(n-i)%(mod)
    for i in range(1,r+1):
        y = y*i%(mod)
    return x * pow(y,mod-2,mod) %mod

v = int(pow(2,n,10**9+7)-1-cmb(n,a,10**9+7)-cmb(n,b,10**9+7))
if v >= 0:
    print(v)
else:
    print(v+10**9+7)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
def kai(g):
    p = 1 
    for i in range(1,g+1):
        p = p*i
    return p
def comb(n,k):
    return kai(n)/(kai(k)*kai(n-k))
print(2**n-1-comb(n,a)-comb(n,b))

Submission status: Wrong Answer

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

from operator import mul
from functools import reduce
import math

flg = (a == n-b)
rep = math.ceil(n/2)
MOD = 10**9+7
memo = 0

def modpow(a: int, p: int, mod: int) -> int:
    # return a**p (mod MOD) O(log p)
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mod_mul, range(n, n - r, -1), 1)
    denom = reduce(mod_mul, range(1, r + 1), 1)
    return numer*pow(denom, MOD-2, MOD)%MOD
  
def mod_mul(a, b):
  return mul(a%MOD, b%MOD)%MOD

s = 0
ans = modpow(2, n, MOD)-1
if flg:
  ans = ans - combinations_count(n, a)
else:
  ans = (ans - combinations_count(n,a))%MOD - combinations_count(n,b)
print(ans%MOD)

Submission status: Wrong Answer

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

from operator import mul
from functools import reduce
import math

flg = (a == n-b)
rep = math.ceil(n/2)
MOD = 10**9+7
memo = 0

def modpow(a: int, p: int, mod: int) -> int:
    # return a**p (mod MOD) O(log p)
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mod_mul, range(n, n - r, -1), 1)
    denom = reduce(mod_mul, range(1, r + 1), 1)
    return numer*pow(denom, MOD-2, MOD)%MOD
  
def mod_mul(a, b):
  return mul(a%MOD, b%MOD)%MOD

s = 0
ans = modpow(2, n, MOD)+1
if flg:
  ans = ans - combinations_count(n, a)
else:
  ans = (ans - combinations_count(n,a))%MOD - combinations_count(n,b)
print(ans%MOD)

Submission status: Wrong Answer

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

from operator import mul
from functools import reduce
import math

flg = (a == n-b)
rep = math.ceil(n/2)
MOD = 10**9+7
memo = 0

def modpow(a: int, p: int, mod: int) -> int:
    # return a**p (mod MOD) O(log p)
    if p == 0:
        return 1
    if p % 2 == 0:
        half = modpow(a, p//2, mod)
        return half*half % mod
    else:
        return a * modpow(a, p-1, mod) % mod


from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mod_mul, range(n, n - r, -1), 1)
    denom = reduce(mod_mul, range(1, r + 1), 1)
    return numer*pow(denom, MOD-2, MOD)%MOD
  
def mod_mul(a, b):
  return mul(a%MOD, b%MOD)%MOD

s = 0
ans = modpow(2, n, MOD)
if flg:
  ans = ans - combinations_count(n, a)
else:
  ans = (ans - combinations_count(n,a))%MOD - combinations_count(n,b)
print(ans%MOD)