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())
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-(mod-nCr(n, a))-(mod-nCr(n, b)))%mod
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def comb(n,r,mod):
    p,q=1,1
    for i in range(r):
        p=p*(n-i)%mod 
        q=q*(i+1)%mod 
    return p*pow(q,mod-2,mod)%mod

def main():
    n,a,b  = map(int, input().split())
    #a,bの制約がなければ，2^n - 1通りだけ使える
    # 2^n ^ nCa - nCb
    mod = 10**9 +7
    nca = comb(n,a,mod)
    ncb = comb(n,b,mod)

    print(pow(2,n,mod)-(nca+ncb)%mod-1)


    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
def gcd(x, y):
  while(y):
      x, y = y, x % y 
  return x 
def ncr(n,r):
  if(n==0 or r==0 or n==r):
    return 1;
  r = min(n-r,r);
  p=1;
  k=1;
  while(r):
    p*=n;
    k*=r;
    g = gcd(p,k);
    p/=g;
    k/=g;
    n-=1;
    r-=1;
  return p;
def power(x,y,p):
  res = 1;
  x = x % p;
  while (y > 0): 
    if (y & 1): 
      res = (res*x) % p;
    y = y>>1;
    x = (x*x) % p;
  return res; 
s = input();
lis = s.split(' ');
n = int(lis[0]);
a = int(lis[1]);
b = int(lis[2]);
hell = 1000000007
ans = (power(2,n,hell)-(ncr(n,a)%hell+ncr(n,b)%hell+1)%hell+hell)%hell;
print(ans);

Submission status: Wrong Answer

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

def r(n,p,m):
    if p==0:
        return 1
    if p%2==0:
        t=r(n,p/2,m)
        return t*t%m
    return n*r(n,p-1,m)

s=r(2,n,10**9+7)-1

x=1
for i in range(a):
    x*=(n-i)
    x%=(10**9+7)
p=(x*r(math.factorial(a),10**9+5,10**9+7))%(10**9+7)

y=1
for i in range(b):
    y*=(n-i)
    y%=(10**9+7)
q=(y*r(math.factorial(b),10**9+5,10**9+7))%(10**9+7)

print(s-p-q)

Submission status: Wrong Answer

Solution code:
import functools

def get_mul_inverse(x: int, p: int) -> int:
    return iterative_square(x, p - 2, p)

def _iterative_square(x: int, n: int, p: int) -> int:
    if n <= 1:
        return x
    div, mod = divmod(n, 2)
    return (((iterative_square(x, div, p) ** 2) % p) * x ** mod) % p

def iterative_square(x: int, n: int, p: int) -> int:
    if n <= 0:
        return None

    return _iterative_square(x, n, p)

def factorial(a, b, p):
  x = 1

  x = functools.reduce(lambda x, y: (x * y) % p, range(a, b + 1), 1)
  return x

def com(n, r, p):
  fact_div_r = get_mul_inverse(factorial(1, r, p), p)

  _result = factorial(n - r + 1, n, p)
  result = (_result * fact_div_r) % p
  
  return result


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


pow_2_n_1 = iterative_square(2, n, p) - 1
pow_w_n_1 = pow_2_n_1 if pow_2_n_1 > 0 else pow_2_n_1 + p

_result = pow_2_n_1 - com(n, a, p)
_result = _result if _result > 0 else _result + p

_result = _result - com(n, b, p)
result = _result if _result > 0 else _result + p

print(result)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
total = 2**n-1
def factorial(z):
  product = 1
  for i in range(1, z+1):
    product *= i
  return product
def ncr(x, y):
  return factorial(x)/(factorial(y)*factorial(x-y))
subt = ncr(n, a) + ncr(n, b)
print(total-subt)

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
total = 2**n
def factorial(z):
  product = 1
  for i in range(1, z+1):
    product *= i
  return product
def ncr(x, y):
  return factorial(x)/(factorial(y)*factorial(x-y))
subt = ncr(n, a) + ncr(n, b)
print(total-subt)

Submission status: Wrong Answer

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

k = n
h = 1
s = 0
while h <= n :
    print(h)
    if h !=a and h != b:
        s += k
    k = int(k*(n-h)//(1+h))
    h += 1

print(s)


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

Submission status: Wrong Answer

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

k = n
h = 1
sum = 0
while n >= h :
  if h !=a and h != b:
  	sum += k
  k = k*(n-h)/(1+h)
  h += 1

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

Submission status: Wrong Answer

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

k = n
h = 1
sum = k
while h <= n-1 :
  k = k*(n-h)/(1+h)
  if h !=a and h != b:
  	sum += k
  h += 1

print(sum)

Submission status: Wrong Answer

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

k = n
h = 1
sum = 0
while n > h :
  if h !=a and h != b:
  	sum += k
  k = k*(n-h)/(1+h)
  h += 1

print(sum)

Submission status: Wrong Answer

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

k = n
h = 1
sum = 0
while n >= h :
  if h !=a and h != b:
  	sum += k
  k = k*(n-h)/(1+h)
  h += 1

print(sum)

Submission status: Wrong Answer

Solution code:
def conbination(n,r):
    x=1
    y=1
    for i in range(r):
        x*=n-r+i+1
        y*=i+1
        x%=(10**9+7)
        y%=(10**9+7)
    z=(x*pow(y,(10**9+5),(10**9+7)))%(10**9+7)
    return z
N,a,b=map(int,input().split())
ans=pow(2,N,(10**9+7))-1
ans=ans-conbination(N,a)-conbination(N,b)
print(ans if ans>0 else ans+10**9+7)

Submission status: Wrong Answer

Solution code:
def conbination(n,r):
    x=1
    y=1
    for i in range(r):
        x*=n-r+i+1
        y*=i+1
        x%=(10**9+7)
        y%=(10**9+7)
    z=(x*pow(y,(10**9+5),(10**9+7)))%(10**9+7)
    return z
N,a,b=map(int,input().split())
ans=pow(2,N,(10**9+7))-1
print(ans-conbination(N,a)-conbination(N,b))

Submission status: Wrong Answer

Solution code:
import math

z = 10**9 + 7

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

r = pow(2, n, z)

def c(m):
  x = 1
  for i in range(n-m+1, n+1):
    x = x*i % z
  
  return (x * pow(math.factorial(m), z-2, z)) % z

r = (r - c(a) - c(b)) % z

print(r)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math as m

def main(**kwargs):
    mod = 10 ** 9 + 7
    r = repeatSquare(2, n, mod) - 1
    r -= factMod(n, n - a + 1, mod) * repeatSquare(factMod(a, 1, mod), mod - 2, mod) % mod
    r -= factMod(n, n - b + 1, mod) * repeatSquare(factMod(b, 1, mod), mod - 2, mod) % mod
    r = r % mod
    return r

def repeatSquare(n, p, m):
    if p == 0:
        return 1

    if p % 2 == 0:
        tmp = repeatSquare(n, p/2, m)
        return tmp * tmp % m

    return n * repeatSquare(n, p-1, m) % m

def factMod(n, r, m):
    res = n % m

    while n > r:
        n -= 1
        res *= n % m

    return res

if __name__ == "__main__":
    
    cin = np.array(input().split(" ")).astype("int")
    n, a, b = cin

    cout = main(n=n, a=a, b=b)
    print(cout)

Submission status: Wrong Answer

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

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

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

ret = 0

ret = 2**n + 10**9+7 + 10**9+7 +1
ret = ret - combination(n, a)
ret = ret - combination(n, b)
ret = ret % (10**9+7)
print(ret)

Submission status: Wrong Answer

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

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

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

ret = 0

ret = 2**n + 10**9+7 + 10**9+7
ret = ret - combination(n, a)
ret = ret - combination(n, b)
ret = ret % (10**9+7)
print(ret)

Submission status: Wrong Answer

Solution code:
import math

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

ret = 0
for i in range(n):
    if i+1 == a : continue
    if i+1 == b : continue
    ret = ret + (math.factorial(n-i-1))
    if ret > 1000000007 : ret - 1000000007
print(ret)

Submission status: Wrong Answer

Solution code:
import math

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


if n > 2:
    aa = math.factorial(n) // (math.factorial(n - a) * math.factorial(a))
    bb = math.factorial(n) // (math.factorial(n - b) * math.factorial(b))
    c = (n * n - aa - bb - 1) % 1000000007
    print("{}".format(c))
else:
    print("0")

Submission status: Wrong Answer

Solution code:
import sys

def comb_mod(n, r, mod):
  x = 1
  y = 1
  for i in range(r):
    x = (x * (n - i)) % mod
    y = (y * (i + 1)) % mod
    
  ans = x * pow_k(y, mod-2, mod)
  
  return ans % mod
  
  
def pow_k(x, n, mod):
  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 (x * K) % mod
  

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

ans = pow_k(2, n, mod) - comb_mod(n,a,mod) - comb_mod(n,b,mod) - 1

if ans < 0:
  print(ans + mod)
else:
  print(ans % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def main(n, a, b):
    res = mod(2 ** n - comb(n, a) - comb(n, b) - 1)
    return res

def comb(n, k):
    res = mod(math.factorial(n)) / mod(math.factorial(n - k)) / mod(math.factorial(k))
    return res

def mod(n):
    mod = 10 ** 9 + 7
    res = n % mod
    return res

if __name__ == "__main__":
    cin = input()
    n = int(cin.split(" ")[0])
    a = int(cin.split(" ")[1])
    b = int(cin.split(" ")[2])
    
    cout = main(n, a, b)
    print(cout)

Submission status: Wrong Answer

Solution code:
import sys

def comb_mod(n, r, mod):
  x = 1
  y = 1
  for i in range(r):
    x = (x * (n - i)) % mod
    y = (y * (i + 1)) % mod
    
  ans = x * pow_k(y, mod-2, mod)
  
  return ans % mod
  
  
def pow_k(x, n, mod):
  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 (x * K) % mod
  

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

if n == 2:
  print(0)
  sys.exit(0)

ans = pow_k(2, n, mod) - comb_mod(n,a,mod) - comb_mod(n,b,mod) - 1

if ans < 0:
  print(ans + 10**9+7)
else:
  print(ans % (10**9+7))

Submission status: Wrong Answer

Solution code:
n, a, b = map(int,input().split())
mod7 = 10 ** 9 + 7
def power(a,b,mod):
    p = 1
    q = a
    while b != 0:
        if b % 2 == 1:
            p = (p * q) % mod
        q = (q * q) % mod
        b = b // 2
    return p

def fact(n, mod):
    p = 1
    for i in range(1,n+1):
        p = (p * i) % mod
    return p

def divi(a,b,mod):
    p = (power(b, mod-2, mod) * a) % mod
    return p

def combi(n,a,mod):
    inv_af = power(fact(a,mod),mod-2,mod)
    p = 1
    for i in range(a):
        p = (p * (n-i)) % mod
    return inv_af * p % mod
    
Answer = power(2, n, mod7) - combi(n, a, mod7) - combi(n, b , mod7) - 1
print(Answer)

Submission status: Wrong Answer

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

for i in range(1,n+1):
    numbers.append(i)
numbers.remove(a)
numbers.remove(b)

if len(numbers) <= 0:
    print(0)
else:
    sum_kinds = 0
    for i in numbers:
        bunshi = 1
        for j in range(1, n+1):
            bunshi = bunshi * j
        bunbo1 = 1
        for j in range(1, i+1):
            bunbo1 = bunbo1 * j
        bunbo2 = 1
        for j in range(1, n-i+1):
            bunbo2 = bunbo2 * j
        a_kinds =bunshi/(bunbo1* bunbo2)
        sum_kinds = sum_kinds + a_kinds

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

Submission status: Wrong Answer

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

for i in range(1,n+1):
    numbers.append(i)
numbers.remove(a)
numbers.remove(b)

if len(numbers) <= 0:
    print('0')
else:
    sum_kinds = 0
    for i in numbers:
        bunshi = 1
        for j in range(1, n+1):
            bunshi = bunshi * j
        bunbo1 = 1
        for j in range(1, i+1):
            bunbo1 = bunbo1 * j
        bunbo2 = 1
        for j in range(1, n-i+1):
            bunbo2 = bunbo2 * j
        a_kinds =bunshi/(bunbo1* bunbo2)
        sum_kinds = sum_kinds + a_kinds

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

Submission status: Wrong Answer

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

for i in range(1,n+1):
    numbers.append(i)
numbers.remove(a)
numbers.remove(b)

if len(numbers) == 0:
    print('0')
else:
    sum_kinds = 0
    for i in numbers:
        bunshi = 1
        for j in range(1, n+1):
            bunshi = bunshi * j
        bunbo1 = 1
        for j in range(1, i+1):
            bunbo1 = bunbo1 * j
        bunbo2 = 1
        for j in range(1, n-i+1):
            bunbo2 = bunbo2 * j
        a_kinds =bunshi/(bunbo1* bunbo2)
        sum_kinds = sum_kinds + a_kinds

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

Submission status: Wrong Answer

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

for i in range(1,n+1):
    numbers.append(i)
numbers.remove(a)
numbers.remove(b)

if len(numbers) == 0:
    print('0')
else:
    sum_kinds = 0
    for i in numbers:
        bunshi = 1
        for j in range(1, n+1):
            bunshi = bunshi * j
        bunbo1 = 1
        for j in range(1, i+1):
            bunbo1 = bunbo1 * j
        bunbo2 = 1
        for j in range(1, n-i+1):
            bunbo2 = bunbo2 * j
        print(bunshi)
        print(bunbo1)
        print(bunbo2)
        a_kinds =bunshi/(bunbo1* bunbo2)
        sum_kinds = sum_kinds + a_kinds

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

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1,n+1):
    numbers.append(i)
numbers.remove(a)
numbers.remove(b)

if len(numbers) == 0:
    print('0')
else:
    sum_kinds = 0
    for i in numbers:
        a_kinds = math.factorial(n)/(math.factorial(i) * math.factorial(n-i))
        sum_kinds = sum_kinds + a_kinds

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

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1,n+1):
    numbers.append(i)
numbers.remove(a)
numbers.remove(b)

sum_kinds = 0
for i in numbers:
    a_kinds = math.factorial(n)/(math.factorial(i) * math.factorial(n-i))
    sum_kinds = sum_kinds + a_kinds
    
print(sum_kinds % (10**9+7))

Submission status: Wrong Answer

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

def func_156d(n, r):
    r =min(r, n-r)
    numerator = 1
    denominator = 1
    
    for i in range(n-r+1, n+1):
        numerator = numerator * i % mod
        
    for i in range(1, r+1):
        denominator = denominator * i % mod
        
    return numerator * pow(denominator, mod-2, mod) %mod

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

Submission status: Wrong Answer

Solution code:
#156D

def comb(n,r,p=7+10**9):
  bunshi = 1
  for i in range(n-r+1, n+1):
    bunshi =bunshi * i % p
  bunbo = 1
  for i in range(1, r+1):
    bunbo = bunbo * i % p
  return bunshi * pow(bunbo, p-2, p)
n,a,b=map(int,input().split())
s=-2+2**n-comb(n,a)-comb(n,b)
print(s%(7+10**9))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

n, a, b = (int(val) for val in input().split())


ans = 1
noa = 1
nob = 1
mod = 1000000007
kaijo = 1
for i in range(n):
    ans *= 2
    ans %= mod
    if i < a:
        noa *= (n - i)
        noa %= mod
    if i == a - 1:
        noa /= kaijo
    if i < b:
        kaijo *= i + 1
        kaijo %= mod
        nob *= (n - i)
        nob %= mod
    if i == b - 1:
        nob /= kaijo
ans -= 1

# ans = ans - noa - nob
# while ans < 0:
#     ans += mod
print((ans - noa - nob) % mod)

Submission status: Wrong Answer

Solution code:
mod = 1e9 + 7

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

def dv(x, y):
    return x * pw(y, mod - 2) % mod

def comb(n, r):
    v = 1
    if n < r or n < 0 or r < 0: return 0
    r = min(r, n - r)
    for i in range(r):
        v = v * dv(n - i, i + 1) % mod
    return v

n, a, b = map(int, input().split())
ans = pw(2, n) - 1 + mod * 10
if a <= n: ans -= comb(n, a)
if b <= n: ans -= comb(n, b)
print(ans % mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,a,b = np.array(input().split()).astype(int)
mod = 10**9+7
import math
def power(x, n):
    ans = 1
    while(n > 0):
        if(bin(n & 1) == bin(1)):
            ans = ans*x%mod
        x = x*x%mod
        n = n >> 1 #ビットシフト
    return ans
def fact(m, n):
    return int(np.prod(range(m,n+1)))
def cmb1(N, r):
    A = fact(N-r+1, N)
    B = math.factorial(r)
    return A, B, (A*power(B, mod-2))%mod
def cmb2(a, b, A, B):
    A = fact(N-a+1, N-b)*A
    B = fact(b+1, a)*B
    return (A*power(B, mod-2))%mod
if(a>N//2):
    a = N-a
if(b>N//2):
    b = N-b
tmp = max(a,b)
b = min(a,b)
a = tmp
A, B, K1 = cmb1(N, b)
K2 = cmb2(a, b, A, B)
print((power(2, N)-1-K1-K2)%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
N,a,b = np.array(input().split()).astype(int)
mod = 10**9+7
import math
def power(x, n):
    ans = 1
    while(n > 0):
        if(bin(n & 1) == bin(1)):
            ans = ans*x%mod
        x = x*x%mod
        n = n >> 1 #ビットシフト
    return ans
def fact(m, n):
    val = 1
    for i in range(m, n + 1):
        val = (val*i)%mod
    return val
def cmb1(N, r):
    A = fact(N-r+1, N)
    B = math.factorial(r)
    return A, B, (A*power(B, mod-2))%mod
  
def cmb2(a, b, A, B):
    A = fact(N-a+1, N-b)*A
    B = math.factorial(a-b)*B
    return (A*power(B, mod-2))%mod
if(a>N//2):
    a = N-a
if(b>N//2):
    b = N-b
tmp = max(a,b)
b = min(a,b)
a = tmp
A, B, K1 = cmb1(N, b)
K2 = cmb2(a, b, A, B)
print((power(2, N)-1-K1-K2)%mod)

Submission status: Wrong Answer

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

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

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

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

    return sss

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

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

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

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
N,a,b = np.array(input().split()).astype(int)
mod = 10**9+7
def power(x, n):
    ans = 1
    while(n > 0):
        if(bin(n & 1) == bin(1)):
            ans = ans*x
        x = x*x%mod
        n = n >> 1 #ビットシフト
    return ans
def fact(m, n):
    val = 1
    for i in range(m, n + 1):
        val = (val*i)%mod
    return val
def cmb(N, r):
    A = fact(N-r+1, N)
    B = math.factorial(r)
    A = (A*power(B, mod-2))%mod
    return A
print((power(N, 2)-1-cmb(N, a)-cmb(N, b))%mod)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
N,a,b = np.array(input().split()).astype(int)
mod = 10**9+7
def power(x, n):
    ans = 1
    while(n > 0):
        if(bin(n & 1) == bin(1)):
            ans = ans*x
        x = x*x%mod
        n = n >> 1 #ビットシフト
    return ans
def fact(m, n):
    val = 1
    for i in range(m, n + 1):
        val = (val*i)%mod
    return val
def cmb(N, r):
    A = fact(N-r, N)
    B = math.factorial(r)
    A = (A*power(B, mod-2))%mod
    return A
print((power(N, 2)-1-cmb(N, a)-cmb(N, b))%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
import math
N,a,b = np.array(input().split()).astype(int)
2**N-1-math.factorial(N)/(math.factorial(a)*math.factorial(N-a))-math.factorial(N)/(math.factorial(b)*math.factorial(N-b))

Submission status: Wrong Answer

Solution code:
import math
def Bouquets(n, a, b):
  bouquets = 2 ** n - nCx(n, a) - nCx(n, b)
  return bouquets
  
def nCx(n, x):
  numerator = math.factorial(n) / math.factorial(n - x)
  denominator = math.factorial(x)
  return int(numerator / denominator)

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

Submission status: Wrong Answer

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

mod = 10**9+7

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

def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

sum = pow(2,n,mod)
case = combination(n,a,mod) + combination(n,b,mod) + 1
ans = sum-case
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 comb(n, r, mod) :
    ans1 = 1
    ans2 = 1
    for i in range(r) :
        ans1 *= n-i
        ans2 *= i+1
    return ans1 * pow(ans2, mod-2, mod)

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

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

    ans = pow(2, n, MOD)-combination_with_mod(n, a)-combination_with_mod(n, b)-combination_with_mod(n, 0)

    if ans < 0:
        print(MOD+ans)
    else:
        print(ans%MOD)

    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:
#!/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

    ans = pow(2, n, MOD)-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:
N, A, B = map(int, input().split())
ten = pow(10, 9) + 7
print(ten)

Submission status: Wrong Answer

Solution code:
def pow(x, n, mod):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x % mod
    x = x*x % mod
    n = n >> 1
  return ans

def kaijou_k(n, k, mod):
    a = 1
    for i in range(k, n+1):
        a *= i
        a %= mod
    return a %mod

def main():
    n, a, b = map(int, input().split())
    mod = 10**9 +7
    allsum = pow(2, n, mod)-1
    abunbo = kaijou_k(n, n-a+1, mod)
    abunsi = kaijou_k(a, 1, mod)
    asum = abunbo * pow(abunsi, mod-2, mod) % mod
    bbunbo = kaijou_k(n, n-b+1, mod)
    bbunsi = kaijou_k(b, 1, mod)
    bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod
    ans = (allsum - asum - bsum) % mod
    print(ans, asum, bsum)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def pow(x, n, mod):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x % mod
    x = x*x % mod
    n = n >> 1
  return ans

def kaijou_k(n, k, mod):
    a = 1
    for i in range(k, n+1):
        a *= i
        a %= mod
    return a

def kaijou2(n, k, mod):
    nu, de = 1, 1
    for i in range(1, k+1):
        nu *= (k-i+1)
        nu %= mod
        de *= i
        de %= mod
    return nu * pow(de, mod-2, mod) % mod


def main():
    n, a, b = map(int, input().split())
    mod = 10**9 +7
    allsum = pow(2, n, mod)-1
    abunbo = kaijou_k(n, n-a+1, mod)
    abunsi = kaijou_k(a, 1, mod)
    asum = abunbo * pow(abunsi, mod-2, mod) % mod
    bbunbo = kaijou_k(n, n-b+1, mod)
    bbunsi = kaijou_k(b, 1, mod)
    bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod
    # asum = kaijou2(n, a, mod)
    # bsum = kaijou2(n, b, mod)
    ans = allsum - asum - bsum
    print(ans)
    print(allsum)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

MOD = 1000000000+7

def two(a,n): #繰返し二乗法
    mul = a
    b = 1
    while n >= 1:
        if n & 1:
            b = b * mul % MOD
        n = n >> 1
        mul **= 2
        mul %= MOD
    return b

def inverse(a): #逆元を求める
    return two(a,MOD-2)

def comb(n,r): #コンビネーション
    ans = 1
    for i in range (r):
        ans *= (n-i) * inverse(i+1) % MOD
        ans %= MOD
    return ans

sum = two(2,n)
case = comb(n,a) + comb(n,b) + 1
ans = sum-case
if ans < 0 :
    ans += MOD

print(ans)

Submission status: Wrong Answer

Solution code:
lis=list(map(int,input().split()))
a=1
for i in range(lis[0]):
  a*=(i+1)
b=1
c=1
for i in range(lis[1]):
  b*=(lis[0]-i+1)
for i in range(lis[2]):
  c*=(lis[0]-i+1)
  
print(a-b-c)

Submission status: Wrong Answer

Solution code:
def pow(x, n, mod):
  ans = 1
  while(n > 0):
    if(bin(n & 1) == bin(1)):
      ans = ans*x % mod
    x = x*x % mod
    n = n >> 1
  return ans

def kaijou_k(n, k, mod):
    a = 1
    for i in range(k, n+1):
        a *= i % mod
    return a

def main():
    n, a, b = map(int, input().split())
    mod = 10**9 +7
    allsum = pow(2, n, mod)-1
    abunbo = kaijou_k(n, n-a+1, mod)
    abunsi = kaijou_k(a, 1, mod)
    asum = abunbo * pow(abunsi, mod-2, mod) % mod
    bbunbo = kaijou_k(n, n-b+1, mod)
    bbunsi = kaijou_k(b, 1, mod)
    bsum = bbunbo * pow(bbunsi, mod-2, mod) % mod
    ans = allsum - asum - bsum
    #print(allsum, asum, bsum, ans)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

mod=10**9+7
def qsq(n,b=2,rtn=2):
  if n==1:
    return rtn
  else:
    if n%2==0:
      return qsq(n//2,b**2,rtn**2)%mod
    else:
      return qsq(n-1,b,rtn*b)%mod

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

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
import math
def comb(n,k):
  return math.factorial(n)//math.factorial(k)//math.factorial(n-k)
mod=10**9+7
def qsq(n,b=2,rtn=2):
  if n==1:
    return rtn
  else:
    if n%2==0:
      return qsq(n//2,b**2,rtn**2)%mod
    else:
      return qsq(n-1,b,rtn*b)%mod
  
print(qsq(n)-1-comb(n,a)-comb(n,b))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import sys

def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    return
    print(*args, **kwargs)


def choose(a, b, mod):
    numer, denomi = 1, 1 
    for i in range(0, b):
        denomi = (denomi * (i + 1)) % mod
        numer = ((a - i) * numer) % mod
    return (numer * pow(denomi, mod - 2, mod)) % mod


def main():
    mod = 1000000007
    n, a, b = read_int_list()
    ans = pow(2, n, mod)
    ans -= 1  # case for zero flowers
    ans -= choose(n, a, mod)
    ans -= choose(n, b, mod)
    if ans < 0:
        ans += mod
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
m=10**9+7
def com(n,k,m):
  p,q=1,1
  for i in range(n-k+1,n+1):
    p*=i
    p%=m
  for i in range(1,k+1):
    q*=i
    q%=m
  return p*pow(q,m-2,m)%m
ca,cb=com(n,a,m),com(n,b,m)
ans=(pow(2,n,m)-1-ca-cb)%m

Submission status: Wrong Answer

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

N = 10 ** 6
inv = [1] * N
for i in range(2, N):
    inv[i] = -inv[mod % i] * (mod // i)
    inv[i] %= mod


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


ans = total - 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())
m=10**9+7
def com(n,k,m):
  p,q=1,1
  for i in range(n-k+1,n+1):
    p*=i
    p%=m
  for i in range(1,k+1):
    q*=i
    q%=m
  return p*pow(q,m-2,m)%m
ca,cb=com(n,a,m),com(n,b,m)
ans=(pow(2,n,m)-ca-cb)%m

Submission status: Wrong Answer

Solution code:
n,a,b=map(int,input().split())
m=10**9+7
def com(n,k,m):
  p,q=1,1
  for i in range(n-k,n+1):
    p*=i
    p%=m
  for i in range(1,k+1):
    q*=i
    q%=m
  return p*pow(q,m-2,m)%m
ca,cb=com(n,a,m),com(n,b,m)
ans=(pow(2,n,m)-ca-cb)%m

Submission status: Wrong Answer

Solution code:
def comb(n_, k_, mod_=10**9+7):
    ans_ = 1
    for i in range(1,k_+1):
        ans_ *= ((n_+1-i)/i)
        ans_ = ans_%mod_
    return round(ans_//1%mod_)

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

for i in [a,b]:
    tmp = comb(n,i)
    if ans_tmp < tmp:
        ans_tmp += mod
    ans_tmp -= tmp
print(ans_tmp%mod)

Submission status: Wrong Answer

Solution code:
def comb(n_, k_, mod_=10**9+7):
    ans_ = 1
    for i in range(1,k_+1):
        ans_ *= ((n_+1-i)/i)
        ans_ = ans_%mod_
    return round(ans_//1%mod_)

n,a,b = map(int, input().split())
ans_tmp = (2**n-1)#%mod

for i in [a,b]:
    tmp = comb(n,i)
    ans_tmp -= tmp
print(ans_tmp%(10**9+7))