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):
def main():
    n, a, b = map(int, input().split())
    p = 10 ** 9 + 7
    r = pow(2, n, p) - 1
    if (n - a) < a:
        a = n - a
    if (n - b) < b:
        b = n - b
    fac_na = 1
    for i1 in range(n, n - a, -1):
        fac_na = (fac_na * i1) % p
    fac_nb = 1
    for i1 in range(n, n - b, -1):
        fac_nb = (fac_nb * i1) % p
    fac_a = 1
    for i1 in range(a+1):
        fac_a = (fac_a * i1) % p
    fac_b = 1
    for i1 in range(b+1):
        fac_b = (fac_b * i1) % p

    an = fac_na * pow(fac_a ,p-2, p)
    bn = fac_nb * pow(fac_b, p-2, p)
    r -= an
    if r < 0:
        r += p
    r -= bn
    if r < 0:
        r += p
    print(int(r))


if __name__ == '__main__':
    main()


def main():
    from math import factorial
    n, a, b = map(int, input().split())
    p = 1000000007

    
    n_all = pow(2, n, p) -1

    
    a_comb = 0      
    a_comb_x = 1    計算の分子。n*(n-1)*…*(n-r+1)のmod p
    a_comb_y = 1    計算の分母。r!のmod pにおける逆元
    for i in range(n, n-a ,-1):
        a_comb_x *= i
        a_comb_x %= p
    a_comb_y = factorial(a)
    a_comb_y = pow(a_comb_y, p-2,p)
    a_comb = (a_comb_x * a_comb_y) % p

    b_comb = 0      
    b_comb_x = 1    
    b_comb_y = 1    
    for i in range(n, n-b ,-1):
        b_comb_x *= i
        b_comb_x %= p
    b_comb_y = factorial(b)
    b_comb_y = pow(b_comb_y, p-2,p)
    b_comb = (b_comb_x * b_comb_y) % p

    
    r = n_all - a_comb - b_comb
    if r < 0:
        r += p
    print(r)

main()

def main():
    n, a, b = map(int, input().split())
    p = 10 ** 9 + 7
    r = pow(2, n, p) - 1
    if (n - a) < a:
        a = n - a
    if (n - b) < b:
        b = n - b
    fac_na = 1
    for i1 in range(n, n - a, -1):
        fac_na = (fac_na * i1) % p
    fac_nb = 1
    for i1 in range(n, n - b, -1):
        fac_nb = (fac_nb * i1) % p
    fac_a = 1
    for i1 in range(1, a+1):
        fac_a = (fac_a * i1) % p
    fac_b = 1
    for i1 in range(1, b+1):
        fac_b = (fac_b * i1) % p

    an = fac_na * pow(fac_a, p-2, p)
    bn = fac_nb * pow(fac_b, p-2, p)
    an = an % p
    bn = bn % p
    r -= an
    if r < 0:
        r += p
    r -= bn
    if r < 0:
        r += p
    if r < 0:
        r += p
    print(int(r))


if __name__ == '__main__':
    main()

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 = list(map(int, input().split()))

p = 10**9 + 7

def pow_mod(n, m, p):
  if m == 0:
    return 1
  elif m % 2 == 0:
    nm2p = pow_mod(n, m//2, p)
    return (nm2p * nm2p) % p
  elif m % 2 == 1:
    return (pow_mod(n, m-1, p) * (n % p)) % p

tot = 2 ** n - 1

def compute_ncr_mod(n, r, p):
  n_factorial = 1
  for i in range(n, n-r, -1):
    n_factorial *= i
  r_factorial = 1
  for i in range(r, 0, -1):
    r_factorial *= i
  ncr_modp = ((n_factorial % p) * pow_mod(r_factorial, p-2, p)) % p
  return ncr_modp

print(tot - compute_ncr_mod(n, a, p) - compute_ncr_mod(n, a, b))

import math

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

p = 10**9 + 7

def pow_mod(n, m, p):
  if m == 0:
    return 1
  elif m % 2 == 0:
    nm2p = pow_mod(n, m//2, p)
    return (nm2p * nm2p) % p
  elif m % 2 == 1:
    return (pow_mod(n, m-1, p) * (n % p)) % p

def compute_ncr_mod(n, r, p):
  r = min(n-r, r)
  n_factorial = 1
  r_factorial = 1
  for i in range(1, r+1):
    n_factorial *= n-i+1
    n_factorial %= p
    r_factorial *= i
    r_factorial %= p
  ncr_modp = (n_factorial * pow_mod(r_factorial, p-2, p)) % p
  return ncr_modp

print((pow_mod(2, n, p) - 1 - compute_ncr_mod(n, a, p) - compute_ncr_mod(n, b, p)) % p)

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):
#!/usr/bin/env python
# coding: utf-8

# In[23]:


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


# In[24]:


def nCk(n, k, mod):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a


# In[25]:


ans = pow(2, n, mod)-1
ans -= nCk(n, a, mod) + nCk(n, b, mod)
print(ans%mod)


# In[ ]:






#!/usr/bin/env python
# coding: utf-8

# In[14]:


import math


# In[21]:


def nCk(n, k, mod):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a


# In[22]:


ans = pow(2, n, mod)-1
ans -= nCk(n, a, mod) + nCk(n, b, mod)
print(ans%mod)


# In[ ]:






#!/usr/bin/env python
# coding: utf-8

# In[1]:


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


# In[2]:


def nCk(n, k, mod):
    a = 1
    for i in range(n, n-k, -1):
        a *= i
        a %= mod
    b = 1
    for i in range(1, k+1):
        b *= i
        b %= mod
    a *= pow(b, mod-2, mod)
    return a


# In[3]:


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


# In[ ]:






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())
p=10**9+7


def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a
    
def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
  
A= comb(n,a,p)
B= comb(n,b,p)

if n>=4:
  print(2**(n-1)-(A+B))
elif n==2:
  print(0)
else:
  if a+b==5:
    print(0)
  else:
    print(2**(n-1)-(A+B))

def framod(x,y,p=10**9+7):
  for i in range(x+1,y+1):
    x = (x*i)%p
  return x
    
#########################################

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

ans=0
for i in [a,b]:
  upper = framod(n-i+1,n,p)
  lower = framod(1,i,p)
  ret = (upper*pow(lower,p-2,p))%p
  ans = (ans+ret)%p
print((pow(2,n,p)-ans-1)%p)

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())
m = 10 ** 9 + 7

def combn(n, r, m):
    X = Y = 1
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % m
        X = X*(n-i+1) % m
    Y = pow(Y, m-2, m)
    return X*Y
  
print((pow(2, n, m) - 1 - combn(n, a, m) - combn(n ,b, m)) % m)

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

def combn(n, r, m):
    X = Y = 1
    if n-r < r:
        r = n-r
    for i in range(1, r+1):
        Y = Y*i % m
        X = X*(n-i+1) % m
    Y = pow(Y, m-2, m)
    return X*Y
  
print((pow(2, n, m) - 1 - combn(n, a, m) - combn(n ,b, m)) % 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):
LARGE = 10 ** 9 + 7


def solve(n, a, b):

    pow_ab = [1] * (b + 1)
    for i in range(b):
        pow_ab[i + 1] = pow_ab[i] * (i + 1)
    pow_ab_inv = [1] * (b + 1)
    pow_ab_inv[-1] = pow(pow_ab[-1], LARGE - 2, LARGE)
    for i in range(b - 1, 0, -1):
        pow_ab_inv[i] = pow_ab_inv[i + 1] * (i + 1) % LARGE

    res_all = pow(2, n, LARGE) - 1
    res_ab = 1
    for i in range(a):
        res_ab *= (n - i)
    res_all -= res_ab * pow_ab_inv[a]
    for i in range(a, b):
        res_ab *= (n - i)
    res_all -= res_ab * pow_ab_inv[b]
    return res_all % LARGE


def main():
    n, a, b = map(int, input().split())
    res = solve(n, a, b)
    print(res)


def test():
    assert solve(4, 1, 3) == 7
    assert solve(1000000000, 141421, 173205) == 34076506


if __name__ == "__main__":
    test()
    main()


LARGE = 10 ** 9 + 7


def solve(n, a, b):

    pow_ab = [1] * (b + 1)
    for i in range(b):
        pow_ab[i + 1] = pow_ab[i] * (i + 1) % LARGE
    pow_ab_inv = [1] * (b + 1)
    pow_ab_inv[-1] = pow(pow_ab[-1], LARGE - 2, LARGE)
    for i in range(b - 1, 0, -1):
        pow_ab_inv[i] = pow_ab_inv[i + 1] * (i + 1) % LARGE

    res_all = pow(2, n, LARGE) - 1
    res_ab = 1
    for i in range(a):
        res_ab *= (n - i)
        res_ab %= LARGE
    res_all -= res_ab * pow_ab_inv[a]
    for i in range(a, b):
        res_ab *= (n - i)
        res_ab %= LARGE
    res_all -= res_ab * pow_ab_inv[b]
    return res_all % LARGE


def main():
    n, a, b = map(int, input().split())
    res = solve(n, a, b)
    print(res)


def test():
    assert solve(4, 1, 3) == 7
    assert solve(1000000000, 141421, 173205) == 34076506


if __name__ == "__main__":
    test()
    main()


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):
#!python3.4
# -*- coding: utf-8 -*-
# abc156/abc156_d
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

MAX = 2 * 10**5 + 10
MOD = 10**9 + 7

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

def getP(n, a, b):
    _n = n
    for i in range(1, a):
        _n = (_n * (n - i)) % MOD
    P_a = _n
    for i in range(a, b):
        _n = (_n * (n - i)) % MOD
    P_b = _n
    return (P_a, P_b)

def main():
    n, a, b = i2nn()
    all_C = (pow(2, n, MOD) - 1) % MOD
    P_a, P_b = getP(n, a, b)
    C_a = (P_a * pow(fac[a], MOD-2, MOD)) % MOD
    C_b = (P_b * pow(fac[b], MOD-2, MOD)) % MOD
    print(all_C, P_a, P_b)
    print((MOD + all_C - C_a - C_b) % MOD)
    return

main()


#!python3.4
# -*- coding: utf-8 -*-
# abc156/abc156_d
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

MAX = 2 * 10**5 + 10
MOD = 10**9 + 7

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

def getP(n, a, b):
    _n = n
    for i in range(1, a):
        _n = (_n * (n - i)) % MOD
    P_a = _n
    for i in range(a, b):
        _n = (_n * (n - i)) % MOD
    P_b = _n
    return (P_a, P_b)

def main():
    n, a, b = i2nn()
    all_C = (pow(2, n, MOD) - 1) % MOD
    P_a, P_b = getP(n, a, b)
    C_a = (P_a * pow(fac[a], MOD-2, MOD)) % MOD
    C_b = (P_b * pow(fac[b], MOD-2, MOD)) % MOD
    print((MOD + all_C - C_a - C_b) % MOD)
    return

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 = map(int, input().split())

M = 10**9 + 7

import math

def my_pow(x, n):
    if n == 0:
        return 1
    if n % 2 == 0:
        return my_pow(x ** 2, n // 2) % M
    else:
        return x * my_pow(x ** 2, (n - 1) // 2) % M

from scipy.misc import comb

all_pattern = my_pow(2, n)
dislike = comb(n, a, exact=True) + comb(n, b, exact=True)
dislike = dislike % M

print( (all_pattern - dislike - 1) )


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

M = 10 ** 9 + 7

all = pow(2, n, M) - 1
all %= M

def C(n,x):
    num = 1
    den = 1
    for i in range(x):
        num *= (n-i)
        num %= M
        den *= (i+1)
        den %= M

    inv = pow(den, M-2, M)

    return num * inv % M

ans = all - C(n,a) - C(n,b)
ans %= M
print(ans)

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):
n,a,b =map(int,input().split())
sum=0
for i in range(n) :
    if i == a :
        continue
    elif i == b :
        continue
    else :
        sum+=pow(n)/(pow(i)*pow(n-i))

print(sum%1000000007)

def com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, 1, mod)

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

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

print(int(sum % mod))


def com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, mod-3, mod)

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

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

print(int(sum % mod))


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

for i in range(n) :
    if i == a :
        continue
    elif i == b :
        continue
    else :
        sum+=math.factorial(n)/(math.factorial(i)*math.factorial(n-i))

print(sum%1000000007)

def com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, mod-1, mod)

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

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

print(int(sum % mod))


def com(n, r, mod):
    num = 1
    denom = 1
    for i in range(r):
        denom = (denom * (i+1)) % mod
        num = (num * (n-i)) % mod
    return num*pow(denom, mod-2, mod)

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

mod = 10**9 + 7

sum = pow(2, n, mod) - 1
sum -= com(n, a, mod)
sum -= com(n, b, mod)

print(int(sum % mod))


Verdicts: Runtime Error

Wrong Answer

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

n = 10 ** 9
k = 2 * 10 ** 5
mod = 10**9 + 7


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


# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
    return power(x, mod-2)

def binomial_coefficients(n, k):
    numera = 1  
    denomi = 1  

    for i in range(k):
        numera *= n-i
        numera %= mod
        denomi *= i+1
        denomi %= mod
    return numera * modinv(denomi) % mod


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



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

n = 10 ** 9
k = 2 * 10 ** 5
mod = 10**9 + 7


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


# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
    return power(x, mod-2)

def binomial_coefficients(n, k):
    numera = 1  
    denomi = 1  

    for i in range(k):
        numera *= n-i
        numera %= mod
        denomi *= i+1
        denomi %= mod
    return numera * modinv(denomi) % mod


print(((((power(2, q) - binomial_coefficients(q, a)) % mod) - binomial_coefficients(q, b)) % mod - 1) % 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 ten_to_n(X, n):
    i = int(X / n)
    s = str(X % n)
    if (i):
        return ten_to_n(i, n) + s
    return s

def solve():
    N, M = map(int, input().split())
    n = ten_to_n(N, M)
    return len(n)
 
print(solve())


def solve():
    n, a, b = list(map(int, input().split()))
    MOD = 10 ** 9 + 7
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    
    for i in range(2, max(a, b)+1):
        fact.append((fact[-1] * i) % MOD)
        inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
        factinv.append((factinv[-1] * inv[-1]) % MOD)
    
    def ncr(n, r):
        ret = factinv[r]
        for i in range(n, n-r, -1):
            ret = ret * i % MOD
        return ret
        
    ans = pow(2, n, MOD)
    ans = (ans-ncr(n, a)-ncr(n, b)-1) % MOD
    return ans


print(solve())


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 comb_mod(n,m,mod):
  p = q = 1
  for i in range(m):
    p = p*(n-i) % mod
    q = q*(i+1) % mod
  return p* pow(q,mod-2,mod) % mod

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

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

n,a,b = map(int,input().split())
mod = 10**9+7
def framod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n, r, mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod

def comb(n, k, mod):
    a=framod(n, mod)
    b=framod(k, mod)
    c=framod(n-k, mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod



xx = 2**n % mod


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


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

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


Verdicts: 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):
import math

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

MOD = 10**9 + 7

def make_fact_list(n, MOD):
    # make factorial list from 0 to n
    fact = [0] * (n+1)
    inv = [0] * (n+1)
    factinv = [0] * (n+1)

    fact[0]=fact[1]=1
    inv[1]=1
    factinv[0]=factinv[1]=1

    for i in range(2,n+1):
        fact[i] = fact[i-1] * i % MOD
        inv[i] = MOD - (( inv[MOD % i] *  (MOD // i)) % MOD )
        factinv[i] = factinv[i-1] * inv[i] % MOD
    
    return fact, factinv

def cbn(n_f, k, MOD, fact = [], factinv = []):
    if len(fact) == 0 and len(factinv) == 0:
        fact, factinv = make_fact_list(n, MOD)
    return fact[n] * factinv[n-k] * factinv[k] % MOD

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

s = power_with_mod(2, n, MOD)-1

fact, factinv = make_fact_list(b, MOD)

s -= cbn(n, a, MOD, fact, factinv)
s -= cbn(n, b, MOD, fact, factinv)


print(s)

import math

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

MOD = int(1e9) + 7

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

def cbn(n, a, MOD):
    x = 1
    for i in range(a):
        x = (x * (n-i)) % MOD

    y = math.factorial(a) % MOD
    return x * pow(y, MOD-2, MOD) %MOD

s = (s- cbn(n, a, MOD)) %MOD
s = (s- cbn(n, b, MOD)) %MOD


print(s)

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):
Sn = pow(2,n,MOD) - 1
if a > b:
    a,b = b,a
Xa, Xb = 1,1
Ya, Yb = 1,1
for i in range(b):
    if i < a:
        Xa = ( Xa * (n-i) ) % MOD
        Ya = ( Ya * pow((a-i),MOD-2, MOD)) % MOD
    Xb = ( Xb * (n-i) ) % MOD
    Yb = ( Yb * pow((b-i),MOD-2, MOD)) % MOD

ans = Sn - Xa*Ya % MOD - Xb*Yb % MOD
while ans < 0:
    ans += MOD
    
print(ans)

MOD = 10**9+7

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

Sn = pow(2,n,MOD) - 1
a = min(a, n-a)
b = min(b, n-b)
if a > b:
    a,b = b,a
Xa, Xb = 1,1
Ya, Yb = 1,1
for i in range(b):
    if i < a:
        Xa = ( Xa * (n-i) ) % MOD
        Ya = ( Ya * pow((a-i),MOD-2, MOD)) % MOD
    Xb = ( Xb * (n-i) ) % MOD
    Yb = ( Yb * pow((b-i),MOD-2, MOD)) % MOD

ans = Sn - Xa*Ya % MOD - Xb*Yb % MOD
while ans < 0:
    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):
from scipy.special import comb

#156D

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


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


Verdicts: 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):
MOD=10**9+7

def powmod(a,n,m): #a^n mod m
    ans=1
    while n!=0:
        if n&1: ans=ans*a%m
        a=a*a%m
        n>>=1
    return ans%m

def fact(n):
    ans=1
    for i in range(n): ans=ans*(i+1)%MOD
    return ans

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

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

ans=powmod(2,n,MOD)-1
ta1=fact(n-a+1,n)
tb1=fact(n-b+1,n)
ta2=pow(fact(a),MOD-2,MOD)
tb2=pow(fact(b),MOD-2,MOD)
a=ta1*ta2%MOD
b=tb1*tb2%MOD
print((ans-a-b)%MOD)

MOD=10**9+7

def powmod(a,n,m): #a^n mod m
    ans=1
    while n!=0:
        if n&1: ans=ans*a%m
        a=a*a%m
        n>>=1
    return ans%m

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

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

ans=powmod(2,n,MOD)-1
ta1=fact(n-a+1,n)
tb1=fact(n-b+1,n)
ta2=pow(fact(1,a),MOD-2,MOD)
tb2=pow(fact(1,b),MOD-2,MOD)
a=ta1*ta2%MOD
b=tb1*tb2%MOD
print((ans-a-b)%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):
def mod_pow(x, n, mod):
    if n == 0:
        return 1
    if n % 2 == 1:
        return x * mod_pow(x, n - 1, mod) % mod
    else:
        return mod_pow(x, n // 2, mod) ** 2 % mod

def choose(n, m, mod):
    x, y = 1, 1
    for i in range(m):
        x = x * (n - i) % mod
        y = x * (i + 1) % mod
    return x * mod_pow(y, mod - 2, mod) % mod

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

ans = (mod_pow(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)) % mod
print(ans)

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

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

ans = (pow(2, n, mod) - 1 - choose(n, a, mod) - choose(n, b, mod)) % 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 = list(map(int, input().split()))

mod = 10**9 + 7

import time
start = time.time()


# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
	return pow(x, mod-2, mod)

modinv_table = [-1] * (b+1)
for i in range(1, b+1):
    modinv_table[i] = modinv(i)

end = time.time()
# print("time: ", end - start)

def binomial_coefficients2(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table[i + 1]
        ans %= mod
    return ans

# (2 ** n - 1) - nCa - nCb
ans = power(2, n) - 1

ans -= (binomial_coefficients2(n, a) + binomial_coefficients2(n, b))
print(ans % mod)





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

mod = 10**9 + 7

import time
start = time.time()


# https://qiita.com/Yaruki00/items/fd1fc269ff7fe40d09a6
def modinv(x):
	return pow(x, mod-2, mod)

modinv_table = [-1] * (b+1)
for i in range(1, b+1):
    modinv_table[i] = modinv(i)

end = time.time()
# print("time: ", end - start)

def binomial_coefficients2(n, k):
    ans = 1
    for i in range(k):
        ans *= n-i
        ans *= modinv_table[i + 1]
        ans %= mod
    return ans

# (2 ** n - 1) - nCa - nCb
ans = pow(2, n, mod) - 1

ans -= (binomial_coefficients2(n, a) + binomial_coefficients2(n, b))
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):
mod=10**9+7
n,a,b=map(int,input().split())
ans=pow(2,mod-2,mod)-1
comb1=1
for i in range(n,n-a,-1):
  comb1*=i
  comb1%=mod
for i in range(1,a+1):
  comb1*=pow(i,mod-2,mod)
  comb1%=mod
comb2=1
for i in range(n,n-b,-1):
  comb2*=i
  comb2%=mod
for i in range(1,b+1):
  comb2*=pow(i,mod-2,mod)
  comb2%=mod
ans-=(comb1+comb2)
ans%=mod
print(ans)

mod=10**9+7
n,a,b=map(int,input().split())
ans=pow(2,n,mod)-1
comb1=1
for i in range(n-a+1,n+1):
  comb1*=i
  comb1%=mod
for i in range(1,a+1):
  comb1*=pow(i,mod-2,mod)
  comb1%=mod
comb2=1
for i in range(n-b+1,n+1):
  comb2*=i
  comb2%=mod
for i in range(1,b+1):
  comb2*=pow(i,mod-2,mod)
  comb2%=mod
ans-=(comb1+comb2)
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())
mod = 10**9+7

def rev(x):
    re = 10**9+5
    num = 1
    ix = x
    while re > 0:
        if re%2 == 1:
            num = (num*ix)%mod
        re //= 2
        ix = (ix**2)%mod
    return(num)

def kaijo(x):
    num = 1
    for i in range(1,x+1):
        num = (num*i)%mod
    return(num)

re = n
ans = 1
i2 = 2
while re > 0:
    if re%2 == 1:
        ans = (ans*i2)%mod
    re //= 2
    i2 = (i2**2)%mod

ans -= 1
kn = kaijo(n)
ans = (ans - (((kn*rev(kaijo(a)))%mod)*rev(kaijo[n-a]))%mod)%mod
ans = (ans - (((kn*rev(kaijo(b)))%mod)*rev(kaijo[n-b]))%mod)%mod
print(ans)


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

def rev(x):
    re = 10**9+5
    num = 1
    ix = x
    while re > 0:
        if re%2 == 1:
            num = (num*ix)%mod
        re //= 2
        ix = (ix**2)%mod
    return(num)

def kaijo(x):
    num = 1
    for i in range(1,x+1):
        num = (num*i)%mod
    return(num)

re = n
ans = 1
i2 = 2
while re > 0:
    if re%2 == 1:
        ans = (ans*i2)%mod
    re //= 2
    i2 = (i2**2)%mod
nca = 1
ncb = 1
for i in range(a):
    nca = (nca*(n-i))%mod
for i in range(b):
    ncb = (ncb*(n-i))%mod

ans -= 1
ans = (ans-(nca*rev(kaijo(a)))%mod)%mod
ans = (ans-(ncb*rev(kaijo(b)))%mod)%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):
n,a,b=map(int,input().split())

def comb(n,k,p):
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p


c=1
d=0
mod=10**9+7
for _ in range(n):
    c=c*2
    d+=1
    if d>30:
        d=0
        c=c%mod
c=c%mod

c-=comb(n,a,mod)+comb(n,b,mod)

if c<0:
    c+=mod

print(c)





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

c=10**9+7

def com(n,k,c):
    l=1
    m=1
    for i in range(k):
        l*=n-i
        m*=i+1
        l%=c
        m%=c
    return l*pow(m,c-2,c)%c

ans=pow(2,n,c)-1-com(n,a,c)-com(n,b,c)

ans%=c

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 numpy as np
import math

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

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

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

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

import numpy as np
import math as m

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

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

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

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

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

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

    return res

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

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

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()))
kumiawase_bunshi = 1
kumiawase_bunbo = 1
t=0
ans = 0
for i in range (1,n+1):
    if(i != a and i != b):
        t=n
        for j in range (n-i+1,n+1):
            kumiawase_bunshi = kumiawase_bunshi * j
        for k in range (1,i+1):
            kumiawase_bunbo = kumiawase_bunbo * k
        ans = ans + (kumiawase_bunshi / kumiawase_bunbo)
        kumiawase_bunshi = 1
        kumiawase_bunbo = 1
ans = ans % 1000000007
print(ans)

def choose(n,r):
    res = 1
    fac = 1
    for i in range(r):
        res *= n-i
        res %= MOD
        fac *= i+1
        fac %= MOD
    return res*pow(fac,MOD-2,MOD)%MOD        

n,a,b = list(map(int,input().split()))
MOD = 10**9+7
t=0
ans = pow(2,n,MOD)-1


ans -= choose(n,a)
ans -= choose(n,b)

ans = ans % MOD
print(int(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):
n,a,b = map(int, input().split())
if n/2 < a: a=n-a
if n/2 < b: b=n-b
total, combination = 0,1

for i in range(1,(n-1)//2+1):
    combination = combination*(n-i+1)/i
    total += combination
    if a == i: a_cnt = combination
    if b == i: b_cnt = combination
        
    total = total%(10**9+7)

if n == 2:
    print(0)
elif n%2==0:
    answer = total*2+combination*(n-i)/(i+1)-a_cnt-b_cnt+1
    print(answer%(10**9+7))
else:
    answer = total*2-a_cnt-b_cnt+1
    print(answer%(10**9+7))

n,a,b = map(int, input().split())        
X,Y = 1,1
for i in range(b):
    X *= n-i
    X %= 10**9+7
    Y *= i+1
    Y %= 10**9+7

    if a-1 == i:
        Xa,Ya = X,Y

comb_a = (Xa*pow(Ya,10**9+5))%(10**9+7)
comb_b = (X*pow(Y,10**9+5))%(10**9+7)

result = pow(2,n)-1-comb_a-comb_b
print(result if result>=0 else result+10**9+7)

n,a,b = map(int, input().split())
if n/2 < a: a=n-a
if n/2 < b: b=n-b
total, combination = 0,1

for i in range(1,(n-1)//2+1):
    combination = combination*(n-i+1)/i
    total += combination
    if a == i: a_cnt = combination
    if b == i: b_cnt = combination
        
    total = total%(10**9+7)

if n%2==0:
    print(total*2+combination*(n-i)/(i+1)-a_cnt-b_cnt+1)
else:
    print(total*2-a_cnt-b_cnt+1)

def pow_self(x,n):
    ans = 1
    while n>0:
        if n&1 == 1:
            ans = (ans*x)%(10**9+7)
            
        x = (x*x)%(10**9+7)
        n >>= 1
    return ans

  
n,a,b = map(int, input().split())        
X,Y = 1,1
for i in range(b):
    X *= n-i
    X %= 10**9+7
    Y *= i+1
    Y %= 10**9+7

    if a-1 == i:
        Xa,Ya = X,Y

comb_a = (Xa*pow_self(Ya,10**9+5))%(10**9+7)
comb_b = (X*pow_self(Y,10**9+5))%(10**9+7)

result = pow_self(2,n)-1-comb_a-comb_b
while result <0:
    result += 10**9+7
print(result)

Verdicts: Runtime Error

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

#print(x*pow(y,(mod-2),mod)%mod)

def conv(n, x, mod):
    X = 1
    for i in range(x):
        k = i+1
        X *= (n-k+1)*pow(k,(mod-2),mod)%mod
        X %= mod
    return X

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

#print(conv(n, a, mod))
#print(conv(n, b, mod))

ans = power_func(2, n, mod) - conv(n, a, mod) - conv(n, b, mod) - 1
ans %= mod
print(ans)n, a, b = map(int, input().split())
mod = 10**9+7

#print(x*pow(y,(mod-2),mod)%mod)

def conv(n, x, mod):
    X = 1
    for i in range(x):
        k = i+1
        X *= (n-k+1)*pow(k,(mod-2),mod)%mod
        X %= mod
    return X

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

#print(conv(n, a, mod))
#print(conv(n, b, mod))

ans = power_func(2, n, mod) - conv(n, a, mod) - conv(n, b, mod) - 1
ans %= mod
print(ans)

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

def cmb2(n, r, mod):
    res = 1
    temp = 1
    for k in range(1, r+1):
        res *= (n-k+1)
        temp *= k
        res %= mod
        temp %= mod
    res *= pow(temp,(mod-2),mod)
    res %= mod
    return res

def power(a, n, mod):
    bi=str(format(n,"b")) 
    res=1
    for i in range(len(bi)):
        res=(res*res) %mod
        if bi[i]=="1":
            res=(res*a) %mod
    return res

ans = power(2, n, mod) - cmb2(n, a, mod) - cmb2(n, b, mod) -1
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):
from math import factorial
import sys 
import math
sys.setrecursionlimit(400000000)
mod=1000000007
n,a,b=map(int,input().split())
def power(x,y):
    count=1
    rem=x
    while 2*count<y:
        x=x**2
        x=x%mod
        count*=2
    res=y-count
    return x*(pow(rem,res))%mod

def nck(x,y):
    sum=1
    for i in range(y):
        sum*=(x-i)/(i+1)
        sum=sum%mod
    return sum

ans=power(2,n)-1-nck(n,a)-nck(n,b)
if ans<1:
    print(0)
else:
    print(ans)



from math import factorial
import sys 
import math
sys.setrecursionlimit(400000000)
mod=1000000007
n,a,b=map(int,input().split())
def fac(n,k,mod):
    sum=1
    for i in range(k):
        sum=sum*(n-i)%mod
    return sum

def nck(x,y,mod):
    y=min(y,x-y)
    ans=fac(x,y,mod)*pow(fac(y,y,mod),mod-2,mod)%mod
    return ans
    
ans=pow(2,n,mod)-1-nck(n,a,mod)-nck(n,b,mod)
ans=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):
import sys
input=sys.stdin.readline
#from collections import defaultdict

#import fractions
#import math
#import collections
#from collections import deque

#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
MOD = 10**9 + 7
def comb(n, k, p):
    if n<0 or k<0 or n<k:
        return 0
    if n==0 or k==0:
        return 1
    k=k if k<=n-k else n-k
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return (x*pow(y,mod-2,mod))%mod
n,a,b = map(int,input().split())
A = comb(n,a,MOD)
B = comb(n,b,MOD)
C = pow(2,n,MOD)
ans = C -A-B-1
print(ans%MOD)

import sys
input=sys.stdin.readline
#from collections import defaultdict

#import fractions
#import math
#import collections
#from collections import deque

#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
#import itertools
MOD = 10**9 + 7
def comb(n, k, mod):
    if n<0 or k<0 or n<k:
        return 0
    if n==0 or k==0:
        return 1
    k=k if k<=n-k else n-k
    x = 1
    y = 1
    for i in range(k):
        x=x*(n-i)%mod
        y=y*(i+1)%mod
    return (x*pow(y,mod-2,mod))%mod
n,a,b = map(int,input().split())
A = comb(n,a,MOD)
B = comb(n,b,MOD)
C = pow(2,n,MOD)
ans = C -A-B-1
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):

from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
      return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
ans = pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod 
if ans < 0:
  ans += mod
  print(ans)


def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(n-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num*pow(den,-1,c) % c
mod = 10**9+7
n,a,b = map(int,input().split())
ans  = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod
if ans < 0:
    ans = 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):
n,a,b = (int(x) for x in input().split())
mod = 10**9+7

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

ans = pow(2,n,mod)-1-minus(b,a)-minus(b,b)
while ans<0:
    ans+=mod
print(ans)


n,a,b = map(int, input().split())
mod = 10**9+7
 
def minus(n,k):
    x,y =1,1
    for i in range(k):
        x*=(n-i)
        y*=(k-i)
        x%=mod
        y%=mod
    return x*pow(y, mod-2, mod)%mod
 
ans = pow(2,n,mod)-1-minus(n,a)-minus(n,b)
while ans<0:
    ans+=mod
print(ans)

Verdicts: Wrong Answer

Accepted