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 modpow(a,n,p):
    if n==1:
        return a%p
    if n%2==1:
        return (a*modpow(a,n-1,p))%p
    t = modpow(a, n / 2, p)
    return (t * t) % p
    
def combinations(n,k,mod):
    x,y = 1,1
    for i in range(k):
        x = (x*(n-i))%mod
        y = (y*(i+1))%mod
    y = modpow(y,mod-2,mod)
    return (x*y)%mod
    

div = 10**9+7
n,a,b = [int(i) for i in input().split()]

ans = modpow(2,n,div)- 1 - combinations(n,a,div) - combinations(n,b,div)

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

Submission status: Wrong Answer

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

mmod = 10**9 + 7


def comb_mod(n, r, mod=mmod):
    nume = 1
    deno = 1

    r = min(r, n - r)

    for i in range(1, r + 1):
        nume = (nume * (n + 1 - i)) % mod
        deno = (deno * i) % mod

    return (nume * pow(deno, mod - 2, mod)) % mod


if n == 2:
    print(0)
    exit

result_a = comb_mod(n, a)
result_b = comb_mod(n, b)
total = (pow(2, n, mmod) - result_a - result_b - 1) % mmod

print(total)

Submission status: Wrong Answer

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

mmod = 10**9 + 7


def comb_mod(n, r, mod=mmod):
    nume = 1
    deno = 1

    r = min(r, r - 1)

    for i in range(1, r + 1):
        nume = (nume * (n + 1 - i)) % mod
        deno = (deno * i) % mod

    return (nume * pow(deno, mod - 2, mod)) % mod


if n == 2:
    print(0)
    exit

total = (pow(2, n, mmod) - comb_mod(n, a) - comb_mod(n, b) - 1) % mmod

print(total)

Submission status: Wrong Answer

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

mmod = 10**9 + 7


def comb_mod(n, r, mod=mmod):
    nume = 1
    deno = 1

    r = min(r, r - 1)

    for i in range(1, r + 1):
        nume = (nume * (n - i)) % mod
        deno = (deno * (i + 1)) % mod

    return (nume * pow(deno, mod - 2, mod)) % mod


if n == 2:
    print(0)
    exit

total = (pow(2, n, mmod) - comb_mod(n, a) - comb_mod(n, b) - 1) % mmod

print(total)

Submission status: Wrong Answer

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

mmod = 10**9 + 7


def comb_mod(n, r, mod=mmod):
    nume = 1
    deno = 1

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

    return (nume * pow(deno, mod - 2, mod)) % mod


if n == 2:
    print(0)
    exit

total = (pow(2, n, mmod) - comb_mod(n, a) - comb_mod(n, b) - 1) % mmod

print(total)

Submission status: Wrong Answer

Solution code:
N,a,b=map(int,input().split())
MOD=10**9+7
def comb(n,k):
  tmp=1
  for i in range(n-k+1,n+1):
    tmp*=pow(i,MOD-2,MOD)
    tmp%=MOD
  for i in range(1,k+1):
    tmp*=i
    tmp%=MOD
  return tmp
ans = pow(2,N,MOD) - 1 - comb(N,a) - comb(N,b)
print(ans%MOD)

Submission status: Wrong Answer

Solution code:
N,a,b=map(int,input().split())
MOD=10**9+7
def comb(n,k):
  tmp=1
  for i in range(n-k+1,n+1):
    tmp*=i
    tmp%=MOD
  for i in range(1,k+1):
    tmp*=pow(i,MOD-2,MOD)
    tmp%=MOD
  return tmp
ans = pow(2,N,MOD) - 1 - comb(N,a) - comb(N,b)
print(ans)

Submission status: Wrong Answer

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

n = 10 ** 9
k = 2 * 10 ** 5
mod = 10**9 + 7

# x ** a をmodで割った余りを、O(log(a))時間で求める。
def power(x, a):
    if a == 0:
        return 1
    elif a == 1:
        return x
    elif a % 2 == 0:
        return power(x, a//2) **2 % mod
    else:
        return power(x, a//2) **2 * x % mod

# xの逆元を求める。フェルマーの小定理より、 x の逆元は x ^ (mod - 2) に等しい。計算時間はO(log(mod))程度。
# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
    return power(x, mod-2)

def binomial_coefficients(n, k):
    numera = 1  # 分子
    denomi = 1  # 分母

    for i in range(k):
        numera *= n-i
        numera %= mod
        denomi *= i+1
        denomi %= mod
    return numera * modinv(denomi) % mod


print((((power(2, n) - binomial_coefficients(n, a)) % mod) - binomial_coefficients(n, b)) % mod - 1)

Submission status: Wrong Answer

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

MOD = 10 ** 9 + 7

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

ret = pow(2, N, MOD) - 1 - comb(N,A,MOD) - comb(N,B,MOD)
ret %= MOD
if ret < 0:
    ret += MOD
print(int(ret))

Submission status: Wrong Answer

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

MOD = 10 ** 9 + 7

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

ret = pow(2, N, MOD) - 1 - comb(N,A,MOD) - comb(N,B,MOD)
ret %= MOD
if ret < 0:
    ret += MOD
print(ret)

Submission status: Wrong Answer

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

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

    return K * x

mod = 10 ** 9 + 7



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

m = min(n, max(a, b) + 10)
inv = [0,1] + [0 for _ in range(m)]
for i in range(2,m+2):
    inv[i] = -inv[mod%i] * (mod // i) % mod

def comb(n,r):
    ret = 1
    for i in range(r):
        ret *= n-i
        ret *= inv[i+1]
        ret %= mod
    return ret



nca = comb(n, a) #comb(n, a, mod)#factorial(n) // factorial(a) // factorial(n-a)
ncb = comb(n, a) #comb(n, b, mod)#factorial(n) // factorial(b) // factorial(n-b)

ans = pow_k(2, n)

ans -= 1 + nca + ncb
ans %= mod
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
def combi(i,j):
  s=1
  t=1
  for k in range(j,i+1):
    s=s*k
  for l in range(1,i-j+1):
    t=t*l
  return s/t

aa=combi(n,a)
bb=combi(n,b)
c=2**n-1-aa-bb
print(c%(10**9+7))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
def combi(i,j):
  s=1
  t=1
  for k in range(j,i+1):
    s=s*k
  for l in range(1,i-j+1):
    t=t*l
  return s/t

aa=combi(n,a)
bb=combi(n,b)
print(2**n-1-aa-bb)

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


n, a, b = mi()

mod = 10**9 + 7
ans = pow(2,n,mod) - 1

n1 = 1
n2 = 1
for i in range(1,b+1):
    n1 = n1 * (n-i+1) % mod
    n2 = n2 * i % mod
    if((i == a) or (i == b)):
        # print(ans,pow(n2,mod-2,mod))
        ans -=  (n1  * pow(n2,mod-2,mod))%mod

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

Submission status: Wrong Answer

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


n, a, b = mi()

mod = 10**9 + 7
ans = pow(2,n,mod) - 1

n1 = 1
n2 = 1
for i in range(1,b+1):
    n1 = n1 * (n-i+1) % mod
    n2 = n2 * i % mod
    if((i == a) or (i == b)):
        print(ans,pow(n2,mod-2,mod))
        ans -=  (n1  * pow(n2,mod-2,mod))%mod

print(ans)

Submission status: Wrong Answer

Solution code:
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

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
    return res

n, a, b = list(map(int, input().split()))
# print(int((2 ** n % (10**9+7)) - 1 - comb(n, a) - comb(n, b)))
print(int((pow(2, n, 10**9+7) - 1 - comb(n, a, 10**9+7) - comb(n, b, 10**9+7))) % 10**9+7)

Submission status: Wrong Answer

Solution code:
from math import factorial
N, a, b = map(int, input().split())
m=0
for i in range(N):
    if not i== a-1 or i==b-1:
        k=factorial(N) // (factorial(N - (i+1)) * factorial(i+1))
        m=m+k
    print(m)

Submission status: Wrong Answer

Solution code:
from math import factorial
N, a, b = map(int, input().split())
m=0
for i in range(N):
    if not i== a-1 or i==b-1:
        k=factorial(N) // (factorial(N - i) * factorial(i))
        m=m+k
    print(m)

Submission status: Wrong Answer

Solution code:
from math import factorial
N, a, b = map(int, input().split())
m=0
for i in range(N):
    if not i== a or i==b:
        k=factorial(N) // (factorial(N - i) * factorial(i))
        m=m+k
    print(m)

Submission status: Wrong Answer

Solution code:
import sys
from io import StringIO
import unittest
import math

mod = 10**9+7

def pow_mod(a, b, mod):
    x = 1
    while b > 0:
        if b & 1:
            x = (x*a)%mod
        a = (a**2)%mod
        b //= 2
 
    return x

def modinv(a, mod):
    return pow_mod(a, mod-2, mod)

def comb(n,r,mod):
    combsum=1
    for i in range(n-r+1,n+1):
        combsum = (combsum * i)%mod

    for i in range(1,r+1):
        combsum = (combsum * inv[i])%mod

    return combsum

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

a=min([a,n-a])
b=min([b,n-b])

maxab=max([a,b])

inv=[modinv(i,mod) for i in range(0,maxab+2)]

print(inv)

def resolve():

    ptn = pow_mod(2,n,mod)
    ptn -= 1

    comba=comb(n,a,mod)
    combb=comb(n,b,mod)

    ptn = (ptn-comba-combb)%mod

    return 

resolve()

Submission status: Wrong Answer

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

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

sum = pow_r(2, n) - 1
A = 1
B = 1
for i in range(1,a + 1):
    A*=(n + 1) - i
    A%=mod
    A = A * pow_r(i,mod - 2) % mod
    A%=mod
for i in range(1,b + 1):
    B*=(n + 1) - i
    B%=mod
    B = B * pow_r(i,mod - 2) % mod
    B%=mod

print(sum - A - B)

Submission status: Wrong Answer

Solution code:
from math import factorial

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

mod = 10**9 + 7

def pow(x, n):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x % mod
    x = x*x % mod
    n = n >> 1 #ビットシフト
  return ans

def ncr(n, r):
    x = 1
    y = 1
    for i in range(r):
        x *= (n-i)
        y *= (i+1)
        x %= mod
        y %= mod
    return (x * pow(y, 10**9+5)) % mod

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

print(ans if ans >= 0 else ans + mod)

Submission status: Wrong Answer

Solution code:
def solve():

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

    # 繰り返し二乗法 使ってない
    def modPow(a, n, mod):
        if n == 1:
            return a
        elif n%2 == 1:
            return a * modPow(a, n-1, mod) % mod
        else:
            t = modPow(a, n/2, mod)
            return (t * t) % mod

    def combination(n, a, mod):
        x = 1
        y = 1
        for i in range(a):
            x = x * (n-i)%mod
            y = y * (a-i)%mod
            #遅い
            #x *= (n-i)%mod
            #y *= (a-i)%mod
        return x * pow(y, mod-2, mod)%mod

    #全ての選び方
    Sigma_nCi = pow(2, n, mod)
    # nCa, nCb
    nCa = combination(n, a, mod)
    nCb = combination(n, b, mod)

    ans = Sigma_nCi - 1 - nCa - nCb

    print(Sigma_nCi, nCa, nCb)
    print(ans%mod)

if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

def fermat(n, r, law):
    x = 1
    y = 1
    for i in range(r):
        x = x * (n - i) % law
        y = y * (i + 1) % law

    ans = x * pow(y, law - 2, law)
    return ans

print((pow(2,n,law)- fermat(n,a,law)-fermat(n,b,law))%law)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
def modcomb(n, r, mod):
    "nCr = X/Yとおく"
    r = min(r, n - r)
    X, Y = 1, 1
    a, b, c = 1, 1, 1
    for i in range(1, n + 1):
        #X = X * (n + 1 - i) % mod
        #Y = Y * i % mod
        a = a * i % mod
        b = b * i % mod
    for i in range(1, r + 1):
        c = c * (n - i + 1) % mod
    return a * pow((b * c) % mod, mod-2, mod) % mod
    # return X * pow(Y, mod-2, mod) % mod

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

Submission status: Wrong Answer

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

comb = [1] * (b + 1)
for i in range(b):
  comb[i+1] = comb[i] * (n - i) // (i + 1) % mod

count = pow(2, n, mod) - 1 - comb[a] - comb[b]
print(count % mod)

Submission status: Wrong Answer

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

    # 1:花束の組み合わせ総数の(mod p)
    n_all = pow(2, n, p) -1

    # 2:aとbの組み合わせ数の(mod p)を出す。
    a_comb = 0      # aの組み合わせ数
    a_comb_x = 1    # aの組み合わせ数計算の分子。n*(n-1)*…*(n-r+1)のmod p
    a_comb_y = 1    # aの組み合わせ数計算の分母。r!のmod pにおける逆元
    for i in range(n, n-a ,-1):
        a_comb_x *= i
        a_comb_x %= p
    a_comb_y = factorial(a)
    a_comb_y = pow(a_comb_y, p-2,p)
    a_comb = (a_comb_x * a_comb_y) % p

    b_comb = 0      
    b_comb_x = 1    
    b_comb_y = 1    
    for i in range(n, n-b ,-1):
        b_comb_x *= i
        b_comb_x %= p
    b_comb_y = factorial(b)
    b_comb_y = pow(b_comb_y, p-2,p)
    b_comb = (b_comb_x * b_comb_y) % p

    # 3: 1の結果から２のそれをマイナスする。結果が負になったら+p
    r = n_all - a_comb - b_comb
    if r < 0:
        r += p
    print(r)

main()

Submission status: Wrong Answer

Solution code:
N, A, B = map(int, input().split())
mo = 1000000007
A_val = 1
for i in range(A):
    A_val = int((A_val * ((N - i)/(i + 1))) % mo)
B_val = 1
for i in range(B):
    B_val = int((B_val * ((N - i)/(i + 1))) % mo)
    
ans = (pow(2, N, mo) - 1 - A_val - B_val) % mo
if ans < 0:
    ans += mo
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)

N, A, B = map(int, input().split())
mo = 10 ** 9 + 7
A_val = 1
for i in range(A):
    A_val = int((A_val * ((N - i)/(i + 1)))) % mo
B_val = 1
for i in range(B):
    B_val = int((B_val * ((N - i)/(i + 1)))) % mo
    
ans = (pow(2, N, mo) - 1 - A_val - B_val) % mo
print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000)

N, A, B = map(int, input().split())
mo = 10 ** 9 + 7
def hanaya(n, x):
    if x == 1:
        return n
    else:
        return ((int((hanaya(n, x-1))*((n-x+1)/x))%mo))

ans = (pow(2, N, mo) - 1 - hanaya(N, A)- hanaya(N, B)) % mo
print(int(ans))

Submission status: Wrong Answer

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

def power(x, n, mod):
    """
    x**n mod in  O(log n)
    """
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % mod
            x = x ** 2 % mod
            n = (n - 1) // 2
        else:
            x = x ** 2 % mod
            n = n // 2
    return K * x % mod
 
def nCrMOD(a,b,m):
    c = 1
    for i in range(b):
        c = c * (a - i) % m
        c = c * modinv(i + 1,m) % m
    return c
 
def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)
 
def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

m=10*9+7

ans = power(2,n,m) -1 - nCrMOD(n,a,m) -nCrMOD(n,b,m)
print(ans%m)

Submission status: Wrong Answer

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

def mpow(a,n):
  if n == 1:
    return a
  x = mpow(a,n//2)
  ans = x*x%mod
  if n%2==1:
    ans *= a
  return ans

def comb(n,a,b):
  if a < b:
    s, l = a, b
  else:
    s, l = b, a
  rs = 1
  for i in range(s):
    rs = rs*(n-i)%mod
  rl = rs
  for i in range(s,l):
    rl = rl*(n-i)%mod
  for i in range(1,s+1):
    rs = rs*mpow(i,mod-2)%mod
  rl = rl
  for i in range(s+1,l+1):
    rl = rl*mpow(i,mod-2)%mod
  if a < b:
    nCa, nCb = rs, rl
  else:
    nCa, nCb = rl, rs
  return nCa, nCb
nCa,nCb = comb(n,a,b)
print((mpow(2,n)-1-nCa-nCb)%mod)
print(nCa,nCb)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

n, a, b = list(map(int, input().split()))
MAX = 510000
MOD = 1000000007

fac = [0 for i in range(MAX)]
finv = [0 for i in range(MAX)]
inv = [0 for i in range(MAX)]
com = [0 for i in range(MAX)]

print(fac[1])

def cominit() :
  fac[0] = fac[1] = 1
  finv[0] = finv[1] = 1
  inv[1] = 1
  com[1] = n
  for i in range(2, MAX) :
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * int(MOD / i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD
    com[i] = com[i-1] * (n-(i-1)) * inv[i] % MOD
    
  return fac, finv, inv, com
 
"""
def combination(n, r, inv) :
  ans = 1
  if(n < r) : 
    return 0
  if((n < 0) or (r < 0)) :
    return 0
  for i in range(0, r) :
    return (fac[n] * (finv[r] * finv[n-r] % MOD) % MOD) 
 """

def two_n_mod(n) :
  ans = 1
  while(n > 32) :
    ans = ans * 2**32 % MOD
    n -= 32
  return ans * 2**n % MOD

temp = cominit()
##print(two_n_mod(1000000000))
print((two_n_mod(n) - 1 - com[a] - com[b]) % MOD)

Submission status: Wrong Answer

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

comb = 1
for i in range(1,b+1):
  comb *= n-i+1
  comb *= pow(i, mod-2, mod)
  comb %= mod
  if i in [a,b]:
    ans -= comb

print(ans%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

def comb_mod(n, k, mod):
    numerator = 1
    denominator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % mod
        denominator = (denominator * (i + 1)) % mod

    return (numerator * pow(denominator, mod - 2, mod)) % mod

ans -= comb_mod(n, a, mod)
ans -= comb_mod(n, b, mod)
print(ans)

Submission status: Wrong Answer

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

print((total - c(n, a) - c(n, b))%mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
 
MOD = 10 ** 9 + 7
 
def comb(n, r):
    ret = 1
    for i in range(r):
        ret *= n - i
        ret *= pow(i+1, MOD-2, MOD)
        ret %= MOD
 
    return ret % MOD
    
 
ans = pow(2, n, MOD) - 1 - comb(n, a) - comb(n, b)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
MOD = 10**9+7

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


def cmb(n, r, mod):
    x = 1
    y = 1
    for i in range(1, r + 1):
        x = (x * (n - i + 1)) % MOD
        y = (y * i) % MOD

    return (x * pow(y, MOD - 2, MOD)) % MOD


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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
MOD = 10**9+7

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


def cmb(n, r, mod):
    x = 1
    y = 1
    for i in range(1, r + 1):
        x = (x * (n - i + 1)) % MOD
        y = (y * i) % MOD

    return (x * pow(y, MOD - 2, MOD)) % MOD


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

Submission status: Wrong Answer

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


def comb_mod(n, k, mod):
    numerator = 1
    denominator = 1
    for i in range(k):
        numerator = (numerator * (n - i)) % mod
        denominator = (denominator * (i + 1)) % mod

    return ((numerator % mod) * (pow(denominator, mod - 2, mod) % mod)) % mod


n_c_a = comb_mod(n, a, mod)
n_c_b = comb_mod(n, b, mod)

result = pow(2, n, mod) - 1 - n_c_a - n_c_b
print(result)

Submission status: Wrong Answer

Solution code:
def fermat_binom(n,k,p):
  if k > n:
    return 0
  num = 1
  for i in range(n,n-k,-1):
    num = (num*i)%p
  denom = 1
  for i in range(1,k+1):
    denom = (denom*i)%p
  return (num * pow(denom,p-2,p))%p

if __name__ == '__main__':
  n, a, b = map(int, input().split())
  mod = 1000000007 
  k = pow(2, n, mod)
  k1 = fermat_binom(n, a, mod)
  k2 = fermat_binom(n, b, mod)
  r = (k1+k2)%mod
  print(max(k-r-1, 0))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

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

k = max(a,b)

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



# n>10**9
#

MOD = 119  # mod
#


fac_k= np.ones(k+1)
finv= np.ones(k+1)
inv= np.ones(k+1)

#

fac_k[0] = 1
fac_k[1] = n
finv[0] = finv[1] = 1
inv[1] = 1
for i in range(2,k+1):
    fac_k[i] = fac_k[i - 1] * (n-i+1) % MOD
    inv[i] = (- inv[MOD%i] * (MOD // i)) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD
    i+=1

#
    
    
def COM(n, c):
    if (n < c):
        return 0
    if (n < 0) | (c < 0):
        return 0
    return (fac_k[c] * finv[c] % MOD)







X = int((Mod_Pow(2,n,(10**9+7))-COM(n, a)-COM(n,b)-1)%(10**9+7))




print(X)

Submission status: Wrong Answer

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

count=0

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
    return x/y

count+=pow(2,n)
print(count)
count-=1
count-=C(n,a)
print(count)
count-=C(n,b)

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

Submission status: Wrong Answer

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

count=0

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
    return x/y

count+=pow(2,n-1)
count-=1
count-=C(n,a)
count-=C(n,b)

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

Submission status: Wrong Answer

Solution code:
# problem - D Bouquet

def cmb(n,k,MOD):
    cmb_sum = 1
    for i in range(1,k+1):
        cmb_sum = (cmb_sum * (n-i+1) / i) % MOD

    return cmb_sum


n, a, b = map(int, input().split())
MOD = 10**9 + 7
num_s = 2**n%MOD
num_a = cmb(n,a,MOD)%MOD
num_b = cmb(n,b,MOD)%MOD
ans = abs(int(num_s - num_a - num_b - 1))
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def pow(x,n):
    ans = 1
    while n>0:
        if n&1 == 1:
            ans = (ans*x)%(10**9+7)
            
        x = (x*x)%(10**9+7)
        n >>= 1
    return ans


def check():
    n,a,b = map(int, input().split())        
    X,Y = 1,1
    for i in range(b):
        X *= n-i
        X %= 10**9+7
        Y *= i+1
        Y %= 10**9+7

        if a-1 == i:
            Xa = X
            Ya = Y

    comb_a = (Xa*pow(Ya,10**9+5))%(10**9+7)
    comb_b = (X*pow(Y,10**9+5))%(10**9+7)

    result = pow(2,n)-1-comb_a-comb_b
    print(result if result>=0 else result+10**9+7)
check()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

def pow(x,n):
    ans = 1
    while n>0:
        if n&1 == 1:
            ans = (ans*x)%(10**9+7)
            
        x = (x*x)%(10**9+7)
        n >>= 1
    return ans


def check():
    n,a,b = map(int, input().split())
        
    if n ==2:
        print(0)
    else:
        X = 1
        for i in range(n,n-b,-1):
            X *= i
            X %= 10**9+7
            if n-a+1 == i:
                Xa = X

        comb_a = (Xa*pow(math.factorial(a),10**9+5))%(10**9+7)
        comb_b = (X*pow(math.factorial(b),10**9+5))%(10**9+7)

        result = pow(2,n)-1-comb_a-comb_b
        print(result if result>=0 else result+10**9+7)
check()

Submission status: Wrong Answer

Solution code:
import math

def pow(x,n):
    ans = 1
    while n>0:
        if n&1 == 1:
            ans = (ans*x)%(10**9+7)
            
        x = (x*x)%(10**9+7)
        n >>= 1
    return ans


def check():
    n,a,b = map(int, input().split())
    X = 1
    
    for i in range(n,n-b,-1):
        X *= i
        X %= 10**9+7
        if n-a+1 == i:
            Xa = X

    comb_a = (Xa*pow(math.factorial(a),10**9+5))%(10**9+7)
    comb_b = (X*pow(math.factorial(b),10**9+5))%(10**9+7)

    result = pow(2,n)-1-comb_a-comb_b
    print(result if result>=0 else result+10**9+7)
check()

Submission status: Wrong Answer

Solution code:
#pが素数の時、p未満の数の積xについてx^(p-1)=1(mod p) <=> x^(p-2)=1/x(mod p) (オイラの小定理)
#ここでpは素数なので、p以下の数a,b,nにおいてcmb(n,a)≡n!/((n-a)!*a!)≡((n-a+1)*…*n)/(a!)≡((n-a+1)*…*n)(a!)^(p-2) (mod p)
#あとは((n-a+1)*…*n)(a!)^(p-2) (mod p)を繰り返し2乗法でO(log(p))で求められる…らしいが普通にpow(n,r,mod)つよそう
#ちゃんと実装します



def modpow(a,n,mod):
    if n==0:
        return 1
    x=modpow(a,n//2,mod)
    x=(x*x)%mod
    if ((n%2)==1):
        x=(x*a)%mod
    return x%mod

def cmb(n,r,mod):
    x=1
    y=1
    for i in range(0,r,1):
        x=(x*(n-i))%mod
        y=(y*(i+1))%mod
    x=x%mod
    y2=modpow(y,mod-2,mod)
    return (x*y2)%mod

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


print(modpow(2,n,p),cmb(n,a,p),cmb(n,b,p))
print((modpow(2,n,p)-1-cmb(n,a,p)-cmb(n,b,p))%p)

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False
"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

mod = 10**9+7 #出力の制限
N = 10**5 * 2
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
def p(n,r):
    if ( r<0 or r>n ):
        return 0
    return g1[n] * g2[n-r] % mod

g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
# a = cmb(n,r)

import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


n,a,b = m()

nn = str(n)[::-1]

co = 1

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

for i in range(len(nn)):
    if i == 0:
        co *= tw[i][int(nn[i])]
    else:
        co = (co * tw[i][int(nn[i])])%mod
        co = co % mod

aaa = 1
bbb = 1
for i in range(min(a,n-a)):
    aaa *= (n-i)
    aaa %= mod
    if i == min(a,n-a)-1:
        aaa *= g2[i+1]
        aaa %= mod
for i in range(min(b,n-b)):
    bbb *= (n-i)
    bbb %= mod
    if i == min(b,n-b)-1:
        bbb *= g2[i+1]
        bbb %= mod


print((co - aaa - bbb - 1)%mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def choose(x, y, m):
    v = 1
    for i in range(0, y):

        v = (v * (x - i) * pow(i + 1, m - 2, m)) % m

    return v


m = 10**9 + 7
print((pow(2, n, m) - choose(n, a, m) - choose(n, b, m)) % m)

Submission status: Wrong Answer

Solution code:
M = int(1e9 + 7)

def C(n , r):
    res = 1
    if r > n - r:
        r = n - 1
    for i in range(r):
        res = (res*(n - i)) % M
        res = (res * pow(i + 1 , M - 2 , M))%M
    return res

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

ans = pow(2 , n , M) - 1;
ans -= C(n , a)
ans -= C(n , b)
ans += 2 * M
print(ans%M)

Submission status: Wrong Answer

Solution code:
import sys, math

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

n, a, b = read_int()
M = pow(10, 9) + 7
comk = [1 for _ in range(b + 2)]

def solve():
    ans = 0
    for i in range(1, b + 1):
        comk[i] = (comk[i - 1] * ((n - i + 1)) / i)
    ans = (pow(2, n, M) - 1)  - ((comk[a] + comk[b]) % M)
    return ans % M

if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
import sys, math

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))

n, a, b = read_int()
M = pow(10, 9) + 7
comk = [1 for _ in range(b + 2)]

def solve():
    ans = 0
    for i in range(1, b + 1):
        print(i)
        comk[i] = (comk[i - 1] * ((n - i + 1)) / i)
    ans = (pow(2, n, M) - 1)  - ((comk[a] + comk[b]) % M)
    return ans % M

if __name__ == "__main__":
    print(solve())