Problem p02729 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>
boost::math::lcm(10,20) ---> use it to find lcm.*/
using namespace std;
#define IO                                                                     \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
typedef long long ll;
#define PI pair<int, int>
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 3;
const int inf = 2e9;

/************ Use when precision need to set to some value **************/
// std::cout << std::setprecision(12);
// std::cout << std::fixed;
/*******************************************/
int max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}

int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
/*		0. Go to main function first.
                1. Take all the
   inputs................................................
                2. Check Once whether the graph given is directed or
   undirected.......
                3. Tree can also be undirected.
                4. Whenever you do multiplication and division in the same line,
   beware.
*/
void solve() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  ans += ((n * (n - 1)) / 2);
  ans += ((m * (m - 1)) / 2);
  cout << ans << endl;
}
/*
        memset() can be used to set all values as 0 or -1 for integer data
   types. It will not work if we use it to set as other values. The reason is
   memset works byte by byte.
*/

int main() {
  IO;

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

  int t;
  // cin >> t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>
boost::math::lcm(10,20) ---> use it to find lcm.*/
using namespace std;
#define IO                                                                     \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(NULL);                                                               \
  cout.tie(NULL)
typedef long long ll;
#define PI pair<int, int>
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 3;
const int inf = 2e9;

/************ Use when precision need to set to some value **************/
// std::cout << std::setprecision(12);
// std::cout << std::fixed;
/*******************************************/
int max(int a, int b) {
  if (a > b)
    return a;
  else
    return b;
}

int min(int a, int b) {
  if (a < b)
    return a;
  else
    return b;
}
/*		0. Go to main function first.
                1. Take all the
   inputs................................................
                2. Check Once whether the graph given is directed or
   undirected.......
                3. Tree can also be undirected.
                4. Whenever you do multiplication and division in the same line,
   beware.
*/
void solve() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  ans += ((n * (n - 1)) / 2);
  ans += ((m * (m - 1)) / 2);
  cout << ans << endl;
}
/*
        memset() can be used to set all values as 0 or -1 for integer data
   types. It will not work if we use it to set as other values. The reason is
   memset works byte by byte.
*/

int main() {
  IO;

  // #ifndef ONLINE_JUDGE
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  // #endif // ONLINE_JUDGE

  int t;
  // cin >> t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}