Problem p02768 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using MinPriorityQueue = priority_queue<T, vector<T>, greater<T>>;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cout << name << " : " << arg1 << std ::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  int len = comma - names;
  for (int i = 0; i < len; ++i) {
    cout << names[i];
  }
  cout << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define int long long
#define db double
#define eb emplace_back
#define pb push_back
#define fast_io()                                                              \
  ios_base ::sync_with_stdio(0);                                               \
  cin.tie(0);                                                                  \
  cout.tie(0)

const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1e-6;
mt19937_64
    rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int mul(int x, int y) {
  int res = ((x % MOD) * (y % MOD)) % MOD;
  return res;
}
int sub(int x, int y) {
  int res = ((x % MOD) - (y % MOD) + MOD) % MOD;
  return res;
}
int binpow(int a, int b) {
  a %= MOD;
  int res = 1;
  while (b) {
    if (b & 1)
      res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
int comb(int n, int k) {
  int fact1 = 1, fact2 = 1;
  for (int i = 1; i <= k; i++)
    fact1 = mul(fact1, i);
  for (int i = 0; i < k; i++)
    fact2 = mul(fact2, n - i);
  int x = binpow(fact1, MOD - 2);
  int res = mul(fact2, x);
  return res;
}
void test() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = sub(binpow(2, n), comb(n, a));
  ans = sub(ans, comb(n, b));
  ans -= 1;
  cout << ans << "\n";
}

int32_t main() {
  fast_io();
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  cout << fixed << setprecision(15);
  int t = 1;
  // cin >> t;
  for (int i = 0; i < t; ++i) {
    test();
  }
#ifdef HOME
  cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
#endif
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using MinPriorityQueue = priority_queue<T, vector<T>, greater<T>>;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
  cout << name << " : " << arg1 << std ::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&...args) {
  const char *comma = strchr(names + 1, ',');
  int len = comma - names;
  for (int i = 0; i < len; ++i) {
    cout << names[i];
  }
  cout << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
#define int long long
#define db double
#define eb emplace_back
#define pb push_back
#define fast_io()                                                              \
  ios_base ::sync_with_stdio(0);                                               \
  cin.tie(0);                                                                  \
  cout.tie(0)

const int MOD = 1e9 + 7;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1e-6;
mt19937_64
    rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int mul(int x, int y) {
  int res = ((x % MOD) * (y % MOD)) % MOD;
  return res;
}
int sub(int x, int y) {
  int res = ((x % MOD) - (y % MOD) + MOD) % MOD;
  return res;
}
int binpow(int a, int b) {
  a %= MOD;
  int res = 1;
  while (b) {
    if (b & 1)
      res = (res * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return res;
}
int comb(int n, int k) {
  int fact1 = 1, fact2 = 1;
  for (int i = 1; i <= k; i++)
    fact1 = mul(fact1, i);
  for (int i = 0; i < k; i++)
    fact2 = mul(fact2, n - i);
  int x = binpow(fact1, MOD - 2);
  int res = mul(fact2, x);
  return res;
}
void test() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = sub(binpow(2, n), comb(n, a));
  ans = sub(ans, comb(n, b));
  ans -= 1;
  cout << ans << "\n";
}

int32_t main() {
  fast_io();
  // #ifndef ONLINE_JUDGE
  //     freopen("input.txt", "r", stdin);
  //     freopen("output.txt", "w", stdout);
  // #endif
  cout << fixed << setprecision(15);
  int t = 1;
  // cin >> t;
  for (int i = 0; i < t; ++i) {
    test();
  }
#ifdef HOME
  cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
#endif
  return 0;
}