Language: C++

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

const int MAX = 1e6;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll k=n;
    ll mod=1e9+7;
    ll ans=RepeatSquaring(2,k,mod);
    COMinit();
    ll nca_a=1,nca_b=1,ncb_a=1,ncb_b=1;
    for(int i=0; i<a; i++){
        nca_a*=(n-i);
        nca_b*=(i+1);
        nca_a%=mod;
        nca_b%=mod;
    }
    for(int i=0; i<b; i++){
        ncb_a*=(n-i);
        ncb_b*=(i+1);
        ncb_a%=mod;
        ncb_b%=mod;
    }
    ll nca=nca_a*modinv(nca_b,mod)%mod,ncb=ncb_a*modinv(ncb_b,mod)%mod;
    //cout<<nca<<" "<<ncb;
    ans-=nca;
    if(ans<0) ans+=mod;
    ans-=ncb;
    if(ans<0) ans+=mod;
    cout<<ans-1<<endl;
}
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

const int MAX = 1e6;
const int MOD = 1e9+7;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK) 
inline long long mod(long long a, long long m) {
    return (a % m + m) % m;
}

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}
int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll k=n;
    ll mod=1e9+7;
    ll ans=RepeatSquaring(2,k,mod);
    COMinit();
    ll nca_a=1,nca_b=1,ncb_a=1,ncb_b=1;
    for(int i=0; i<a; i++){
        nca_a*=(n-i);
        nca_b*=(i+1);
        nca_a%=mod;
        nca_b%=mod;
    }
    for(int i=0; i<b; i++){
        ncb_a*=(n-i);
        ncb_b*=(i+1);
        ncb_a%=mod;
        ncb_b%=mod;
    }
    ll nca=nca_a*modinv(nca_b,mod)%mod,ncb=ncb_a*modinv(ncb_b,mod)%mod;
    //cout<<nca<<" "<<ncb;
    ans-=nca;
    if(ans<0) ans+=mod;
    ans-=ncb;
    if(ans<0) ans+=mod;
    cout<<ans-1<<endl;
}


Compiler output:
a.cc:88:4: error: redefinition of 'll GCD(ll, ll)'
   88 | ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
      |    ^~~
a.cc:4:4: note: 'll GCD(ll, ll)' previously defined here
    4 | ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
      |    ^~~
a.cc:90:11: error: redefinition of 'const int MAX'
   90 | const int MAX = 1e6;
      |           ^~~
a.cc:6:11: note: 'const int MAX' previously defined here
    6 | const int MAX = 1e6;
      |           ^~~
a.cc:91:11: error: redefinition of 'const int MOD'
   91 | const int MOD = 1e9+7;
      |           ^~~
a.cc:7:11: note: 'const int MOD' previously defined here
    7 | const int MOD = 1e9+7;
      |           ^~~
a.cc:93:11: error: redefinition of 'long long int fac [1000000]'
   93 | long long fac[MAX], finv[MAX], inv[MAX];
      |           ^~~
a.cc:9:11: note: 'long long int fac [1000000]' previously declared here
    9 | long long fac[MAX], finv[MAX], inv[MAX];
      |           ^~~
a.cc:93:21: error: redefinition of 'long long int finv [1000000]'
   93 | long long fac[MAX], finv[MAX], inv[MAX];
      |                     ^~~~
a.cc:9:21: note: 'long long int finv [1000000]' previously declared here
    9 | long long fac[MAX], finv[MAX], inv[MAX];
      |                     ^~~~
a.cc:93:32: error: redefinition of 'long long int inv [1000000]'
   93 | long long fac[MAX], finv[MAX], inv[MAX];
      |                                ^~~
a.cc:9:32: note: 'long long int inv [1000000]' previously declared here
    9 | long long fac[MAX], finv[MAX], inv[MAX];
      |                                ^~~
a.cc:95:6: error: redefinition of 'void COMinit()'
   95 | void COMinit() {
      |      ^~~~~~~
a.cc:11:6: note: 'void COMinit()' previously defined here
   11 | void COMinit() {
      |      ^~~~~~~
a.cc:106:11: error: redefinition of 'long long int COM(int, int)'
  106 | long long COM(int n, int k){
      |           ^~~
a.cc:22:11: note: 'long long int COM(int, int)' previously defined here
   22 | long long COM(int n, int k){
      |           ^~~
a.cc:111:11: error: redefinition of 'long long int extGCD(long long int, long long int, long long int&, long long int&)'
  111 | long long extGCD(long long a, long long b, long long &x, long long &y) {
      |           ^~~~~~
a.cc:27:11: note: 'long long int extGCD(long long int, long long int, long long int&, long long int&)' previously defined here
   27 | long long extGCD(long long a, long long b, long long &x, long long &y) {
      |           ^~~~~~
a.cc:123:18: error: redefinition of 'long long int mod(long long int, long long int)'
  123 | inline long long mod(long long a, long long m) {
      |                  ^~~
a.cc:39:18: note: 'long long int mod(long long int, long long int)' previously defined here
   39 | inline long long mod(long long a, long long m) {
      |                  ^~~
a.cc:128:11: error: redefinition of 'long long int modinv(long long int, long long int)'
  128 | long long modinv(long long a, long long m) {
      |           ^~~~~~
a.cc:44:11: note: 'long long int modinv(long long int, long long int)' previously defined here
   44 | long long modinv(long long a, long long m) {
      |           ^~~~~~
a.cc:133:4: error: redefinition of 'll RepeatSquaring(ll, ll, ll)'
  133 | ll RepeatSquaring(ll N, ll P, ll M){
      |    ^~~~~~~~~~~~~~
a.cc:49:4: note: 'll RepeatSquaring(ll, ll, ll)' previously defined here
   49 | ll RepeatSquaring(ll N, ll P, ll M){
      |    ^~~~~~~~~~~~~~
a.cc:141:5: error: redefinition of 'int main()'
  141 | int main(){
      |     ^~~~
a.cc:57:5: note: 'int main()' previously defined here
   57 | int main(){
      |     ^~~~