Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    // 整数の入力
    int N;
    ll result = 0;
    cin >> N;
    vector<string> S[5];
    bool b[5];

    for (int i = 0; i < N; i++) {
        string s;
        cin >> s;
        if (s[0] == 'M') {
            S[0].push_back(s);
        } else if (s[0] == 'A') {
            S[1].push_back(s);
        } else if (s[0] == 'R') {
            S[2].push_back(s);
        } else if (s[0] == 'C') {
            S[3].push_back(s);
        } else if (s[0] == 'H') {
            S[4].push_back(s);
        } else {
            // ignore
        }
    }

    //count
    int count = 0;
    for (int i = 0; i < 5; i++) {
        if (S[i].size() <= 0) {
            count++;
            b[i] = false;
        } else {
            b[i] = true;
        }
    }

    if (N - count <= 2) {
        cout << result << endl;
        return 0;
    }
  	
    if (b[0] && b[1] && b[2]) {
        for (int i = 0; i < S[0].size(); i++) {
            for (int j = 0; j < S[1].size(); j++) {
                for (int k = 0; k < S[2].size(); k++) {
                    result++;
                }
            }
        }
    } if (b[0] && b[1] && b[3]) {
        for (int i = 0; i < S[0].size(); i++) {
            for (int j = 0; j < S[1].size(); j++) {
                for (int k = 0; k < S[3].size(); k++) {
                    result++;
                }
            }
        }
    } if (b[0] && b[1] && b[4]) {
        for (int i = 0; i < S[0].size(); i++) {
            for (int j = 0; j < S[1].size(); j++) {
                for (int k = 0; k < S[4].size(); k++) {
                    result++;
                }
            }
        }        
    } if (b[0] && b[2] && b[3]) {
        for (int i = 0; i < S[0].size(); i++) {
            for (int j = 0; j < S[2].size(); j++) {
                for (int k = 0; k < S[3].size(); k++) {
                    result++;
                }
            }
        }        
    } if (b[0] && b[2] && b[4]) {
        for (int i = 0; i < S[0].size(); i++) {
            for (int j = 0; j < S[2].size(); j++) {
                for (int k = 0; k < S[4].size(); k++) {
                    result++;
                }
            }
        }
    } if (b[0] && b[3] && b[4]) {
        for (int i = 0; i < S[0].size(); i++) {
            for (int j = 0; j < S[3].size(); j++) {
                for (int k = 0; k < S[4].size(); k++) {
                    result++;
                }
            }
        }
    } if (b[1] && b[2] && b[3]) {
        for (int i = 0; i < S[1].size(); i++) {
            for (int j = 0; j < S[2].size(); j++) {
                for (int k = 0; k < S[3].size(); k++) {
                    result++;
                }
            }
        }
    } if (b[1] && b[2] && b[4]) {
        for (int i = 0; i < S[1].size(); i++) {
            for (int j = 0; j < S[2].size(); j++) {
                for (int k = 0; k < S[4].size(); k++) {
                    result++;
                }
            }
        }   
    } if (b[1] && b[3] && b[4]) {
        for (int i = 0; i < S[1].size(); i++) {
            for (int j = 0; j < S[3].size(); j++) {
                for (int k = 0; k < S[4].size(); k++) {
                    result++;
                }
            }
        }  
    } if (b[2] && b[3] && b[4]) {
        for (int i = 0; i < S[2].size(); i++) {
            for (int j = 0; j < S[3].size(); j++) {
                for (int k = 0; k < S[4].size(); k++) {
                    result++;
                }
            }
        }     
    }
    cout << result << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:5: error: 'll' was not declared in this scope
   10 |     ll result = 0;
      |     ^~
a.cc:45:17: error: 'result' was not declared in this scope
   45 |         cout << result << endl;
      |                 ^~~~~~
a.cc:53:21: error: 'result' was not declared in this scope
   53 |                     result++;
      |                     ^~~~~~
a.cc:61:21: error: 'result' was not declared in this scope
   61 |                     result++;
      |                     ^~~~~~
a.cc:69:21: error: 'result' was not declared in this scope
   69 |                     result++;
      |                     ^~~~~~
a.cc:77:21: error: 'result' was not declared in this scope
   77 |                     result++;
      |                     ^~~~~~
a.cc:85:21: error: 'result' was not declared in this scope
   85 |                     result++;
      |                     ^~~~~~
a.cc:93:21: error: 'result' was not declared in this scope
   93 |                     result++;
      |                     ^~~~~~
a.cc:101:21: error: 'result' was not declared in this scope
  101 |                     result++;
      |                     ^~~~~~
a.cc:109:21: error: 'result' was not declared in this scope
  109 |                     result++;
      |                     ^~~~~~
a.cc:117:21: error: 'result' was not declared in this scope
  117 |                     result++;
      |                     ^~~~~~
a.cc:125:21: error: 'result' was not declared in this scope
  125 |                     result++;
      |                     ^~~~~~
a.cc:130:13: error: 'result' was not declared in this scope
  130 |     cout << result << endl;
      |             ^~~~~~