Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, a, n) for (int i = (n); i < (a); i++)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define repr2(i, a, n) for (int i = (n); i >= (a); i--)

template <typename T, typename U> void Inparray(T &f, U n) {
  for (int i = 0; i < n; i++)
    cin >> f[i];
}

template <typename T, typename U> void Printarray(T f, U n) {
  for (int i = 0; i < n; i++)
    i != n ? cout << f[i] << " " : cout << f[i];
}
template <typename T, typename U> void Printarray2(T f, U n) {
  for (int i = 0; i < n; i++)
    cout << f[i] << endl;
}
template <typename T, typename U, typename V> void Printarray3(T f, U a, V b) {
  rep(i, a) {
    rep(j, b) { cout << f[i][j]; }
    cout << endl;
  }
}
template <typename T, typename U> void Printarray4(T f, U n) {
  rep(i, n) {
    rep(j, n) { cout << f[i][j]; }
    cout << endl;
  }
}
void flagfunc(bool flag, string A, string B) {
  flag ? cout << A << endl : cout << B << endl;
}
void flag2func(bool flag) {
  flag ? cout << "Yes" << endl : cout << "No" << endl;
}
void flag3func(bool flag) {
  flag ? cout << "YES" << endl : cout << "NO" << endl;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  // cout<<hoge(n)<<" "<<hoge(m)<<endl;
  // cout<<hoge(n)/(2*hoge(n-2))<<" "<<hoge(m)/2*hoge(m-2)<<endl;
  // cout<<hoge(n)/(2*hoge(n-2))<<" "<<hoge(m)/(2*hoge(m-2))<<endl;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define All(s) s.begin(), s.end()
#define rAll(s) s.rbegin(), s.rend()
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, a, n) for (int i = (n); i < (a); i++)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define repr2(i, a, n) for (int i = (n); i >= (a); i--)

template <typename T, typename U> void Inparray(T &f, U n) {
  for (int i = 0; i < n; i++)
    cin >> f[i];
}

template <typename T, typename U> void Printarray(T f, U n) {
  for (int i = 0; i < n; i++)
    i != n ? cout << f[i] << " " : cout << f[i];
}
template <typename T, typename U> void Printarray2(T f, U n) {
  for (int i = 0; i < n; i++)
    cout << f[i] << endl;
}
template <typename T, typename U, typename V> void Printarray3(T f, U a, V b) {
  rep(i, a) {
    rep(j, b) { cout << f[i][j]; }
    cout << endl;
  }
}
template <typename T, typename U> void Printarray4(T f, U n) {
  rep(i, n) {
    rep(j, n) { cout << f[i][j]; }
    cout << endl;
  }
}
void flagfunc(bool flag, string A, string B) {
  flag ? cout << A << endl : cout << B << endl;
}
void flag2func(bool flag) {
  flag ? cout << "Yes" << endl : cout << "No" << endl;
}
void flag3func(bool flag) {
  flag ? cout << "YES" << endl : cout << "NO" << endl;
}

// 髫惹ｹ励ｒ豎ゅａ繧・
ll hoge(int n) {
  ll cnt = 1;
  repr2(i, 2, n) cnt *= i;
  return cnt;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  // cout<<hoge(n)<<" "<<hoge(m)<<endl;
  // cout<<hoge(n)/(2*hoge(n-2))<<" "<<hoge(m)/2*hoge(m-2)<<endl;
  // cout<<hoge(n)/(2*hoge(n-2))<<" "<<hoge(m)/(2*hoge(m-2))<<endl;
  cout << hoge(n) / (2 * hoge(n - 2)) + hoge(m) / (2 * hoge(m - 2)) << endl;
}