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
kinds = 0

def mod_factorial(nr, nl, m):
    r = 1
    for i in range(nl+1, nr+1):
        r *= i
        r %= m
    return r

def mod_inv_factorial(n1, n2, m):
    n = max(n1, n2)
    invs = [0] * (n + 1)
    invs[1] = 1
    for i in range(2, n + 1):
        invs[i] = m - invs[m % i] * (m//i) % m

    r1 = r2 = 1
    for i in range(1, n+1):
        r1 *= invs[i]
        r1 %= m
        if i == min(n1, n2):
            r2 = r1
    if n1 > n2:
        return r1, r2
    else:
        return r2, r1

kinds = 2 ** n -1

la = max(a, n-a)
sa = min(a, n-a)
lb = max(b, n-b)
sb = min(b, n-b)

upper1 = mod_factorial(n, la, mod)
upper2 = mod_factorial(n, la, mod)

r1, r2 = mod_inv_factorial(sa, sb, mod)

print((kinds - upper1 * r1 - upper2 * r2)% mod)
t = 0

Submission status: Wrong Answer

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


def modInverse(a, p):
    return pow(a, p-2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % p

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p

def solve(n: int, a: int, b: int):
    p = 10**9+7
    ans = pow(2, n, p) - modBinomial(n, a, p) - modBinomial(n,b,p)
    if ans < 0:
        ans += p
    if ans <= 0:
        print(0)
    else:
        print(ans-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
import sys
import itertools
f = sys.stdin
n, a, b = map(int, f.readline().split(' '))
result = pow(2, n)
print(result)
c_a = len(list(itertools.combinations(range(n), a)))
print(c_a)
c_b = len(list(itertools.combinations(range(n), b)))
print(c_b)

result = result - c_a - c_b - 1

print(result)

Submission status: Wrong Answer

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

def kaijo(n, c):
    bo, shi = 1, 1
    for j in range(c):
        bo *= n-j
        shi *= j+1
    return bo // shi

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

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

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

#def combinations_count(n, r):
#    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
mod = 10 ** 9 + 7
n, a, b = map(int, input().split())

sn = math.floor(math.sqrt(n))
#H = [0 for _ in range(n+1)]
sub = [0 for _ in range(2)]

if a > sn :
  a = n-a
if b > sn :
  b = n-b


ni = n
ri = 1
nsum = n
rsum = 1
sum = 0
snv = 0
for i in range(1, sn+1) :
  if i == a :
    sub[0] = nsum // rsum
  if i == b :
    sub[1] = nsum // rsum
  if i == sn :
    snv = nsum // rsum
    
  sum += nsum // rsum
  nsum *= ni-i
  rsum *= ri+i

sum *= 2
#print (sum)
if n % 2 == 0 :
  sum -= snv
sum += 1
#print (sum)
#print(sub)
if a == sn :
  sum -= sub[0]
else :
  sum -= sub[0]*2
#print (sum)
if a != b :
  if b == sn :
    sum -= sub[1]
  else :
    sum -= sub[1]*2
#print (sum)
print (sum%mod)

Submission status: Wrong Answer

Solution code:
l = [int(i) for i in input().split()]
n = l[0]
a = l[1]
na = 0
b = l[2]
nb = 0
mn = n//2
flag = 0
ans = 1
amt = 1
if n%2 == 0:
    flag = 1
if a>mn:
    a -= mn
if b >mn:
    b -= mn
for i in range(1,mn+1):
    amt *= (n-i+1)/i
    if i == a:
        na = amt
    if i == b:
        nb = amt
    ans += amt
if flag == 1:
    ans -= amt
    ans *= 2
    ans += amt
else:
    ans *=2
ans -= na+nb+1
print(ans)

Submission status: Wrong Answer

Solution code:
import math

n, a, b = map(int, input().split())
mod = 10**9 + 7
#
# def cc(n, r):
#     return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

def conv(n, k):
    amari = []
    while n != 0:
        amari.append(n % k)
        n = n // k
    # amari.reverse()
    return amari

nn = conv(n, 2)

n2 = 1
for n in nn:
    n2 *= (2**(2**n))%mod
print('nn', nn)
print('n2', n2)

# po_2 = list(map(int, str(bin(n))[2:]))
# print('po2:', po_2)
# n22 = 1
# for p in po_2:
#     n22 *= (2**(2**p))%mod
# print('n22', n22)


xx = cmb(n, a)%mod + cmb(n, b)%mod
cn = n2 - cmb(n, 0)%mod

print(cn-xx)

Submission status: Wrong Answer

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


def modInverse(a, p):
    return pow(a, p-2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % p

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p

def solve(n: int, a: int, b: int):
    p = 10**9+7
    ans = pow(2, n, p) - modBinomial(n, a, p) - modBinomial(n,b,p)
    if ans < 0:
        ans += p
    if ans == 0:
        print(ans)
    else:
        print(ans-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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:
def comb(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
def cmb(n, r):
    if n - r < r:
      r = n - r
    if r == 0: 
      return 1
    if r == 1: 
      return n
    numerator = [] 
    mod = 10**9+7
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= mod

    return result
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
n, a, b = map(int, input().split())
mod = 10**9+7
ALL = power_func(2,n,mod)-1
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 
if n > 10**3:
  A = cmb(n, a) % mod
  B = cmb(n, b) % mod
else:
  for i in range( 2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
  A = comb(n,a,mod)
  B = comb(n,b,mod)
ans = ALL-A-B
if ans < 0:
  ans = mod + ans
print(ans)

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def cmb(n, r, p):
  a=1
  for i in range(r):
    a*=n
    a%=mod
    n-=1
  b=1
  for i in range(1,r+1):
    b*=i
    b%=mod

  inv_b=mod_inv(b,mod)
  # print(a,inv_b)
  return a*inv_b

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%=mod
        x *= x
        n //= 2
        x%=mod

    return (K * x)%mod

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
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def main():
  n,a,b=LI()
  if n==2:
    return 0

  ans=pow_k(2,n)

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

  if ans<0:
    ans+=mod

  return ans-1

# main()
print(main())

Submission status: Wrong Answer

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

mod = 10**9+7
ans = 0
tmp_a = 1
tmp_b = 1

for i in range(1,n):
    tmp_a = (tmp_a * (n - i + 1)) % mod
    tmp_b = (i * tmp_b) % mod
    r = int(tmp_a / tmp_b)
    if (i != a) and (i != b):
        ans = (ans + r) % mod

print(ans)

Submission status: Wrong Answer

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

dp_n = 2 ** n - 1
dp_a = 2 ** (n-a) - 1
dp_b = 2 ** (n-b) - 1

print((dp_n - dp_a - dp_b) % (10**9 + 7))

Submission status: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

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

    __repr__ = __str__

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

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

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

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

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

    __radd__ = __add__

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

    __rmul__ = __mul__

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

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


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


def f(p):
    if p == 0:
        return ModInt(1)
    if p % 2 == 0:
        t = f(p // 2)
        return t * t
    return 2 * f(p // 2)


nC = [ModInt(1)]
for i in range(1, 200005):
    nC.append(nC[-1] * (n - i + 1) / i)
# print(nC[-10:])

print((f(n) - nC[a] - nC[b] - 1))

Submission status: Wrong Answer

Solution code:
line = input('')
n = int(line.split(' ')[0])
a = int(line.split(' ')[1])
b = int(line.split(' ')[2])

sum_case = 0
for i in range(1,n):
  if i != a and i != b:
    c = n * (n-1) / 2
    sum_case += c

all_case = 10**9+7
print((sum_case+1) % all_case)

Submission status: Wrong Answer

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def cmb(n, r, p):
  a=1
  for i in range(r):
    a*=n
    a%=mod
    n-=1
  b=1
  for i in range(1,r+1):
    b*=i
    b%=mod

  inv_b=mod_inv(b,mod)
  # print(a,inv_b)
  return a*inv_b

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%=mod
        x *= x
        n //= 2
        x%=mod

    return (K * x)%mod

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
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def main():
  n,a,b=LI()
  if n==2:
    return 0

  ans=pow_k(2,n)

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

  if ans<0:
    ans+=mod

  return ans

# main()
print(main())

Submission status: Wrong Answer

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

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

sum_num = 0
for r in range(1,n+1):
  if r==a or r==b: continue
  sum_num =+ cmb(n,r)%mod

print(sum_num%mod)

Submission status: Wrong Answer

Solution code:
import numpy as np
n, a, b = map(int, input().split())
a, b = min(a, b), max(a, b)
MOD = 10**9 + 7
v = pow(2, n, MOD) - 1


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5 + 1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n - 1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n - 1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64)
    x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv


# a / b = (a % N * pow(b, N - 2, N)) % N(mod=N)
fact, fact_inv = make_fact(2 * 10**5 + 1, MOD)
# print(fact)
# a_fact = fact[a]
# b_fact = fact[b]

n_fact = [n] * (b + 1)
for i in range(1, b + 1):
    n_fact[i] = (n_fact[i - 1] * (n - i)) % MOD
an_fact = n_fact[a - 1]
bn_fact = n_fact[b - 1]
# print('an a_fact', an_fact, a_fact)
# print('bn b_fact', bn_fact, b_fact)
# print('an a_fact', an_fact)
# print('bn b_fact', bn_fact)


def f(a, b, MOD):
    a, b = int(a), int(b)
    return (a % MOD * pow(b, MOD - 2, MOD)) % MOD


ca = an_fact
for i in range(1, a + 1):
    ca = f(ca, i, MOD)

cb = bn_fact
for i in range(1, b + 1):
    cb = f(cb, i, MOD)

# ca = f(an_fact, a_fact, MOD)
# cb = f(bn_fact, b_fact, MOD)
# print('v, ca, cb', v, ca, cb)
print(v - ca - cb)

Submission status: Wrong Answer

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, factorial
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


yn = 'YNeos'
ynflg = False
cnt = 0
ans = None

def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

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



NUM = (10**9) + 7
def modpow(n):
    a = 2
    res = 1
    while n > 0:
        if (n & 1) == 1:
            res = res * a % NUM
        a = a * a % NUM
        n >>= 1

    return res;

n, a, b = mulinputs()

a1 = modpow(a) - 1
a1 %= NUM
b1 = modpow(b) - 1
b1 %= NUM
n1 = modpow(n) - 1
n1 = n1 - a1 - b1
print(n1%NUM)

Submission status: Wrong Answer

Solution code:
MOD = 10 ** 9 + 7


class ModInt:
    def __init__(self, x):
        self.x = x % MOD

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

    __repr__ = __str__

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

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

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

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

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

    __radd__ = __add__

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

    __rmul__ = __mul__

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

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


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


def f(p):
    if p == 0:
        return ModInt(1)
    if p % 2 == 0:
        t = f(p // 2)
        return t * t
    return 2 * f(p // 2)


nC = [ModInt(1)]
for i in range(1, 200005):
    nC.append(nC[-1] * (n - i + 1) / i)
print(nC[-10:])

print((f(n) - nC[a] - nC[b] - 1))

Submission status: Wrong Answer

Solution code:

import math
import itertools

if __name__ == "__main__":
    n, a, b = map(int, input().split())
    ret = 0
    n_fact = math.factorial(n) 
    print(n_fact)
    n_all = len(list(itertools.combinations(list(range(n)), n)))
    print(n_all)
    npk_a = math.factorial(n - a)
    print(npk_a)
    npk_b = math.factorial(n - b)
    print(npk_b)
    kind = n_all - npk_a - npk_b
    print(kind)
    x = 10**9 + 7
    ret = kind % x
    print(ret)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

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

n, a, b = read_int()
M = pow(10, 9) + 7

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


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

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
n,a,b = map(int,input().split())
result = 0


tmp_res = comb(n, 1, exact=True) % (10**9+7)
result += tmp_res

if n % 2 == 1:
	for i in range(2,(n+1)//2):
		tmp_res = (n-(i-1)) * tmp_res // i % (10**9+7)
		result += tmp_res
	result *= 2

else:
	for i in range(2,n//2):
		tmp_res = (n-(i-1)) * tmp_res // i % (10**9+7)
		result += tmp_res
	result *= 2
	result += comb(n, n//2, exact=True) % (10**9+7)

result -= (comb(n, a, exact=True) + comb(n, b, exact=True)) % (10**9+7)

print( (result+1) % (10**9+7) )

Submission status: Wrong Answer

Solution code:
N,a,b=map(int,input().split())
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
ans=0
for i in range(N//2+1):
  ans+=cmb(N,i)%(10**9+7)

ans%=10**9+7
ans-=cmb(N,a)%(10**9+7)
if a+b!=N:
  ans-=cmb(N,b)%(10**9+7)
print(ans)

Submission status: Wrong Answer

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

up = 1
down = 1
ans = 0
mod = 10 ** 9 + 7

for i, o in zip(range(1, n//2 + 1), range(n, 0, -1)):
    up = (up%mod) * (o%mod)
    down = (down%mod) * (i%mod)
    if (i != a) and (i != b):
        ans += up/down
        ans %= mod
 
    if i != (n - i):
        if ((n - i) != a) and ((n - i) != b):
            ans += up/down
            ans %= mod
  

if (n != a) and (n != b):
    ans += 1
print(ans%mod)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
n,a,b = map(int,input().split())
result = 0


tmp_res = comb(n, 1, exact=True) % (10**9+7)
print(1,tmp_res)
result += tmp_res

if n % 2 == 1:
	for i in range(2,(n+1)//2):
		tmp_res = (n-(i-1)) * tmp_res // i % (10**9+7)
		result += tmp_res
		print(i, tmp_res)
	result *= 2

else:
	for i in range(2,n//2):
		tmp_res = (n-(i-1)) * tmp_res // i % (10**9+7)
		result += tmp_res
		print(i, tmp_res)
	result *= 2
	result += comb(n, n//2, exact=True) % (10**9+7)

result -= (comb(n, a, exact=True) + comb(n, b, exact=True)) % (10**9+7)

print( (result+1) % (10**9+7) )

Submission status: Wrong Answer

Solution code:
from math import factorial

n, a, b = [int(_) for _ in input().split()]
total = 0
length = n//2
for i in range(length):
    max = n-i
    r = i+1
    if not (r == a or r == b):
        # 小さい値から
        total += factorial(n) // factorial(r) // factorial(n - r)
    if not (max == a or max == b):
        # 大きい値から
        total += factorial(n) // factorial(max) // factorial(n - max)

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

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
x = n-a
y = n-b
a = min(a,x)
b = min(b,y)
fa = 1
for i in range(n,n-a,-1):
  fa*=i
  fa%=mod
a_mi = fa
fa = 1
for i in range(n,n-b,-1):
  fa*=i
  fa%=mod
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+1)

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
x = n-a
y = n-b
a = min(a,x)
b = min(b,y)
fa = 1
for i in range(n,n-a,-1):
  fa*=i
  fa%=mod
a_mi = fa
fa = 1
for i in range(n,n-b,-1):
  fa*=i
  fa%=mod
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-1)

Submission status: Wrong Answer

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


def modInverse(a, p):
    return pow(a, p-2, p)

def modBinomial(n, k, p):
    numerator = 1
    for i in range(k):
        numerator = (numerator * (n-i)) % p

    denominator = 1
    for i in range(1, k+1):
        denominator = (denominator * i) % p

    return (numerator * modInverse(denominator, p)) % p

def solve(n: int, a: int, b: int):
    p = 10**9+7
    ans = pow(2, n, p) - modBinomial(n, a, p) - modBinomial(n,b,p)
    if ans < 0:
        ans += p
    print(ans-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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())

from scipy.misc import comb
"""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

mod = 10**9+7 #出力の制限
N = 10**4
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 )
"""
mod = 10**9 + 7 
r = 0
ans = 2 ** n 
ans = ans - (comb(n,a,exact=True)+comb(n,a,exact=True)+1)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

n, a, b = na()
k = n - 1
ans = k * (k + 1)# (k * (k + 1) * (2 * k + 1) // 6)
ans %= 1000000007
ans *= 2 * k + 1
ans %= 1000000007
ans //= 6
ans %= 1000000007
ans += (k * (k + 1) // 2)
ans %= 1000000007
ans //= 2
ans %= 1000000007
ans += k + 1
ans %= 1000000007
if a == 1:
    ans -= n
    ans %= 1000000007
else:
    l = (n - a + 1) * ((n - a + 1) + 1) // 2
    l %= mod
    ans -= l
    ans %= 1000000007
l = (n - b + 1) * ((n - b + 1) + 1) // 2
l %= mod
ans -= l
ans %= 1000000007
print(ans)

Submission status: Wrong Answer

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

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

sum_num = 0
for r in range(1,n+1):
  if r==a or r==b: continue
  a = cmb(n,r)%mod
  sum_num =+ a

print(sum_num%mod)

Submission status: Wrong Answer

Solution code:
nab = input().split()
n = int(nab[0])
a = int(nab[1])
b = int(nab[2])

ans = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    tp = 1
    for j in range(n, 1, -1):
        if j > i:
            tp *= j
        else:
            tp /= j
    ans += tp
ans = round(ans % (10**9 + 7))
print(ans)

Submission status: Wrong Answer

Solution code:
def main():
    n, a, b = map(int, input().split(" "))
    num = 0
    count = 0
    for i in range(2, 2**n):
        for j in range(n):
            if ((i >> j) & 1):
                num += 1
        if (num != a and num !=b):
            # print(num, bin(i))
            count+= 1
        num = 0
    print(count % (10**9 + 7))



def power(x, p):
    return (x - p)**2

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n, a, b = map(int, input().split())
a = n-a+1
b = n-b+1
cult = n+1
culd = 0
ans = 0
plus = 1
for i in range(4, 0, -1) :
    cult -= 1
    culd +=1
    plus = plus*cult/culd
    if i == a or i == b :
        continue
    if plus > 1000000007 :
        ans += plus % (10**9+7)
    else :
        ans += plus
    if ans >= 1000000007:
        ans %= 1000000007
ans2 = ans % (10**9/7)
print(int(ans2))

Submission status: Wrong Answer

Solution code:
def ruijo(n, l, mod):
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

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

mod = 10**9+7 #出力の制限
N = 10**6
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 )

def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

mod = 10**9+7 #出力の制限
    
n,a,b = map(int, input().split())
ans = power(2,n,mod) - 1 - cmb(n, a, mod) - cmb(n ,b ,mod)
if ans < 0:
    ans += mod
if ans < 0:
    ans += mod
print(ans)

Submission status: Wrong Answer

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

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

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

ans = 0
for i in range(0,a[0]):
    if(i != a[1] and i != a[2]):
            ans += cmb(a[0],i)
            #print("ans:%d"%(ans))
        
print(ans%(10**9+7))

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 = [] 
    mod = 10**9+7
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
            result %= mod

    return result
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
n, a, b = map(int, input().split())
mod = 10**9+7
ALL = power_func(2,n,mod)-1
A = cmb(n, a)%mod
B = cmb(n, b)%mod
ans = ALL-A-B
if ans < 0:
  ans = mod + ans
print(ans)