Problem p03425 (C++)

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

#define FOR(VAR, ST, END) for (int VAR = ST; VAR < END; ++VAR)
#define FORI(VAR, ST, END) for (int VAR = ST; VAR <= END; ++VAR)
#define ROF(VAR, ST, END) for (int VAR = ST; VAR > END; --VAR)
#define ROFI(VAR, ST, END) for (int VAR = ST; VAR >= END; --VAR)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define MAXI(a, b) (a = (a > b ? a : b))
#define MINI(a, b) (a = (a < b ? a : b))
#define MINI_NZ(a, b)                                                          \
  {                                                                            \
    if (a == 0)                                                                \
      a = b;                                                                   \
    else                                                                       \
      a = a < b ? a : b;                                                       \
  }
#define SWAP_IF(type, x, y, cond)                                              \
  if (cond) {                                                                  \
    type tmp = x;                                                              \
    x = y;                                                                     \
    y = tmp;                                                                   \
  }
#define SWAP(type, x, y)                                                       \
  {                                                                            \
    type tmp = x;                                                              \
    x = y;                                                                     \
    y = tmp;                                                                   \
  }
#define INF 0x3f3f3f3f

using namespace std;

#define MAX_N 10000

char names[MAX_N][11];

long long cnt[26];

#define IDX(x) (x - 'A')
#define CNT(x) cnt[IDX(x)]

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

  FOR(i, 0, n) {
    cin >> names[i];
    cin.get();
    ++cnt[names[i][0] - 'A'];
  }

  long long ans =
      CNT('M') * CNT('A') * CNT('R') + CNT('M') * CNT('A') * CNT('C') +
      CNT('M') * CNT('A') * CNT('H') + CNT('M') * CNT('R') * CNT('C') +
      CNT('M') * CNT('R') * CNT('H') + CNT('M') * CNT('C') * CNT('H') +
      CNT('A') * CNT('R') * CNT('C') + CNT('A') * CNT('R') * CNT('H') +
      CNT('A') * CNT('C') * CNT('H') + CNT('R') * CNT('C') * CNT('H');

  cout << ans << endl;

  return 0;
}

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

#define FOR(VAR, ST, END) for (int VAR = ST; VAR < END; ++VAR)
#define FORI(VAR, ST, END) for (int VAR = ST; VAR <= END; ++VAR)
#define ROF(VAR, ST, END) for (int VAR = ST; VAR > END; --VAR)
#define ROFI(VAR, ST, END) for (int VAR = ST; VAR >= END; --VAR)
#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define MAXI(a, b) (a = (a > b ? a : b))
#define MINI(a, b) (a = (a < b ? a : b))
#define MINI_NZ(a, b)                                                          \
  {                                                                            \
    if (a == 0)                                                                \
      a = b;                                                                   \
    else                                                                       \
      a = a < b ? a : b;                                                       \
  }
#define SWAP_IF(type, x, y, cond)                                              \
  if (cond) {                                                                  \
    type tmp = x;                                                              \
    x = y;                                                                     \
    y = tmp;                                                                   \
  }
#define SWAP(type, x, y)                                                       \
  {                                                                            \
    type tmp = x;                                                              \
    x = y;                                                                     \
    y = tmp;                                                                   \
  }
#define INF 0x3f3f3f3f

using namespace std;

#define MAX_N 100000

char names[MAX_N][11];

long long cnt[26];

#define IDX(x) (x - 'A')
#define CNT(x) cnt[IDX(x)]

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

  FOR(i, 0, n) {
    cin >> names[i];
    cin.get();
    ++cnt[names[i][0] - 'A'];
  }

  long long ans =
      CNT('M') * CNT('A') * CNT('R') + CNT('M') * CNT('A') * CNT('C') +
      CNT('M') * CNT('A') * CNT('H') + CNT('M') * CNT('R') * CNT('C') +
      CNT('M') * CNT('R') * CNT('H') + CNT('M') * CNT('C') * CNT('H') +
      CNT('A') * CNT('R') * CNT('C') + CNT('A') * CNT('R') * CNT('H') +
      CNT('A') * CNT('C') * CNT('H') + CNT('R') * CNT('C') * CNT('H');

  cout << ans << endl;

  return 0;
}