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:
n,a,b=map(int, input().split())
f_num=0
if n==2:
    print('0')
else:
    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
    for i in range(2,n+1):
        f_num+=cmb(n,i)
    print(f_num%(10**9+7))

Submission status: Wrong Answer

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

c = factorial(n)/(factorial(n)*factorial(n-n))
total = 0
k=factorial(n)
for i in range(1,n+1):
    if i==a or i ==b:continue
    total += k/(factorial(i)*factorial(n-i))

print(total)

Submission status: Wrong Answer

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


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


p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]

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

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

Submission status: Wrong Answer

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

for i in range(1,n+1):
    if i == a or i == b:
        continue
    if n >= 1*10**9:
        ans += math.factorial(n) * (math.factorial(n-i)** 5) * (math.factorial(i) ** 5)
    else:
        ans += math.factorial(n) // math.factorial(n - i) * math.factorial(i)
        print(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
def strr():
 a=raw_input()
 return a
def sstrr():
 a=raw_input().split()
 return a
def intt():
 a=int(raw_input())
 return a
def iintt():
 x=raw_input()
 a=[int(s) for s in x.split()]
 return a
def nestt(t):
 a=[raw_input().split() for s in range(t)] 
 return a

nab=iintt()
n=nab[0]
a=nab[1]
b=nab[2]
x=1
for i in range(max(a,b)):
 if i==max(a,b)-min(a,b)-1:
  x=x*(n-i+1)%1000000007
 else:
  x=x*(n-i)%1000000007

res=1
nn=0
ab=2
s=1
while n>0:
 if n//(ab/2)%2==1:
  res=res*ab%1000000007
  n-=s
 s*=2
 ab=ab*ab%1000000007
res-=1
aa=res-x
if 0>aa:
 aa+=1000000007
print aa

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N0,a0,b0=map(int,input().split())
tmp1=10**9+7
a=a0%tmp1
b=b0%tmp1
N=N0%tmp1
res=[]
res.append((N/1))
res.append((N/1))
for n in range(2,N+1,1):
    tmp=(N-n+1)/n
    res.append(res[n-1]*tmp)
cnt=sum(res)-res[0]-res[a]-res[b]
print(cnt%tmp1)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb


if __name__ == "__main__":
    n, a, b = map(int, input().split())
    ans=0
    if n == 2:
        if (a == 1 and b == 1) or (a == 2 and b == 1):
            print(0)
    else:
        for i in range(1, int(n // 2)):
            cnt=2
            if i == a or i == b:
                cnt -= 1
            if (n - i) == a or (n - i) == b:
                cnt -= 1
            ans += comb(n,i,exact=True)*cnt
        if n%2==0 and (int(n//2) !=a and int(n//2) != b):
            ans += comb(n,int(n//2),exact=True)
        if n != a and n != b:
            ans += 1
        print(ans % (10 ** 9 + 7))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# sys.setrecursionlimit(10000000)
INF = 1<<32
# import numpy as np

MOD = 1000000007  # type: int

def solve(n: int, a: int, b: int):
    def combination_with_mod(n, r, mod=10**9+7):
        n1, r = n+1, min(r, n-r)
        numer = denom = 1
        for i in range(1, r+1):
            numer = numer * (n1-i) % mod
            denom = denom * i % mod
        return numer * pow(denom, mod-2, mod) % mod

    def power_func(a,n,p):
        bi=str(format(n,"b"))#2進表現に
        res=1
        for i in range(len(bi)):
            res=(res*res) %p
            if bi[i]=="1":
                res=(res*a) %p
        return res

    ans = 0
    ans = power_func(2, n, MOD)

    ans = ans-combination_with_mod(n,a)-combination_with_mod(n, b)-combination_with_mod(n,0)
    if ans < 0:
        print(MOD+ans)
    else:
        print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

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

    ans = 0

    if n % 2 == 0:
        for i in range(0, (n//2)):
            tmp = cmb(n, i)
            if (a != i) and (b != i):
                ans += (tmp % mod)
            if (a != (n - i)) and (b != (n - i)):
                ans += (tmp % mod)
        ans -= 1
        if (a != (n//2)) and (b != (n//2)):
            ans += cmb(n, n//2)
    else:
        for i in range(0, (n//2)+1):
            tmp = cmb(n, i)
            if (a != i) and (b != i):
                ans += (tmp % mod)
            if (a != (n - i)) and (b != (n - i)):
                ans += (tmp % mod)
        ans -= 1

    print(ans)
    return 0

Submission status: Wrong Answer

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

list = input().split()
N = int(list[0])
a = int(list[1])
b = int(list[2])
S = 0
k = N // 2
x = 10**9 + 7

if N %2 == 0:
  for i in range(1,k+1):
    S += cmb(N,i)
  S += S
else:
  for i in range(1,k+1):
    S += cmb(N,i)
  S += S + 1
S += -cmb(N,a)-cmb(N,b)
S = S % x
print(int(S))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline
N,a_,b_=map(int,input().split())
l=[min(a_,N-a_),min(b_,N-b_)]
a=min(l)
b=max(l)
#print(a,b)
cmb=1
mod=10**9+7
for i in range(1,a+1):
    cmb*=N-(a-i)
    cmb=cmb//i
#print('cmb1='+str(cmb))
ans=-(1+cmb)
for i in range(a,b):
    cmb*=(N-i)
    cmb=cmb//(i+1)
    cmb=cmb%mod
#print('cmb2='+str(cmb))
ans-=cmb

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

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

    return K * x
ans+=pow_k(2,N)
print(ans%mod)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1
fact = [1]*(2*10**5+1)
for i in range(2,2*10**5+1):
  tmp = fact[i-1]*i
  tmp %= mod
  fact[i]=tmp
  
a_mi = 0
b_mi = 0
x = n-a
y = n-b
a = min(a,x)
b = min(b,y)
k = n-max(a,b)
x = n-a+1
y = n-b+1
fa = 1
for i in range(n,k,-1):
  fa*=i
  fa%=mod
  if i==x:
    a_mi=fa
  if i==y:
    b_mi=fa
    
if a_mi==0:
  a_mi=1
if b_mi==0:
  b_mi=1
ans-=((a_mi*pow(fact[a],mod-2,mod))%mod+(b_mi*pow(fact[b],mod-2,mod))%mod)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import math
from operator import mul
from functools import reduce
n,a,b=map(int,input().split())
mod=10**9+7
def comb(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = (numer*(n1-i)) % mod
        denom = (denom*i) % mod
    return numer * pow(denom, mod-2, mod) % mod

def kumi(nn):
  y=2
  ass=1
  two=[]
  r = int(math.log2(nn))
  for i in range(r+1):
      if nn >= 2**r:
          nn = n-2**r
          two.append(1)
      else:
          two.append(0)
      r = r-1
  two = two[::-1]
  for i in range(len(two)):
    if two[i] == 1:
      ass = ass * y %mod
    y = y**2%mod
  return ass
a1=kumi(n)
print((a1-comb(n,a)-comb(n,b)-1)%mod)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
# sys.setrecursionlimit(10000000)
INF = 1<<32
# import numpy as np

MOD = 1000000007  # type: int

def solve(n: int, a: int, b: int):
    def combination_with_mod(n, r, mod=10**9+7):
        n1, r = n+1, min(r, n-r)
        numer = denom = 1
        for i in range(1, r+1):
            numer = numer * (n1-i) % mod
            denom = denom * i % mod
        return numer * pow(denom, mod-2, mod) % mod

    def power_func(a,n,p):
        bi=str(format(n,"b"))#2進表現に
        res=1
        for i in range(len(bi)):
            res=(res*res) %p
            if bi[i]=="1":
                res=(res*a) %p
        return res

    ans = 0
    ans = power_func(2, n, MOD)
    # print(mod_inv(ans, MOD))
    # print(ans)

    # for i in range(1,n+1):
    #     ans += combination_with_mod(n, i)

    ans = ans-combination_with_mod(n,a)-combination_with_mod(n, b)-combination_with_mod(n,0)
    if ans < 0:
        print(MOD+ans)
    else:
        print(ans)


    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(n, a, b)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline
N,a_,b_=map(int,input().split())
l=[min(a_,N-a_),min(b_,N-b_)]
a=min(l)
b=max(l)
print(a,b)
cmb=1
mod=10**9+7
for i in range(1,a+1):
    cmb*=N-(a-i)
    cmb=cmb//i
print('cmb1='+str(cmb))
ans=-(1+cmb)
for i in range(a,b):
    cmb*=(N-i)
    cmb=cmb//(i+1)
    cmb=cmb%mod
print('cmb2='+str(cmb))
ans-=cmb

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

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

    return K * x
ans+=pow_k(2,N)
print(ans%mod)

Submission status: Wrong Answer

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

import math

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

l = [int(i) for i in range(1,n+1)]
#print(l)

x = 0
for j in range(n):
    x += combinations_count(n, l[j])

y = combinations_count(n, a) + combinations_count(n, b)

print((x-y)/(10**9+7))

Submission status: Wrong Answer

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

import math

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

l = [int(i) for i in range(1,n+1)]
print(l)

x = 0
for j in range(n):
    x += combinations_count(n, l[j])

y = combinations_count(n, a) + combinations_count(n, b)

print((x-y)/(10**9+7))

Submission status: Wrong Answer

Solution code:
N0,a0,b0=map(int,input().split())
tmp1=10**9+7
a=a0%tmp1
b=b0%tmp1
N=N0%tmp1
res=[]
res.append((N/1))
res.append((N/1))
for n in range(2,N+1,1):
    tmp=(N-n+1)/n
    res.append(res[n-1]*tmp)
cnt=sum(res)-res[0]-res[a]-res[b]
print(cnt)

Submission status: Wrong Answer

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

def aaa(base, n):
#     base = 2
    ans = 1
    nn = n
    while True:
    #     print(base, nn)
        if nn == 0:
            break
        if nn % 2 == 0:
            base = base ** 2
            base = base % mod
            nn /= 2
        else:
            ans *= base
            ans = ans % mod
            nn -= 1
    return ans

xn = aaa(2, n)

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

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

def div(a, b):
    return mul(a, power(b, mod-2))


def fac(start, length, mod):
    x = 1
    for k in range(start, start + length):
        x *= k
        x %= mod
    return x

aa = fac(n - a + 1 , a, mod)
aaa = fac(1, a, mod)
xa = div(aa, aaa)
if aa == 0:
    if aaa == 0:
        xa = 1


bb = fac(n - b + 1 , b, mod)
bbb = fac(1, b, mod)
xb = div(bb, bbb)
if bb == 0:
    if bbb == 0:
        xb = 1
        

x = xn - xa - xb - 1
if x < 0:
    x += mod
print(x)

Submission status: Wrong Answer

Solution code:
num_line=input().rstrip().split(" ")
num=int(num_line[0])
a=int(num_line[1])
b=int(num_line[2])

import math

sum1=0


if(num%2==0):
    for i in range(1,(num//2)):
        kumiawase=math.factorial(num)//((math.factorial(num-i))*(math.factorial(i)))
        #print(kumiawase)
        sum1+=kumiawase
    sum1=sum1*2+(math.factorial(num)//((math.factorial(num//2))**2))
    
else:
     for i in range(1,(num//2)+1):
        kumiawase=math.factorial(num)//((math.factorial(num-i))*(math.factorial(i)))
        print(kumiawase)
        sum1+=kumiawase
     sum1=2*sum1

a1=math.factorial(num)//((math.factorial(num-a))*(math.factorial(a)))
b1=math.factorial(num)//((math.factorial(num-b))*(math.factorial(b)))

dele=a1+b1


kekka=1+sum1-dele
print(kekka%(10**9+7))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n, a, b  = map(int,input().split())
ans = 0
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m
m = 10**9+7
res1 = 1
res2 = 1
for i in range(1,n+1):
    res1 = res1*i%m
for i in range(1,a+1):
    res1 = res1*mod_inv(i,m)%m
for i in range(1,n-a+1):
    res1 = res1*mod_inv(i,m)%m
    print(res1)

for i in range(1,n+1):
    res2 = res2*i%m
for i in range(1,b+1):
    res2 = res2*mod_inv(i,m)%m
for i in range(1,n-b+1):
    res2 = res2*mod_inv(i,m)%m

ans = ((2 ** n - res1 - res2 - 1)%m)
print(ans)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
counter = 0
nCr = 1
for r in range(n):
    nCr_1 = nCr * (n - r) // (r + 1)
    nCr = nCr_1
    if ((r != a) and (r != b)):
        counter += nCr_1
print((counter-1)%(10**9+7))

Submission status: Wrong Answer

Solution code:
mod = 10**9+7
n,a,b = map(int, input().split())
ans = 0
c = 1
x = n
y = 1
if a!=n and b!=n: ans+=c
for i in range(1,-(-n//2)+1):
    c = c*x//y
    x-=1
    y+=1
    ans += c*2
    if i==a or n-i==a:
        ans -= c
    if i==b or n-i==b:
        ans -= c
    if i==n/2:
        ans -= c
    ans %= mod

print(ans)

Submission status: Wrong Answer

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

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


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

mod = 10**9+7 #出力の制限
N = 2 * 10 ** 5
g1 = [n % mod] # 元テーブル
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 )

ans -= cmb(n, a, mod)
ans -= cmb(n, b, mod)
ans %= mod

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
from scipy.misc import comb
c=-comb(n,a)-comb(n,b)
for i in range(1,n+1):
  c+=comb(n,i)
print(int(c%(10**9+7)))

Submission status: Wrong Answer

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

    all = 2 ** n

    mod = 10**9+7 #出力の制限
    N = n
    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("done prepare")
    def combinations_count(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

    all -= combinations_count(n, a, mod)
    all -= combinations_count(n, b, mod)

    if n==2 and a != b:
        print(0)
        return 

    print(all - 1)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

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

list = input().split()
N = int(list[0])
a = int(list[1])
b = int(list[2])
S = 0
x = 10**9 + 7
for i in range(1,N+1):
  if i != a and i != b:
    S += cmb(N,i)
  if S >= x:
    S += -x
print(S)

Submission status: Wrong Answer

Solution code:
def strr():
 a=raw_input()
 return a
def sstrr():
 a=raw_input().split()
 return a
def intt():
 a=int(raw_input())
 return a
def iintt():
 x=raw_input()
 a=[int(s) for s in x.split()]
 return a
def nestt(t):
 a=[raw_input().split() for s in range(t)] 
 return a

print "ok"
nab=iintt()
n=nab[0]
a=nab[1]
b=nab[2]
x=1
for i in range(max(a,b)):
 if i==max(a,b)-min(a,b)-1:
  x=x*(n-i+1)%1000000007
 else:
  x=x*(n-i)%1000000007

res=1
nn=0
ab=2
s=1
while n>0:
 if n//(ab/2)%2==1:
  res=res*ab%1000000007
  n-=s
 s*=2
 ab=ab*ab%1000000007
res-=1
aa=res-x
if 0>aa:
 aa+=1000000007
print aa

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

for i in range(n):
  if i == a or i == b:
    continue
  c = min(i, n - i)
  numer = reduce(mul, range(n, n - c, -1), 1)
  denom = reduce(mul, range(1, c + 1), 1)
  total += numer // denom

total = total % (10**9 + 7)
print(total)

Submission status: Wrong Answer

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

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


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

mod = 10**9+7 #出力の制限
N = 2 * 10 ** 5
g1 = [n % mod] # 元テーブル
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 )

ans -= cmb(n, a, mod)
ans -= cmb(n, b, mod)
ans %= mod

print(ans)

Submission status: Wrong Answer

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


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


total = pow_k(2, n) - 1

now = 1
div = 1
ans = 0
for i in range(max(a, b) + 1):
    print(i)
    now *= (n - i)
    div *= i + 1
    if i == a-1 and i != b-1:
        total -= now // div
print(total % (10 ** 9 + 7))

Submission status: Wrong Answer

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

ans = 0
k = 1

for i in range(1,n+1):
    k = (k*(n-i+1)//i)%1000000007
    if i != a and i != b:
        ans = (ans+k)%1000000007

if n == b:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,a,b=map(int,input().split())
sum=0
for i in range(n):
    if(i!=a or i!=b):
        tmp=combinations_count(n,i)
        sum+=tmp
result= sum%(10**9+7)
print(result)

Submission status: Wrong Answer

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


for i in range(n):
    delta=1
    for j in range(i):
        delta=delta*(n-j)/(j+1)
    if i!=a and i!=b:
        comb=comb+delta

if comb<10**9+7:
    print(int(comb))
else:
    print(int(comb)%10**9)

Submission status: Wrong Answer

Solution code:
def modpow(a,b,mod):
    ans=1
    a=a%mod
    while b>0:
        if b%2==1:
            ans=(ans*a)%mod
        a=(a**2)%mod
        b=b//2
    return ans
def modfinvseq(n,mod):
    inv=[1]
    seq=[1]
    for i in range(2,n+1):
        a=mod-(inv[mod%i-1]*(mod//i))%mod
        inv.append(a)
        seq.append((seq[i-2]*a)%mod)
    return seq

N,A,B=map(int,input().split())
I=modfinvseq(max(A,B),10**9+7)
ans=modpow(2,N,10**9+7)-1
c=1
for i in range(A):
  c=(c*(N-i))%(10**9+7)
ans-=(c*I[A-1])%(10**9+7)
c=1
for i in range(B):
  c=(c*(N-i))%(10**9+7)
ans-=(c*I[B-1])%(10**9+7)
if ans<0:
  ans+=10**9+7
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1
fact = [0]*(2*10**5+1)
fact[1]=1
for i in range(2,2*10**5+1):
  tmp = fact[i-1]*i
  tmp %= mod
  fact[i]=tmp
  
a_mi = 0
b_mi = 0
x = n-a
y = n-b
a = min(a,x)
b = min(b,y)
k = n-max(a,b)
x = n-a+1
y = n-b+1
fa = 1
for i in range(n,k,-1):
  fa*=i
  fa%=mod
  if i==x:
    a_mi=fa
  if i==y:
    b_mi=fa

ans-=((a_mi*pow(fact[a],mod-2,mod))%mod+(b_mi*pow(fact[b],mod-2,mod))%mod)%mod
print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1
fact = [0]*(2*10**5+1)
fact[1]=1
for i in range(2,2*10**5+1):
  tmp = fact[i-1]*i
  tmp %= mod
  fact[i]=tmp
  
a_mi = 0
b_mi = 0
x = n-a
y = n-b
a = min(a,x)
b = min(b,y)
k = n-max(a,b)
x = n-a+1
y = n-b+1
fa = 1
for i in range(n,k,-1):
  fa*=i
  fa%=mod
  if i==x:
    a_mi=fa
  if i==y:
    b_mi=fa
    
print(a_mi,b_mi)
ans-=((a_mi*pow(fact[a],mod-2,mod))%mod+(b_mi*pow(fact[b],mod-2,mod))%mod)%mod
print(ans)

Submission status: Wrong Answer

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

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        x=x%mod
        n //= 2
    return (K * x)

n,a,b=map(int,input().split())
#n,r=map(int,input().split())
A=1
B=1
mod=10**9+7

for i in range(a):
  A=A*(n-i)//(i+1)
  A%=mod
for i in range(b):
  B=B*(n-i)//(i+1)
  B%=mod
  #print("B",B)

ans=pow_k(2, n,mod)-1-A-B
#print(pow_k(2,n,mod))
while ans>mod:
  ans%=mod
print(ans)

Submission status: Wrong Answer

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

def factorial(n):
    fact = 1
    while n > 1:
        fact *= n
        n -= 1
    return fact

sumv = 0
f = factorial(n)
for i in range(1, n + 1):
    sumv += f / (factorial(i) * factorial(n-i))
sumv -= f / (factorial(a) * factorial(n - a))
sumv -= f / (factorial(b) * factorial(n - b))
print(sumv)

Submission status: Wrong Answer

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

p = 10 ** 9 + 7

binom = n # n choose 1
ans = 0 if a == 1 or b == 1 else n

# x^nを求める
def exp_by_sq(x, n):
    if n == 0:
        exp = 1
    elif n == 1:
        exp = x % p
    elif  n % 2 == 0:
        exp = exp_by_sq(x * x % p, n // 2)
    else:
        exp = x * exp_by_sq(x * x % p, (n - 1) // 2) % p
    return exp % p


def binomial_p(n, k, p):
    '''
    Input: integers n, k such that n >= k >= 0, prime number p
    Output: n choose k mod p
    '''
    k = min(k, n-k)
    numer = n  # n * (n-1) * ... * (n- k + 1)
    inv = [0, 1]    # inv[i] : inverse of i mod p
    invfct_k = 1 # factorial of inverse of k mod p = 1^(-1) * 2^(-1) * ... * k^(-1) mod p

    for i in range(2, k + 1):
        numer = numer * (n - i + 1) % p
        inv.append(( inv[p % i] * (p - p//i) ) % p ) # inverse of i
        invfct_k = invfct_k * inv[-1] % p

    return numer * invfct_k % p

ans = (exp_by_sq(2, n) - 1 - binomial_p(n, a, p) - binomial_p(n, b, p)) % p

print(ans)

Submission status: Wrong Answer

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

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


dif1 = keep[0]
dif2 = keep[1]
dif = (dif1 + dif2) % MOD
def power_func(a,n,p):
  bi=str(format(n,"b"))
  res=1
  for i in range(len(bi)):
    res=(res*res) %p
    if bi[i]=="1":
      res=(res*a) %p
  return res
ans = power_func(2,n,MOD)

ans = (ans - dif - 1) % MOD
print(ans)

Submission status: Wrong Answer

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

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    ans=0
    if n == 2:
        if (a == 1 and b == 1) or (a == 2 and b == 1):
            print(0)
    else:
        for i in range(1, int(n // 2)):
            cnt=2
            if i == a or i == b:
                cnt -= 1
            if (n - i) == a or (n - i) == b:
                cnt -= 1
            ans += cmb(n,i)*cnt
        if n%2==0 and (int(n//2) !=a and int(n//2) != b):
            ans += cmb(n,int(n//2))
        if n != a and n != b:
            ans += 1
        print(ans % (10 ** 9 + 7))

Submission status: Wrong Answer

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

from math import factorial
ans = 0

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

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

if a == 0:
    ans += 1
if b == 0:
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

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

Submission status: Wrong Answer

Solution code:
from math import factorial
n, a, b=map(int,input().split())
con=0
for r in range(0,n):
    if r==a or r==b:
        continue
    else:
        c = factorial(n) / factorial(r) / factorial(n - r)
        con+=c
print(int(con))

Submission status: Wrong Answer

Solution code:
M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1)
  c = c * (n - i)
  if i + 1 == a:
    r = (r - c * pow(f, M - 2, M))
print((r - c * pow(f, M - 2, M) % M))

Submission status: Wrong Answer

Solution code:

mod = int(1e9) + 7

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

def aaa(base, n):
#     base = 2
    ans = 1
    nn = n
    while True:
    #     print(base, nn)
        if nn == 0:
            break
        if nn % 2 == 0:
            base = base ** 2
            base = base % mod
            nn /= 2
        else:
            ans *= base
            ans = ans % mod
            nn -= 1
    return ans

xn = aaa(2, n)

def mul(a, b):
    return ((a % mod) * (b % mod)) % mod

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

def div(a, b):
    return mul(a, power(b, mod-2))


def fac(start, length, mod):
    x = 1
    for k in range(start, start + length):
        x *= k
        x %= mod
    return x

xa = div(fac(n - a + 1 , a, mod), fac(1, a, mod))
xb = div(fac(n - b + 1 , b, mod), fac(1, b, mod))

x = xn - xa - xb - 1
if x < 0:
    x += mod
print(x)

Submission status: Wrong Answer

Solution code:
import math

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

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

C = []
for i in range(1, n//2+1):
    C.append(comb(n, i))

if n%2==0:
    Sum = 2 * sum(C) +1 - max(C)
else:
    Sum = 2 * sum(C) +1

if a==n-b:
    ans = Sum - comb(n, a) - comb(n, b)
else:
    ans = Sum - comb(n, a) - comb(n, b) - comb(n, n-a) - comb(n, n-b)

print(ans)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
mod = 10**9+7
ans = pow(2,n,mod)-1
fact = [1]*(2*10**5+1)
for i in range(2,2*10**5+1):
  tmp = fact[i-1]*i
  tmp %= mod
  fact[i]=tmp
  
a_mi = 0
b_mi = 0
x = n-a
y = n-b
a = min(a,x)
b = min(b,y)
k = n-max(a,b)
x += 1
y += 1
fa = 1
for i in range(n,k,-1):
  fa*=i
  fa%=mod
  if i==x:
    a_mi=fa
  if i==y:
    b_mi=fa
    
ans-=((a_mi*pow(fact[a],mod-2,mod))%mod+(b_mi*pow(fact[b],mod-2,mod))%mod)%mod
print(ans)

Submission status: Wrong Answer

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