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:
# From https://ja.wikipedia.org/wiki/%E5%86%AA%E5%89%B0%E4%BD%99#%E3%81%95%E3%82%89%E3%81%AA%E3%82%8B%E6%9C%80%E9%81%A9%E5%8C%96

import math

def bits(integer): #Gets number of bits in integer
   result = 0
   while integer:
      integer >>= 1
      result += 1
   return result

def power(base, exponent, modulo=1000000007): #Allows fast exponentation with and without moduli
   result = 1
   if not modulo:
      iteration = bits(exponent)
      while iteration >= 0:
         result *= result
         if (exponent >> iteration) & 1:
            result *= base
         iteration -= 1
   else:
         firstModulus = base % modulo
         iteration = bits(exponent)
         while iteration >= 0:
            result = (result * result) % modulo
            if (exponent >> iteration) & 1:
               result = (result * firstModulus) % modulo
            iteration -= 1
   return result

# End of citation

def nCk(n, k, DIVISOR=1000000007):
    C = 1
    for n, d in zip(range(n, n - k, -1), range(1, k + 1, 1)):
        C = ((C * n) // d) % DIVISOR
    return C

def sub(a, b, DIVISOR=1000000007):
    return (a - b) % DIVISOR

def main():
    N, A, B = map(int, input().split())
    num_bouquets = sub(sub(sub(power(2, N), 1), nCk(N, A)), nCk(N, B))
    print(num_bouquets)

main()

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

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

c=0

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

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

Submission status: Wrong Answer

Solution code:
def modpow(a,b,mod):
    ans=1
    a=a%mod
    while b>0:
        if b%2==1:
            ans=(ans*a)%mod
        a=(a**2)%mod
        b=b//2
    return ans

N,A,B=map(int,input().split())

ans=modpow(2,N,10**9+7)-1
c=1
d=1
for i in range(A):
  c=(c*(N-i))%(10**9+7)
for i in range(A):
  d=(d*(i+1))%(10**9+7)
d=modpow(d,10**9+5,10**9+7)
ans-=(c*d)%(10**9+7)
c=1
d=1
for i in range(B):
  c=(c*(N-i))%(10**9+7)
for i in range(B):
  d=(d*(i+1))%(10**9+7)
d=modpow(d,10**9+5,10**9+7)
ans-=(c*d)%(10**9+7)
if ans<0:
  ans+=10**9+7
print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

n, a, b = map(int, input().split())
summ = 0
for i in range(n):
    if i == a or i == b:
        continue
    comb = combinations([x for x in range(n)], i)
    summ += len(list(comb))

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

Submission status: Wrong Answer

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

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

print(int(comb-1))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split(" "))
from math import factorial
c = n
ans = c
for i in range(1, n + 1):
    c *= (n - i) / (i + 1)
    if i + 1 != a and i + 1 != b:
        ans += c % (10 ** 9 + 7)
if a == 1:
    ans -= n
elif b == 1:
    ans -= n
print(ans)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

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

c=0

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

print(c%((10**9)+1))

Submission status: Wrong Answer

Solution code:
def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2 % MOD, n // 2) % MOD
    else:  # standard case ② n is odd
        return x * pow_r(x ** 2 % MOD, (n - 1) // 2) % MOD


N, A, B = map(int, input().split())
MOD = 10**9+7
all_number = (pow_r(2, N)-1)
# nがさらに巨大な時
tmp_A = 1
for i in range(1, A+1):
    tmp_A %= MOD
    tmp_A *= (N-i+1)
    tmp_A //= i

tmp_B = 1
for i in range(1, B+1):
    tmp_B %= MOD
    tmp_B *= (N-i+1)
    tmp_B //= i
# print(tmp_A, tmp_B)
tmp_A %= MOD
tmp_B %= MOD
# print(all_number, tmp_A, tmp_B)
ans = (all_number - (tmp_A+tmp_B) + MOD)%MOD
print(ans % MOD)

Submission status: Wrong Answer

Solution code:
from math import factorial
def combinationsCount(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
n,a,b = map(int, input().split())
print((2**n - 1 - combinationsCount(n, a) - combinationsCount(n, b)) % (10e9+7) )

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
print(0)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
def power_func(a,n,p=10**9+7):
    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

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
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y
ans = power_func(2,N) - 1 - combination(N,A) - combination(N,B)
# if N == 2:
#     ans = 0
print(ans) if ans >= 0 else print(ans+10**9+7)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

MAX = 10**9 + 7

def pow_mod_p(n, k, p):
  x = 1
  while k:
    if k % 2 == 1:
      x *= n
      x %= p
    n **= 2
    n %= p
    k >>= 1
  return x

def comb_mod_p(n, k, p):
  x = 1
  for ik in range(k):
    x *= ((n-ik) * pow_mod_p(ik+1, p-2, p))
    x %= p
  return x


def main():
  n, a, b = map(int, input().strip().split())
  sum = pow_mod_p(2, n, MAX) - 1
  sum = sum - comb_mod_p(n, a, MAX) - comb_mod_p(n, b, MAX)
  if sum < 0:
    print(MAX + sum)
  else:
    print(sum)


if __name__=='__main__':
  main()

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
#k=max(a,b)
"""
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p
"""

p = 10 ** 9 + 7
N = 2 * (10**5)  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

def ss(n,a,p):
    sss=1
    for i in range(a):
        k=n-i % p
        sss=sss * k % p

    return sss

def cmbs(n, r, p):
    if (r < 0) or (n < r):
        return 0
    #r = min(r, n - r)
    sss=1
    for i in range(r):
        k=(n-i) % p
        sss=sss * k % p
    #print(sss)
    #print(factinv[r])
    return sss * factinv[r] % p

acom=cmbs(n, a, p)
bcom=cmbs(n, b, p)
#print(acom)
#print(bcom)
def pos(x, n, m):
    if n == 0:
        return 1
    res = pos(x*x%m, n//2, m)
    if n%2 == 1:
        res = res*x%m
    return res

sums=pos(2,n,p)-1
#print(sums)
ans=sums-acom-bcom
if(ans<0):
    ans=ans+p
print(ans)

Submission status: Wrong Answer

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

for i in range(1,n+1):
    if i!=a and i!=b:
        total+=combinations_count(n, i)
        print(i)
        
if total==0:
    print(0)
else:
    print(total%(10^9+7))

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

N,a,b=map(int,input().split())
#P=list(map(int,input().split()))

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

def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2, n // 2)
    else:  # standard case ② n is odd
        return x * pow_r(x ** 2, (n - 1) // 2)

print(N)
c=pow_r(2,N)
print(N)
A=cmb(N, a)
B=cmb(N, b)

c=c-A-B-1

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

Submission status: Wrong Answer

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

from math import factorial
ans = 0

if n % 2 == 1:
    for i in range(1, n // 2 + 1):
        ans += factorial(n) // factorial(i) // factorial(n - i)
    ans *= 2 + 1
else:
    for i in range(1, n // 2):
        ans += factorial(n) // factorial(i) // factorial(n - i)
    ans *= 2
    ans += factorial(n) // factorial(n // 2) // factorial(n - n // 2) + 1

ans -= factorial(n) // factorial(a) // factorial(n - a)
ans -= factorial(n) // factorial(b) // factorial(n - b)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y
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
def pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = (ans*x)
      ans%=MOD 
    x = (x*x)%MOD
    n = n >> 1 #ビットシフト
  return ans
def COMint():
  fac[0]=1
  fac[1]=1
  finv[0]=1
  finv[1]=1
  inv[1]=1
  for i in range(2,N+1):
    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):
  if n<k:
    return 0
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD
MOD=10**9+7
#繰り返し２乗法を使う場合
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
#print(ans1)
n,a,b,= [int(x) for x in input().split()]
ans1 = pow(2,n)
N = n
a1=combination(n,a)
b1 = combination(n,b)
if ans1-a1%MOD-b1%MOD-1<0:
  print(ans1-a1%MOD-b1%MOD-1+MOD)
else:
  print(ans1-a1%MOD-b1%MOD-1)

Submission status: Wrong Answer

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

MOD = 10**9+7

keep = [1]
for i in range(b):
    keep.append(keep[i] * (n-i) //(i + 1) % MOD)


dif1 = keep[a]
dif2 = keep[b]
dif = (dif1 + dif2) % MOD
def pow_k(x, n):
    if n == 0:
        return 1

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

    return K * x % MOD
ans = pow_k(2,n)
ans = (ans - dif) % MOD
print(ans - 1)

Submission status: Wrong Answer

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


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


mod = 10**9+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

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

Submission status: Wrong Answer

Solution code:
#inp = list(map(lambda x: int(x), input().split()))
#n,k = map(lambda x: int(x), input().split())
#p_n = list(map(lambda x:int(x),input().split()))

from operator import mul
from functools import reduce

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


def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


result = 0
for i in range(n):
    if i == 0:
        pass
    elif i+1 == a:
        pass
    elif i+1 == b:
        pass
    else:
        c = cmb(n,i+1)
        result = (result + c%mod)%mod


print(result)

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
def power_func(a,n,p=10**9+7):
    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

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
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y
ans = power_func(2,N) - 1 - combination(N,A) - combination(N,B)
if N == 2:
    ans = 0
print(ans) if ans >= 0 else print(ans+10**9+7)

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 power_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
N, a, b = map(int, input().split())
mod = 10**9+7
ALL = power_func(2,N,mod)-1
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, a, mod)
B = cmb(N, b, mod)
Ans = (ALL - A - B)
print(A,B,ALL,Ans)

Submission status: Wrong Answer

Solution code:
N,a,b=map(int, raw_input().split())
 
mod=10**9+7
inv_fact=[1]
fact_tmp = 1
for i in range(1, b+1):
    fact_tmp *= i
    fact_tmp %= mod
    inv_fact.append(pow(fact_tmp, mod-2, mod))
 
fact=[1]
fact_tmp = 1
for i in range(N,N-b-2,-1):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)

def ncr(n,r):
    return (fact[r]*inv_fact[r])%mod

ans=pow(2,N,mod)-ncr(N,a)-ncr(N,b)-1
if 0<=ans:
    print ans%mod
else:
    print ans+mod

Submission status: Wrong Answer

Solution code:
from math import factorial
def combinationsCount(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
n,a,b = map(int, input().split())
print((2**n - 1 - combinationsCount(n, a) - combinationsCount(n, b)) / (10e9+7) )

Submission status: Wrong Answer

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

mod = 10 ** 9 + 7
f = [1]
for i in range(1,2*(10 ** 5)+1):
    f.append((f[-1] * i) % mod)
def comb(n,r):
    z = 1
    for i in range(n-r+1, n+1):
        z *= i
        z %= mod
    return (z * pow(f[r], mod-2, mod)) % mod

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

print(ans)

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:
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 = power_func(2,n,mod) - 1

A = 0
B = 0

if a<=n:
    A = combination(n,a)
if b<=n:
    B = combination(n,b)

ans = S-A-B
if ans<0:
    ans += mod
print(ans)

Submission status: Wrong Answer

Solution code:
N,a,b=map(int, raw_input().split())
 
mod=10**9+7
inv_fact=[1]
fact_tmp = 1
for i in range(1, max(a,b)+1):
    fact_tmp *= i
    fact_tmp %= mod
    inv_fact.append(pow(fact_tmp, mod-2, mod))
 
fact=[1]
fact_tmp = 1
for i in range(N,N-max(a,b)-1,-1):
    fact_tmp *= i
    fact_tmp %= mod
    fact.append(fact_tmp)

def ncr(n,r):
    return (fact[r]*inv_fact[r])%mod

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

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 = (r - c * pow(f, M - 2, M)) % M
print((r - c * pow(f, M - 2, M) % M))

Submission status: Wrong Answer

Solution code:
N,A,B = map(int,input().split())
def power_func(a,n,p=10**9+7):
    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

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
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y
ans = power_func(2,N) - 1 - combination(N,A) - combination(N,B)
print(ans) if ans > 0 else print(ans+10**9+7)

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int,input().split())
score = 1
total = 0
for i in range(1,a):
  score = score * (n-i+1) // i
  total += score
score = score * (n-a+1)//a
for j in range(a,b):
  score =score * (n-j+1) // j
  total += score
score =score * (n-b+1) // b
for k in range(b,n//2 +1):
  score = score * (n-k+1) // k
  total += score
  if n % 2 == 1:
    total += score * (n-n//2) // (n//2 + 1)
print(total % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
a = min(a,n-a)
b = min(b,n-b)
c = max(a,b)
mod = 10**9+7
 
fact = [n,n*(n-1)]
finv = [1,1]
inv = [0,1]
 
for i in range(2,c+2):
    fact.append((fact[-1]*(n-i))%mod)
    inv.append((inv[mod%i]*(mod-mod//i))%mod)
    finv.append((finv[-1]*inv[-1])%mod)
 
def nCr(n,r,mod):
      
    return fact[r-1]*finv[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
            K %= mod
        x *= x
        x %= mod
        n //= 2

    return K * x % mod
ans = pow_k(2,n,mod)-1-nCr(n,a,mod)-nCr(n,b,mod)

print(ans%mod)

Submission status: Wrong Answer

Solution code:
from math import factorial
def combinationsCount(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
n,a,b = map(int, input().split())
print(2**n - 1 - combinationsCount(n, a) - combinationsCount(n, b)  / (10e9+7) )

Submission status: Wrong Answer

Solution code:
import math
import sys
sys.setrecursionlimit(int(10**9))

mod = 10**9 + 7

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y/2)**2 % mod
    else            : return power(x, y//2)**2 * x % mod

def fact(n):
    if n == 1: 
        return 1
    else:
        return (fact(n-1)*n)%mod

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = [int(x) for x in input().split()]

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

def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2, n // 2)
    else:  # standard case ② n is odd
        return x * pow_r(x ** 2, (n - 1) // 2)

a_ = cmb(n,a)
b_ = cmb(n,b)

print((pow_r(2, n)-(a_+b_))%10**9+7)

Submission status: Wrong Answer

Solution code:
from math import factorial
def combinationsCount(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
n,a,b = map(int, input().split())
ans = 2**n - 1 - combinationsCount(n, a) - combinationsCount(n, b)

Submission status: Wrong Answer

Solution code:

def main():
    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())
    mod = 10**9 + 7
    
    res = 0
    for i in range(2, n + 1):
        if i == a or i == b: continue
        cmb_num = cmb(n, i)
        res += cmb_num % mod
    print(res)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


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

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 )

ans=0
for r in (a,b):
    ans += cmb(n,r,mod)
    ans = ans%mod
print(ans)
all=(2**n - 1)%mod
print((all-ans)%mod)

Submission status: Wrong Answer

Solution code:
n, a, b = [int(x) for x in input().split()]

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

def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2, n // 2)
    else:  # standard case ② n is odd
        return x * pow_r(x ** 2, (n - 1) // 2)

a_ = cmb(n,a)
b_ = cmb(n,b)

print((pow_r(2, n)-(a_+b_))//10**9+7)

Submission status: Wrong Answer

Solution code:
modulo = 10000000007
m1 = 23
m2 = 2293
m3 = 189613

def ncrm(n, r, p = modulo):
    num = den = 1
    for i in range(r):
        num = (num * (n - i)) % p
        den = (den * (i + 1)) % p
    return (num * pow(den, p - 2, p)) % p

def chnReminder(n, r):
    r1 = ncrm(n, r, m1)
    r2 = ncrm(n, r, m2)
    r3 = ncrm(n, r, m3)
    s = r1 * m2 * m3 + r2 * m1 * m3 + r3 * m1 * m2
    return s % (m1 * m2 * m3)

def bouquet(n, a, b):
    if n > 33:
        total = modulo
    else:
        total = 2 ** n - 1
    if (2 * a) > n:
        a = n - a + 1
    if (2 * b) > n:
        b = n - b + 1
    print(total - chnReminder(n, a) - chnReminder(n, b))

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    n, a, b = [int(_) for _ in in_str[0].split(' ')]
    bouquet(n, a, b)

Submission status: Wrong Answer

Solution code:
import scipy.misc as scm

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

t = 0
for i in range(1, n+1, 1):
    if i == a or i == b:
        continue
    t += scm.comb(n, i, exact=True)

if t == 0:
    print(0)
else:
    t % (10**9 + 7)

Submission status: Wrong Answer

Solution code:
#コンビネーション。
def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p

#累乗
def mpow(x: int, k: int, MOD=1000000007) -> int:
    res = 1
    y = x
    while (k):
        if(k % 2 == 1):
            res = (res * y) % MOD
        y = (y ** 2) % MOD
        k = k // 2
    return res



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

CA = comb(n,a,10**9+7)
CB = comb(n,b,10**9+7)
X = mpow(2,n,10**9+7)
output = X-CA-CB-1
if output<0:
    output += 10**9+7
print(output)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,a,b = map(int, input().split())
x = 0
for i in range(1,n+1):
    if i in [a,b]:
        continue
    y = cmb(n,i)
    print(y)
    x += y
print(x%(10**9+7))

Submission status: Wrong Answer

Solution code:
def mod_inv(a, m):
    return pow(a, m-2, m)


def combination(a, b):
    if b > a - b:
        return combination(a, a - b)

    # 10C3 = (10*9*8)/(3*2*1)
    # 10*9*8 -> ans_mul
    # 3*2*1 -> ans_div
    ans_mul = 1
    ans_div = 1
    for i in range(b):
        ans_mul *= a - i
        ans_div *= i + 1
        ans_mul %= MOD
        ans_div %= MOD
    # ans_mul / ans_div をやりたい
    # ans_div の逆元を使って求める
    ans = ans_mul * mod_inv(ans_div, MOD)
    return ans


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

N %= MOD
sm = pow(2, N, MOD) % MOD
sm -= 1

a = combination(N, A)
a %= MOD

b = combination(N, B)
b %= MOD

ans = sm - a - b
if ans < 0:
    ans += MOD
print(ans)

Submission status: Wrong Answer

Solution code:

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


P = 10**9 + 7
N = 200001
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

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

def comb(x):
    res=1
    for i in range(n-x+1,n+1):
        res*=i
        res=res%mod
    for i in range(1,x+1):
        res*=inv_t[i]
        res=res%mod
    return res

al=power_func(2,n,mod)
print((al-comb(a)-comb(b))%mod)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
m = 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, m) - 1 - nCr(n, a, m) - nCr(n, b, m)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

LIM=10**9+7

hana=0
C=N
for i in range(1,N+1):
  #print(i, C%LIM, hana)
  if(i==a or i==b):
    C=C*(N-i)//(i)
    continue
  else:
    if(hana > LIM):
      hana = hana % LIM
    hana += hana + C%LIM
    C=C*(N-i)//(i)

if(hana > LIM):
  hana = hana % LIM
print(hana)

Submission status: Wrong Answer

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


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

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

print(c-cmb(n, a, p)-cmb(n, a, p))

Submission status: Wrong Answer

Solution code:
from math import factorial

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

for i in range(2, n + 1):
    if i not in [a, b]:
        ans += factorial(n) / factorial(i) / factorial(n - i)

print(int(ans % mod))

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))

sum = 0

for i in range(n):
    if i == a:
        continue
    if i == b:
        continue
    sum = sum + combinations_count(n,i)

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

Submission status: Wrong Answer

Solution code:
import math
n, a, b = map(int,input().split())
score = 1
total = 0
for i in range(1,n//2+1):
  score = score * (n-i+1) // i
  total += 2 * score
  if n % 2 == 1:
    total += score * (n-n//2) // (n//2 + 1)
  total  = total - math.factorial(n)//(math.factorial(a)*math.factorial(n-a)) -math.factorial(n) //(math.factorial(b) * math.factorial(n-b))
print(total % (10**9 + 7))