Problem p02768 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout << endl
#define rt int Q[100005] = {0}
#define mp make_pair
#define test()                                                                 \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<int>())
#define oa(a, n)                                                               \
  for (int i = 0; i < n; i++)                                                  \
    cout << a[i] << " ";                                                       \
  nl
#define cn(a, n)                                                               \
  for (int i = 0; i < n; i++)                                                  \
    cin >> a[i];
#define ov(a, n)                                                               \
  for (int i = n - 1; i >= 0; i--)                                             \
    cout << a[i] << " ";                                                       \
  nl
#define ovp(a, n)                                                              \
  for (int i = 0; i < n; i++)                                                  \
    cout << a[i].ff << " " << a[i].ss << endl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
typedef pair<int, int> pii;
ll powe(ll n, ll m) {
  if (m == 0)
    return 1;
  ll t = powe(n, m / 2);
  if (m % 2 == 0)
    return (t * t);
  return (((t * t)) * n);
}
ll mpowe(ll n, ll m) {
  if (m == 0)
    return 1;
  ll t = mpowe(n, m / 2);
  t %= MOD;
  if (m % 2 == 0)
    return (t * t) % MOD;
  return (((t * t) % MOD) * n) % MOD;
}
int logtwo(int n) {
  if (n == 1)
    return 0;
  return logtwo(n / 2) + 1;
}
vector<int> v[200005]; // Vector for maintaining adjacency list explained above
int level[200005];
bool vis[200005]; // Mark the node if visited
void bfs(int s) {
  queue<int> q;
  q.push(s);
  level[s] = 0; // Setting the level of the source node as 0
  vis[s] = true;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    for (int i = 0; i < v[p].size(); i++) {
      if (vis[v[p][i]] == false) {
        // Setting the level of each node with an increment in the level of
        // parent node
        level[v[p][i]] = level[p] + 1;
        q.push(v[p][i]);
        vis[v[p][i]] = true;
      }
    }
  }
}
int main() {
  fastio();
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ll n, a, b;
  cin >> n >> a >> b;
  ll na = 1, nrn = 1;
  for (ll i = 1; i <= a; i++) {
    na = (na * i) % MOD;
  }
  for (ll i = n; i >= n - a + 1; i--) {
    nrn = (nrn * i) % MOD;
  }
  ll nca = (nrn * mpowe(na, MOD - 2) % MOD) % MOD;
  na = 1;
  nrn = 1;
  for (ll i = 1; i <= b; i++) {
    na = (na * i) % MOD;
  }
  for (ll i = n; i >= n - b + 1; i--) {
    nrn = (nrn * i) % MOD;
  }
  ll ncb = (nrn * mpowe(na, MOD - 2) % MOD) % MOD;
  // cout<<ncb<<endl;
  ll ans = (mpowe(2, n) - 1 - nca - ncb + 2 * MOD) % MOD;
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout << endl
#define rt int Q[100005] = {0}
#define mp make_pair
#define test()                                                                 \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<int>())
#define oa(a, n)                                                               \
  for (int i = 0; i < n; i++)                                                  \
    cout << a[i] << " ";                                                       \
  nl
#define cn(a, n)                                                               \
  for (int i = 0; i < n; i++)                                                  \
    cin >> a[i];
#define ov(a, n)                                                               \
  for (int i = n - 1; i >= 0; i--)                                             \
    cout << a[i] << " ";                                                       \
  nl
#define ovp(a, n)                                                              \
  for (int i = 0; i < n; i++)                                                  \
    cout << a[i].ff << " " << a[i].ss << endl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define fastio()                                                               \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0)
typedef pair<int, int> pii;
ll powe(ll n, ll m) {
  if (m == 0)
    return 1;
  ll t = powe(n, m / 2);
  if (m % 2 == 0)
    return (t * t);
  return (((t * t)) * n);
}
ll mpowe(ll n, ll m) {
  if (m == 0)
    return 1;
  ll t = mpowe(n, m / 2);
  t %= MOD;
  if (m % 2 == 0)
    return (t * t) % MOD;
  return (((t * t) % MOD) * n) % MOD;
}
int logtwo(int n) {
  if (n == 1)
    return 0;
  return logtwo(n / 2) + 1;
}
vector<int> v[200005]; // Vector for maintaining adjacency list explained above
int level[200005];
bool vis[200005]; // Mark the node if visited
void bfs(int s) {
  queue<int> q;
  q.push(s);
  level[s] = 0; // Setting the level of the source node as 0
  vis[s] = true;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    for (int i = 0; i < v[p].size(); i++) {
      if (vis[v[p][i]] == false) {
        // Setting the level of each node with an increment in the level of
        // parent node
        level[v[p][i]] = level[p] + 1;
        q.push(v[p][i]);
        vis[v[p][i]] = true;
      }
    }
  }
}
int main() {
  fastio();
  /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
   #endif*/
  ll n, a, b;
  cin >> n >> a >> b;
  ll na = 1, nrn = 1;
  for (ll i = 1; i <= a; i++) {
    na = (na * i) % MOD;
  }
  for (ll i = n; i >= n - a + 1; i--) {
    nrn = (nrn * i) % MOD;
  }
  ll nca = (nrn * mpowe(na, MOD - 2) % MOD) % MOD;
  na = 1;
  nrn = 1;
  for (ll i = 1; i <= b; i++) {
    na = (na * i) % MOD;
  }
  for (ll i = n; i >= n - b + 1; i--) {
    nrn = (nrn * i) % MOD;
  }
  ll ncb = (nrn * mpowe(na, MOD - 2) % MOD) % MOD;
  // cout<<ncb<<endl;
  ll ans = (mpowe(2, n) - 1 - nca - ncb + 2 * MOD) % MOD;
  cout << ans << endl;
}