Problem:


Score : 400 points

Problem Statement

Akari has n kinds of flowers, one of each kind.

She is going to choose one or more of these flowers to make a bouquet.

However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.

How many different bouquets are there that Akari can make?

Find the count modulo (10^9 + 7).

Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.

Constraints

All values in input are integers.

2 \leq n \leq 10^9

1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5)

Input

Input is given from Standard Input in the following format:

n a b

Output

Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)

Sample Input 1

4 1 3

Sample Output 1

7

In this case, Akari can choose 2 or 4 flowers to make the bouquet.

There are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.

Sample Input 2

1000000000 141421 173205

Sample Output 2

34076506

Print the count modulo (10^9 + 7).



Sample input:
4 1 3


Sample output:
7

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define FORN(i, a, n) for (int i = a; i < n; i++)
#define FRON(i, a, n) for (int i = a; i > n; i--)
#define FOR(i, n) for (int i = 0; i < n; i++)
#define FRO(i, a) for (int i = a; i > -1; i--)
#define mp make_pair
#define pb push_back
#define INF 1000000010
#define MOD 1000000007 // 998244353
#define PI 3.141592653589793238462643383279502884197169399375105820974945
#define FASTIO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef vector<string> vs;
typedef vector<vi> vii;

//debugging output in cerr
#define n_l '\n'
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: "; cerr << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void debugm(){;} template<typename Heads, typename... Tails> void debugm(Heads H, Tails... T){ cerr << to_string(H) << " | "; debugm(T...); } 
#define debugm(...) cerr << "[" << #__VA_ARGS__ << "]: "; debugm(__VA_ARGS__); cerr << endl

double round(double num, int dec) {return std::round(num*pow(10,dec))/pow(10,dec);}
vector<string> split(string s, char delim) {replace(s.begin(),s.end(),delim,' ');stringstream ss(s); string buf;vector<string> v;while (ss>>buf) v.push_back(buf);return v;}
template<typename T, int size> int siz(T(&)[size]){return size;}
long long POW(long long base, long long exp) {long long res = 1;while (exp > 0) {if (exp % 2 == 1){res= (res * base) % MOD;}exp = exp >> 1;base = (base * base) % MOD;}return res;}



ll nCr(int n, int r) {
    ll first = max(n-r, r);
    ll numerator = 1;
    for (int i = first+1; i <= n; i++) {
        numerator *= i;
        numerator %= MOD;
    }
    ll second = min(n-r, r);
    ll denominator = 1;
    for (int i = 1; i <= second; i++) {
        denominator *= POW(i, MOD-2);
        denominator %= MOD;
    }
    return numerator * denominator % MOD;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    ll ans = POW(2, n);
    debug(nCr(4, 2));
    ans = (ans - (nCr(n, a) + nCr(n, b)) % MOD - 1) % MOD;
    cout << ans;

}

Submission status: Runtime Error

Solution code:
import math
 
 
mod=10**9+7
 
def ncr(n,r):
	res=1
	for i in range(1,r+1):
		res=(res*(n-r+i))%mod
		inv=pow(i,mod-2,mod)
		res=(res*inv)%mod
	return res
 
n,a,b=map(int,raw_input().split())
p=pow(2,n,mod)
p=(p-1+mod)%mod
p=(p-ncr(n,a)+mod)%mod
p=(p-ncr(n,b)+mod)%mod
print p

Submission status: Runtime Error

Solution code:
import sys
input=sys.stdin.readline
#from collections import defaultdict
#d = defaultdict(int)
#import fractions
#import math
#import collections
#from collections import deque
#from bisect import bisect_left
#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)

Submission status: Runtime Error

Solution code:
import math
import scipy
def I():
  return input()
def II():
  return int(input())
def MII():
  return map(int, input().split())
def LMII():
  return list(map(int, input().split()))
n,a,b = MII()
print(2**n-1-scipy.misc.comb(n,a)-scipy.misc.comb(n,b))

Submission status: Runtime Error

Solution code:
import sys

MOD = 10 ** 9 + 7


class ModInt:

	def __init__(self, x, inv=None):
		self.x = x.x if isinstance(x, ModInt) else x % MOD
		self.inv = inv

	__str__ = lambda self:str(self.x)
	__repr__ = __str__
	__int__ = lambda self: self.x
	__index__ = __int__

	__add__ = lambda self, other: ModInt(self.x + ModInt(other).x)
	__radd__ = lambda self, other: ModInt(other + self.x)
	__iadd__ = __add__

	__sub__ = lambda self, other: ModInt(self.x - ModInt(other).x)
	__rsub__ = lambda self, other: ModInt(other - self.x)
	__isub__ = __sub__

	__mul__ = lambda self, other: ModInt(self.x * ModInt(other).x)
	__rmul__ = lambda self, other: ModInt(other * self.x)
	__imul__ = __mul__

	__pow__ = lambda self, other: ModInt(pow(self.x, ModInt(other).x, MOD))
	__rpow__ = lambda self, other: ModInt(pow(other, self.x, MOD))
	__pow__ = __pow__

	def __truediv__(self, other):
		if isinstance(other, ModInt) and other.inv != None:
			return ModInt(self.x * other.inv)
		else:
			return ModInt(self.x * pow(ModInt(other).x - 2))
	
	def __rtruediv__(self, other):
		if not self.inv:
			return ModInt(other * pow(self.x - 2))
		else:
			return ModInt(other * self.inv)

	__itruediv__ = __truediv__

	__floordiv__ = __truediv__
	__rfloordiv__ = __rtruediv__
	__ifloordiv__ = __itruediv__

	__mod__ = lambda self, other: ModInt(self.x % other)
	__rmod__ = lambda self, other: ModInt(other % self.x)
	__imod__ = __mod__

	__lt__ = lambda self, other: self.x < ModInt(other).x
	__gt__ = lambda self, other: self.x > ModInt(other).x
	__le__ = lambda self, other: self.x <= ModInt(other).x
	__ge__ = lambda self, other: self.x >= ModInt(other).x
	__eq__ = lambda self, other: self.x == ModInt(other).x
	__ne__ = lambda self, other: self.x != ModInt(other).x

class Fact:
	def __init__(self, MAX):
		self.fact = [0] * MAX
		finv = [0] * MAX
		inv = [0] * MAX
		self.fact[0] = 1
		self.fact[1] = 1
		finv[0] = 1
		finv[1] = 1
		inv[1] = 1
		for i in range(2, MAX):
			self.fact[i] = self.fact[i - 1] * i % MOD
			inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
			finv[i] = finv[i - 1] * inv[i] % MOD
		for i in range(MAX):
			self.fact[i] = ModInt(self.fact[i], inv=finv[i])
	def __call__(self, value):
		return self.fact[value]

class Comb:
	def __init__(self, MAX):
		self.fact = Fact(MAX)
	def __call__(self, n, r):
		return self.fact(n) // self.fact(n-r) // self.fact(r)

class MiniComb:
	def __init__(self, MAX):
		self.fact = Fact(MAX)
	def __call__(self, n, r):
		a = ModInt(1)
		for i in range(r):
			a *= n - i
		return a // self.fact(r)


def main():
	n, a, b = map(int, sys.stdin.readline().split())
	comb = MiniComb(2*10**5)
	print(ModInt(2**ModInt(n) - 1 - comb(n, a) - comb(n, b)))
main()

Submission status: Runtime Error

Solution code:
import sys

MOD = 10 ** 9 + 7


class ModInt:

	def __init__(self, x, inv=None):
		self.x = x.x if isinstance(x, ModInt) else x % MOD
		self.inv = inv

	__str__ = lambda self:str(self.x)
	__repr__ = __str__
	__int__ = lambda self: self.x
	__index__ = __int__

	__add__ = lambda self, other: ModInt(self.x + ModInt(other).x)
	__radd__ = lambda self, other: ModInt(other + self.x)
	__iadd__ = __add__

	__sub__ = lambda self, other: ModInt(self.x - ModInt(other).x)
	__rsub__ = lambda self, other: ModInt(other - self.x)
	__isub__ = __sub__

	__mul__ = lambda self, other: ModInt(self.x * ModInt(other).x)
	__rmul__ = lambda self, other: ModInt(other * self.x)
	__imul__ = __mul__

	__pow__ = lambda self, other: ModInt(pow(self.x, ModInt(other).x, MOD))
	__rpow__ = lambda self, other: ModInt(pow(other, self.x, MOD))
	__pow__ = __pow__

	def __truediv__(self, other):
		if isinstance(other, ModInt) and other.inv != None:
			return ModInt(self.x * other.inv)
		else:
			return ModInt(self.x * pow(ModInt(other).x - 2))
	
	def __rtruediv__(self, other):
		if not self.inv:
			return ModInt(other * pow(self.x - 2))
		else:
			return ModInt(other * self.inv)

	__itruediv__ = __truediv__

	__floordiv__ = lambda self, other: ModInt(self.x // ModInt(other).x)
	__rfloordiv__ = lambda self, other: ModInt(other // self.x)
	__ifloordiv__ = __floordiv__

	__mod__ = lambda self, other: ModInt(self.x % other)
	__rmod__ = lambda self, other: ModInt(other % self.x)
	__imod__ = __mod__

	__lt__ = lambda self, other: self.x < ModInt(other).x
	__gt__ = lambda self, other: self.x > ModInt(other).x
	__le__ = lambda self, other: self.x <= ModInt(other).x
	__ge__ = lambda self, other: self.x >= ModInt(other).x
	__eq__ = lambda self, other: self.x == ModInt(other).x
	__ne__ = lambda self, other: self.x != ModInt(other).x

class Fact:
	def __init__(self, MAX):
		self.fact = [0] * MAX
		finv = [0] * MAX
		inv = [0] * MAX
		self.fact[0] = 1
		self.fact[1] = 1
		finv[0] = 1
		finv[1] = 1
		inv[1] = 1
		for i in range(2, MAX):
			self.fact[i] = self.fact[i - 1] * i % MOD
			inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
			finv[i] = finv[i - 1] * inv[i] % MOD
		for i in range(MAX):
			self.fact[i] = ModInt(self.fact[i], inv=finv[i])
	def __call__(self, value):
		return self.fact[value]

class Comb:
	def __init__(self, MAX):
		self.fact = Fact(MAX)
	def __call__(self, n, r):
		return self.fact(n) // self.fact(n-r) // self.fact(r)

class MiniComb:
	def __init__(self, MAX):
		self.fact = Fact(MAX)
	def __call__(self, n, r):
		a = ModInt(1)
		for i in range(r):
			a *= n - i
		return a / self.fact(r)


def main():
	n, a, b = map(int, sys.stdin.readline().split())
	comb = MiniComb(2*10**5)
	print(ModInt(2**ModInt(n) - 1 - comb(n, a) - comb(n, b)))
main()

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
import math
#再起限界突破
import sys
sys.setrecursionlimit(1000000000)
def action(k):
    if k == 1:
        return 1
    else:
        return k * action(k-1)
ans = pow(2,n,mod)  - action(n)/action(n-a)/action(a) - action(n)/(action(n-b)*action(b)) - 1
print(int(ans%mod))

Submission status: Runtime Error

Solution code:
n,a,b = [int(x) for x in input().split()]
mod = 10**9 + 7
import math
#再起限界突破
import sys
sys.setrecursionlimit(2000000000)
#メモ化再帰
from functools import lru_cache
@lru_cache(maxsize=2000000000)
def action(k):
    if k == 1:
        return 1
    else:
        return k * action(k-1)
ans = pow(2,n,mod)  - action(n)/action(n-a)/action(a) - action(n)/(action(n-b)*action(b)) - 1
print(int(ans%mod))

Submission status: Runtime Error

Solution code:
def comb(n,r,mod=10**9+7):
    return((n(n-1)//2 - r(r-1)//2)%mod)

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

ans = (pow(2,n,mod)-1-comb(n,a)-comb(n,b)) % mod #値が大きくなるので全てmodで計算
print(ans)

Submission status: Runtime Error

Solution code:
n,a,b=map(int,input().split())
mod=10**9+7
fact=[0]*(n+1)
inv=[0]*(n+1)
fact_inv=[0]*(n+1)

def shisuu(n):
  if n==1:
    return 2
  elif n%2==1:
    return (2*shisuu(n//2)**2) % mod
  else:
    return (shisuu(n//2)**2) % mod
  
def preComb(a):
  fact[0]=1
  fact[1]=1
  inv[0]=1
  inv[1]=1
  fact_inv[0]=1
  fact_inv[1]=1
  for i in range(2,a+1):
    fact[i]=fact[i-1] * i % mod
    inv[i]=mod - inv[mod % i] * (mod // i) % mod
    fact_inv[i]=fact_inv[i-1] * inv[i] %mod
preComb(n)
def comb(n,a):
  return fact[n]*(fact_inv[n-a]*fact_inv[a] % mod) % mod
ans=(shisuu(n)-comb(n,a)-comb(n,b)-1) % mod
print(ans)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

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

p = 10 ** 9 + 7
N = 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)
    
aa=cmb(n,a,p)
bb=cmb(n,b,p)

print((2**n-1-aa-bb)%(10**9+7))

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
mod = 10 **9 +7
fac = [1] * 200000
inv = [1] * 200000
for i in range(1,len(fac)):
    fac[i] = fac[i-1] * i % mod
    inv[i] = pow(fac[i], mod-2, mod)

facna = 1
facnb = 1
for i in range(n-a+1,n+1):
    facna = facna * i %mod
for i in range(n-b+1,n+1):
    facnb = facnb * i %mod
ret = pow(2,n,mod) - 1 - facna * inv[a] - facnb * inv[b]
ret = ret%mod
print(ret)

Submission status: Runtime Error

Solution code:
import sys 
sys.setrecursionlimit(10**10)

def mod_combination(n, k, mod):
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod

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

Submission status: Runtime Error

Solution code:
def mod_combination(n, k, mod):
    def mod_permutation(n, k, mod):
        if n<=k:
            return 1
        else:
            return (n * mod_permutation(n-1,k,mod))%mod

    def mod_inv_permutation(k, mod):
        k, mod = int(k), int(mod)
        if k<=1:
            return 1
        else:
            return (pow(k,mod-2,mod) * mod_inv_permutation(k-1, mod))%mod

    return (mod_permutation(n,n-k,mod) * mod_inv_permutation(k, mod))%mod

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
def mod_comb(n, r, mod):
    ans = 1
    for i in range(1, r + 1):
        ans *= n - (i - 1)
        ans %= mod
        ans *= inv[i]
        ans %= mod
    return int(ans)
 p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
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)
import math
mod = 10 ** 9 + 7
res = pow(2, n, mod) - 1 - mod_comb(n, a, mod) - mod_comb(n, b, mod)
print(res % mod)

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
def cmb(n, r, p):
    ans = 1
    for i in range(1, r + 1):
        ans *= 
        ans /= i
        ans %= mod
    return int(ans)
 p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
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)
import math
mod = 10 ** 9 + 7
res = pow(2, n, mod) - 1 - mod_comb(n, a, mod) - mod_comb(n, b, mod)
print(res % mod)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

# 繰り返し二乗法
def pow_r_mod(x:int, n:int, mod=10**9+7)->int:
    # 計算量 : log N
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        x %= mod
        n //= 2
    return (K * x) % mod

m, a, b = mi()

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

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

mcb = mca

for i in range(a+1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

print((pow_r_mod(2, m)-1-mca-mcb) % P)

Submission status: Runtime Error

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

n_sum = 2**n-1

a_sum = 1
for x in range(a):
  a_sum *= (n-x)/(x+1)

b_sum = 1
for y in range(b):
  b_sum *= (n-y)/(y+1)
  
print(int((n_sum - a_sum - b_sum)%(10**9+7)))

Submission status: Runtime Error

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

n_sum = 2**n

a_sum = 1
for x in range(a):
  a_sum *= (n-x)/(x+1)

b_sum = 1
for y in range(b):
  b_sum *= (n-y)/(y+1)
  
print(int((n_sum - a_sum - b_sum)%(10**9+7)))

Submission status: Runtime Error

Solution code:
MOD = 10**9+7 # p=MOD
n, a, b = map(int, input().split())
whole = pow(2, n, MOD)-1 # 2^n-1(mod p)を計算。
# nCaの計算
comb1=1
for i in range(n-a+1,n+1): # n*(n-1)*(n-2)*...*(n-a+1)(mod p)を計算
  comb1 *= i
  comb1 %= mod
for i in range(1,a+1): # 1/a!(mod p)を計算 フェルマーの小定理:1/a = a^p-2(mod p)を利用
  comb1 *= pow(i,mod-2,mod)
  comb1 %= mod
comb2=1
for i in range(n-b+1,n+1): # n*(n-1)*(n-2)*...*(n-b+1)(mod p)を計算
  comb2 *= i
  comb2 %= mod
for i in range(1,b+1):
  comb2 *= pow(i,mod-2,mod)
  comb2 %= mod
whole -= (comb1+comb2)
whole %= mod
print(whole)

Submission status: Runtime Error

Solution code:
MOD = 10**9+7 # p=MOD
n, a, b = map(int, input().split())
whole = pow(2, n, MOD)-1 # 2^n-1(mod p)を計算。
# nCaの計算
comb1=1
for i in range(n-a+1,n+1): # n*(n-1)*(n-2)*...*(n-a+1)(mod p)を計算
  comb1 *= i
  comb1 %= mod
for i in range(1,a+1): # 1/a!(mod p)を計算 フェルマーの小定理:1/a = a^p-2(mod p)を利用
  comb1 *= pow(i,mod-2,mod)
  comb1 %= mod
comb2=1
for i in range(n-b+1,n+1): # n*(n-1)*(n-2)*...*(n-b+1)(mod p)を計算
  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)

Submission status: Runtime Error

Solution code:
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
    
def main():
    n, a, b = map(int, input().split())
    whole = 2**n-1
    a = combinations_count(n, a)
    b = combinations_count(n, b)
    print((whole-a-b)%(10**9+7))

if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

#制限なしで全ての花束の作り方
wa = pow(2, n, 10 ** 9 + 7) - 1

#a本の花束の作り方
#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)

Submission status: Runtime Error

Solution code:
from scipy.special import comb
n,a,b=input().split()        
n=int(n)
a=int(a)
b=int(b)
l=[]
for i in range(1,n+1):
    l.append(i)

l.remove(a)
l.remove(b)
c=0
for i in l:
    c+=comb(n,i)  
print(int(c))

Submission status: Runtime Error

Solution code:
from functools import reduce

def inv(n):
    return p - inv(p%n) * (p//n)%p

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(lambda x, y: (x*y)%p, range(n, n - r, -1))
    inv_denom = reduce(lambda x, y: (x*inv(y))%p, range(1, r + 1))
    return (numer * inv_denom) % p

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

ans = pow(2, n, p) - 1
ans -= cmb(n, a, p) + cmb(n, b, p)
print(ans % p)

Submission status: Runtime Error

Solution code:
from functools import reduce

def inv(n):
    return p - inv(p%n) * (p//n)%p

def cmb(n, r, p):
    r = min(n - r, r)
    if r == 0:
        return 1
    numer = reduce(lambda x, y: (x*y)%p, range(n, n - r, -1))
    inv_denom = reduce(lambda x, y: inv((x*y)%p), range(1, r + 1))
    return (numer * inv_denom) % p

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

ans = pow(2, n, p) - 1
ans -= cmb(n, a, p) + cmb(n, b, p)
print(ans % p)

Submission status: Runtime Error

Solution code:
from functools import reduce

def cmb(n, r, p):
    r = min(n - r, r)
    numer = reduce(lambda x, y: (x*y)%p, range(n, n - r, -1))
    denom = reduce(lambda x, y: (x*y)%p, range(1, r + 1))
    return (numer * pow(denom, p-2, p)) % p

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

Submission status: Runtime Error

Solution code:
#TLE

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

#　ans = 2**n
na = list(bin(n))
nb = na[3:]

ans = 2

for b in nb:
    if b == '0':
        ans **= 2
    else:
        ans = (ans ** 2) * 2

if n == 0:
    ans = 1

#　数え過ぎたものを引く
def comb(n, r):
    m = 1
    for i in range(n-r+1, n+1):
        m *= i
    for i in range(1, r+1):
        m //= i
    return m
ans -= comb(n, a) + comb(n, b) + 1

print(int(ans % (1000000007)))

Submission status: Runtime Error

Solution code:
from scipy.misc import comb

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

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


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

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

print(res)

Submission status: Runtime Error

Solution code:
from scipy.special import comb

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

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


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

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

print(res)

Submission status: Runtime Error

Solution code:
def n_kaijo(n):
    if n == 0:
        return 1
    return n * n_kaijo(n-1)

def nCr(n, r):
    if n == r:
        return 1
    return int(n_kaijo(n) / (n_kaijo(r) * n_kaijo(n-r)))

def nCr_ver2(n, r):
    if n == r:
        return 1
    product_n = 1
    for i in range(n-r+1, n+1):
        product_n *= i            
    return int(product_n / n_kaijo(r))

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

something = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    something += nCr_ver2(n, i)
print(something % (10**9 + 7))

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(10*9)

def n_kaijo(n):
    if n == 0:
        return 1
    return n * n_kaijo(n-1)

def nCr(n, r):
    if n == r:
        return 1
    return int(n_kaijo(n) / (n_kaijo(r) * n_kaijo(n-r)))
    
n, a, b = map(int, input().split())

something = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    something += nCr(n, i)
print(something % (10**9 + 7))

Submission status: Runtime Error

Solution code:
def n_kaijo(n):
    if n == 0:
        return 1
    return n * n_kaijo(n-1)

def nCr(n, r):
    if n == r:
        return 1
    return int(n_kaijo(n) / (n_kaijo(r) * n_kaijo(n-r)))
    
n, a, b = map(int, input().split())

something = 0
for i in range(1, n+1):
    if i == a or i == b:
        continue
    something += nCr(n, i)
print(something)

Submission status: Runtime Error

Solution code:
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

Submission status: Runtime Error

Solution code:
import math
n,a,b=map(int, input().split())
count=0
for i in range(n):#i+1本の花束の組み合わせ
    # print(i)
    if i+1==a or i+1==b:
        continue
    # print(i)
    count += math.factorial(n)/math.factorial(i+1)/math.factorial(n-(i+1))
print(int(count%(10^9+7))

Submission status: Runtime Error

Solution code:
class Cmb:
    def __init__(self, N=10**5, mod=10**9+7):
        self.fact = [1,1]
        self.fact_inv = [1,1]
        self.inv = [0,1]
        
        """ 階乗を保存する配列を作成 """
        for i in range(2, N+1):
            self.fact.append((self.fact[-1]*i) % mod)
            self.inv.append((-self.inv[mod%i] * (mod//i))%mod)
            self.fact_inv.append((self.fact_inv[-1]*self.inv[i])%mod)
    
    """ 関数として使えるように、callで定義 """
    def __call__(self, n, r, mod=10**9+7):
        if (r<0) or (n<r):
            return 0
        r = min(r, n-r)
        return self.fact[n] * self.fact_inv[r] * self.fact_inv[n-r] % mod

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

Submission status: Runtime Error

Solution code:
n, a, b = map(int, input().split())
p = 10**9 + 7
def ModComb(n, r, p):
    N = n%p
    R = r%p
    if N<R:
        return 0
    if N < 2*R:
        R = N-R
    if R == 0:
        return 1
    else:
        return (n*pow(r, p-2, p))%p*ModComb(n-1, r-1, p)

ans = 1
for i in range(N):
  ans *= 2
  ans = ans%p
ans = ans - 1 - ModComb(n, a, p) - ModComb(n, b, p)
ans = ans%p
print(ans)

Submission status: Runtime Error

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


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

  
mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range(2, N+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)

nCa = cmb(n, a, mod)
nCb = cmb(n, b, mod)
print(2**n-1-nCa-nCb)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret


N, A, B = map(int, input().split())
MOD = 10**9+7
F = FactMod(N+1, MOD)

print((pow(N, 2, MOD)-1 - F.comb(N, A) - F.comb(N, B)+MOD) % MOD)

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
from math import factorial
N = 10**9+7
def combinations_count(n, r, N):
    ''' 組み合わせ '''
    return (factorial(n) // (factorial(n - r) * factorial(r)) ) % N

lis = list(range(1, a+1))
lis.remove(a)
lis.remove(b)

data1 = list(map(combinations_count, lis))
print(lis)
print(combinations_count(5, 2, N))

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
import math

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

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

ans=2**N-1

X1=permutations_count(N,a)
Y1=math.factrial(a)
X2=permutations_count(N,b)
Y2=math.factrial(b)

A=X1*pow(Y1,(10**9+5))%(10**9+7)
B=X2*pow(Y2,(10**9+5))%(10**9+7)

ans=(ans-A-B)%(10**9+7)

Submission status: Runtime Error

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

mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, max(a, b) + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((- inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

def nCr(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

p = 1000000007
total = (2 ** n - 1) % p
total = (total - nCr(n, a, p) - nCr(n, b, p)) % p
print(total)

Submission status: Runtime Error

Solution code:
import math
from scipy.special import comb

def comb(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 -= comb(n, a, mod)
sum -= comb(n, b, mod)

print(int(sum % mod))