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:
# nC0 + nC1 + nC2 + ... + nCn - (nC0 + nCa + nCb)
p = pow(10, 9) + 7 # prime number

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

if n == 2:
    print(0)

else:

    inversions = [0, 1] # 0 is unreachable
        
    for i in range(2, max(a, b) + 1):
        inversion = p - (p // i) * inversions[p % i]
        inversions.append(inversion)

    c = [1, n]

    for i in range(2, max(a, b) + 1):
        nCi = (c[i - 1] * (n - i + 1) % p) * inversions[i] % p # nCi = nCi-1 * (n - i + 1) / i

        if nCi < 0:
            nCi += p

        c.append(nCi)


    ans = pow(2, n, p) - (c[0] + c[a] + c[b])
    if ans < 0:
        ans += p
    print(ans)

Submission status: Wrong Answer

Solution code:
# nC0 + nC1 + nC2 + ... + nCn - (nC0 + nCa + nCb)
p = pow(10, 9) + 7

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

inversions = [0, 1]
    
for i in range(2, min(max(a, b) + 1, p)):
    i %= p
    inversion = p - (p // i) * inversions[p % i]
    inversions.append(inversion)

c = [1, n]
for i in range(2, max(a, b) + 1):
    nCi = (c[i - 1] * (n - i + 1) % p) * inversions[i % p] % p
    if nCi < 0:
        nCi += p
    c.append(nCi)


ans = pow(2, n, p) - (c[0] + c[a] + c[b])
if ans < 0:
    ans += p
print(ans)

Submission status: Wrong Answer

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

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

if n%2==0:
    for i in range(1,int(n/2)):
        ans+=conbinations_count(n,i)
        ans%=MOD
    ans=ans*2
    ans+=1
    ans+=conbinations_count(n,int(n/2))
    ans-=conbinations_count(n,a)%MOD
    ans-=conbinations_count(n,b)%MOD
    ans%=MOD

else:
    for i in range(1,int(n/2)+1):
        ans+=conbinations_count(n,i)
        ans%=MOD
    ans+=1
    ans-=conbinations_count(n,a)
    ans-=conbinations_count(n,b)
    ans%=MOD

print(ans)

Submission status: Wrong Answer

Solution code:
N, a, b = map(int, input().split())
MOD = 10**9+7
z = pow(2, N)-1
xa = ya = 0
for i in range(a):
  xa *= N-i
  xa = xa%MOD 
  ya *= a-i
  ya = ya%MOD
za = (xa*(pow(ya, MOD-2)%MOD))%MOD
xb = yb = 0
for j in range(b):
  xb *= N-i
  xb = xb%MOD
  yb *= a-i
  yb = yb%MOD
zb = (xb*(pow(yb, MOD-2)%MOD))%MOD
print(z-za-zb)

Submission status: Wrong Answer

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


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


all_combi = power_func(2,n,10**9+7)




ncr = 1

for i in range(n):
    
    ncr *= n-i
    ncr //= (i+1)
    ncr %= (10**9+7)
    
    if i==a-1:
        nca = ncr
        
    if i==b-1:
        ncb = ncr
        break
        
ans = all_combi -nca -ncb -1
ans %= (10**9+7)
    
print(ans)

Submission status: Wrong Answer

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

from functools import lru_cache

MOD = 10**9+7
fact = [1]
fact_inv = [1]
fact_rev = [1]

for i in range(1, max(a,b)+1):
    fact.append(fact[i-1] * i % MOD)
    fact_inv.append(pow(fact[i], MOD-2, MOD))
    fact_rev.append(fact_rev[i-1] * (n-i+1) % MOD)

@lru_cache(maxsize=None)
def combi(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact_rev[n] * fact_inv[k] % MOD

pattern = pow(2, n, MOD) - 1 
if a==b:
    pattern -= (combi(a, a))
else:
    pattern -= (combi(a, a) + combi(b, b))

if pattern < 0:
    pattern += MOD

print(pattern)

Submission status: Wrong Answer

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

from functools import lru_cache

MOD = 10**9+7
fact = [1]
fact_inv = [1]
fact_rev = [1]

for i in range(1, max(a,b)+1):
    fact.append(fact[i-1] * i % MOD)
    fact_inv.append(pow(fact[i], MOD-2, MOD))
    fact_rev.append(fact_rev[i-1] * (n-i+1) % MOD)

@lru_cache(maxsize=None)
def combi(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact_rev[n] * fact_inv[k] % MOD

pattern = pow(2, n, MOD) - 1 
pattern -= (combi(a, a) + combi(b, b))

if pattern < 0:
    pattern += MOD

print(pattern)

Submission status: Wrong Answer

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

def two_n(x):
  #calc2**n-1
  ans=0
  base=2
  for i in range(18):
    if n&1<<i:
      ans+=base
      ans%=10**9+7
      base*=2
      base%=10**9+7
print(two_n(1))
print(two_n(2))
print(two_n(3))

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

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


def factorial_mod(N, mod=MOD):
    ret = 1
    for n in range(1, N + 1):
        ret *= n
        ret %= mod
    return ret


def permutations_mod(n, r, mod=MOD):
    ret = 1
    for _ in range(r):
        ret *= n
        ret %= mod
        n -= 1
    return ret


def combinations_mod(n, r, mod=MOD):
    return permutations_mod(n, r, mod) // factorial_mod(r, mod)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = il()
    print((pow(2, N, MOD)-(combinations_mod(N, A, MOD)+combinations_mod(N, B, MOD))-1)%MOD)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

q = n // 1000
r = n % 1000

tot1 = 1
for i in range(q):
    tot1 = (688423210 * tot1) % (10**9 + 7)

tot2 = 1
for i in range(r):
    tot2 = (2 * tot2) % (10**9 + 7)

tot = (tot1 * tot2) % (10**9 + 7)

num_a = 1
den_a = 1
for i in range(1, a + 1):
   num_a = (num_a * (n - i + 1)) % (10**9 + 7)
   den_a = (den_a * i) % (10**9 + 7)

con_a = num_a // den_a

num_b = 1
den_b = 1
for i in range(1, b + 1):
   num_b = (num_b * (n - i + 1)) % (10**9 + 7)
   den_b = (den_b * i) % (10**9 + 7) 

con_b = num_b // den_b

ans = tot - con_a - con_b - 1

print(ans)

Submission status: Wrong Answer

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

def nCr(n, r, p):
    total = 1
    for i in range(r):
        total *= (n - i) * abp(r - i, p - 2, p)
        total %= p
    return total

n, a, b = map(int, input().split())
p = 1000000007
ret = abp(2, n, p) - nCr(n, a, p) - nCr(n, b, p) - 1
print(ret if ret >= 0 else ret + p)

Submission status: Wrong Answer

Solution code:
def modinv(a, m):
    b = m
    u = 1
    v = 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u %= m
    if u < 0:
        u += m
    return u

def nCk(N, k, mod):
    ret_val = 1
    for i in range(k):
        ret_val *= (N - i)
        ret_val %= mod
        ret_val *= modinv(i + 1, mod)
        ret_val %= mod
    return ret_val


n, a, b = map(int, input().split())
MOD = 10 ** 9 + 7
all_cnt = pow(2, n, MOD) - 1
a_cnt = nCk(n, a, MOD)
b_cnt = nCk(n, b, MOD)
ans = all_cnt - a_cnt - b_cnt
if ans < 0:
    ans += MOD
print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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


# nCr = n*(n-1)*...(n-a+1)/ a!
# n*(n-1)*...(n-a+1)
c1 = 1
for i in range(n-a+1, n+1):
    c1 *= i
    c1 %= mod

#1/a!=1/(1*2*…*a)=1^(p-2)*2^(p-2)*…*a^(p-2) (p=10**9+7)を計算
for i in range(1, a+1):
    c1 *= pow(i, mod-2, mod)
    c1 %= mod
    
c2 = 1
for i in range(n-a+1, n+1):
    c2 *= i
    c2 %= mod

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

Submission status: Wrong Answer

Solution code:
mod = 10**9 + 7
n, a, b = 1000, 23, 30
res = pow(2, n, mod)-1

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

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

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

Submission status: Wrong Answer

Solution code:
def factorial(a,n):
  # n*(n-1)*,,,,,*(n-a+1)
  ans=1
  for i in range(n,n-a,-1):
    ans=(ans*i)%M
  return ans


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


def main():
  ans=pow(2,N) - 1
  ans-=(factorial(A,N)*pow(factorial(A,A),M-2))%M
  ans+= 0 if ans>0 else M
  ans-=(factorial(B,N)*pow(factorial(B,B),M-2))%M
  print(ans if ans>0 else ans+M)
  
  
if __name__=='__main__':
  N, A, B = map(int, input().split())
  M = 10**9 + 7
  main()

Submission status: Wrong Answer

Solution code:
import math


n, a, b = map(int, input().split())
P = int(1e9+7)
ans = pow(2, n, P) - 1  # 1本以上の花束の種類


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


# ans = (ans - combinations_count(n, a)) % P
# ans = (ans - combinations_count(n, b)) % P
print(ans)

Submission status: Wrong Answer

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

X=1
Y=1

for i in range(1,a+1):
    X=X*(n+1-i)%MOD
    Y=Y*i%MOD
    if i==b:
        b_Y=Y
a_Y=Y
def calc(X,Y,MOD):
    return X*pow(Y,MOD-2,MOD)


ans=pow(2,n,MOD)%MOD-1-calc(X,a_Y,MOD)-calc(X,b_Y,MOD)

print(ans%MOD)

Submission status: Wrong Answer

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

MOD = 10 ** 9 + 7

x=1
ans=0
for i in range(1,n+1):
    x=x*(n-1)//i%MOD
    if i==a or i==b:
        continue
    ans+=x

print(ans)

Submission status: Wrong Answer

Solution code:
MOD = 10**9 + 7
def nCr(n, r, MOD):
    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])
            result %= MOD

    return result
n, a, b = map(int,input().split())
ans = pow(2,n,MOD)-1-nCr(n,a,MOD)-nCr(n,b,MOD)
if ans < 0:
    ans += MOD
print(ans)

Submission status: Wrong Answer

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

MOD = 10**9 + 7
N = pow(2,n,MOD)

def com(n,r):
    s = 1
    for i in range(n-r+1, n+1):
        s *= i
        s %= MOD

    t = 1
    for j in range(1,r+1):
        t *= j
        t %= MOD


    return s * pow(t,MOD-2, MOD) % MOD

print((N - com(n, a) - com(n, b)) % (MOD))

Submission status: Wrong Answer

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

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

ans = pow(2, n, MOD)-1
ans -= 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=10**9+7
def modpow(a,n):
    if n<1:
        return 1
    ans=modpow(a,n//2)
    ans=(ans*ans)%mod
    if n%2==1:
        ans*=a
    return ans%mod
    
def cmb(n,i):#逆元
    inv,ans=1,1
    for j in range(1,i+1):
        ans=ans*(n-j+1)%mod
        inv=inv*j%mod
    return (ans*modpow(inv,mod-2))%mod



ans_n=pow(2,n,mod)-1
ans_a=cmb(n,a)%mod
ans_b=cmb(n,b)%mod

print(ans_n-(ans_a+ans_b)%mod)

Submission status: Wrong Answer

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

# modが素であるとする
def modinv(a, mod):
    return modpow(a, mod-2, mod) % mod

def moddiv(a, b, mod):
    return ((a%mod) * modinv(b, mod)) % mod

def modcombination(n, k, mod):
    fact = [1 for _ in range(n+1)]
    inv = [1 for _ in range(n+1)]
    finv = [1 for _ in range(n+1)]

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


n, a, b = [int(i) for i in input().split()]
mod = (10**9)+7
# 全部でn**2(0本は除くかも)
# a本を選ぶ場合の数はnCa
total = modpow(n, 2, mod)
tota = modcombination(n, a, mod)
totb = modcombination(n, b, mod) 
print((total-tota-totb-1)%mod)

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split()))
#2^n-nCa-nCbを求めればいい。ただし100000007で割ったあまりでなくてはならない
#まずは2^nを求める
def pow(x,n,m):
  if n==0:
    return 1
  res=pow(x*x%m,n//2,m)
  if n%2==1:
    res=res*x%m
  return res

#コンビネーションを求める
c=max(a,b)
inv=[0 for i in range(c+1)]
finv=[0 for i in range(c+1)]
inv[1]=1
finv[0]=finv[1]=1
for i in range(2,c+1):
  #iの逆数を求める。
  #mod　p=1000000007の世界で逆元を求める
  #p=(p//a)*a+(p%a)
  #mod pをとると a=-(p//a)*(p%a)^-1
  inv[i]=1000000007-(1000000007//i)*inv[1000000007%i]%1000000007
  finv[i]=finv[i-1]*inv[i]%1000000007
def kaizyou(k):
  num=1
  for i in range(n-k+1,n+1):
    num=num*i%1000000007
  return num
    
def combinations(k):
  return kaizyou(k)*finv[k]%1000000007

print(pow(2,n,1000000007)-combinations(a)-combinations(b)-1)

Submission status: Wrong Answer

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator

def ncr(n, r):
    if n < r: return 0
    r = min(r, n-r)
    if r == 0: return 1
    numer = functools.reduce(operator.mul, range(n, n-r, -1), 1)
    denom = functools.reduce(operator.mul, range(1, r+1), 1)
    return numer // denom

def solve():
    n, a, b = map(int, input().split())
    mod = 10**9+7
    max_par = n**2-1
    max_par -= (ncr(n, a) + ncr(n, b))
    max_par %= mod
    print(max_par)
    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
def cmb(n, r, p):
  numerator = 1
  for i in range(n-r+1, n+1):
    numerator = numerator * i % p
  denominator = 1
  for j in range(1, r+1):
    denominator = denominator * j % p
  denominator = pow(denominator, p-2, p)
  return (numerator * denominator)%p

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

Submission status: Wrong Answer

Solution code:
def per(n, r, mod=10**9+7):  # 順列数
    per = 1
    for i in range(r):
        per = per*(n-i) % mod
    return per
 
 
def com(n, r, mod=10**9+7):  # 組み合わせ数
    bunshi = per(n, r, mod)
    bunbo = 1
    for i in range(1, r+1):
        bunbo = bunbo*i % mod
    return bunshi*pow(bunbo, -1, mod)
 
 
n, a, b = map(int, input().split())
 
ans = pow(2,n,10**9+7)
 
print(ans-com(n,a)-com(n,b)-1)

Submission status: Wrong Answer

Solution code:
def per(n, r, mod=10**9+7):  # 順列数
    per = 1
    for i in range(r):
        per = per*(n-i) % mod
    return per


def com(n, r, mod=10**9+7):  # 組み合わせ数
    bunshi = per(n, r, mod)
    bunbo = 1
    for i in range(1, r+1):
        bunbo = bunbo*i % mod
    return bunshi*pow(bunbo, -1, mod)


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

print(ans-com(n,a)-com(n,b))

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc156/tasks/abc156_d

import sys
input = sys.stdin.readline


from operator import mul
from functools import reduce

def pow_k(x, n):
    """
    O(log n)
    """
    MOD = 10**9 + 7
    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

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    MOD = 10**9 + 7
    over,under  = 1,1
    for i in range(n, n - r, -1):
        over = (over*i)%MOD
    # over = reduce(mul, range(n, n - r, -1))
    for i in range(1, r + 1):
        under = (under*i) %MOD
    return (over // under) %MOD

def main():
    MOD = 10**9 + 7
    n,a,b = [int(i) for i in input().strip().split()]
    _sum = ((pow_k(2, n))-1) % MOD
    cmb_a = cmb(n, a) %MOD
    cmb_b = cmb(n, b) % MOD
    ans = (_sum - cmb_a - cmb_b) % MOD
    
    print(ans)
    

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def combination(n, r, m):
    res = 1
    r = min(r, n - r)

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

mod = 10**9 + 7
n, a, b = map(int, input().split())
total = pow(2, n, mod) - 1

total -= (combination(n, a, mod) + combination(n, b, mod)) % mod

print(total)

Submission status: Wrong Answer

Solution code:
def modpow(x, n, m):
    res = 1
    while n > 0:
        if n % 2 == 1:
            res = (res * x) % m
        x = (x * x) % m
        n >>= 1
    return res

def combination(n, r, m):
    res = 1

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

mod = 10**9 + 7
n, a, b = map(int, input().split())
total = pow(2, n, mod) - 1

total -= (combination(n, a, mod) + combination(n, b, mod)) % mod

print(total)

Submission status: Wrong Answer

Solution code:
def modpow(x, n, m):
    res = 1
    while n > 0:
        if n % 2 == 1:
            res = (res * x) % m
        x = (x * x) % m
        n >>= 1
    return res

def combination(n, r, m):
    res = 1

    for i in range(1, r + 1):
        res = (res * (n - r + i)) % m
        res = (res * modpow(i, m - 2, m)) % m
    return res

mod = 10**9 + 7
n, a, b = map(int, input().split())
total = modpow(2, n, mod) - 1

total -= (combination(n, a, mod) + combination(n, b, mod)) % mod

print(total)

Submission status: Wrong Answer

Solution code:
def modpow(x, n, m):
    if n == 0:
        return 1
    if n == 1:
        return x % m
    if n % 2 == 1:
        return ( x * modpow(x, n - 1, m) ) % m
    _val = modpow(x, n // 2, m)
    return (_val * _val) % m

def combination(n, r, m):
    numerator = 1
    denominator = 1

    # n*(n-1)* ... *(n - r + 1)計算
    for i in range(n - r + 1, n + 1):
        numerator = (numerator * i) % m
    # 逆元計算
    for i in range(2, r + 1):
        denominator = (denominator * modpow(i, m - 2, m)) % m

    return (numerator * denominator) % m 

mod = 10**9 + 7
n, a, b = map(int, input().split())
total = modpow(2, n, mod) - 1

total -= (combination(n, a, mod) + combination(n, b, mod)) % mod

print(total)

Submission status: Wrong Answer

Solution code:
def modpow(x, n, m):
    if n == 0:
        return 1
    if n == 1:
        return x % m
    if n % 2 == 1:
        return ( x * modpow(x, n - 1, m) ) % m
    _val = modpow(x, n // 2, m)
    return (_val * _val) % m

def combination(n, r, m):
    numerator = 1
    denominator = 1

    # n*(n-1)* ... *(n - r + 1)計算
    for i in range(n - r + 1, n + 1):
        numerator = (numerator * i) % m
    # r!計算
    for i in range(2, r + 1):
        denominator = (denominator * i) % m

    # 逆元r!^{m-2}計算
    denominator = modpow(denominator, m - 2, m)

    return (numerator * denominator) % m 

mod = 10**9 + 7
n, a, b = map(int, input().split())
total = modpow(2, n, mod) - 1

total -= (combination(n, a, mod) + combination(n, b, mod)) % mod

print(total)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
p=10**9+7
sub=((n*(n+1))/2)%p
sub=(sub*(n-1)/3)%p
sub1=(a*(a-1)/2)%p
sub2=(b*(b-1)/2)%p
print(int((sub-sub1-sub2)%p))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
p=10**9+7
sub=((n*(n+1))/2)%p
sub=(sub*(n-1)/3)%p
sub1=(a*(a-1)/2)%p
sub2=(b*(b-1)/2)%p
print((sub-sub1-sub2)%p)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
p=10**9+7
sub=(n*(n+1))%p
sub=sub*(n-1)%p
sub1=(3*a*(a-1))%p
sub2=(3*b*(b-1))%p
print(((sub-sub1-sub2)/6)%p)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
print(int(((n*(n+1)*(n-1)-3*a*(a-1)-3*b*(b-1))/6)%(10**9+7)))

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
print(((n*(n+1)*(n-1)-3*a*(a-1)-3*b*(b-1))/6)%(10**9+7))

Submission status: Wrong Answer

Solution code:
class Factorial():
    def __init__(self, mod=10**9 + 7):
        self.mod = mod
        self._factorial = [1]
        self._size = 1
        self._factorial_inv = [1]
        self._size_inv = 1

    def __call__(self, n):
        return self.fact(n)

    def fact(self, n):
        ''' n! % mod '''
        if n >= self.mod:
            return 0
        self._make(n)
        return self._factorial[n]
    
    def _make(self, n):
        if n >= self.mod:
            n = self.mod
        if self._size < n+1:
            for i in range(self._size, n+1):
                self._factorial.append(self._factorial[i-1]*i % self.mod)
            self._size = n+1

    def fact_inv(self, n):
        ''' n!^-1 % mod '''
        if n >= self.mod:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        self._make(n)
        if self._size_inv < n+1:
            self._factorial_inv += [-1] * (n+1-self._size_inv)
            self._size_inv = n+1
        if self._factorial_inv[n] == -1:
            self._factorial_inv[n] = self.modinv(self._factorial[n])
        return self._factorial_inv[n]
    
    @staticmethod
    def xgcd(a, b):
        '''
        Return (gcd(a, b), x, y) such that a*x + b*y = gcd(a, b)
        '''
        x0, x1, y0, y1 = 0, 1, 1, 0
        while a != 0:
            (q, a), b = divmod(b, a), a
            y0, y1 = y1, y0 - q * y1
            x0, x1 = x1, x0 - q * x1
        return b, x0, y0

    def modinv(self, n):
        g, x, _ = self.xgcd(n, self.mod)
        if g != 1:
            raise ValueError('Modinv is not exist! arg={}'.format(n))
        return x % self.mod

    def comb(self, n, r):
        ''' nCr % mod '''
        if r > n:
            return 0
        t = self(n)*self.fact_inv(n-r) % self.mod
        return t*self.fact_inv(r) % self.mod
    
    def comb_(self, n, r):
        '''
        nCr % mod
        when r is not large and n is too large
        '''
        c = 1
        for i in range(1, r+1):
            c *= (n-i+1) * self.fact_inv(i)
            c %= self.mod
        return c

    def comb_with_repetition(self, n, r):
        ''' nHr % mod '''
        t = self(n+r-1)*self.fact_inv(n-1) % self.mod
        return t*self.fact_inv(r) % self.mod

    def perm(self, n, r):
        ''' nPr % mod '''
        if r > n:
            return 0
        return self(n)*self.fact_inv(n-r) % self.mod

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

Submission status: Wrong Answer

Solution code:
def cmb(n, r, p):
    r = min(r, n - r)
    upper = 1
    for i in range(n, n - r, -1):
        upper = (upper * i) % p

    lower = 1
    for i in range(1, r + 1):
        lower = (lower * i) % p

    # フェルマーの小定理よりp素数ならupper**(p-2)は逆元
    return (upper * pow(lower, p - 2, p)) % p

mod = pow(10, 9) + 7
n, a, b = map(int, input().split())
ans = pow(2, n, mod) - 1 - cmb(n, a, mod) - cmb(n, b, mod)
print(ans)

Submission status: Wrong Answer

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

def cmb(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 * j % mod
    d = pow(denominator, mod-2, mod)
    return numerator * d
 
a = cmb(n, a)
b = cmb(n, b)

total=pow(2,n,mod)-(1+a+b)%mod

print(total)

Submission status: Wrong Answer

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

modinv_table_a = [-1] * (a+1)
modinv_table_a[1] = 1
for i in range(2, a+1):
    modinv_table_a[i] = (-modinv_table_a[mod % i] * (mod // i)) % mod

modinv_table_b = [-1] * (b+1)
modinv_table_b[1] = 1
for i in range(2, b+1):
    modinv_table_b[i] = (-modinv_table_b[mod % i] * (mod // i)) % mod

def binomial_coefficients_a(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table_a[i + 1]
        ans %= mod
    return ans

def binomial_coefficients_b(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table_b[i + 1]
        ans %= mod
    return ans

res = pow(2,n,mod)-binomial_coefficients_a(n,a)-binomial_coefficients_b(n,b)-1
if a == n or b == n:
    res += 1
print(res if res >= 0 else res+mod)

Submission status: Wrong Answer

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

if n==2 and a+b==3:
    res = "'0'"
    print(res)
    exit()

modinv_table_a = [-1] * (a+1)
modinv_table_a[1] = 1
for i in range(2, a+1):
    modinv_table_a[i] = (-modinv_table_a[mod % i] * (mod // i)) % mod

modinv_table_b = [-1] * (b+1)
modinv_table_b[1] = 1
for i in range(2, b+1):
    modinv_table_b[i] = (-modinv_table_b[mod % i] * (mod // i)) % mod

def binomial_coefficients_a(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table_a[i + 1]
        ans %= mod
    return ans

def binomial_coefficients_b(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table_b[i + 1]
        ans %= mod
    return ans

res = pow(2,n,mod)-binomial_coefficients_a(n,a)-binomial_coefficients_b(n,b)-1
print(res if res >= 0 else res+mod)

Submission status: Wrong Answer

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

modinv_table_a = [-1] * (a+1)
modinv_table_a[1] = 1
for i in range(2, a+1):
    modinv_table_a[i] = (-modinv_table_a[mod % i] * (mod // i)) % mod

modinv_table_b = [-1] * (b+1)
modinv_table_b[1] = 1
for i in range(2, b+1):
    modinv_table_b[i] = (-modinv_table_b[mod % i] * (mod // i)) % mod

def binomial_coefficients_a(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table_a[i + 1]
        ans %= mod
    return ans

def binomial_coefficients_b(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table_b[i + 1]
        ans %= mod
    return ans

res = pow(2,n,mod)-binomial_coefficients_a(n,a)-binomial_coefficients_b(n,b)-1
print(res if res >= 0 else res+mod)

Submission status: Wrong Answer

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

mod = 10**9+7

ans = 1
r = 2
m = n
while(True):
    if(m%2 == 1):
        ans *= r
        ans %= mod
    r = r**2
    r %= mod
    m = m//2
    if(m == 0):
        break

a = max(a,n-a)
b = max(b,n-b)
base = []
rbase = [0,1]
c = min(a,b)
d = max(a,b)

bas = 1
for i in range(n,c,-1):
    bas *= i
    bas %= mod
    base.append(bas)

#0からn-cまでの逆元
rbase = [0,1]
for i in range(2,n-c+1):
    q = mod//i
    r = mod % i
    rbase.append(-q * rbase[r] % mod)
rbases = []
rbas = 1
for i in range(1,n-c+1):
    rbas *= rbase[i]
    rbas %= mod
    rbases.append(rbas)

if(c == 0):
    a_ = 1
else:
    a_ = base[n-c-1]*rbases[n-c-1]%mod
b_ = base[n-d-1]*rbases[n-d-1]%mod
print((ans - a_ - b_ - 1)%mod)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
u, d, c = [1], [1], [1]
for i in range(1, b + 1):
    u.append(u[-1] * (n - i + 1) % mod)
    d.append(d[-1] * i % mod)
    c.append(u[i] * pow(d[i], -1) % mod)
    #print(u,d,c)
print((pow(2, n, mod) - 1 - int(c[a] + c[b])) % mod)

Submission status: Wrong Answer

Solution code:
n,a,b=list(map(int,input().split()))
import math
mod=10**9+7
x=math.factorial(n)//(math.factorial(n-a)*math.factorial(a))
y=math.factorial(n)//(math.factorial(n-b)*math.factorial(b))
def power(n,a,p):
    res=1
    while n>0:
        if n%2:
            res=(res*a)%p
            n-=1
        else:
            a=(a*a)%p
            n/=2
    return res
print((power(2,n,mod)-1-x-y)%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
from math import cos,sin,tan,sqrt
import cmath as cma
import copy as cp
import sys
import re
import bisect as bs
sys.setrecursionlimit(10**7)
EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf
MOD = 10**9 + 7

def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def adj(n): return [[] for _ in range(n)]

#整数問題セット
def gcd(numbers): return func.reduce(frac.gcd, numbers)
def lcm(numbers): return func.reduce(LCM, numbers)
def inv(a): return pow(a, MOD-2, MOD) #逆元
def comb(n,r):
    ans = 1
    for i in range(r): ans *= n-i; ans *= inv(r-i); ans %= MOD
    return ans

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