Problem p02768 (C++)

Buggy submission (status: Runtime Error):
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n, x)                                                             \
  for (int i = 0; i < (n); i++)                                                \
    cin >> x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template <class T> using V = vector<T>;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
// V,P(大文字)使用不可

const ll INF = 1e18;

// const ll MAX = 200010;//自分で大きさを調節
//  const ll MOD = 1000000007;

// 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(ll n,ll k){
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }

ll mod_pow(ll x, ll n, ll m) {
  if (n == 0)
    return 1;
  ll res = mod_pow(x * x % m, n / 2, m);
  if (n & 1)
    res = res * x % m;
  return res;
}

// ll mod_fact(ll n,ll p,ll &e){
//     e=0;
//     if(n==0) return 1;
//     ll res=mod_fact(n/p,p,e);
//     e+=n/p;
//     if(n/p%2!=0) return res*(p-fac[n%p])%p;
//     return res*fac[n%p]%p;
// }

ll c(ll n, ll k) {
  if (k == 0 || n == k || n == 0)
    return 1;
  if (k == 1)
    return n;
  return (c(n - 1, k - 1) + c(n - 1, k)) % mod;
}

signed main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;
  ll s, t, u, v, w, x;
  ans = (mod_pow(2, n, mod) - 1 - c(n, a) - c(n, b)) % mod;
  cout << ans << endl;
}

Fixed submission:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n, x)                                                             \
  for (int i = 0; i < (n); i++)                                                \
    cin >> x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template <class T> using V = vector<T>;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
// V,P(大文字)使用不可

const ll INF = 1e18;

// const ll MAX = 200010;//自分で大きさを調節
//  const ll MOD = 1000000007;

// 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(ll n,ll k){
//     if (n < k) return 0;
//     if (n < 0 || k < 0) return 0;
//     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
// }

ll mod_pow(ll x, ll n, ll m) {
  if (n == 0)
    return 1;
  ll res = mod_pow(x * x % m, n / 2, m);
  if (n & 1)
    res = res * x % m;
  return res;
}

// ll mod_fact(ll n,ll p,ll &e){
//     e=0;
//     if(n==0) return 1;
//     ll res=mod_fact(n/p,p,e);
//     e+=n/p;
//     if(n/p%2!=0) return res*(p-fac[n%p])%p;
//     return res*fac[n%p]%p;
// }

ll c(ll n, ll k) {
  if (k == 0 || n == k || n == 0)
    return 1;
  if (k == 1)
    return n;
  return (c(n - 1, k - 1) + c(n - 1, k)) % mod;
}

signed main() {
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;
  ll cnt = 1;
  ll bb = 1;
  for (ll i = 0; i <= a - 1; i++)
    cnt = cnt * (n - i) % mod;
  for (ll i = 2; i <= a; i++)
    cnt = cnt * mod_pow(i, mod - 2, mod) % mod;
  for (ll i = 0; i <= b - 1; i++)
    bb = bb * (n - i) % mod;
  for (ll i = 2; i <= b; i++)
    bb = bb * mod_pow(i, mod - 2, mod) % mod;
  ans = (mod_pow(2, n, mod) - 1 - cnt - bb) % mod;
  if (ans < 0) {
    while (ans < 0)
      ans += mod;
  }
  cout << ans << endl;
}