TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split())
ans = 2 ** n -1
val = 1
for i in range(a):
    val *= (n-i) / (i+1)
ans -= val
val = 1
for i in range(b):
    val *= (n-i) / (i+1)
ans -= val
print(int(ans % int(1e9) + 7))

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

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split())
ans = 0

if n > 0:
  temp = 1
  for i in range(n):
    if i!=a and i!=b:
      temp = temp * (n-i) / (i+1)
      ans += temp
      
ans = ans % (10**9+7)
print(ans)

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

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

x = 1
y = 1
for i in range(a):
  x = x*(n - i)%mod
  y = y*(i + 1)%mod
ans -= x*pow(y, mod - 2, mod)%mod
  
x = 1
y = 1
for i in range(b):
  x = x*(n - i)%mod
  y = y*(i + 1)%mod
ans -= x*pow(y, mod - 2, mod)%mod
  
print(ans%mod)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int,input().split())
mod = 10**9+7
total = pow(2, n, mod) - 1
print(total)
def c(n, r):
    p, q = 1, 1
    for i in range(r):
        p *= (n-i)%mod
        q *= (i+1)%mod
    return p * pow(q, mod-2, mod)%mod

print((total - c(n, a) - c(n, b))%mod)

n, a, b = map(int,input().split())
mod = 10**9+7
total = pow(2, n, mod) - 1
def c(n, r):
    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

print((total - c(n, a) - c(n, b))%mod)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split())

mmod = 10**9 + 7


def comb_mod(n, r, mod=mmod):
    nume = 1
    deno = 1

    r = min(r, r - 1)

    for i in range(1, r + 1):
        nume = (nume * (n + 1 - i)) % mod
        deno = (deno * i) % mod

    return (nume * pow(deno, mod - 2, mod)) % mod


if n == 2:
    print(0)
    exit

total = (pow(2, n, mmod) - comb_mod(n, a) - comb_mod(n, b) - 1) % mmod

print(total)


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

mmod = 10**9 + 7


def comb_mod(n, r, mod=mmod):
    nume = 1
    deno = 1

    r = min(r, r - 1)

    for i in range(1, r + 1):
        nume = (nume * (n - i)) % mod
        deno = (deno * (i + 1)) % mod

    return (nume * pow(deno, mod - 2, mod)) % mod


if n == 2:
    print(0)
    exit

total = (pow(2, n, mmod) - comb_mod(n, a) - comb_mod(n, b) - 1) % mmod

print(total)


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

mmod = 10**9 + 7


def comb_mod(n, r, mod=mmod):
    nume = 1
    deno = 1

    r = min(r, n - r)

    for i in range(1, r + 1):
        nume = (nume * (n + 1 - i)) % mod
        deno = (deno * i) % mod

    return (nume * pow(deno, mod - 2, mod)) % mod


result_a = comb_mod(n, a)
result_b = comb_mod(n, b)
total = (pow(2, n, mmod) - result_a - result_b - 1) % mmod

print(total)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from functools import reduce
def cmb(n,r):
    numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
    denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
    return numerator * pow(denominator, mod - 2, mod) % mod

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

# ans=imp_pow(2,n)-1
ans=pow(2,c,10**9+7)-1
ans-=cmb(n,a)
ans-=cmb(n,b)
print(ans%10**9+7)

from functools import reduce
def cmb(n,r):
    numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
    denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
    return numerator * pow(denominator, mod - 2, mod) % mod

ans=0
c,a,b = map(int,(input().split()))

# ans=imp_pow(2,n)-1
ans=pow(2,c,10**9+7)-1
ans-=cmb(c,a)
ans-=cmb(c,b)
print(ans%10**9+7)

from functools import reduce
def cmb(r):
    numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
    denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
    return numerator * pow(denominator, mod - 2, mod) % mod
n,a,b = map(int,(input().split()))
ans=0
mod=10**9+7

ans=pow(2,n,10**9+7)-1
ans-=cmb(a)
ans-=cmb(b)
print(ans%mod)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def inv_mod(a, N):
    

    def extgcd(a, b):
        
        d = fractions.gcd(a, b)
        if b == 0:
            return 1, 0, a
        else:
            q, r = divmod(a, b)
            x, y, d = extgcd(b, r)
            s, t = y, x - q * y
            return s, t, d

    return extgcd(a, N)[0]


def bpm(x, y, N):
    
    ans = 1
    x %= MOD
    digit = int((math.log2(y) // 1 + 1))  
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


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

nCa = 1
nCb = 1

inv_list = []

for i in range(max(a, b)):
    inv_list.append(inv_mod(i + 1, MOD))

for i in range(a):
    nCa *= inv_list[i]
    nCa %= MOD
    nCa *= n - i
    nCa %= MOD

for i in range(b):
    nCb *= inv_list[i]
    nCb %= MOD
    nCb *= n - i
    nCb %= MOD

print((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)


import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()


def inv_mod(a, N):
    

    def bpm(x, y, N):
        
        ans = 1
        x %= MOD
        digit = int((math.log(y, 2) // 1 + 1))  
        for i in range(digit):
            if (y >> i) & 1 == 1:
                ans *= x
                ans %= MOD
            x **= 2
            x %= MOD
        return ans

    return bpm(a, N - 2, N)


def bpm(x, y, N):
    
    ans = 1
    x %= MOD
    digit = int((math.log(y, 2) // 1 + 1))  
    for i in range(digit):
        if (y >> i) & 1 == 1:
            ans *= x
            ans %= MOD
        x **= 2
        x %= MOD
    return ans


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

nCa = 1
nCb = 1

inv_list = [1]  
for i in range(max(a, b)):
    inv_list.append(int(MOD - inv_list[(MOD % (i + 2)) - 1] * (MOD // (i + 2)) % MOD))

for i in range(a):
    nCa *= inv_list[i]
    nCa %= MOD
    nCa *= n - i
    nCa %= MOD

for i in range(b):
    nCb *= inv_list[i]
    nCb %= MOD
    nCb *= n - i
    nCb %= MOD

print((bpm(2, n, MOD) - 1 - nCa - nCb) % MOD)


Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
mod = (10 ** 9 + 7)

def comb(n, r):
    p, q = 1, 1

    for i in range(r):
        p = p *(n-i)%mod
        q = q *(i+1)%mod

    return (p / q) % mod

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

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

print((s - comb(n, a) - comb(n, b)) % mod)


mod = (10 ** 9 + 7)

def comb(n, r):
    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


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

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

print((s - comb(n, a) - comb(n, b)) % mod)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def modpow(a, n, p):
    if n == 0:
        return 1
    elif n == 1:
        return a % p
    if n % 2 == 1:
        return (a * modpow(a, n-1, p)) % p
    tmp = modpow(a, n//2, p)
    return (tmp * tmp) % p


def modfactrial(a, p):
    ret = 1
    for i in (a, 1, -1):
        ret = ret * i % p
    return ret


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

    
    

    ans = (modpow(2, n, mod) - 1) % mod

    
    c_a = 1
    for i in range(n, n-a, -1):
        c_a *= i
        c_a %= mod
    c_a *= modpow(modfactrial(a, mod), mod-2, mod)
    ans -= c_a
    ans %= mod

    
    c_b = 1
    for i in range(n, n-b, -1):
        c_b *= i
        c_b %= mod
    c_b *= modpow(modfactrial(b, mod), mod-2, mod)
    ans -= c_b
    ans %= mod

    print(ans)


if __name__ == "__main__":
    main()


def modpow(a, n, p):
    if n == 0:
        return 1
    elif n == 1:
        return a % p
    if n % 2 == 1:
        return (a * modpow(a, n-1, p)) % p
    tmp = modpow(a, n//2, p)
    return (tmp * tmp) % p


def modfactrial(a, p):
    ret = 1
    for i in range(a, 1, -1):
        ret = ret * i % p
    return ret


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

    
    

    ans = (modpow(2, n, mod) - 1) % mod

    
    c_a = 1
    for i in range(n, n-a, -1):
        c_a *= i
        c_a %= mod
    c_a *= modpow(modfactrial(a, mod), mod-2, mod)
    ans -= c_a
    ans %= mod

    
    c_b = 1
    for i in range(n, n-b, -1):
        c_b *= i
        c_b %= mod
    c_b *= modpow(modfactrial(b, mod), mod-2, mod)
    ans -= c_b
    ans %= mod

    print(ans)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n,a,b = list(map(int,input().split()))
mod = 10**9 + 7
ans = (pow(2,n,mod) - 1
numerator = 1
denominator = 1

for i in range(1,n+1):
    numerator = (numerator*(n-i+1))%mod
    denominator = (denominator*i)%mod
    if i == a or i == b:
        ans = ans - (numerator*pow(denominator,mod-2,mod))%mod
        if i == b:
            break

print(ans%mod)

n,a,b = list(map(int,input().split()))
mod = 10**9 + 7
ans = pow(2,n,mod) - 1
numerator = 1
denominator = 1

for i in range(1,n+1):
    numerator = (numerator*(n-i+1))%mod
    denominator = (denominator*i)%mod
    if i == a or i == b:
        ans = ans - (numerator*pow(denominator,mod-2,mod))%mod
        if i == b:
            break

print(ans%mod)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
# ABC156D

import numpy as np
def f(n, x):
    mean =  np.mean(x)
    s1 = sum((x-np.floor(mean))**2)
    s2 = sum((x-np.ceil(mean))**2)
    print(int(min(s1, s2)))

n = int(input())
x = list(map(int, input().split()))
f(n, x)


from functools import reduce
def comb(n, r, mod=10 ** 9 + 7):
    numerator = reduce(lambda x, y: x * y % mod, [n - r + k + 1 for k in range(r)])
    denominator = reduce(lambda x, y: x * y % mod, [k + 1 for k in range(r)])
    return numerator * pow(denominator, mod - 2, mod) % mod

n, a, b = map(int, input().split())
mod = 1000000007
print((pow(2, n, mod) - 1 - comb(n, a, mod) - comb(n, b, mod)) % mod)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
mod=10**9+7
l,a,b=map(int,input().split())
def C(n,k,m):
  for i in range(1,k):
    n*=(n-i)%m
    k*=(k-i)%m
  return n*pow(k,m-2,m)

ans=pow(2,l,mod)
ca=C(l,a,mod)
print(ca)
cb=C(l,b,mod)
print(cb)
print((ans-ca-cb)%mod)

mod=10**9+7
l,a,b=map(int,input().split())
def C(n,k,m):
  g=k
  f=n
  for i in range(1,k):
    n=n*(f-i)%m
    k=k*(g-i)%m
  return (n*pow(k,m-2,m))%m
ans=pow(2,l,mod)-1
ca=C(l,a,mod)
cb=C(l,b,mod)
print((ans-ca-cb)%mod)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
mod = 10**9 + 7
def cmb(n,r,mod):
	a=1
	b=1
	r = min(r,n-r)
	for i in range(r):
		a = a*(n-i)%mod
		b = b*(i+1)%mod
	return a*pow(b,mod-2,mod)%mod

n,a,b = map(int,input().split())
count = 0
all = pow(2,n,mod) - 1
nCa = cmb(n,a,mod)
nCb = cmb(n,b,mod)
ans = all - (nCa + nCb) + mod
print(ans)

n,a,b = map(int,input().split())
count = 0
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 
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 )
for j in range(2,n + 1):
  if j == a or i == b:
    pass
  else:
    count += cmb(n, j, p)
print(count)


N,A,B = map(int,input().split())

mod = 10**9 + 7
def cmb(n,r,mod):
	a=1
	b=1
	r = min(r,n-r)
	for i in range(r):
		a = a*(n-i)%mod
		b = b*(i+1)%mod
	return a*pow(b,mod-2,mod)%mod

all = pow(2,N,mod) + mod
nCa = cmb(N,A,mod)
nCb = cmb(N,B,mod)

ans = all - nCa - nCb
print((ans-1)%mod)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def ncr(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

N, a, b = map(int, input().split())
p = 10 ** 9 + 7
"N = 10 ** 6  
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

 
al = 2**N -1
acr = ncr(N, a, p)
bcr = ncr(N, b, p)
print(al-acr-bcr)

mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print((al-(acr+bcr))%mod

mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print( (al-(acr+bcr))%mod )

Verdicts: Time Limit Exceeded

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):

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


P = 10**9 + 7
N = 200001
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

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

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

al=power_func(2,n,mod)
print((al-comb(a)-comb(b))%mod)


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


P = 10**9 + 7
N = 200001
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

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

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

al=power_func(2,n,mod)-1
print((al-comb(a)-comb(b))%mod)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#input
n, a, b = map(int, input().split())

#output
mod = 10**9 + 7

n_ = 10**9 + 1
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def cmb(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod

answer = 2**n - 1 - cmb(n, a) - cmb(n, b)
print(answer % mod)

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

#output
mod = pow(10, 9) + 7

n_ = pow(10, 9) + 1
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def cmb(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod

answer = pow(2, n) - 1 - cmb(n, a) - cmb(n, b)
print(answer % mod)

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

#output
mod = pow(10, 9) + 7

def cmb(n, k):
    numerator = 1
    denominator = 1

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


answer = pow(2, n, mod) - 1 - cmb(n, a) - cmb(n, b)
print(answer % mod)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
n,a,b = map(int,input().split())


wa = pow(2, n, 10 ** 9 + 7) - 1


#val1 = comb(n, a, exact=True)
#val2 = comb(n, b, exact = True)

x = 1
y = 1
for i in range(a):
    x = (x * (n-i)) % (10 ** 9 + 7)
    y = (y * (i+1)) % (10 ** 9 + 7)
val1 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)

x = 1
y = 1
for i in range(b):
    x = (x * (n-i)) % (10 ** 9 + 7)
    y = (y * (i+1)) % (10 ** 9 + 7)

val2 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)

ans = wa - val1 - val2
for i in range(100):
if ans < 0:
    ans += 10 ** 9 + 7
print(ans)

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


wa = pow(2, n, 10 ** 9 + 7) - 1


#val1 = comb(n, a, exact=True)
#val2 = comb(n, b, exact = True)

x = 1
y = 1
for i in range(a):
    x = (x * (n-i)) % (10 ** 9 + 7)
    y = (y * (i+1)) % (10 ** 9 + 7)
val1 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)

x = 1
y = 1
for i in range(b):
    x = (x * (n-i)) % (10 ** 9 + 7)
    y = (y * (i+1)) % (10 ** 9 + 7)

val2 = (x * pow(y, 10 ** 9 + 7 - 2, 10 ** 9 + 7)) % (10 ** 9 + 7)

ans = wa - val1 - val2
for i in range(100):
    if ans < 0:
        ans += 10 ** 9 + 7
print(ans)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
from operator import mul
from functools import reduce

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

so=10**9+7

large=(pow(2,n,so))

def kumiawase(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1)) % so
    under = reduce(mul, range(1,r + 1))
    
    return over * pow(under,so-2,so)

ajogai = kumiawase(n,a) % so
bjogai = kumiawase(n,b) % so
print((large - ajogai - bjogai + 2*so) % so)

from operator import mul
from functools import reduce
import math

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

so=10**9+7

large=(pow(2,n,so))

def kumiawase(n,r):
    return math.fractorial(n) / (math.fractorial(n-r) * math.fractorial(r)

ajogai = kumiawase(n,a) % so
bjogai = kumiawase(n,b) % so
print((large - ajogai - bjogai + 2*so) % so)

from operator import mul
from functools import reduce
import math

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

so=10**9+7

large=(pow(2,n,so))

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

ajogai = kumiawase(n,a) % so
bjogai = kumiawase(n,b) % so
print(large)
print(ajogai)
print(bjogai)
print((large - 1 - ajogai - bjogai + 2*so) % so)

from operator import mul
from functools import reduce
import math

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

so=10**9+7

large=(pow(2,n,so)-1)

def kumiawase(n,r):
    over=1
    for i in range(r):
        over *= n-i
        over %= so
    under = math.factorial(r)
    return over * pow(under,so-2,so)

ajogai = kumiawase(n,a) % so
bjogai = kumiawase(n,b) % so
print((large - ajogai - bjogai + 2*so) % so)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
#D
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7


def comb(n, x):
    numerator = 1
    for i in range(n, n - x, -1):
        numerator = numerator * i % mod

    denominator = 1
    for j in range(x, 1, -1):
        denominator = denominator * j % mod

    d = denominator ** mod - 2 % mod

    return numerator * d

# #pow
# # def pow(x, n, mod=10e9+7):
# #     ans = 1
# #     while (n > 0):
# #         if bin(n & 1) == bin(1):
# #             ans *= x
# #         x *= x
# #         n = n >> 1
# #     return ans

a = comb(n, a)
b = comb(n, b)

print((2**n %mod - 1 - a - b) % mod)


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

def comb(n, x):
    numerator = 1
    for i in range(n, n - x, -1):
        numerator = numerator * i % mod

    denominator = 1
    for j in range(x, 1, -1):
        denominator = denominator * j % mod

    d = pow(denominator, mod-2, mod)

    return numerator * d

a = comb(n, a)
b = comb(n, b)

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

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
def combination(n,r,mod=10**9+7):
    n1 = n+1
    r = min(r,n-r)
    numer = denom = 1
    for i in range(1,r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom,mod-2,mod) % mod
 
def power_func(a,n,p):
    bi=str(format(n,"b"))
    res=1
    for i in range(len(bi)):
        res=(res*res) %p
        if bi[i]=="1":
            res=(res*a) %p
    return res
 
mod = int(1e9+7)
n,a,b= map(int,input().split())
 
S = (pow(2,n,mod))%mod
A = combination(n,a)
B = combination(n,b)
ans = (S-A-B)%mod
 
print(ans)

def combination(n,r,mod=10**9+7):
    n1 = n+1
    r = 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
 
mod = int(1e9+7)
n,a,b= map(int,input().split())
 
S = (pow(2,n,mod) - 1)%mod
A = combination(n,a)
B = combination(n,b)
ans = (S-A-B)%mod
 
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
from scipy.misc import comb
N,a,b=map(int,input().split())
MOD=10**9+7
cnt=0
for i in range(1,N+1):
  cnt+=comb(N, i, exact=True)
A=comb(N, a, exact=True)
B=comb(N, b, exact=True)
cnt=cnt-A-B
ans=cnt%MOD
print(ans)

def MI(): return map(int, input().split())
MOD=10**9+7
def nCr(n,k):
  tmp=1
  for i in range(n-k+1,n+1):
    tmp*=i
    tmp%=MOD
  for i in range(1,k+1):
    tmp*=pow(i,MOD-2,MOD)
    tmp%=MOD
  return tmp
N,A,B=MI()
ans=pow(2,N,MOD)-1-nCr(N,A)-nCr(N,B)
print(ans%MOD)

Verdicts: Time Limit Exceeded

Accepted
Problem: 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.

Submission attempts (in order):
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())

import sys, math

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

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 + 1):
        print(i)
        comk[i] = (comk[i - 1] * ((n - i + 1)) / i)
    ans = (pow(2, n, M) - 1)  - ((comk[a] + comk[b]) % M)
    return ans % M

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

import sys, math

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

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 + 1):
        comk[i] = (comk[i - 1] * ((n - i + 1)) / i)
    ans = (pow(2, n, M) - 1)  - ((comk[a] + comk[b]) % M)
    return ans % M

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


import sys, math

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

n, a, b = read_int()
M = pow(10, 9) + 7
sys.setrecursionlimit(300000)

def solve():
    ans = (pow(2, n, M) - 1) - kai(n, 0, a) * pow(kai(a, 0, a), M - 2, M) - kai(n, 0, b) * pow(kai(b, 0, b), M - 2, M)
    return ans % M

def kai(n, i, m):
    if i == m:
        return 1
    return (n * kai(n - 1, i + 1, m)) % M

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


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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.

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

def comb(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 = list(map(int, input().split()))
# print(int((2 ** n % (10**9+7)) - 1 - comb(n, a) - comb(n, b)))
print(int((pow(2, n, 10**9+7) - 1 - comb(n, a, 10**9+7) - comb(n, b, 10**9+7))) % 10**9+7)

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

def comb(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 = list(map(int, input().split()))
mod = 10**9+7
print(int(pow(2, n, mod) - 1 - comb(n, a, mod) - comb(n, b, mod)) % mod)

Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
def main():
    import numpy as np
    n, a, b = map(int, input().split())
    mod = 10**9+7

    def cumprod(vector, mod=10**9+7):
        a, n = np.array(vector, dtype=np.int64), len(vector)
        nsq = int((n-1)**0.5)+1
        a.resize(nsq, nsq)
        for i in range(1, nsq):
            a[:, i] *= a[:, i-1]
            a[:, i] %= mod
        for i in range(1, nsq):
            a[i] *= a[i-1, -1]
            a[i] %= mod
        a.resize(n)
        return a

    xx = cumprod([i for i in range(n, n-200001, -1)])
    yy = cumprod([i for i in range(200001)])

    ans1 = xx[a]*pow(int(yy[a]), mod-2, mod)
    ans2 = xx[b]*pow(int(yy[b]), mod-2, mod)

    print((pow(2, n, mod)-ans1-ans2-1) % mod)


main()


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

    nn = n
    ans1 = 1
    while a > 0:
        ans1 = (ans1 * n * pow(a, mod-2, mod)) % mod
        n -= 1
        a -= 1

    ans2 = 1
    n = nn
    while b > 0:
        ans2 = (ans2 * n * pow(b, mod-2, mod)) % mod
        n -= 1
        b -= 1

    print((pow(2, nn, mod)-ans1-ans2-1) % mod)


main()


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 

#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
  
MOD = pow(10, 9) + 7
n, a, b = map(int, input().split())

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


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


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





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

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

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



# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 

#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
  
MOD = pow(10, 9) + 7
n, a, b = map(int, input().split())
 
#   (2^n -1 - nCa - nCb) mod MOD
# = ( (2^n - 1 mod MOD) - (nCa mod MOD) - (nCb mod MOD ) ) mod MOD
#   (nCr mod MOD) = ( n*(n-1)*...*(n-r+1) * (a!)^-1 ) mod MOD
# = ( (n mod MOD) * ((n-1) mod MOD) * ... * ((n-r+1) mod MOD) * (r!)^(MOD-2) )  mod MOD

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


nCr_Mol_ModList = [1 for _ in range(rMAX+1)]

fac_ModList = [1 for _ in range(rMAX+1)]

nCr_Mol_ModList[1] = n % MOD
fac_ModList[1] = 1 % MOD

for i in range(2, rMAX+1) :
  nCr_Mol_ModList[i] = (nCr_Mol_ModList[i-1] * (n-i+1)) % MOD
  fac_ModList[i] = (fac_ModList[i-1] * i) % MOD

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


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

ans = (X - Y - Z) % MOD
print (ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
import math
n,a,b=map(int,input().split())

count=0

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
    return x/y

count+=pow(2,n-1)
count-=1
count-=C(n,a)
count-=C(n,b)

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

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

count=0

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
    return x/y

count+=pow(2,n)
print(count)
count-=1
count-=C(n,a)
print(count)
count-=C(n,b)

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

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

count=0
mod=1000000007

def C(n,a):
    x=1
    y=1
    for i in range(a):
        x*=n-i
        y*=i+1
        x%=mod
        y%=mod
    return x*pow(y,mod-2,mod)%mod

count+=pow(2,n,mod)
#print(count)
count-=1
count-=C(n,a)
#print(count)
count-=C(n,b)

print(max(0,(count)%mod))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split())

import math

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

MDO = 10 ** 9 + 7

total = 2 ** n - 1
ans = total - combinations_count(n, a) - combinations_count(n, b)
print(ans % MOD)



from functools import reduce

def combinations_count_mod(n, r, m):
    num = reduce(lambda x, y: x * y % m, range(n, n - r, -1))
    den = reduce(lambda x, y: x * y % m, range(1, r + 1))
    return num * pow(den, m - 2, m) % m

N, A, B = map(int, input().split())

MOD = 10 ** 9 + 7
 
answer = pow(2, N, MOD) - 1 - combinations_count_mod(N, A, MOD) - combinations_count_mod(N, B, MOD)
answer %= MOD
print(answer)

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
def factorial_mod(a, M):
    ans = 1
    for i in range(a,1,-1):
        ans = (ans * i) % M
    return ans
def test(n, a, M):
    ans = 1
    for i in range(a):
        ans = (ans * (n-i)) % M
    return ans
def combination_mod(n,a,M):
    tmp = factorial_mod(a,M)
    tmp = pow(tmp, M-2, M)
    ans = test(n,a,M) * tmp % M
    return ans
def output(n,a,b):
    M = 10**9+7
    ans = (pow(2,n,M) - 1 - combination_mod(n,a,M) - combination_mod(n,b,M)) % M
    return ans
n, a, b = map(int, input().split())
print(output(a,b,c))

def factorial_mod(a, M):
    # return a!(mod M)
    ans = 1
    for i in range(a,1,-1):
        ans = (ans * i) % M
    return ans
def test(n, a, M):
    
    ans = 1
    for i in range(a):
        ans = (ans * (n-i)) % M
    return ans
def combination_mod(n,a,M):
    # return nCa % M
    tmp = factorial_mod(a,M)
    tmp = pow(tmp, M-2, M)
    ans = test(n,a,M) * tmp % M
    return ans
def output(n,a,b):
    M = 10**9+7
    ans = (pow(2,n,M) - 1 - combination_mod(n,a,M) - combination_mod(n,b,M)) % M
    return ans
n, a, b = map(int, input().split())
print(output(n,a,b))

Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
MOD = 1000000007

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

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def xgcd(a, b):
	x0, y0, x1, y1 = 1, 0, 0, 1
	while b != 0:
		q, a, b = a // b, b, a % b
		x0, x1 = x1, x0 - q * x1
		y0, y1 = y1, y0 - q * y1
	return a, x0, y0

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def modinv(a, m):
	g, x, y = xgcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def combination(n, r):
	ans = 1
	for i in range(n - r + 1, n + 1):
		ans *= i
		ans %= MOD
	for i in range(1, r + 1):
		ans *= modinv(i, MOD)
		ans %= MOD
	return ans

ans = 0
ans += pow(2, n, MOD)
 - 1
ans += MOD - combination(n, a)
ans += MOD - combination(n, b)
ans %= MOD

print(ans)


MOD = 1000000007

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

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def xgcd(a, b):
	x0, y0, x1, y1 = 1, 0, 0, 1
	while b != 0:
		q, a, b = a // b, b, a % b
		x0, x1 = x1, x0 - q * x1
		y0, y1 = y1, y0 - q * y1
	return a, x0, y0

# https://tex2e.github.io/blog/crypto/modular-mul-inverse
def modinv(a, m):
	g, x, y = xgcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def combination(n, r):
	ans = 1
	for i in range(n - r + 1, n + 1):
		ans *= i
		ans %= MOD
	for i in range(1, r + 1):
		ans *= modinv(i, MOD)
		ans %= MOD
	return ans

ans = 0
ans += pow(2, n, MOD) - 1
ans += MOD - combination(n, a)
ans += MOD - combination(n, b)
ans %= MOD

print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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.

Submission attempts (in order):
#!/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)


#!/usr/bin/env python


def pow(m, n):
    if n == 0:
        return 1
    elif n % 2 == 0:
        return (pow(m, int(n / 2)) ** 2) % mod
    elif n % 2 == 1:
        return (pow(m, int((n - 1) * 0.5)) ** 2 * m) % mod


def conb(n, a):
    mod1 = 1
    mod2 = 1
    for i in range(a):
        mod1 *= n - i
        mod1 %= mod
        mod2 *= i + 1
        mod2 %= mod
    mod2 = pow(mod2, mod - 2)
    return (mod1 * mod2) % mod


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


ans = 1
noa = 1
nob = 1
mod = 1000000007
ans = pow(2, n) - 1 - conb(n, a) - conb(n, b)
ans %= mod
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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.

Submission attempts (in order):
n, a, b = map(int, input().split())
nca = len(list(itertools.combinations(range(n), a)))
ncb = len(list(itertools.combinations(range(n), b)))
# answer = 2**n - 1 - nca - ncb
# print(answer % (10**9 + 7))
print((2**n - 1 - nca - ncb) % (10**9 + 7))


mod = int(1e9 + 7)
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

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

    return result


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

base = 1
waru = 1000
syou = n // waru
amari = n % waru
kakeru = 2**waru % mod
for _ in range(syou):
    base = base * kakeru
    base %= mod
base = base * 2**amari
base %= mod

nca = cmb(n, a%mod)
ncb = cmb(n, b%mod)
answer = (base - 1 - nca - ncb) % mod
print(answer)


Verdicts: Runtime Error

Accepted