prithivMLmods/Coder-Stat huggingface dataset:
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()   // reverse
#define strall(v) (v).cbegin(), (v).cend() // const_itterator
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
template <class t, class u> void chmax(t &a, u b) {
  if (a < b)
    a = b;
}
template <class t, class u> void chmin(t &a, u b) {
  if (b < a)
    a = b;
}

const int INF = 1e9 + 5;

int one[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int two[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
int thr[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  map<char, int> m;
  rep(i, n) {
    if (s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' ||
        s[i][0] == 'H') {
      m[s[i][0]]++;
    }
  }
  ll res = 0;
  vector<ll> d(5, 0);
  int index = 0;
  for (auto ma : m) {
    d[index] = (ll)ma.second;
    index++;
  }
  rep(i, 10) res += (d[one[i] * d[two[i]]] * d[thr[i]]);
  cout << res << endl;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()   // reverse
#define strall(v) (v).cbegin(), (v).cend() // const_itterator
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
template <class t, class u> void chmax(t &a, u b) {
  if (a < b)
    a = b;
}
template <class t, class u> void chmin(t &a, u b) {
  if (b < a)
    a = b;
}

const int INF = 1e9 + 5;

int one[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int two[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
int thr[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};
int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  map<char, int> m;
  rep(i, n) {
    if (s[i][0] == 'M' || s[i][0] == 'A' || s[i][0] == 'R' || s[i][0] == 'C' ||
        s[i][0] == 'H') {
      m[s[i][0]]++;
    }
  }
  ll res = 0;
  vector<ll> d(5, 0);
  int index = 0;
  for (auto ma : m) {
    d[index] = (ll)ma.second;
    index++;
  }
  rep(i, 10) res += (d[one[i]] * d[two[i]] * d[thr[i]]);
  cout << res << endl;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

#define ALL(obj) (obj).begin(), (obj).end()

typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;

typedef pair<int, int> P;

#define LINF ((ll)1 << 63 - 1)
#define INF (1 << 29)
#define MINF -2000000007
#define MAX 205

const int MOD = 1e9 + 7;
// テンプレ終了
//====================================================================//

//
int main() {
  int N;
  cin >> N;
  int nf[5] = {0, 0, 0, 0, 0};

  REP(i, N) {
    string s;
    cin >> s;
    switch (s[0]) {
    case 'M':
      nf[0]++;
      break;
    case 'A':
      nf[1]++;
      break;
    case 'R':
      nf[2]++;
      break;
    case 'C':
      nf[3]++;
      break;
    case 'H':
      nf[4]++;
      break;
    default:;
    }
  }

  ll ans = 0;
  REP(i, N - 2) REPS(j, i + 1, N - 1) REPS(k, j + 1, N) {
    ans += (ll)nf[i] * nf[j] * nf[k];
  }

  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)

#define ALL(obj) (obj).begin(), (obj).end()

typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;

typedef pair<int, int> P;

#define LINF ((ll)1 << 63 - 1)
#define INF (1 << 29)
#define MINF -2000000007
#define MAX 205

const int MOD = 1e9 + 7;
// テンプレ終了
//====================================================================//

//
int main() {
  int N;
  cin >> N;
  int nf[5] = {0, 0, 0, 0, 0};

  REP(i, N) {
    string s;
    cin >> s;
    switch (s[0]) {
    case 'M':
      nf[0]++;
      break;
    case 'A':
      nf[1]++;
      break;
    case 'R':
      nf[2]++;
      break;
    case 'C':
      nf[3]++;
      break;
    case 'H':
      nf[4]++;
      break;
    default:;
    }
  }

  ll ans = 0;
  REP(i, 5 - 2) REPS(j, i + 1, 5 - 1) REPS(k, j + 1, 5) {
    ans += (ll)nf[i] * nf[j] * nf[k];
  }

  cout << ans << endl;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
  int n;
  cin >> n;
  vector<string> s;
  for (int i = 0; i < n; i++)
    cin >> s[i];

  sort(s.begin(), s.end());

  s.erase(unique(s.begin(), s.end()), s.end());

  vector<int> v(5, 0);
  for (int i = 0; i < s.size(); i++) {
    if (s[i][0] == 'M')
      v[0]++;
    if (s[i][0] == 'A')
      v[1]++;
    if (s[i][0] == 'R')
      v[2]++;
    if (s[i][0] == 'C')
      v[3]++;
    if (s[i][0] == 'H')
      v[4]++;
  }

  int ans = 0;
  for (int i = 0; i < (1 << 5); i++) {
    if (__builtin_popcount(i) == 3) {
      int tmp = 1;
      for (int j = 0; j < 5; j++) {
        if (i & (1 << j))
          tmp *= v[j];
      }
      ans += tmp;
    }
  }

  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++)
    cin >> s[i];

  sort(s.begin(), s.end());

  s.erase(unique(s.begin(), s.end()), s.end());

  vector<int> v(5, 0);
  for (int i = 0; i < s.size(); i++) {
    if (s[i][0] == 'M')
      v[0]++;
    if (s[i][0] == 'A')
      v[1]++;
    if (s[i][0] == 'R')
      v[2]++;
    if (s[i][0] == 'C')
      v[3]++;
    if (s[i][0] == 'H')
      v[4]++;
  }

  int ans = 0;
  for (int i = 0; i < (1 << 5); i++) {
    if (__builtin_popcount(i) == 3) {
      int tmp = 1;
      for (int j = 0; j < 5; j++) {
        if (i & (1 << j))
          tmp *= v[j];
      }
      ans += tmp;
    }
  }

  cout << ans << endl;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
typedef vector<int> vi;
const int mod = 1000000007;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  map<char, int> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' ||
        s[0] == 'H') {
      m[s[0]]++;
    }
  }
  int ans = 0, i = 1;
  vi v;
  if (m.size() == 0) {
    cout << 0 << endl;
    return 0;
  }
  tr(it, m) { v.pb(it->second); }

  for (int i = 0; i < v.size() - 2; i++) {
    if (v[i] == 0)
      continue;
    for (int j = i + 1; j < v.size() - 1; j++) {
      if (v[j] == 0)
        continue;
      for (int k = j + 1; k < v.size(); k++) {
        if (v[k] == 0)
          continue;
        ans = ans + v[i] * v[j] * v[k];
      }
    }
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define int unsigned long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
typedef vector<int> vi;
const int mod = 1000000007;

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  map<char, int> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' ||
        s[0] == 'H') {
      m[s[0]]++;
    }
  }
  int ans = 0, i = 1;
  vi v;
  if (m.size() < 3) {
    cout << 0 << endl;
    return 0;
  }
  tr(it, m) { v.pb(it->second); }

  for (int i = 0; i < v.size() - 2; i++) {
    if (v[i] == 0)
      continue;
    for (int j = i + 1; j < v.size() - 1; j++) {
      if (v[j] == 0)
        continue;
      for (int k = j + 1; k < v.size(); k++) {
        if (v[k] == 0)
          continue;
        ans = ans + v[i] * v[j] * v[k];
      }
    }
  }
  cout << ans << endl;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;

  string s[10000];
  long long m = 0, a = 0, r = 0, c = 0, h = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];

    if (s[i][0] == 'M')
      m++;
    if (s[i][0] == 'A')
      a++;
    if (s[i][0] == 'R')
      r++;
    if (s[i][0] == 'C')
      c++;
    if (s[i][0] == 'H')
      h++;
  }

  cout << m * a * r + m * a * c + m * a * h + m * r * c + m * r * h +
              m * c * h + a * r * c + a * r * h + a * c * h + r * c * h
       << endl;

  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n;
  cin >> n;

  string s[100000];
  long long m = 0, a = 0, r = 0, c = 0, h = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];

    if (s[i][0] == 'M')
      m++;
    if (s[i][0] == 'A')
      a++;
    if (s[i][0] == 'R')
      r++;
    if (s[i][0] == 'C')
      c++;
    if (s[i][0] == 'H')
      h++;
  }

  cout << m * a * r + m * a * c + m * a * h + m * r * c + m * r * h +
              m * c * h + a * r * c + a * r * h + a * c * h + r * c * h
       << endl;

  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, a) for (int i = 0; i < a; i++)
#define mp make_pair
#define pb push_back
#define P pair<int, int>
// #define ll __int64
#define ll long long
int n;
string t[1000];
ll c[10];
int main() {
  cin >> n;
  rep(i, n) {

    cin >> t[i];
    if (t[i][0] == 'M')
      c[0]++;
    if (t[i][0] == 'A')
      c[1]++;
    if (t[i][0] == 'R')
      c[2]++;
    if (t[i][0] == 'C')
      c[3]++;
    if (t[i][0] == 'H')
      c[4]++;
  }
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++)
        ans += (c[i] * c[j] * c[k]);
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, a) for (int i = 0; i < a; i++)
#define mp make_pair
#define pb push_back
#define P pair<int, int>
// #define ll __int64
#define ll long long
int n;
string t[200000];
ll c[10];
int main() {
  cin >> n;
  rep(i, n) {

    cin >> t[i];
    if (t[i][0] == 'M')
      c[0]++;
    if (t[i][0] == 'A')
      c[1]++;
    if (t[i][0] == 'R')
      c[2]++;
    if (t[i][0] == 'C')
      c[3]++;
    if (t[i][0] == 'H')
      c[4]++;
  }
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++)
        ans += (c[i] * c[j] * c[k]);
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  vector<long long> march(5, 0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'M')
      march[0]++;
    if (s[0] == 'A')
      march[1]++;
    if (s[0] == 'R')
      march[2]++;
    if (s[0] == 'C')
      march[3]++;
    if (s[0] == 'H')
      march[4]++;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        ans += march[i] * march[j] * march[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  vector<long long> march(5, 0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s[0] == 'M')
      march[0]++;
    if (s[0] == 'A')
      march[1]++;
    if (s[0] == 'R')
      march[2]++;
    if (s[0] == 'C')
      march[3]++;
    if (s[0] == 'H')
      march[4]++;
  }
  long long ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += march[i] * march[j] * march[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define first fst
#define second scd

#define repi(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define repn(i, n) for (int i = n; i >= 0; i--)
#define int long long

signed main() {
  int cnt[5] = {0}; // m,a,r,c,h
  int n;
  string s;
  cin >> n;
  rep(i, n) {
    cin >> s;
    if (s[0] == 'M')
      cnt[0]++;
    if (s[0] == 'A')
      cnt[1]++;
    if (s[0] == 'R')
      cnt[2]++;
    if (s[0] == 'C')
      cnt[3]++;
    if (s[0] == 'H')
      cnt[4]++;
  }
  int ans = 0;
  rep(i, n) {
    repi(j, i + 1, n) {
      repi(k, j + 1, n) { ans += cnt[i] * cnt[j] * cnt[k]; }
    }
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define first fst
#define second scd

#define repi(i, x, n) for (int i = x; i < n; i++)
#define rep(i, n) repi(i, 0, n)
#define repn(i, n) for (int i = n; i >= 0; i--)
#define int long long

signed main() {
  int cnt[5] = {0}; // m,a,r,c,h
  int n;
  string s;
  cin >> n;
  rep(i, n) {
    cin >> s;
    if (s[0] == 'M')
      cnt[0]++;
    if (s[0] == 'A')
      cnt[1]++;
    if (s[0] == 'R')
      cnt[2]++;
    if (s[0] == 'C')
      cnt[3]++;
    if (s[0] == 'H')
      cnt[4]++;
  }
  int ans = 0;
  rep(i, 5) {
    repi(j, i + 1, 5) {
      repi(k, j + 1, 5) { ans += cnt[i] * cnt[j] * cnt[k]; }
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03425 (Python)

Buggy submission (status: Runtime Error):
from functools import reduce
from itertools import combinations

N = int(input())
S = {"M": [], "A": [], "R": [], "C": [], "H": []}
for _ in range(N):
    i = input()
    head = i[0]
    if head == "M":
        S["M"].append(i)
    elif head == "A":
        S["A"].append(i)
    elif head == "R":
        S["R"].append(i)
    elif head == "C":
        S["C"].append(i)
    elif head == "H":
        S["H"].append(i)
result = [len(S[head]) for head in list("MARCH") if len(S[head]) != 0]

ans = sum(
    [
        reduce(lambda x, y: x * y, list(combinations(result, 3))[i])
        for i in range(len(result))
    ]
)
print(ans)


Fixed submission:
from functools import reduce
from itertools import combinations

N = int(input())
S = {"M": [], "A": [], "R": [], "C": [], "H": []}
for _ in range(N):
    i = input()
    head = i[0]
    if head == "M":
        S["M"].append(i)
    elif head == "A":
        S["A"].append(i)
    elif head == "R":
        S["R"].append(i)
    elif head == "C":
        S["C"].append(i)
    elif head == "H":
        S["H"].append(i)
counter = [len(S[head]) for head in list("MARCH") if len(S[head]) != 0]
combs = list(combinations(counter, 3))
ans = sum([reduce(lambda x, y: x * y, e) for e in combs])
print(ans)
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define maxi 100000
#define maxw 100000
#define maxn 100
using ll = long long;
int main() {
  ll N, x[5] = {0}, sum(0);
  string s[maxn];
  cin >> N;
  for (ll i(0); i < N; i++) {
    cin >> s[i];
    if (s[i][0] == 'M')
      x[0] += 1;
    else if (s[i][0] == 'A')
      x[1] += 1;
    else if (s[i][0] == 'R')
      x[2] += 1;
    else if (s[i][0] == 'C')
      x[3] += 1;
    else if (s[i][0] == 'H')
      x[4] += 1;
  }

  sum += x[0] * x[1] * x[2];
  sum += x[0] * x[1] * x[3];
  sum += x[0] * x[1] * x[4];
  sum += x[0] * x[2] * x[3];
  sum += x[0] * x[2] * x[4];
  sum += x[0] * x[3] * x[4];
  sum += x[1] * x[2] * x[3];
  sum += x[1] * x[2] * x[4];
  sum += x[1] * x[3] * x[4];
  sum += x[2] * x[3] * x[4];
  cout << sum;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define maxi 100000
#define maxw 100000
#define maxn 100000
using ll = long long;
int main() {
  ll N, x[5] = {0}, sum(0);
  string s[maxn];
  cin >> N;
  for (ll i(0); i < N; i++) {
    cin >> s[i];
    if (s[i][0] == 'M')
      x[0] += 1;
    else if (s[i][0] == 'A')
      x[1] += 1;
    else if (s[i][0] == 'R')
      x[2] += 1;
    else if (s[i][0] == 'C')
      x[3] += 1;
    else if (s[i][0] == 'H')
      x[4] += 1;
  }

  sum += x[0] * x[1] * x[2];
  sum += x[0] * x[1] * x[3];
  sum += x[0] * x[1] * x[4];
  sum += x[0] * x[2] * x[3];
  sum += x[0] * x[2] * x[4];
  sum += x[0] * x[3] * x[4];
  sum += x[1] * x[2] * x[3];
  sum += x[1] * x[2] * x[4];
  sum += x[1] * x[3] * x[4];
  sum += x[2] * x[3] * x[4];
  cout << sum;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define RREP(i, s, t) for (int i = s; i >= t; i--)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

string K = "MARCH";
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int cnt[5] = {};
  rep(i, N) {
    string S;
    cin >> S;
    rep(j, 5) if (S[0] == K[j]) cnt[j]++;
  }
  int ans = 0;
  rep(i, N) {
    REP(j, i + 1, N - 1) {
      REP(k, j + 1, N - 1) { ans += cnt[i] * cnt[j] * cnt[k]; }
    }
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n; i >= 0; i--)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define RREP(i, s, t) for (int i = s; i >= t; i--)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

string K = "MARCH";
signed main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int cnt[5] = {};
  rep(i, N) {
    string S;
    cin >> S;
    rep(j, 5) if (S[0] == K[j]) cnt[j]++;
  }
  int ans = 0;
  rep(i, 5) {
    REP(j, i + 1, 4) {
      REP(k, j + 1, 4) { ans += cnt[i] * cnt[j] * cnt[k]; }
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<char, ll> ma;
  string S;
  rep(i, N) {
    cin >> S;
    ma[S[0]]++;
  }
  char s[5] = {'M', 'A', 'R', 'C', 'H'};

  ll ans = 0;

  REP(i, 0, N - 1) {
    REP(j, i + 1, N - 1) {
      REP(k, j + 1, N - 1) { ans += ma[s[i]] * ma[s[j]] * ma[s[k]]; }
    }
  }
  cout << ans << endl;

  return 0;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, s, t) for (int i = s; i <= t; i++)
#define dump(x) cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<char, ll> ma;
  string S;
  rep(i, N) {
    cin >> S;
    ma[S[0]]++;
  }
  char s[5] = {'M', 'A', 'R', 'C', 'H'};

  ll ans = 0;

  REP(i, 0, 4) {
    REP(j, i + 1, 4) {
      REP(k, j + 1, 4) { ans += ma[s[i]] * ma[s[j]] * ma[s[k]]; }
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for (ll i = (k); i < (n); i++)
#define FORe(i, k, n) for (ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for (ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for (ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void) {
  ll n;
  cin >> n;
  map<char, ll> mp;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s[0]]++;
  }
  string s = "MARCH";
  ll ans = 0;
  REP(i, n - 2) FOR(j, i + 1, n - 1) FOR(k, j + 1, n) {
    ans += mp[s[i]] * mp[s[j]] * mp[s[k]];
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for (ll i = (k); i < (n); i++)
#define FORe(i, k, n) for (ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for (ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for (ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void) {
  ll n;
  cin >> n;
  map<char, ll> mp;
  REP(i, n) {
    string s;
    cin >> s;
    mp[s[0]]++;
  }
  string s = "MARCH";
  n = s.size();
  ll ans = 0;
  REP(i, n - 2) FOR(j, i + 1, n - 1) FOR(k, j + 1, n) {
    ans += mp[s[i]] * mp[s[j]] * mp[s[k]];
  }
  cout << ans << endl;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s[10000];
  long long mm = 0;
  long long aa = 0;
  long long rr = 0;
  long long cc = 0;
  long long hh = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    if (s[i][0] == 'M') {
      mm++;
    } else if (s[i][0] == 'A') {
      aa++;
    } else if (s[i][0] == 'R') {
      rr++;
    } else if (s[i][0] == 'C') {
      cc++;
    } else if (s[i][0] == 'H') {
      hh++;
    }
  }
  long long ans = 0;
  if (mm != 0 && aa != 0 && rr != 0) {
    ans = ans + mm * aa * rr;
  }
  if (mm != 0 && aa != 0 && cc != 0) {
    ans = ans + mm * aa * cc;
  }
  if (mm != 0 && aa != 0 && hh != 0) {
    ans = ans + mm * aa * hh;
  }
  if (mm != 0 && rr != 0 && cc != 0) {
    ans = ans + mm * rr * cc;
  }
  if (mm != 0 && rr != 0 && hh != 0) {
    ans = ans + mm * rr * hh;
  }
  if (mm != 0 && cc != 0 && hh != 0) {
    ans = ans + mm * cc * hh;
  }
  if (aa != 0 && rr != 0 && cc != 0) {
    ans = ans + aa * rr * cc;
  }
  if (aa != 0 && rr != 0 && hh != 0) {
    ans = ans + aa * hh * rr;
  }
  if (aa != 0 && cc != 0 && hh != 0) {
    ans = ans + cc * aa * hh;
  }
  if (rr != 0 && cc != 0 && hh != 0) {
    ans = ans + hh * cc * rr;
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s[100000];
  long long mm = 0;
  long long aa = 0;
  long long rr = 0;
  long long cc = 0;
  long long hh = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    if (s[i][0] == 'M') {
      mm++;
    } else if (s[i][0] == 'A') {
      aa++;
    } else if (s[i][0] == 'R') {
      rr++;
    } else if (s[i][0] == 'C') {
      cc++;
    } else if (s[i][0] == 'H') {
      hh++;
    }
  }
  long long ans = 0;
  if (mm != 0 && aa != 0 && rr != 0) {
    ans = ans + mm * aa * rr;
  }
  if (mm != 0 && aa != 0 && cc != 0) {
    ans = ans + mm * aa * cc;
  }
  if (mm != 0 && aa != 0 && hh != 0) {
    ans = ans + mm * aa * hh;
  }
  if (mm != 0 && rr != 0 && cc != 0) {
    ans = ans + mm * rr * cc;
  }
  if (mm != 0 && rr != 0 && hh != 0) {
    ans = ans + mm * rr * hh;
  }
  if (mm != 0 && cc != 0 && hh != 0) {
    ans = ans + mm * cc * hh;
  }
  if (aa != 0 && rr != 0 && cc != 0) {
    ans = ans + aa * rr * cc;
  }
  if (aa != 0 && rr != 0 && hh != 0) {
    ans = ans + aa * hh * rr;
  }
  if (aa != 0 && cc != 0 && hh != 0) {
    ans = ans + cc * aa * hh;
  }
  if (rr != 0 && cc != 0 && hh != 0) {
    ans = ans + hh * cc * rr;
  }
  cout << ans << endl;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N;
vector<ll> let(5);
const char letter[5] = {'M', 'A', 'R', 'C', 'H'};

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    string temp;
    cin >> temp;
    for (int j = 0; j < 5; j++) {
      if (temp[0] == letter[j]) {
        let[j]++;
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < N; k++) {
        res += let[i] * let[j] * let[k];
      }
    }
  }
  cout << res << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int N;
vector<ll> let(5);
const char letter[5] = {'M', 'A', 'R', 'C', 'H'};

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    string temp;
    cin >> temp;
    for (int j = 0; j < 5; j++) {
      if (temp[0] == letter[j]) {
        let[j]++;
      }
    }
  }
  ll res = 0;
  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        res += let[i] * let[j] * let[k];
      }
    }
  }
  cout << res << endl;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long int group[5] = {};
  long long int ans = 0;

  string tmp;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> tmp;
    switch (tmp[0]) {
    case 'M':
      group[0]++;
      break;
    case 'A':
      group[1]++;
      break;
    case 'R':
      group[2]++;
      break;
    case 'C':
      group[3]++;
      break;
    case 'H':
      group[4]++;
      break;
    }
  }

  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; 5; k++) {
        ans += group[i] * group[j] * group[k];
      }
    }
  }

  printf("%lld\n", ans);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long int group[5] = {};
  long long int ans = 0;

  string tmp;
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> tmp;
    switch (tmp[0]) {
    case 'M':
      group[0]++;
      break;
    case 'A':
      group[1]++;
      break;
    case 'R':
      group[2]++;
      break;
    case 'C':
      group[3]++;
      break;
    case 'H':
      group[4]++;
      break;
    }
  }

  for (int i = 0; i < 3; i++) {
    for (int j = i + 1; j < 4; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += group[i] * group[j] * group[k];
      }
    }
  }

  printf("%lld\n", ans);
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  long long int a, e = 0;
  cin >> a;
  vector<long long int> c(a);
  vector<long long int> d(a);
  string b;
  rep(i, a) c[i] = 0;
  rep(i, a) d[i] = i;
  rep(i, a) {
    cin >> b;
    if (b.at(0) == 'M')
      c[0]++;
    if (b.at(0) == 'A')
      c[1]++;
    if (b.at(0) == 'R')
      c[2]++;
    if (b.at(0) == 'C')
      c[3]++;
    if (b.at(0) == 'H')
      c[4]++;
  }
  rep(i, a - 2) {
    for (int j = i + 1; j < a - 1; j++) {
      for (int o = j + 1; o < a; o++) {
        e += c[i] * c[o] * c[j];
      }
    }
  }
  cout << e;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main() {
  long long int a, e = 0;
  cin >> a;
  vector<long long int> c(a);
  vector<long long int> d(a);
  string b;
  rep(i, a) c[i] = 0;
  rep(i, a) d[i] = i;
  rep(i, a) {
    cin >> b;
    if (b.at(0) == 'M')
      c[0]++;
    if (b.at(0) == 'A')
      c[1]++;
    if (b.at(0) == 'R')
      c[2]++;
    if (b.at(0) == 'C')
      c[3]++;
    if (b.at(0) == 'H')
      c[4]++;
  }
  rep(i, 3) {
    for (int j = i + 1; j < 4; j++) {
      for (int o = j + 1; o < 5; o++) {
        e += c[i] * c[o] * c[j];
      }
    }
  }
  cout << e;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  map<char, int> mp;
  rep(i, N) {
    string S;
    cin >> S;
    mp[S[0]] = (mp.count(S[0]) != 0) ? mp[S[0]] + 1 : 1;
  }
  vector<int> vec(5);
  vec[0] = (mp.count('M') != 0) ? mp['M'] : 0;
  vec[1] = (mp.count('A') != 0) ? mp['A'] : 0;
  vec[2] = (mp.count('R') != 0) ? mp['R'] : 0;
  vec[3] = (mp.count('C') != 0) ? mp['C'] : 0;
  vec[4] = (mp.count('H') != 0) ? mp['H'] : 0;
  ll ans = 0;
  FOR(i, 0, N - 2) FOR(j, i + 1, N - 1) FOR(k, j + 1, N) {
    ans += (ll)vec[i] * (ll)vec[j] * (ll)vec[k];
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  map<char, int> mp;
  rep(i, N) {
    string S;
    cin >> S;
    mp[S[0]] = (mp.count(S[0]) != 0) ? mp[S[0]] + 1 : 1;
  }
  vector<int> vec(5);
  vec[0] = (mp.count('M') != 0) ? mp['M'] : 0;
  vec[1] = (mp.count('A') != 0) ? mp['A'] : 0;
  vec[2] = (mp.count('R') != 0) ? mp['R'] : 0;
  vec[3] = (mp.count('C') != 0) ? mp['C'] : 0;
  vec[4] = (mp.count('H') != 0) ? mp['H'] : 0;
  ll ans = 0;
  FOR(i, 0, 3) FOR(j, i + 1, 4) FOR(k, j + 1, 5) {
    ans += (ll)vec[i] * (ll)vec[j] * (ll)vec[k];
  }
  cout << ans << endl;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <iostream>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define RUP(a, b) ((a + b - 1) / (b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int, int, bool> Tb;

int atcoder() {
  int n;
  cin >> n;
  ll march[5] = {};
  REP(i, n) {
    string tmp;
    cin >> tmp;
    if (tmp[0] == 'M')
      ++march[0];
    else if (tmp[0] == 'A')
      ++march[1];
    else if (tmp[0] == 'R')
      ++march[2];
    else if (tmp[0] == 'C')
      ++march[3];
    else if (tmp[0] == 'H')
      ++march[4];
  }
  ll ans = 0;

  for (int i = 0; i < n - 2; ++i) {
    for (int j = i + 1; j < n - 1; ++j) {
      for (int k = j + 1; k < n; ++k)
        ans += march[i] * march[j] * march[k];
    }
  }

  cout << ans << ENT;
  return 0;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  atcoder();
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <iostream>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define RUP(a, b) ((a + b - 1) / (b))
#define ENT "\n"

typedef long long ll;
typedef tuple<int, int, bool> Tb;

int atcoder() {
  int n;
  cin >> n;
  ll march[5] = {};
  REP(i, n) {
    string tmp;
    cin >> tmp;
    if (tmp[0] == 'M')
      ++march[0];
    else if (tmp[0] == 'A')
      ++march[1];
    else if (tmp[0] == 'R')
      ++march[2];
    else if (tmp[0] == 'C')
      ++march[3];
    else if (tmp[0] == 'H')
      ++march[4];
  }
  ll ans = 0;

  for (int i = 0; i < 3; ++i) {
    for (int j = i + 1; j < 4; ++j) {
      for (int k = j + 1; k < 5; ++k)
        ans += march[i] * march[j] * march[k];
    }
  }

  cout << ans << ENT;
  return 0;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  atcoder();
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;

  string s;
  ll a[5], ans = 0;
  rep(i, n) a[i] = 0;

  rep(i, n) {
    cin >> s;
    if (s[0] == 'M') {
      a[0]++;
    } else if (s[0] == 'A') {
      a[1]++;
    } else if (s[0] == 'R') {
      a[2]++;
    } else if (s[0] == 'C') {
      a[3]++;
    } else if (s[0] == 'H') {
      a[4]++;
    }
  }
  ans = a[0] * a[1] * a[2] + a[0] * a[1] * a[3] + a[0] * a[1] * a[4] +
        a[0] * a[2] * a[3] + a[0] * a[2] * a[4] + a[0] * a[3] * a[4] +
        a[1] * a[2] * a[3] + a[1] * a[2] * a[4] + a[1] * a[3] * a[4] +
        a[2] * a[3] * a[4];
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;

  string s;
  ll a[5], ans = 0;
  rep(i, 5) a[i] = 0;

  rep(i, n) {
    cin >> s;
    if (s[0] == 'M') {
      a[0]++;
    } else if (s[0] == 'A') {
      a[1]++;
    } else if (s[0] == 'R') {
      a[2]++;
    } else if (s[0] == 'C') {
      a[3]++;
    } else if (s[0] == 'H') {
      a[4]++;
    }
  }
  ans = a[0] * a[1] * a[2] + a[0] * a[1] * a[3] + a[0] * a[1] * a[4] +
        a[0] * a[2] * a[3] + a[0] * a[2] * a[4] + a[0] * a[3] * a[4] +
        a[1] * a[2] * a[3] + a[1] * a[2] * a[4] + a[1] * a[3] * a[4] +
        a[2] * a[3] * a[4];
  cout << ans << endl;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
#define rep(i, n) for (int i = 0; i < n; i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main() {
  std::ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  ll cnt[5];
  rep(i, 5) cnt[i] = 0LL;
  rep(i, n) {
    string s;
    cin >> s;
    if (s[0] == 'M')
      cnt[0]++;
    else if (s[0] == 'A')
      cnt[1]++;
    else if (s[0] == 'R')
      cnt[2]++;
    else if (s[0] == 'C')
      cnt[3]++;
    else if (s[0] == 'H')
      cnt[4]++;
  }

  ll ans = 0LL;
  rep(i, 5) for (int j = i + 1; j < n; ++j) for (int k = j + 1; k < n; ++k) {
    ans += cnt[i] * cnt[j] * cnt[k];
  }

  cout << ans << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
#define rep(i, n) for (int i = 0; i < n; i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main() {
  std::ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  ll cnt[5];
  rep(i, 5) cnt[i] = 0LL;
  rep(i, n) {
    string s;
    cin >> s;
    if (s[0] == 'M')
      cnt[0]++;
    else if (s[0] == 'A')
      cnt[1]++;
    else if (s[0] == 'R')
      cnt[2]++;
    else if (s[0] == 'C')
      cnt[3]++;
    else if (s[0] == 'H')
      cnt[4]++;
  }

  ll ans = 0LL;
  rep(i, 5) for (int j = i + 1; j < 5; ++j) for (int k = j + 1; k < 5; ++k) {
    ans += cnt[i] * cnt[j] * cnt[k];
  }

  cout << ans << endl;

  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a) a.begin(), a.end()
// #define for(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
  ll N, Ans = 0;
  ;
  cin >> N;
  vector<ll> A(5);

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;

    if (S[0] == 'M')
      A[0]++;
    if (S[0] == 'A')
      A[1]++;
    if (S[0] == 'R')
      A[2]++;
    if (S[0] == 'C')
      A[3]++;
    if (S[0] == 'H')
      A[4]++;
  }

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      for (int k = j + 1; k < N; k++) {

        Ans += A[i] * A[j] * A[k];
      }
    }
  }
  cout << Ans;
}

Fixed submission:
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a) a.begin(), a.end()
// #define for(i, K, N)  for(int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
  ll N, Ans = 0;
  ;
  cin >> N;
  vector<ll> A(5);

  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;

    if (S[0] == 'M')
      A[0]++;
    if (S[0] == 'A')
      A[1]++;
    if (S[0] == 'R')
      A[2]++;
    if (S[0] == 'C')
      A[3]++;
    if (S[0] == 'H')
      A[4]++;
  }

  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {

        Ans += A[i] * A[j] * A[k];
      }
    }
  }
  cout << Ans;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <numeric>
#include <string>
using namespace std;

int main() {

  long N;
  cin >> N;
  string S[100000];
  for (int i = 1; i <= N; i++)
    cin >> S[i];
  long res = 0;

  long march[10];
  march[1] = 0;
  march[2] = 0;
  march[3] = 0;
  march[4] = 0;
  march[5] = 0;
  for (int i = 1; i <= N; i++) {

    if (S[i][0] == 'M')
      march[1]++;
    if (S[i][0] == 'A')
      march[2]++;
    if (S[i][0] == 'R')
      march[3]++;
    if (S[i][0] == 'C')
      march[4]++;
    if (S[i][0] == 'H')
      march[5]++;
  }

  for (int i = 1; i <= 5; i++)
    for (int j = i + 1; j <= 5; j++)
      for (int k = j + 1; k <= 5; k++)
        res += march[i] * march[j] * march[k];

  cout << res << endl;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <numeric>
#include <string>
using namespace std;

int main() {

  long N;
  cin >> N;
  string S[100009];
  for (int i = 1; i <= N; i++)
    cin >> S[i];
  long res = 0;

  long march[10];
  march[1] = 0;
  march[2] = 0;
  march[3] = 0;
  march[4] = 0;
  march[5] = 0;
  for (int i = 1; i <= N; i++) {

    if (S[i][0] == 'M')
      march[1]++;
    if (S[i][0] == 'A')
      march[2]++;
    if (S[i][0] == 'R')
      march[3]++;
    if (S[i][0] == 'C')
      march[4]++;
    if (S[i][0] == 'H')
      march[5]++;
  }

  for (int i = 1; i <= 5; i++)
    for (int j = i + 1; j <= 5; j++)
      for (int k = j + 1; k <= 5; k++)
        res += march[i] * march[j] * march[k];

  cout << res << endl;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

int main() {

  long long int d, m, a, r, c, h, b[10], e;
  string s[100010];

  cin >> d;

  for (int i = 0; i < d; i++) {
    cin >> s[i];
  }

  for (int i = 0; i < 11; i++) {
    b[i] = 0;
  }
  m = 1, a = 2, r = 3, c = 4, h = 5;
  for (int i = 0; i < d; i++) {
    if (s[i][0] == 'M') {
      b[m]++;
    } else if (s[i][0] == 'A') {
      b[a]++;
    } else if (s[i][0] == 'R') {
      b[r]++;
    } else if (s[i][0] == 'C') {
      b[c]++;
    } else if (s[i][0] == 'H') {
      b[h]++;
    }
  }
  e = 0;

  for (int i = 1; i <= 5; i++) {
    for (int j = i + 1; j <= 5; j++) {
      for (int k = j + 1; k <= 5; k++) {
        e += b[i] * b[j] * b[k];
      }
    }
  }
  cout << e << endl;

  return 0;
}


Fixed submission:
#include <algorithm>
#include <bits/stdc++.h>
#include <iostream>

using namespace std;

int main() {

  long long int d, m, a, r, c, h, b[10], e;
  string s[100010];

  cin >> d;

  for (int i = 0; i < d; i++) {
    cin >> s[i];
  }

  for (int i = 1; i <= 5; i++) {
    b[i] = 0;
  }
  m = 1, a = 2, r = 3, c = 4, h = 5;
  for (int i = 0; i < d; i++) {
    if (s[i][0] == 'M') {
      b[m]++;
    } else if (s[i][0] == 'A') {
      b[a]++;
    } else if (s[i][0] == 'R') {
      b[r]++;
    } else if (s[i][0] == 'C') {
      b[c]++;
    } else if (s[i][0] == 'H') {
      b[h]++;
    }
  }
  e = 0;

  for (int i = 1; i <= 5; i++) {
    for (int j = i + 1; j <= 5; j++) {
      for (int k = j + 1; k <= 5; k++) {
        e += b[i] * b[j] * b[k];
      }
    }
  }
  cout << e << endl;

  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  string MARCH = "MARCH";
  map<char, ll> mp;
  REP(i, N) {
    string S;
    cin >> S;
    REP(i, 5) {
      if (S[0] == MARCH[i]) {
        mp[S[0]]++;
      }
    }
  }

  ll ans = 0;
  REP(i, N) {
    FOR(j, i + 1, N) {
      FOR(k, j + 1, N) { ans += mp[MARCH[i]] * mp[MARCH[j]] * mp[MARCH[k]]; }
    }
  }

  cout << ans;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll N;
  cin >> N;
  string MARCH = "MARCH";
  map<char, ll> mp;
  REP(i, N) {
    string S;
    cin >> S;
    REP(i, 5) {
      if (S[0] == MARCH[i]) {
        mp[S[0]]++;
      }
    }
  }

  ll ans = 0;
  REP(i, 5) {
    FOR(j, i + 1, 5) {
      FOR(k, j + 1, 5) { ans += mp[MARCH[i]] * mp[MARCH[j]] * mp[MARCH[k]]; }
    }
  }

  cout << ans;
  return 0;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

int mark[30], n;
string s;
char ch[5] = {'M', 'A', 'R', 'C', 'H'};
long long ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    mark[s[0] - 'A']++;
  }
  for (int i = 0; i < 5; i++)
    for (int j = i + 1; j < n; j++)
      for (int k = j + 1; k < n; k++)
        ans +=
            (1LL * mark[ch[k] - 'A'] * mark[ch[j] - 'A'] * mark[ch[i] - 'A']);
  cout << ans;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

int mark[30], n;
string s;
char ch[5] = {'M', 'A', 'R', 'C', 'H'};
long long ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    mark[s[0] - 'A']++;
  }
  for (int i = 0; i < 5; i++)
    for (int j = i + 1; j < 5; j++)
      for (int k = j + 1; k < 5; k++)
        ans +=
            (1LL * mark[ch[k] - 'A'] * mark[ch[j] - 'A'] * mark[ch[i] - 'A']);
  cout << ans;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

long long int n;
string s[100000];

long long int matching_num = 0;

long long int num[5];

int main() {

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  for (int i = 0; i < n; i++) {
    num[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    if (s[i][0] == 'M') {
      num[0] += 1;
    } else if (s[i][0] == 'A') {
      num[1] += 1;
    } else if (s[i][0] == 'R') {
      num[2] += 1;
    } else if (s[i][0] == 'C') {
      num[3] += 1;
    } else if (s[i][0] == 'H') {
      num[4] += 1;
    }
  }

  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        matching_num += num[i] * num[j] * num[k];
      }
    }
  }

  cout << matching_num << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

long long int n;
string s[100000];

long long int matching_num = 0;

long long int num[5];

int main() {

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }

  for (int i = 0; i < 5; i++) {
    num[i] = 0;
  }

  for (int i = 0; i < n; i++) {
    if (s[i][0] == 'M') {
      num[0] += 1;
    } else if (s[i][0] == 'A') {
      num[1] += 1;
    } else if (s[i][0] == 'R') {
      num[2] += 1;
    } else if (s[i][0] == 'C') {
      num[3] += 1;
    } else if (s[i][0] == 'H') {
      num[4] += 1;
    }
  }

  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        matching_num += num[i] * num[j] * num[k];
      }
    }
  }

  cout << matching_num << endl;
}
Problem p03425 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64, i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int n;
string s[101010];
void solve() {
  cin >> n;
  i64 cnt[5] = {};
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    if (s[i][0] == 'M')
      cnt[0]++;
    if (s[i][0] == 'A')
      cnt[1]++;
    if (s[i][0] == 'R')
      cnt[2]++;
    if (s[i][0] == 'C')
      cnt[3]++;
    if (s[i][0] == 'H')
      cnt[4]++;
  }

  i64 ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      for (int k = j + 1; k < n; k++) {
        ans += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64, i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

int n;
string s[101010];
void solve() {
  cin >> n;
  i64 cnt[5] = {};
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    if (s[i][0] == 'M')
      cnt[0]++;
    if (s[i][0] == 'A')
      cnt[1]++;
    if (s[i][0] == 'R')
      cnt[2]++;
    if (s[i][0] == 'C')
      cnt[3]++;
    if (s[i][0] == 'H')
      cnt[4]++;
  }

  i64 ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }

  return 0;
}