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 com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, mod-1, mod)

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

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

print(int(sum % mod))

Submission status: Wrong Answer

Solution code:
def com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, mod-3, mod)

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

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

print(int(sum % mod))

Submission status: Wrong Answer

Solution code:
def com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, 1, mod)

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

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

print(int(sum % mod))

Submission status: Wrong Answer

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

for i in range(n) :
    if i == a :
        continue
    elif i == b :
        continue
    else :
        sum+=math.factorial(n)/(math.factorial(i)*math.factorial(n-i))

print(sum%1000000007)

Submission status: Wrong Answer

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

#組み合わせを定義する
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


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

print(sum%1000000007)

Submission status: Wrong Answer

Solution code:

def power(x, y, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    二分累乗法でx ** yを求める
    
    2 ** n = 4 ** (n//2) = 16 ** (n//4)
    みたいなことをする
    """

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


def mul(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味したかけ算を行う
    """
    return ((a % mod) * (b % mod)) % mod

def div(a, b, mod):
    """
    https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
    modを加味した割り算を行う    
    """
    if a == b:
        return 1
    return mul(a, power(b, mod-2, mod), mod)


def factorial_part(start, last, mod):
    """
    startからlastまでのかけ算を行う
    
    factorial_part(2, 4, mod) = 2 * 3 * 4 = 24    
    """
    assert(start <= last)
    x = 1
    for k in range(start, last+1):
        x *= k
        x %= mod
    return x


mod = int(1e9) + 7
n, a, b = map(int, input().split())

nCa = div(factorial_part(n - a + 1, n, mod), factorial_part(1, a, mod), mod)
nCb = div(factorial_part(n - b + 1, n, mod), factorial_part(1, b, mod), mod)
n2 = power(2, n, mod)
ans = n2 - nCa - nCb - 1
if ans < 0:
    ans += mod
print(ans)

Submission status: Wrong Answer

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

import functools
mod = 10**9+7

def mod_square(k):
    table = [False]*32
    squares = [1]*32
    base = 2
    for i in range(0, 32):
        squares[i] = base
        base = (base*base)%mod
    itr = 0
    while k > 0:
        if k & 1:
            table[itr] = True
            # print(itr)
        k >>= 1
        itr+=1
        
    # print(table, squares)
    return functools.reduce(lambda x,y:(x*y)%mod, [squares[i] if table[i] else 1 for i in range(32)])
    

def cmb(n, r, mod=mod):
    # g1[r]: nPr
    # g2[r]: nPr^{-1}
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[r] * g2[r]  % mod

N = max(a,b)
g1 = [1, n]  # 元テーブル
g2 = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

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

# print(mod_square(n), cmb(n,a), cmb(n,b))
print(((mod_square(n)-cmb(n,a))%mod -cmb(n,b))%mod)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
mod = 1000000007
ans = pow(2,n,mod) - 1

def solve(nu):
    res = 1
    for i in range(nu):
        res *= n-i
        res/=i+1
    res%=mod
    return res

ans -=solve(a)
ans %= mod
ans -= solve(b)
ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
mod = 1000000007
ans = pow(2,n,mod) - 1

def solve(nu):
    res = 1
    for i in range(nu):
        res *= n-i
        res/=i+1
        res%=mod
    return res

ans -=solve(a)
ans %= mod
ans -= solve(b)
ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
x = [int(str) for str in input().split()]
n = x[0]
a = x[1]
b = x[2]

res = 1
rep = n
while rep > 0:
  if rep >= 30:
    res = res * 73741817 % 1000000007
    rep -= 30
  else:
    res = res * (2**rep) % 1000000007
    rep = 0
  
abs = 1
bbs = 1

al = list(range(n,n-a,-1))
bl = list(range(n,n-b,-1))

for x1 in range(a):
  for x2 in range(a):
    if al[x2] % (x1+1) == 0:
      al[x2] /= (x1+1)
      break
for y1 in range(b):
  for y2 in range(b):
    if bl[y2] % (y1+1) == 0:
      bl[y2] /= (y1+1)
      break
for x3 in al:
  abs = abs * x3 % 1000000007
for y3 in bl:
  bbs = bbs * y3 % 1000000007

res -= int(abs+bbs)+1
if res <= 0:
  res += 1000000007
  if res <= 0:
    res += 1000000007
print(res)

Submission status: Wrong Answer

Solution code:
x = [int(str) for str in input().split()]
n = x[0]
a = x[1]
b = x[2]

res = 1
for z in range(n):
  res = res * 2 % 1000000007

abs = 1
bbs = 1

al = list(range(n,n-a,-1))
bl = list(range(n,n-b,-1))

for x1 in range(a):
  for x2 in range(a):
    if al[x2] % (x1+1) == 0:
      al[x2] /= (x1+1)
      break
for y1 in range(b):
  for y2 in range(b):
    if bl[y2] % (y1+1) == 0:
      bl[y2] /= (y1+1)
      break
for x3 in al:
  abs = abs * x3 % 1000000007
for y3 in bl:
  bbs = bbs * y3 % 1000000007

res -= int(abs+bbs)+1
if res <= 0:
  res += 1000000007
  if res <= 0:
    res += 1000000007
print(res)

Submission status: Wrong Answer

Solution code:
x = [int(str) for str in input().split()]
n = x[0]
a = x[1]
b = x[2]

res = 1
for z in range(n):
  res = res * 2 % 1000000007

abs = 1
bbs = 1

al = list(range(n,n-a,-1))
bl = list(range(n,n-b,-1))

for x1 in range(a):
  for x2 in range(a):
    if al[x2] % (x1+1) == 0:
      al[x2] /= (x1+1)
      break
for y1 in range(b):
  for y2 in range(b):
    if bl[y2] % (y1+1) == 0:
      bl[y2] /= (y1+1)
      break
for x3 in al:
  abs = abs * x3 % 1000000007
for y3 in bl:
  bbs = bbs * y3 % 1000000007

res -= int(abs+bbs)
if res <= 0:
  res += 1000000007
  if res <= 0:
    res += 1000000007
print(res)

Submission status: Wrong Answer

Solution code:
import math

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

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

ans=0

for i in range(N):
    if not i==a:
        if not i==b:
           ans=ans+combinations_count(N,i)
ans=ans%(10**9+7)
print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc156/submissions/10277689

# コンテスト中に通せたけどmodintクラスで実装してみる
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


class ModInt:
    def __init__(self, x, MOD=10 ** 9 + 7):
        self.mod = MOD
        self.x = x if x < MOD else x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x + other.x, self.mod)
        else:
            return ModInt(self.x + other, self.mod)

    def __sub__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x - other.x, self.mod)
        else:
            return ModInt(self.x - other, self.mod)

    def __mul__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * other.x, self.mod)
        else:
            return ModInt(self.x * other, self.mod)

    def __truediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(self.x * pow(other.x, self.mod - 2, self.mod))
        else:
            return ModInt(self.x * pow(other, self.mod - 2, self.mod))

    def __pow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(self.x, other.x, self.mod))
        else:
            return ModInt(pow(self.x, other, self.mod))

    __radd__ = __add__

    def __rsub__(self, other):  # 演算の順序が逆
        if isinstance(other, ModInt):
            return ModInt(other.x - self.x, self.mod)
        else:
            return ModInt(other - self.x, self.mod)

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        if isinstance(other, ModInt):
            return ModInt(other.x * pow(self.x, self.mod - 2, self.mod))
        else:
            return ModInt(other * pow(self.x, self.mod - 2, self.mod))

    def __rpow__(self, other):
        if isinstance(other, ModInt):
            return ModInt(pow(other.x, self.x, self.mod))
        else:
            return ModInt(pow(other, self.x, self.mod))


def combination_mod(n, r, mod):
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


def combination(n, r):
    if r > n:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = ModInt(1)
    for i in range(r):
        nf = nf * (n - i)
        rf = rf * (i + 1)
    return nf / rf


# すべての通り(2^n-1)からnCa,nCbを引けば良い
MOD = 10**9 + 7
n, a, b = read_ints()
# tmp = pow(2, n, MOD) - 1
# ans = tmp - combination_mod(n, a, MOD) - combination_mod(n, b, MOD)
# print(ans % MOD)

tmp = ModInt(2)**n - 1
ans = tmp - combination(n, a) - combination(n, b)
print(ans)

Submission status: Wrong Answer

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

M = 10**9 + 7
result = pow(2, n, M)

def comb(n, r):
    x = 1
    y = 1

    for i in range(r):
        x *= (n - i)
        y *= (i + 1)
        x %= M
        y %= M

    x %= M
    y %= M
    return x // y

print(result - comb(n, a) - comb(n, b))

Submission status: Wrong Answer

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

def my_pow(num, p, mod):
    if p==0:
        return 1
    elif p%2==0:
        return (my_pow(num, p//2, mod)**2)%mod
    else:
        return (my_pow(num, p-1, mod)*num)%mod

def comb(num, r, mod):
    r = min(r, num-r)
    y = 1
    for i in range(num-r+1, num+1):
        y = (y*i)%mod
    x = 1
    for i in range(1, r+1):
        x = (x*i)%mod
    return (y*my_pow(x, mod-2, mod))%mod

result = my_pow(2, n, mod)-1 -comb(n, a, mod) -comb(n, b, mod)
if result < 0:
    result += mod
print(result)

Submission status: Wrong Answer

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

cnt=0
for k in range(1,n+1):
    cnt+=comb(n,k)
    print(cnt)
cnt=cnt-comb(n,a)-comb(n,b)
ans=int(cnt%(10**9+7))

Submission status: Wrong Answer

Solution code:
x = [int(str) for str in input().split()]
n = x[0]
a = x[1]
b = x[2]

res = 1
for z in range(n):
  res = res * 2 % 1000000007

abs = 1
bbs = 1

for y in range(a):
  abs *= n - y
  abs /= y + 1
  abs = int(abs)
  
for z in range(b):
  bbs *= n - z
  bbs /= z + 1
  bbs = int(bbs)

res -= int(abs+bbs)
if res >= 1000000007:
  r=str(res)
  res = int(r[:-9])*7+int(r[-9:])
print(res)

Submission status: Wrong Answer

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

def comb_mod(N,x):
    numerator_mod=1
    denominator_mod=1
    for i in range(x):
        numerator_mod=(numerator_mod*(N-i))%(10**9+7)
    for i in range(1,x+1):
        denominator_mod=(denominator_mod*i)%(10**9+7)
    return numerator_mod/denominator_mod

print(int((total_mod-comb_mod(n,a)-comb_mod(n,b))%(10**9+7)))

Submission status: Wrong Answer

Solution code:
def mod_rep_pow(a, n, mod=(10 ** 9 + 7)):
    res = 1
    while n > 0:
        if n % 2 == 0:
            a = a ** 2 % mod
            n //= 2
        else:
            res = res * a % mod
            n -= 1
    return (res % mod)


def mod_comb(n, k, mod=(10 ** 9 + 7)):
    res1 = 1
    for i in range(n, (n - k), -1):
        res1 *= i
        res1 %= mod
    res2 = 1
    for i in range(1, (k + 1)):
        res2 *= i
        res2 %= mod
    return ((res1 * mod_rep_pow(res2, (mod - 2), mod)) % mod)


n, a, b = map(int, input().split())
mod = 10 ** 9 + 7
ans = mod_rep_pow(2, n, mod) - 1
ans -= mod_comb(n, a, mod)
ans -= mod_comb(n, b, mod)
if ans < 0:
    ans += mod
print(ans)

Submission status: Wrong Answer

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

p = 10**9 + 7

def pow_mod(n, m, p):
  if m == 0:
    return 1
  elif m % 2 == 0:
    nm2p = pow_mod(n, m//2, p)
    return (nm2p * nm2p) % p
  elif m % 2 == 1:
    return (pow_mod(n, m-1, p) * (n % p)) % p

tot = 2 ** n - 1

def compute_ncr_mod(n, r, p):
  n_factorial = 1
  for i in range(n, n-r, -1):
    n_factorial *= i
  r_factorial = 1
  for i in range(r, 0, -1):
    r_factorial *= i
  ncr_modp = ((n_factorial % p) * pow_mod(r_factorial, p-2, p)) % p
  return ncr_modp

print(tot - compute_ncr_mod(n, a, p) - compute_ncr_mod(n, a, b))

Submission status: Wrong Answer

Solution code:
def kaijo(n):
    fact = 1
    for i in range(1, n+1):
        fact *=i
    return fact

n,a,b=map(int,input().split())
mod=10*9+7
s=2**n-1-int(kaijo(n)/(kaijo(n-a)*kaijo(a)))-int(kaijo(n)/(kaijo(n-a)*kaijo(a)))
print(s%mod)

Submission status: Wrong Answer

Solution code:
import sys


def alg_combination_mod(n, r, mod):
    r = min(n - r, r)
    if r == 0:
        return 1
    else:
        denominator = 1
        for i in range(n, n - r, -1):
            denominator = (denominator * i) % mod
        molecule = 1
        for i in range(1, r + 1):
            molecule = (molecule * i) % mod
        return denominator * pow(molecule, mod - 2, mod) % mod


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n, a, b = list(map(int, input().rstrip('\n').split()))
    all_cnt = pow(2, n, mod) + mod
    a_cnt = alg_combination_mod(n, a, mod)
    b_cnt = alg_combination_mod(n, b, mod)
    print(all_cnt - a_cnt - b_cnt - 1)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

mod = 10**9 + 7

def comb_mod(n, r, mod):
    if n < r:
        return 0
    elif n < 0 or r < 0:
        return 0
    else:
        fac = [1, 1]
        finv = [1, 1]
        inv = [0, 1]
        for i in range(2, n + 1):
            fac.append(fac[-1] * i % mod)
            inv.append(-inv[mod % i] * (mod // i) % mod)
            finv.append((finv[-1] * inv[-1]) % mod)
        return int(fac[n] * finv[r] * finv[n - r] % mod)

m = pow(2,n,mod)

a = comb_mod(n,a,mod)

b = comb_mod(n,b,mod)

ans = m - a - b

print(ans%mod)

Submission status: Wrong Answer

Solution code:
import math
n,a,b = input().split()
n = int(n)
a = int(a)
b = int(b)
p = []
for i in range(2,n+1):
    if i != a and i != b:
        p.append(i)
        
sum = 0;
for pp in p:
    # nCppを求める
    sum += math.factorial(n) / (math.factorial(pp) * math.factorial(n - pp))
print(int(sum % (10**9+7)))

Submission status: Wrong Answer

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

def combination(n, a, mod):
    bunshi = 1
    bunbo = 1
    for i in range(a):
        bunshi *= n-i
        bunshi = bunshi%mod
        bunbo *= a-i
        bunbo = bunbo%mod
    return bunshi*pow(bunbo, mod-2, mod)%mod
mod = 100000007
answer = pow(2, n, mod)
answer -= 1
answer -= combination(n, a, mod)
answer -= combination(n, b, mod)
print(answer%mod)

Submission status: Wrong Answer

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd
enu = enumerate

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

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = 1
    for i in range(n, n - r, -1):
        over = over * i % p
    under = 1
    for i in range(1, r + 1):
        under = under * i % p
    inv = pow(under, p - 2, p)
    return over * inv % p

cnt = pow(2, n, mod)
ng1 = cmb(n, a, mod)
ng2 = cmb(n, b, mod)

res = cnt - ng1 - ng2 - 1

print(res)

Submission status: Wrong Answer

Solution code:
from functools import reduce
  
def perm(n, k, p):
  ret = 1
  for i in range(n, n-k-1, -1):
    ret = (ret * i)%p
  return ret

def comb(n, k, p):
  """power_funcを用いて(nCk) mod p を求める"""
  a = perm(n, k, p)
  b = perm(k, k, p)
  return (a*pow(b, p-2, p))%p
  
n, a, b = map(int, input().split())

MOD = 10**9 + 7


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

Submission status: Wrong Answer

Solution code:
from functools import reduce
  
def perm(n, k, p):
  ret = 1
  for i in range(n, n-k-1, -1):
    ret = (ret * i) % p
  return ret

def comb(n, k, p):
  """power_funcを用いて(nCk) mod p を求める"""
  a = perm(n, k, p)
  b = perm(n, n-k, p)
  return (a*pow(b, p-2, p))%p
  
n, a, b = map(int, input().split())

MOD = 10**9 + 7


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

Submission status: Wrong Answer

Solution code:
from functools import reduce
  
def perm(n, k, p):
  ret = 1
  for i in range(n, n-k, -1):
    ret = (ret * i)%p
  return ret

def comb(n, k, p):
  """power_funcを用いて(nCk) mod p を求める"""
  a = perm(n, k, p)
  b = perm(n, n-k, p)
  return (a*pow(b, p-2, p))%p
  
n, a, b = map(int, input().split())

MOD = 10**9 + 7


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

Submission status: Wrong Answer

Solution code:

from functools import reduce
  
def comb(n, k, p):
  """power_funcを用いて(nCk) mod p を求める"""
  a = reduce(lambda x,y: x*y%MOD, range(n,n-k,-1))
  b = reduce(lambda x,y: x*y%MOD, range(1,k+1))
  return (a*b)%p
  
n, a, b = map(int, input().split())

MOD = 10**9 + 7


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

Submission status: Wrong Answer

Solution code:
import numpy as np
def comb_mod(n, a, m):
  if a > n:
    return 0
  a = min(a, n-a+1)
  # tbl = [[0]*(a+1) for _ in range(2)]
  tbl = np.zeros((2, a+1), dtype=np.int64)
  tbl[0][0] = 1
  tbl[1][0] = 1
  for i in range(n+1):
    # tbl[i%2][0] = 1
    tbl[i%2][1:] = (tbl[(i+1)%2][1:] + tbl[(i+1)%2][:-1]) % m
    # for k in range(min(i+1, len(tbl[i%2]))):
    #   if i == k:
    #     tbl[i%2][k] = 1
    #   elif i < k:
    #     tbl[i%2][k] = 0
    #   elif k == 0:
    #     tbl[i%2][k] = 1
    #   else:
    #     tbl[i%2][k] = (tbl[(i-1)%2][k-1] + tbl[(i-1)%2][k]) % m
  return tbl[i%2][a]
n, a, b = map(int, input().split(' '))
c = 0
for i in range(1, n+1):
  if i == a or i == b:
    continue
  c += comb_mod(n, i, 1000000007)
  c %= 1000000007
print(c)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
  
MOD = pow(10, 9) + 7
n, a, b = map(int, input().split())
 
#   (2^n - nCa - nCb) mod MOD
# = ( (2^n - 1 mod MOD) - (nCa mod MOD) - (nCb mod MOD ) ) mod MOD
#   (nCr mod MOD) = ( n*(n-1)*...*(n-r+1) * (a!)^-1 ) mod MOD
# = ( (n mod MOD) * ((n-1) mod MOD) * ... * ((n-r+1) mod MOD) * (r!)^(MOD-2) )  mod MOD

a = min(a, n-a)
b = min(b, n-b)
rMAX = max(a, b)

#分子のmod
nCr_Mol_ModList = [0 for _ in range(rMAX+1)]
#分母（rの階乗）のmod
fac_ModList = [0 for _ in range(rMAX+1)]
nCr_Mol_ModList[1] = n % MOD
fac_ModList[1] = 1 % MOD
for i in range(2, rMAX+1) :
  nCr_Mol_ModList[i] = (nCr_Mol_ModList[i-1] * (n-i+1)) % MOD
  fac_ModList[i] = (fac_ModList[i-1] * i) % MOD

#(2^n - 1 mod MOD) = X
#(nCa mod MOD) = Y
#(nCb mod MOD ) = Z とする

X = pow(2,n,MOD)-1%MOD
Y = ( nCr_Mol_ModList[a] * pow(fac_ModList[a], MOD-2, MOD) )%MOD
Z = ( nCr_Mol_ModList[b] * pow(fac_ModList[b], MOD-2, MOD) )%MOD
ans = (X - Y - Z) % MOD
ans = max(ans, 0)
print (ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
  
MOD = pow(10, 9) + 7
n, a, b = map(int, input().split())
 
#   (2^n - nCa - nCb) mod MOD
# = ( (2^n - 1 mod MOD) - (nCa mod MOD) - (nCb mod MOD ) ) mod MOD
#   (nCr mod MOD) = ( n*(n-1)*...*(n-r+1) * (a!)^-1 ) mod MOD
# = ( (n mod MOD) * ((n-1) mod MOD) * ... * ((n-r+1) mod MOD) * (r!)^(MOD-2) )  mod MOD

a = min(a, n-a)
b = min(b, n-b)
rMAX = max(a, b)

#分子のmod
nCr_Mol_ModList = [0 for _ in range(rMAX+1)]
#分母（rの階乗）のmod
fac_ModList = [0 for _ in range(rMAX+1)]
nCr_Mol_ModList[1] = n % MOD
fac_ModList[1] = 1 % MOD
for i in range(2, rMAX+1) :
  nCr_Mol_ModList[i] = (nCr_Mol_ModList[i-1] * (n-i+1)) % MOD
  fac_ModList[i] = (fac_ModList[i-1] * i) % MOD

#(2^n - 1 mod MOD) = X
#(nCa mod MOD) = Y
#(nCb mod MOD ) = Z とする

X = pow(2,n,MOD)-1%MOD
Y = ( nCr_Mol_ModList[a] * pow(fac_ModList[a], MOD-2, MOD) )%MOD
Z = ( nCr_Mol_ModList[b] * pow(fac_ModList[b], MOD-2, MOD) )%MOD
ans = (X - Y - Z) % MOD
print (ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
  
MOD = pow(10, 9) + 7
n, a, b = map(int, input().split())

#   (2^n - nCa - nCb) mod MOD
# = ( (2^n - 1 mod MOD) - (nCa mod MOD) - (nCb mod MOD ) ) mod MOD


a = min(a, n-a)
b = min(b, n-b)
rMAX = max(a, b)


#   (nCr mod MOD) = ( n*(n-1)*...*(n-r+1) * (a!)^-1 ) mod MOD
# = ( (n mod MOD) * ((n-1) mod MOD) * ... * ((n-r+1) mod MOD) * (a!)^(MOD-2) )  mod MOD
#   (nCr mod MOD) = ( n! * (r!)^(-1) * ((n-r)!)^(-1)) mod MOD
# = ( (n! mod MOD) * ((r!)^(MOD-2)) * ((n-r)!)^(MOD-2)) mod MOD
#def nCr_mod(n, r, mod) :
#  r = n

#階乗テーブル作成（0～rまで）



#ans = ( pow(2, n, MOD) - ()%MOD - ()%MOD ) % MOD

n = pow(10, 5)
#n = 10
#MOD = 11
fac = [0 for _ in range(n+1)]

fac[0] = 1
fac[1] = 1
for i in range(2, n+1) :
  fac[i] = (fac[i-1] * i) % MOD
  
print (1)

Submission status: Wrong Answer

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

num_in = list(map(int, input().split()))
n = num_in[0]
a = num_in[1]
b = num_in[2]
result = 0
i = 1

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

if n <= b:
  print(0)
else:
  if n < 2 * 10 ** 5:
    while i < n:
      result += cmb(n,i)
  else:
    while i < 2 * 10 ** 5:
      result += cmb(n,i)
  result -= cmb(n,a) + cmb(n,b)
  print(result % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
m = int(1e9) + 7
ans = (pow(2, n, m) -1) % m
val = 1
val2 = 1
for i in range(a):
    val = (val * n - i) % m
    val2 = (val2 * i + 1) % m
ans -= (val * (pow(val2, m-2, m)))
val = 1
val2 = 1
for i in range(b):
    val *= (n - i) % m
    val2 *= (i + 1) % m
ans -= (val * (pow(val2, m-2, m)))
print(ans % (int(1e9) + 7))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
m = int(1e9) + 7
ans = (pow(2, n, m) -1) % m
val = 1
val2 = 1
for i in range(a):
    val = (val * n - i) % m
    val2 = (val2 * i + 1) % m
ans -= (val * (pow(val2, m-2, m)))
val = 1
val2 = 1
for i in range(b):
    val *= n - i
    val2 *= i + 1
ans -= (val * (pow(val2, m-2, m)))
print(ans % (int(1e9) + 7))

Submission status: Wrong Answer

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

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

for i in range(n):
    if i != a:
        if i != b:
            X += comb(n, i)

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

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 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))
n,a,b=[int(x) for x in input().split()]
ans1 = pow(2,n,MOD)
N = n
a1=combination(n,a)
b1 = combination(n,b)
if ans1-a1%MOD-b1%MOD<0:
  print(((ans1-a1%MOD-b1%MOD)%MOD+MOD)%MOD)
else:
  print(ans1-a1%MOD-b1%MOD)

Submission status: Wrong Answer

Solution code:
MOD = 10**9+7
def pow(a, b):
    res = 1
    while b:
        if b & 1: res = res * a % MOD
        a = a**2 % MOD
        b >>= 1
    return res

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

ans = pow(2, n)-1

for X in [a, b]:
    x = 1
    y = 1
    for i in range(X):
        x = x * (n-i) % MOD
        y = y * (i+1) % MOD

    t = x * pow(y, MOD-2) % MOD
    ans -= t

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

l = set(range(2, n+1))
try:
    l.remove(a)
except:
    pass
try:
    l.remove(b)
except:
    pass

print(sum([cmb(n, r) for r in l])%mod)

Submission status: Wrong Answer

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

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

l = set(range(2, n+1))
try:
    l.remove(a)
except:
    pass
try:
    l.remove(b)
except:
    pass

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)

print(sum([cmb(n, r, mod) for r in l]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 11:36:40 2020

@author: Kanaru Sato
"""

#overflowしない階乗
def modfact(n,mod):
    a = int(n/2)
    tmp = 1
    for i in range(1,a+1):
        tmp *= 2*i-1
        tmp *= 2*i
        tmp %= mod
    if n%2 == 1:
        tmp *= n
        tmp %= mod
    return tmp

#nCrをO(r)で求める
def mod_c_count(n,r,mod):
    div = modfact(r,mod)
    tmp = 1
    for i in range(0,r):
        tmp = tmp*(n-i)%mod
    return (tmp//div)%mod

#繰り返し2乗法
def sep(a,n):
    if n >= 2:
        m = n%2
        return sep(a,n//2)*sep(a,n//2)*sep(a,m)
    elif n == 1:
        return a
    elif n == 0:
        return 1

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

T = 7+10**9
Max = 2*(10**5)

Nocase = mod_c_count(n,a,T)+mod_c_count(n,b,T)

if n <= Max:
    S = sep(2,n)%T
else:
    S = sep(2,Max)%T

Case = S - Nocase
ans = Case % T
print(ans-1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  3 11:36:40 2020

@author: Kanaru Sato
"""

#overflowしない階乗
def modfact(n,mod):
    a = int(n/2)
    tmp = 1
    for i in range(1,a+1):
        tmp *= 2*i-1
        tmp *= 2*i
        tmp %= mod
    if n%2 == 1:
        tmp *= n
        tmp %= mod
    return tmp

#nCrをO(r)で求める
def mod_c_count(n,r,mod):
    div = modfact(r,mod)
    tmp = 1
    for i in range(0,r):
        tmp = tmp*(n-i)%mod
    return (tmp//div)%mod

#繰り返し2乗法
def sep(a,n):
    if n >= 2:
        m = n%2
        return sep(a,n//2)*sep(a,n//2)*sep(a,m)
    elif n == 1:
        return a
    elif n == 0:
        return 1

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

T = 7+10**9
Max = 2*(10**5)

Nocase = mod_c_count(n,a,T)+mod_c_count(n,b,T)

if n <= Max:
    S = sep(2,n)%T
else:
    S = sep(2,Max)%T

Case = S - Nocase
ans = Case % T
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i 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 *= numerator[k]
            result %= mod
    return int(result)

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