Language: C++

#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#define size 500010
#define debug(x) cerr<<#x<<"="<<x
#define gc getchar()
#define db double
#define ll long long
#define rep(i,s,n) for (register int i=s;i<=n;i++)
#define drep(i,n,s) for (register int i=n;i>=s;i--)
#define il inline
using namespace std;

il ll r()
{
	char c; ll x,f=1;
	for (c=gc;!isdigit(c);c=gc) if (c=='-') f=-1; x=c-'0';
	for (c=gc;isdigit(c);c=gc) x=(x<<1)+(x<<3)+c-'0';
	return f*x;
}

map<char,int>mp;
int n;
char cz[110];
ll a[10];

int main()
{
	n=r();
	mp['M']=1;
	mp['A']=2;
	mp['R']=3;
	mp['C']=4;
	mp['H']=5;
	rep(i,1,n)
	{
		scanf("%s",cz);
		a[mp[cz[0]]]++;
	}
	ll ans=0;
	rep(i,1,5) rep(j,i+1,5) rep(k,j+1,5)  ans+=1ll*a[i]*a[j]*a[k];
	cout<<ans<<endl;
	return 0;
}
















#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#define size 500010
#define debug(x) cerr<<#x<<"="<<x
#define gc getchar()
#define db double
#define ll long long
#define rep(i,s,n) for (register int i=s;i<=n;i++)
#define drep(i,n,s) for (register int i=n;i>=s;i--)
#define il inline
using namespace std;

il ll r()
{
	char c; ll x,f=1;
	for (c=gc;!isdigit(c);c=gc) if (c=='-') f=-1; x=c-'0';
	for (c=gc;isdigit(c);c=gc) x=(x<<1)+(x<<3)+c-'0';
	return f*x;
}

map<char,int>mp;
int n;
char cz[110];
ll a[10];

int main()
{
	n=r();
	mp['M']=1;
	mp['A']=2;
	mp['R']=3;
	mp['C']=4;
	mp['H']=5;
	rep(i,1,n)
	{
		scanf("%s",cz);
		a[mp[cz[0]]]++;
	}
	ll ans=0;
	rep(i,1,5) rep(j,i+1,5) rep(k,j+1,5)  ans+=1ll*a[i]*a[j]*a[k];
	cout<<ans<<endl;
	return 0;
}


















Compiler output:
a.cc: In function 'int main()':
a.cc:43:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |         rep(i,1,n)
      |             ^
a.cc:17:38: note: in definition of macro 'rep'
   17 | #define rep(i,s,n) for (register int i=s;i<=n;i++)
      |                                      ^
a.cc:49:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   49 |         rep(i,1,5) rep(j,i+1,5) rep(k,j+1,5)  ans+=1ll*a[i]*a[j]*a[k];
      |             ^
a.cc:17:38: note: in definition of macro 'rep'
   17 | #define rep(i,s,n) for (register int i=s;i<=n;i++)
      |                                      ^
a.cc:49:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   49 |         rep(i,1,5) rep(j,i+1,5) rep(k,j+1,5)  ans+=1ll*a[i]*a[j]*a[k];
      |                        ^
a.cc:17:38: note: in definition of macro 'rep'
   17 | #define rep(i,s,n) for (register int i=s;i<=n;i++)
      |                                      ^
a.cc:49:37: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   49 |         rep(i,1,5) rep(j,i+1,5) rep(k,j+1,5)  ans+=1ll*a[i]*a[j]*a[k];
      |                                     ^
a.cc:17:38: note: in definition of macro 'rep'
   17 | #define rep(i,s,n) for (register int i=s;i<=n;i++)
      |                                      ^
a.cc: At global scope:
a.cc:90:7: error: redefinition of 'long long int r()'
   90 | il ll r()
      |       ^
a.cc:22:7: note: 'long long int r()' previously defined here
   22 | il ll r()
      |       ^
a.cc:98:14: error: redefinition of 'std::map<char, int> mp'
   98 | map<char,int>mp;
      |              ^~
a.cc:30:14: note: 'std::map<char, int> mp' previously declared here
   30 | map<char,int>mp;
      |              ^~
a.cc:99:5: error: redefinition of 'int n'
   99 | int n;
      |     ^
a.cc:31:5: note: 'int n' previously declared here
   31 | int n;
      |     ^
a.cc:100:6: error: redefinition of 'char cz [110]'
  100 | char cz[110];
      |      ^~
a.cc:32:6: note: 'char cz [110]' previously declared here
   32 | char cz[110];
      |      ^~
a.cc:101:4: error: redefinition of 'long long int a [10]'
  101 | ll a[10];
      |    ^
a.cc:33:4: note: 'long long int a [10]' previously declared here
   33 | ll a[10];
      |    ^
a.cc:103:5: error: redefinition of 'int main()'
  103 | int main()
      |     ^~~~
a.cc:35:5: note: 'int main()' previously defined here
   35 | int main()
      |     ^~~~
a.cc: In function 'int main()':
a.cc:111:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  111 |         rep(i,1,n)
      |             ^
a.cc:85:38: note: in definition of macro 'rep'
   85 | #define rep(i,s,n) for (register int i=s;i<=n;i++)
      |                                      ^
a.cc:117:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  117 |         rep(i,1,5) rep(j,i+1,5) rep(k,j+1,5)  ans+=1ll*a[i]*a[j]*a[k];
      |             ^
a.cc:85:38: note: in definition of macro 'rep'
   85 | #define rep(i,s,n) for (register int i=s;i<=n;i++)
      |                                      ^
a.cc:117:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  117 |         rep(i,1,5) rep(j,i+1,5) rep(k,j+1,5)  ans+=1ll*a[i]*a[j]*a[k];
      |                        ^
a.cc:85:38: note: in definition of macro 'rep'
   85 | #define rep(i,s,n) for (register int i=s;i<=n;i++)
      |                                      ^
a.cc:117:37: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
  117 |         rep(i,1,5) rep(j,i+1,5) rep(k,j+1,5)  ans+=1ll*a[i]*a[j]*a[k];
      |                                     ^
a.cc:85:38: note: in definition of macro 'rep'
   85 | #define rep(i,s,n) for (register int i=s;i<=n;i++)
      |                                      ^