Problem p03425 (C++)

Buggy submission (status: Runtime Error):
// raja1999
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
// setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
// setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
// setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
// cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) f(i, 0, n)
#define fd(i, a, b) for (i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define ss second
#define ff first
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(a) a.size()
#define inf (1000 * 1000 * 1000 + 5)
#define all(a) a.begin(), a.end()
#define tri pair<int, pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000 * 1000 * 1000 + 7)
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int, vi, greater<int>>

// std::ios::sync_with_stdio(false);
vl v;
int main() {
  std::ios::sync_with_stdio(false);
  ll n, i, j, k, res = 0, c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0;
  string c[105];
  cin >> n;
  rep(i, n) {
    cin >> c[i];
    if (c[i][0] == 'M') {
      c1++;
      // return 0;
    }
    if (c[i][0] == 'A') {
      c2++;
    }
    if (c[i][0] == 'R') {
      c3++;
    }
    if (c[i][0] == 'C') {
      c4++;
    }
    if (c[i][0] == 'H') {
      c5++;
    }
  }
  v.pb(c1);
  v.pb(c2);
  v.pb(c3);
  v.pb(c4);
  v.pb(c5);
  rep(i, v.size()) {
    f(j, i + 1, v.size()) {
      f(k, j + 1, v.size()) { res += v[i] * v[j] * v[k]; }
    }
  }
  cout << res << endl;
}


Fixed submission:
// raja1999
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
// setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
// setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
// setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
// cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) f(i, 0, n)
#define fd(i, a, b) for (i = a; i >= b; i--)
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vector<ll>
#define ss second
#define ff first
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define sz(a) a.size()
#define inf (1000 * 1000 * 1000 + 5)
#define all(a) a.begin(), a.end()
#define tri pair<int, pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000 * 1000 * 1000 + 7)
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int, vi, greater<int>>

// std::ios::sync_with_stdio(false);
vl v;
int main() {
  std::ios::sync_with_stdio(false);
  ll n, i, j, k, res = 0, c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0;
  string c[100005];
  cin >> n;
  rep(i, n) {
    cin >> c[i];
    if (c[i][0] == 'M') {
      c1++;
      // return 0;
    }
    if (c[i][0] == 'A') {
      c2++;
    }
    if (c[i][0] == 'R') {
      c3++;
    }
    if (c[i][0] == 'C') {
      c4++;
    }
    if (c[i][0] == 'H') {
      c5++;
    }
  }
  v.pb(c1);
  v.pb(c2);
  v.pb(c3);
  v.pb(c4);
  v.pb(c5);
  rep(i, v.size()) {
    f(j, i + 1, v.size()) {
      f(k, j + 1, v.size()) { res += v[i] * v[j] * v[k]; }
    }
  }
  cout << res << endl;
}