Language: C++

#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i!=n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}

using namespace std;

const int mod=1e9+7;

void run();
int fact(int n);
int combi(int n, int r);

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin >> n;
    vi march(n,0);
    string s;
    rep(i,n)
    {
        cin >> s;
        if(s[0]!='M'&&s[0]!='A'&&s[0]!='R'&&s[0]!='C'&&s[0]!='H')continue;
        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];
    }
    int ans=0;
    rep(i,5)
    {
        if(march[i]>=1)++ans;
    }
    ans = combi(ans,3);
    rep(i,5)
    {
        if(march[i]>=1)ans*=march[i];
    }

    cout << ans << endl;

}

//階乗を計算してくれる関数
int fact(int n){
    int sum=1;
    for(int i = 1; i <= n; ++i)
    {
        sum*=i;
    }
    return sum;
}

//n個からr個を選ぶ選び方の数を計算してくれる関数
int combi(int n,int r){
    int num=1;
    num = fact(n)/fact(r)/fact(n-r);
    return num;
}
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i!=n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
signed gcd(int a, int b){return b?gcd(b,a%b):a;}

using namespace std;

const int mod=1e9+7;

void run();
int fact(int n);
int combi(int n, int r);

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin >> n;
    vi march(n,0);
    string s;
    rep(i,n)
    {
        cin >> s;
        if(s[0]!='M'&&s[0]!='A'&&s[0]!='R'&&s[0]!='C'&&s[0]!='H')continue;
        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];
    }
    int ans=0;
    rep(i,5)
    {
        if(march[i]>=1)++ans;
    }
    ans = combi(ans,3);
    rep(i,5)
    {
        if(march[i]>=1)ans*=march[i];
    }

    cout << ans << endl;

}

//階乗を計算してくれる関数
int fact(int n){
    int sum=1;
    for(int i = 1; i <= n; ++i)
    {
        sum*=i;
    }
    return sum;
}

//n個からr個を選ぶ選び方の数を計算してくれる関数
int combi(int n,int r){
    int num=1;
    num = fact(n)/fact(r)/fact(n-r);
    return num;
}


Compiler output:
a.cc:111:11: error: redefinition of 'const long long int mod'
  111 | const int mod=1e9+7;
      |           ^~~
a.cc:24:11: note: 'const long long int mod' previously defined here
   24 | const int mod=1e9+7;
      |           ^~~
a.cc:123:8: error: redefinition of 'int main()'
  123 | signed main(){
      |        ^~~~
a.cc:36:8: note: 'int main()' previously defined here
   36 | signed main(){
      |        ^~~~