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:
nab = input().split()
n = int(nab[0])
a = int(nab[1])
b = int(nab[2])

ans = 0
for i in range(1, round(n/2)+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
    if i%2 == 1:
        tp /= 2
    ans += tp
ans *= 2
ans = round(ans % (10**9 + 7))
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,a,b = map(int,input().split())
    def bigcomb(n,r):
        r = min(r,n-r)
        ans = 1
        for i in range(1,r+1):
            ans *= (n-i+1)/i
            ans %= Mod
        return int(ans)
    i1 = bigcomb(n,a)
    i2 = bigcomb(n,b)
    def log_two_integer(i):
        if i // 2 == 0:
            return 0
        else:
            return 1 + log_two_integer(i//2)
    p = log_two_integer(n)
    print(p,i1,i2)
    i = 1
    def pow(x, n):
        ans = 1
        while(n > 0):
            if(bin(n & 1) == bin(1)):
                ans = ans*x
                ans %= Mod
                x = x*x
                n = n >> 1
        return ans
    ans = pow(2,n)

    print(ans,(ans - i1 - i2 - 1)%Mod)
#endline===============================================
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def combi(n, r):
    p = 1
    for i in range(1, r+1):
        p = p * (n-i+1) // i
    return p

n, a, b = [int(n) for n in input().split()]
c = 0
m = 0
d = 10**9+7
if n%2==0:
    for i in range(0, n//2):
        print(i)
        c = c + combi(n,i) * 2 
    c += combi(n, n//2)
else:
    for i in range(0, n//2+1):
        c = c + combi(n,i) * 2
m += combi(n, a)
m += combi(n, b)
m += 1
print((c-m)%d)

Submission status: Wrong Answer

Solution code:
def pow(x, y):
    if y == 0:
        return 1
    if y % 2 == 0:
        ans = pow(x ** 2 % INF, y // 2)
    else:
        ans = (pow(x ** 2 % INF, y // 2) * x) % INF
    return ans

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

ans = pow(2, n) - 1
atmp = pow(2, a) - 1
btmp = pow(2, b) - 1
x = INF + ans
ax = INF + atmp
bx = INF + btmp
x = x - ax - bx

print(x % INF)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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


#N = math.factorial(n)

Factorial_list = []
#Factorial_list.append(1)
for i in range(n+1):
    if(i == 0):
        Factorial_list.append(1)
    else:
        Factorial_list.append(Factorial_list[i-1] * i)

N = Factorial_list[n]
#print(Factorial_list)

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


def combinations_count2(n, r):
    return N // (Factorial_list[n-r] * Factorial_list[r])

sum=0
previous = 1
for i in range(n):
    if i == a:
        continue
    if i == b:
        continue
    sum += combinations_count2(n,i)

answer = sum % (pow(10,9) + 7)

print(answer)

Submission status: Wrong Answer

Solution code:
n,a,b = map(int,input().split())
mod = 1000000007
factorial = [1]

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]  # 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)

# print(cmb(4,2, mod))

def modpow(x,e,mod):
    a = 1
    p = x
    while e>0:
        if e%2 ==0:
            p*=p%mod
            e/=2
        else:
            a*=p%mod
            e-=1

    return a

ans = modpow(2,n,mod) - cmb(n,a,mod) - cmb(n,b,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 = [] 
    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)
B = cmb(n, b)
ans = ALL-A-B
if ans < 0:
  ans = mod + ans
print(ans)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb

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

total = 0
for i in range(n):
  if not (i == a or i == b):
    total += comb(n, i, exact=True)
print(total)

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):
  a = cmb(n,r)%mod
  sum_num =+ a

print(sum_num%mod)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from math import sqrt,factorial
from operator import mul
from functools import reduce
def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
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+=combinations_count(N,i)
print(ans%(10**9+7))

Submission status: Wrong Answer

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

c=c-(math.factorial(n)//(math.factorial(n - a) * math.factorial(a)))%(pow(10,9)+7)
c=c-(math.factorial(n)//(math.factorial(n - b) * math.factorial(b)))%(pow(10,9)+7)
print(c)
#TLE

Submission status: Wrong Answer

Solution code:
def calc(a,b,p):
    if(b==0):
        return 1
    elif b % 2 == 0 :
        d = calc(a,b/2, p)
        return (d*d)%p
    else:
        return (a * calc(a, b - 1, p)) % p

M = 10**9+7

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

res = 0
for i in range(1,n):
    if i == a or i == b:
        continue
    res += calc(n,i,M)

print(res)

Submission status: Wrong Answer

Solution code:
a,b,c=map(int,input().split())
print(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)

Submission status: Wrong Answer

Solution code:
s = list(map(int, input().split()))

N = s[0]
a = s[1]
b = s[2]

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

x = 0
for i in range(N):
  if i == a or i == b:
    pass
  else:
    x += cmb(N, i)
    
print(x % (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)
B = cmb(n, b)
ans = ALL-A-B
if ans < 0:
  ans = mod + ans
print(ans)

Submission status: Wrong Answer

Solution code:
import math


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

res = 2 ** n - 1

dpa = {}
dpb = {}

factriala = 1
factrialb = n
for i in range(1, min(2*(10**5), n)+1):
  dpb[i] = factrialb
  factriala *= i
  factriala %= MOD
  factrialb *= n-i
  factrialb %= MOD
  dpa[i] = factriala

def ncr_count(r):
  return dpb[r] // dpa[r]

res = res - ncr_count(a) - ncr_count(b)

print(res%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(a, n):
        if not n:
            return 1
        x = power(a, n >> 1)
        x *= x
        return a * x if n & 1 else x

    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%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:
from math import factorial
def cmb(N2,n,r):
  return N2 / factorial(r) / factorial(n - r)

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


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

Submission status: Wrong Answer

Solution code:
from math import sqrt,factorial
import numpy as np
from operator import mul
from functools import reduce
def combinations_count(n, r):
    r = np.minimum(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom
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+=combinations_count(N,i)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:
modulo = 10000000007

def gcd(a, b, p):
    if (a == 0):
        p[0] = 0
        p[1] = 1
        return b
    p1 = [0, 0]
    g = gcd(b % a, a, p1)
    p[0] = p1[1] - (b // a) * p1[0]
    p[1] = p1[0]
    return g

def ncrm(n, r, m):
    if (r > n):
        return 0
    if (r > (n - r)):
        r = n - r
    a = b = 1
    for i in range(r):
        a = (a * (n - i)) % m
        b = (b * (i + 1)) % m
    p = [0, 0]
    gcd(b, m, p)
    return (a * (p[0] % m + m) % m) % m

def bouquet(n, a, b):
    if n > 33:
        total = modulo
    else:
        total = 2 ** n - 1
    print(total - ncrm(n, a, modulo) - ncrm(n, b, modulo))

if __name__ == "__main__":
    import sys
    in_str = []
    for line in sys.stdin:
        in_str.append(line)
    n, a, b = [int(_) for _ in in_str[0].split(' ')]
    bouquet(n, a, b)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline
mod=10**9+7
N,a_,b_=map(int,input().split())
l=[min(a_,N-a_),min(b_,N-b_)]
a=min(l)
b=max(l)
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)-1)

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-=(cmb(N,a)%mod)
ans-=(cmb(N,b)%mod)
print(ans)

Submission status: Wrong Answer

Solution code:

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

res = 1
 
def cmb(n, r):
    if (r < 0 or r > n):
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod
 
 
mod = 10**9+7  # 問題によって変える、ここは素数でないとうまく動かない
N_cmb = 0
N_cmb += n # 入力の制約によって変えるところ、nCrの計算で欲しいnの最大値
fac = [1, 1]  # 階乗テーブル
finv = [1, 1]  # 逆元テーブル
inverse = [0, 1]  # 逆元テーブル計算用テーブル

for ZZZ in range(2, N_cmb + 1):
    fac.append((fac[-1] * ZZZ) % mod)
    inverse.append(mod-inverse[mod % ZZZ]*(mod//ZZZ) % mod)
    finv.append((finv[-1] * inverse[-1]) % mod)
    
ans = pow(2,n)%mod - cmb(n,a) - cmb(n,b)  +1
print(ans)

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(a, n):
        if not n:
            return 1
        x = power(a, n >> 1)
        x *= x
        return a * x if n & 1 else x

    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:
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)
B = cmb(n, b)
print(ALL-A-B)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
input = sys.stdin.readline
mod=10**9+7
N,a_,b_=map(int,input().split())
l=[min(a_,N-a_),min(b_,N-b_)]
a=min(l)
b=max(l)
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)

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-=(cmb(N,a)%mod)
ans-=(cmb(N,b)%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 = [] 
    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)
B = cmb(n, b)
print(ALL,A,B)

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


ans = 0
if n%2 == 0:
    t = n//2 - 1
else:
    t = n//2

for i in range(1,t+1):
    ans += cmb(n, i)
ans *= 2
ans += cmb(n, t+1)
ans += 1
ans -= cmb(n, a)
ans -= cmb(n, b)
print(ans%(10**9+7))

Submission status: Wrong Answer

Solution code:

def fact(a,b):
  f=1
  for i in range(a,b+1):
    f *= i 
  return f

def C(n, r):
  if(r>n-r):
    return fact(r+1,n)//fact(1,n-r)
  else:
    return fact(n-r+1, n)//fact(1,r)

def func(n, LIMI):
  if(n==0):
    return 1
  else:
    return (func(n//2,LIM) * func(n//2,LIMI)*(2**(n%2)))%LIMI

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

LIM=10**9+7
print(C(N,a) + C(N,b))
hana=  (func(N,LIM)-1)%LIM
hana -= C(N,a) + C(N,b)



print(hana)

Submission status: Wrong Answer

Solution code:
def main():
    n,a,b = map(int,input().split())
    MOD = (10**9)+7
    # s = powpow(2,n)
    s=pow(2,n,MOD) -1
    print(s)
    f,inv_f=comInit(MOD,n)

    s-=calCom(n,a,MOD,f,inv_f)
    s-=calCom(n,b,MOD,f,inv_f)

    print(s)

def powpow(a,n):
    mod = (10**9)+7
    x = 1
    i = 0
    while n > 0:
        print(bin(n))
        if bin(n & 1):
            x=x*a
            # x%=mod
        a*=a
        print(x)
        # a%=mod
        i+=1
        n=n>>1

    print('aaa')
    return x

def comInit(MOD, n):
    fact=[1,1] # fact[n]はnの階乗
    invr=[0,1] # invr[n]はnの逆元
    invr_fact=[1,1] # invr_fact[n]は逆元の階乗

    for i in range(2,n+1):
        fact.append(fact[-1]*i%MOD)
        invr.append(-invr[MOD%i]*(MOD//i)%MOD)
        invr_fact.append(invr_fact[-1]*invr[-1]%MOD)
    return fact,invr_fact

def calCom(n,k,MOD,fact,invr_fact):
    k=min(k,n-k)
    return fact[n]*invr_fact[k]*invr_fact[n-k]%MOD



if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

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

if __name__ == '__main__':
    main()

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+1)//2):
    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(" "))
from math import factorial
c = n
ans = c

for i in range(1, int(n // 2 - 1)):
    c *= (n - i) / (i + 1)
    if i + 1 != a and i + 1 != b:
        ans += c % (10 ** 9 + 7)
ans *= 2
ans += 1
if n % 2 == 0:
    ans += factorial(n) / factorial(n - n / 2) / factorial(n / 2)
ans -= factorial(n) / factorial(n - a) / factorial(a)
ans -= factorial(n) / factorial(n - b) / factorial(b)
print(ans)

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce

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

# ans = (2 ** n - 1) - comb(n, a) - comb(n, b)
ans = 2 ** n - 1

nCr = 1
a = min(a, n - a) - 1
b = min(b, n - b) - 1
for r in range(min(a, b) + 1):
    nCr_1 = nCr * (n - r) // (r + 1)
    nCr = nCr_1
    # print((r, nCr_1))
    if r == a:
      # print(nCr)
      ans -= nCr
    if r == b:
      # print(nCr)
      ans -= nCr

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

Submission status: Wrong Answer

Solution code:
mod = 10**9+7

def comb(n, r):
    if r==1:
        return n
    
    if r==n:
        return 1
    
    if r > n/2:
        r = n-r
    frac_up = 1
    frac_down = 1
    for i in range(n-r,n):
        frac_up *= i
        frac_up = frac_up % mod
    for i in range(1,r):
        frac_down *= i % mod
        frac_down = frac_down % mod        
    return int(frac_up/frac_down)%mod
    

n, a, b = map(int, input().split(" "))
s = 0
for i in range(0, n):
    if i != a and i!= b:
        s += comb(n,i)
        
print(s)

Submission status: Wrong Answer

Solution code:
import math

m, a, b = (int(x) for x in input().split())

j = 0

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

sum = 0

while j <= m :

    # print('[j]')
    # print(j)

    # あかりさんが嫌う数かどうか
    if(j != a and j != b) :
        c = combinations_count(m, j)
        # print('OK')
        # print(c)
        
    sum = sum + c
    c = 0
    # print('sum')
    # print(sum)

    j = j + 1

sum = sum - 1

sum = sum / (10^9 + 7)

print(sum)

Submission status: Wrong Answer

Solution code:
mod = 5 #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
x = x%mod
if x < 0:
    x += mod
print(x)

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
# print('v', v)


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('a_fact', a_fact, an_fact)
# print('b_fact', 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 = f(an_fact, a_fact, MOD)
cb = f(bn_fact, b_fact, MOD)
# print('ca, cb', ca, cb)
print(v - ca - cb)

Submission status: Wrong Answer

Solution code:
def binary(n):
    return bin(n)[2:]


# バイナリ法
def pow_by_binary_exponentiation(a, x, n):  # a^x mod n
    x = [int(b) for b in binary(x)]
    y = a
    for i in range(1, len(x)):
        y = (y**2) % n
        if x[i] == 1:
            y = (y * a) % n
    return y


# mを法とするaの乗法的逆元
def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


# nCr mod m
# modinvが必要
# rがn/2に近いと非常に重くなる
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


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

mod = 10**9 + 7
S = pow_by_binary_exponentiation(2, n, mod) - 1
A = combination(n, a, mod)
B = combination(n, b, mod)

ans = S -A -B
if ans < 0:
    ans += mod
print(ans)

Submission status: Wrong Answer

Solution code:

def fac(x):
    k = 1
    for i in range(1,x+1):
        k = k *(i %(10**9 + 7))
        k = k%(10**9 + 7)
    k = k%(10**9 + 7)
    return k

def C(x,y):
    a = fac(x) // ((fac(y) * fac(x-y))%(10**9 + 7))
    a = a%(10**9 + 7)
    return a
ans = 0
k =1
n, a, b = map(int, input().split())
if n %2 ==0:
    ans += C(n,int(n/2))
for i in range(1,int(n/2)):
    k = int((k *(n-i+1)%(10**9 + 7))/(i%(10**9 + 7)))%(10**9 + 7)

    ans += 2*k%(10**9 + 7)
    ans = ans%(10**9 + 7)
ans = ans - C(n,a)%(10**9 + 7)
ans = ans - C(n,b)%(10**9 + 7)
ans += 1
ans = ans%(10**9 +7)
print(ans)

Submission status: Wrong Answer

Solution code:
import math
n, a, b = (int(x) for x in input().split())
sum = 0
for i in range(n):
    if i != a-1 and i != b-1:
        x = math.factorial(i+1)
        y = math.factorial(n-i-1)
        sum += math.factorial(n) / (x * y)
ans = sum % 1000000007
print(ans)

Submission status: Wrong Answer

Solution code:
import math

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


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


sum = 0

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

if n == 2:
    # こうなる時の条件をちゃんと考えよう
    if a == 1:
        if b == 2:
            sum = 0
    if b == 1:
        if a == 2:
            sum = 0

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