stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

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

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

typedef long long int ll;



#define EPS (1e-7)

#define INF (1e9)

#define PI (acos(-1))

#define MOD (1000000007)

int dx[4] = {1, 0, -1, 0};

int dy[4] = {0, 1, 0, -1}; // 移動方向



int n;

string s[100010];

vector<string> march[5];

void input(){

    cin >> n;

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

}



int next_combination(int sub) {

    int x = sub & -sub, y = sub + x;

    return (((sub & ~y) / x) >> 1) | y;

}



int main()

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    input();

    ll ans = 0;

    for(int i=0;i<n;i++){

        if(s[i][0]=='M') march[0].push_back(s[i]);

        else if(s[i][0]=='A') march[1].push_back(s[i]);

        else if(s[i][0]=='R') march[2].push_back(s[i]);

        else if(s[i][0]=='C') march[3].push_back(s[i]);

        else if(s[i][0]=='H') march[4].push_back(s[i]);

    }

    int sz[5];

    for(int i=0;i<5;i++) sz[i] = march[i].size();

    for(int bit=(1<<3)-1;bit<(1<<5);bit=next_combination(bit)){

        ll tmp = 1;

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

            if(bit&(1<<i)) tmp *= sz[i];

        }

        ans += tmp;

    }

    cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

template <class T> inline bool chmax(T &a, T b) {

    if(a < b) {

        a = b;

        return 1;

    }

    return 0;

}

template <class T> inline bool chmin(T &a, T b) {

    if(a > b) {

        a = b;

        return 1;

    }

    return 0;

}

using ll = long long;



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

#define RALL(v) (v).rbegin(), (v).rend()

#define endl "\n"

const double EPS = 1e-7;

const int INF = 1 << 30;

const ll LLINF = 1LL << 60;

const double PI = acos(-1);

constexpr int MOD = 1000000007;

const int dx[4] = {1, 0, -1, 0};

const int dy[4] = {0, 1, 0, -1};



//-------------------------------------



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);

    int n;

    cin >> n;

    vector<int> cnt(5, 0);

    for(int i = 0; i < n; i++) {

        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 = 0;

    for(int bit = 0; bit < (1 << 5); bit++) {

        vector<int> id;

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

            if(bit & (1 << i)) {

                id.push_back(i);

            }

        }

        if(id.size() == 3) {

            ll tmp = 1;

            for(auto i : id) {

                tmp *= cnt[i];

            }

            ans += tmp;

        }

    }

    cout << ans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string>

#include<complex>

#include<vector>

#include<algorithm>

#include<functional>

#include<array>

using namespace std;

typedef unsigned long long ull;

typedef long long ll;





int main() {

	ull n,m=0,a=0,r=0,c=0,h=0;

	ull b = 0;

	cin >> n;

	string s[100001];

	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++; }

	}

	b = (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);

	cout << b << endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<string>

#include<complex>

#include<vector>

#include<algorithm>

#include<functional>

#include<array>

#include<map>

using namespace std;

typedef unsigned long long ull;

typedef long long ll;

#define INF 1e+9





int main() {



	int n;

	string s;

	ull m = 0, a = 0, r = 0, c = 0, h = 0,ans=0;



	cin >> n;

	for (int i = 0; i < n; i++) {

		cin >> s;

		switch (s[0]) {

		case 'M':m++; break;

		case 'A':a++; break;

		case 'R':r++; break;

		case 'C':c++; break;

		case 'H':h++; break;

		}

	}



	ans = 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;

	cout << ans << endl;



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main() {

  int N;

  cin >> N;

  string S[100010];

  for (int i = 0; i < N; i++) cin >> S[i];



  long long cnt[10] = {};

  string str = "MARCH";

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

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

      if (S[i][0] == str[j]) cnt[j]++;

    }

  }



  long long 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++) {

        long long tmp = cnt[i] * cnt[j] * cnt[k];

        ans += tmp;

      }

    }

  }



  cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



int main() {

    int N;

    cin >> N;

    long long cnt[10] = {};

    string pattern = "MARCH";

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

        string S;

        cin >> S;

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

            if (S[0] == pattern[j]) cnt[j]++;

        }

    }



    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 += cnt[i] * cnt[j] * cnt[k];

            }

        }

    }



    cout << ans << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define Sheryang main

typedef long long ll;

#pragma GCC optimize(3)

#define HEAP(...) priority_queue<__VA_ARGS__ >

#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >

template<class T> inline T min(T &x,const T &y){return x>y?y:x;}

template<class T> inline T max(T &x,const T &y){return x<y?y:x;}

int read()

{

    int x=0,f=1;	char c=getchar();

    while(c<'0'||c>'9')	{if(c=='-') f=-1;c=getchar();}

    while(c>='0'&&c<='9')	{x=x*10+c-'0';c=getchar();}

    return x*f;

}

struct ios

{

    inline char gc()

    {

        static const int IN_LEN=1<<18|1;

        static char buf[IN_LEN],*s,*t;

        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;

    }

    template <typename _Tp> inline ios & operator >> (_Tp&x)

    {

        static char ch,sgn; ch = gc(), sgn = 0;

        for(;!isdigit(ch);ch=gc())

        {   

            if(ch==-1)return *this;sgn|=ch=='-';

        }

        for(x=0;isdigit(ch);ch=gc())x=(((x<<2)+x)<<1)+(ch^'0');

        sgn&&(x=-x); return *this;

    }

}io;

const int maxn = 1e5 + 7;

const int mod = 1e9 + 7;

/** keep hungry and keep calm! **/



/**

1 2 3 4 5

共有10种情况

1 2 3

1 2 4

1 2 5

1 3 4

1 3 5

1 4 5

2 3 4

2 3 5

2 4 5

3 4 5

暴力枚举每一种情况 

**/

ll n,a[6],ans;

string s[200000];

int main()

{

    n = read();

    for(int i=1;i<=n;i++) cin >> s[i];

    for(int i=1;i<=n;i++)

	{

        if(s[i][0] == 'M') ++a[1];

        if(s[i][0] == 'A') ++a[2];

        if(s[i][0] == 'R') ++a[3];

        if(s[i][0] == 'C') ++a[4];

        if(s[i][0] == 'H') ++a[5];

    }

    ans += a[1]*a[2]*a[3];

    ans += a[1]*a[2]*a[4];

    ans += a[1]*a[2]*a[5];

    ans += a[1]*a[3]*a[4];

    ans += a[1]*a[3]*a[5];

    ans += a[1]*a[4]*a[5];

    ans += a[2]*a[3]*a[4];

    ans += a[2]*a[3]*a[5];

    ans += a[3]*a[4]*a[5];

    ans += a[2]*a[4]*a[5];

    printf("%lld\n",ans);

    return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <bits/stdc++.h>

using namespace std;

map<char,long long int>q;

int main()

{

    int n;

    scanf("%d",&n);

    char str[16];

    for(int i=0;i<n;i++)

    {

        scanf("%s",str);

        q[str[0]]++;

    }

    long long int sum=0;

    sum+=q['M']*q['A']*(q['R']+q['C']+q['H'])+q['A']*q['R']*(q['C']+q['H'])+q['R']*q['C']*q['H']+q['M']*q['R']*(q['C']+q['H'])+q['M']*q['C']*q['H']+q['A']*q['C']*q['H'];

    printf("%lld",sum);





}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string>

#include<vector>

#include<cmath>

#include<algorithm>

#include<cstdio>

#include<set>

#include<queue>

#include<functional>

using namespace std;



typedef long long ll;



ll cnt[6];

int main() {

  int N; cin >> N;

  string s[100010];

  ll ans = 0;



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

    cin >> s[i];

    if ( s[i][0] == 'M' ) cnt[1]++;

    if ( s[i][0] == 'A' ) cnt[2]++;

    if ( s[i][0] == 'R' ) cnt[3]++;

    if ( s[i][0] == 'C' ) cnt[4]++;

    if ( s[i][0] == 'H' ) cnt[5]++;    

  }



  sort(cnt+1,cnt+6,greater<int>());

  int cnt2 = 0;

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

    //cout << cnt[i] << endl;

    if (cnt[i] != 0 ) cnt2++;

  }

  //cout << cnt2 << endl;



  if ( cnt2 <= 2 ) cout << 0 << endl;

  else if ( cnt2 == 3 ) cout << cnt[1] * cnt[2] * cnt[3] << endl;

  else if ( cnt2 == 4 ) {

    //4C3

    for ( int i = 1; i <= 3; i++ ) {

      for ( int j = i + 1; j <= 4; j++ ) {

	for ( int k = j + 1; k <= 4; k++ ) {

	  ans += cnt[i] * cnt[j] * cnt[k];

	}

      }

    }

  

    cout << ans << endl;

  } else if( cnt2 == 5 ){

    //5C3

    for ( int i = 1; i <= 3; i++ ) {

      for ( int j = i + 1; j <= 4; j++ ) {

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

	  ans += cnt[i] * cnt[j] * cnt[k];

	}

      }

    }

    cout << ans << endl;

  }

  return 0;

}


// Optimized solution to the same problem (faster):
#include<iostream>

#include<string>

#include<vector>

#include<cmath>

#include<algorithm>

#include<cstdio>

#include<set>

#include<queue>

using namespace std;



typedef long long ll;



int main() {

  string s = "MARCH";

  ll c[5] = {0};

  int N; cin >> N;

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

    string t;

    cin >> t;

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

      if( t[0] == s[j] ) c[j]++;

    }

  }

  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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <algorithm>

#include <iostream>

#include <cstring>

#include <vector>

using namespace std;



typedef long long ll;



const ll MAX_N = 2e5 + 10;

ll n, ans;

ll cnt[MAX_N];

string s, march = "MARCH";



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n;

	for (ll i = 0; i < n; i++) {

		cin >> s;

		cnt[s[0] - 'A']++;

	}



	for (ll mask = 0; mask < 32; mask++)

		if (__builtin_popcount(mask) == 3) {

			ll res = 1;

			for (int i = 0; i < 5; i++)

				if ((mask >> i) & 1)

					res *= cnt[march[i] - 'A'];



			ans += res;

		}



	cout << ans << "\n";

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>





long long count[5];

int combine[10][3] = {

	{0,1,2},{0,1,3},{0,1,4},{0,2,3},{0,2,4},{0,3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4}

};

int main()

{

	int n;

	long long ans;

	char str[15];

	while(~scanf("%d",&n)){

		ans = 0;

		for(int i = 0; i<5; i++)count[i] = 0;

		for(int i = 0; i<n; i++){

			scanf("%s",str);

			if(str[0] == 'M') count[0]++;//M

			else if(str[0] == 'A') count[1]++;//A

			else if(str[0] == 'R') count[2]++;//R

			else if(str[0] == 'C') count[3]++;//C

			else if(str[0] == 'H') count[4]++;//H

			else continue;

		}

		for(int i = 0; i<10; i++){

			ans +=count[combine[i][0]]*count[combine[i][1]]*count[combine[i][2]];

		}

		printf("%lld\n",ans);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



typedef long long ll;

const int N = 5;

const string march = "MARCH";



ll n, ans, cnt[N];

string s;



int main() {

	ios::sync_with_stdio(false), cin.tie(0);

	cin >> n;

	while(n--) {

		cin >> s;

		for (int i = 0; i < N; i++)

			if(s[0] == march[i])

				cnt[i]++;

	}

	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;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>





long long count[5];

int combine[10][3] = {

	{0,1,2},{0,1,3},{0,1,4},{0,2,3},{0,2,4},{0,3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4}

};

int main()

{

	int n;

	long long ans;

	char str[15];

	while(~scanf("%d",&n)){

		ans = 0;

		for(int i = 0; i<5; i++)count[i] = 0;

		for(int i = 0; i<n; i++){

			scanf("%s",str);

			if(str[0] == 'M') count[0]++;//M

			else if(str[0] == 'A') count[1]++;//A

			else if(str[0] == 'R') count[2]++;//R

			else if(str[0] == 'C') count[3]++;//C

			else if(str[0] == 'H') count[4]++;//H

			else continue;

		}

		for(int i = 0; i<10; i++){

			ans +=count[combine[i][0]]*count[combine[i][1]]*count[combine[i][2]];

		}

		printf("%lld\n",ans);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int main()

{

	int n;

	long long  a[5];//march

	cin>>n;

	for(int i=0;i<5;i++)

	a[i]=0;

	for(int i=0;i<n;i++)

	{

		string s;

		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]++;

	}

	long long num=0;

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

		if(a[i]==0)continue;

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

		{

			if(a[j]==0) continue;

			for(int z=j+1;z<5;z++)

			{

				if(a[z]==0) continue;

				num+=a[i]*a[j]*a[z];

			}

		}

			

	}

	printf("%lld",num);	

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>





long long count[5];

int combine[10][3] = {

	{0,1,2},{0,1,3},{0,1,4},{0,2,3},{0,2,4},{0,3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4}

};

int main()

{

	int n;

	long long ans;

	char str[15];

	while(~scanf("%d",&n)){

		ans = 0;

		for(int i = 0; i<5; i++)count[i] = 0;

		for(int i = 0; i<n; i++){

			scanf("%s",str);

			if(str[0] == 'M') count[0]++;//M

			else if(str[0] == 'A') count[1]++;//A

			else if(str[0] == 'R') count[2]++;//R

			else if(str[0] == 'C') count[3]++;//C

			else if(str[0] == 'H') count[4]++;//H

			else continue;

		}

		for(int i = 0; i<10; i++){

			ans +=count[combine[i][0]]*count[combine[i][1]]*count[combine[i][2]];

		}

		printf("%lld\n",ans);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<string>

#include<cstring>

using namespace std;

long long int n,rs,f[5];string s;

int main()

{

	cin>>n;

	memset(f,0,sizeof(f));

	while(n-->0)

	{

		cin>>s;

		if(s[0]=='M')f[0]++;else if(s[0]=='A')f[1]++;else if(s[0]=='R')f[2]++;else if(s[0]=='C')f[3]++;else if(s[0]=='H')f[4]++;

	}

	long long int ly=0;rs=0;

	for(int i=0;i<5;i++)if(f[i]>0)ly++;

	if(ly>=3)

	{

			for(int i=0;i<5;i++)

			{

				if(f[i]==0)continue;

				for(int j=i;j<5;j++)

				{

					if(j==i||f[j]==0)continue;

					for(int t=j;t<5;t++)

					{

						if(i==t||t==j||f[t]==0)continue;

						rs+=f[i]*f[j]*f[t];

					}

				}

			}

	}

	cout<<rs<<endl;

}

// Optimized solution to the same problem (faster):
#include<cstdio>





long long count[5];

int combine[10][3] = {

	{0,1,2},{0,1,3},{0,1,4},{0,2,3},{0,2,4},{0,3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4}

};

int main()

{

	int n;

	long long ans;

	char str[15];

	while(~scanf("%d",&n)){

		ans = 0;

		for(int i = 0; i<5; i++)count[i] = 0;

		for(int i = 0; i<n; i++){

			scanf("%s",str);

			if(str[0] == 'M') count[0]++;//M

			else if(str[0] == 'A') count[1]++;//A

			else if(str[0] == 'R') count[2]++;//R

			else if(str[0] == 'C') count[3]++;//C

			else if(str[0] == 'H') count[4]++;//H

			else continue;

		}

		for(int i = 0; i<10; i++){

			ans +=count[combine[i][0]]*count[combine[i][1]]*count[combine[i][2]];

		}

		printf("%lld\n",ans);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#pragma comment(linker,"/STACK:102400000,102400000")

#include <iostream>

#include <cstdio>

#include <algorithm>

#include <vector>

#include <string>

#include <cstring>

#include <cctype>

#include <climits>

#include <cmath>

#include <set>

#include <map>

#include <sstream>

#include <queue>

#include <stack>



using namespace std;



int main(){

	int n;

	scanf("%d",&n);

	char name[20];

	map<char,long long> arr;

	set<char> st;

	vector<char> letter;

	for(int i=0;i<n;i++){

		scanf("%s",name);

		switch(name[0]){

			case 'M':

				st.insert(name[0]);

				arr['M']++;

				break;

			case 'A':

				st.insert(name[0]);

				arr['A']++;

				break;

			case 'R':

				st.insert(name[0]);

				arr['R']++;

				break;

			case 'C':

				st.insert(name[0]);

				arr['C']++;

				break;

			case 'H':

				st.insert(name[0]);

				arr['H']++;

				break;

		}

	}

	for(auto it=st.begin();it!=st.end();it++)

		letter.push_back(*it);

	long long ans;

	if(st.size()<3) ans=0;

	else if(st.size()==3){

		ans=arr[letter[0]]*arr[letter[1]]*arr[letter[2]];

	}

	else if(letter.size()==4){

		ans=arr[letter[0]]*arr[letter[1]]*arr[letter[2]];

		ans+=arr[letter[0]]*arr[letter[1]]*arr[letter[3]];

		ans+=arr[letter[0]]*arr[letter[2]]*arr[letter[3]];

		ans+=arr[letter[1]]*arr[letter[2]]*arr[letter[3]];

	}

	else if(letter.size()==5){

		ans=arr[letter[0]]*arr[letter[1]]*arr[letter[2]];

		ans+=arr[letter[0]]*arr[letter[1]]*arr[letter[3]];

		ans+=arr[letter[0]]*arr[letter[2]]*arr[letter[3]];

		ans+=arr[letter[1]]*arr[letter[2]]*arr[letter[3]];

		ans+=arr[letter[0]]*arr[letter[1]]*arr[letter[4]];

		ans+=arr[letter[0]]*arr[letter[2]]*arr[letter[4]];

		ans+=arr[letter[0]]*arr[letter[3]]*arr[letter[4]];

		ans+=arr[letter[1]]*arr[letter[2]]*arr[letter[4]];

		ans+=arr[letter[1]]*arr[letter[3]]*arr[letter[4]];

		ans+=arr[letter[2]]*arr[letter[3]]*arr[letter[4]];

	}

	printf("%lld\n",ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>





long long count[5];

int combine[10][3] = {

	{0,1,2},{0,1,3},{0,1,4},{0,2,3},{0,2,4},{0,3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4}

};

int main()

{

	int n;

	long long ans;

	char str[15];

	while(~scanf("%d",&n)){

		ans = 0;

		for(int i = 0; i<5; i++)count[i] = 0;

		for(int i = 0; i<n; i++){

			scanf("%s",str);

			if(str[0] == 'M') count[0]++;//M

			else if(str[0] == 'A') count[1]++;//A

			else if(str[0] == 'R') count[2]++;//R

			else if(str[0] == 'C') count[3]++;//C

			else if(str[0] == 'H') count[4]++;//H

			else continue;

		}

		for(int i = 0; i<10; i++){

			ans +=count[combine[i][0]]*count[combine[i][1]]*count[combine[i][2]];

		}

		printf("%lld\n",ans);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define ll long long 

int main()

{

string s;char x;

 vector<char>v;

    map<char,ll>m;

    ll a,b,c,d,i,j,k,l=0;

  cin>>a;

for(i=1;i<=a;i++)

{

  cin>>s;x=s[0];  

if(x=='C'||x=='R'||x=='A'||x=='M'||x=='H'){

  if(m[x]==0)

  {

        v.push_back(x);

   }

            m[x]++;

  }

}

 for(i=0;i<v.size();i++)

{

for(j=i+1;j<v.size();j++)

   {

for(k=j+1;k<v.size();k++)

{

l+=(m[v[i]]*m[v[j]]*m[v[k]]);

}

}

 }

cout<<l<<endl;

}

// Optimized solution to the same problem (faster):
#include<cstdio>





long long count[5];

int combine[10][3] = {

	{0,1,2},{0,1,3},{0,1,4},{0,2,3},{0,2,4},{0,3,4},{1,2,3},{1,2,4},{1,3,4},{2,3,4}

};

int main()

{

	int n;

	long long ans;

	char str[15];

	while(~scanf("%d",&n)){

		ans = 0;

		for(int i = 0; i<5; i++)count[i] = 0;

		for(int i = 0; i<n; i++){

			scanf("%s",str);

			if(str[0] == 'M') count[0]++;//M

			else if(str[0] == 'A') count[1]++;//A

			else if(str[0] == 'R') count[2]++;//R

			else if(str[0] == 'C') count[3]++;//C

			else if(str[0] == 'H') count[4]++;//H

			else continue;

		}

		for(int i = 0; i<10; i++){

			ans +=count[combine[i][0]]*count[combine[i][1]]*count[combine[i][2]];

		}

		printf("%lld\n",ans);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <functional>

#include <vector>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <bitset>

#include <cassert>

#include <exception>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<ll,ll> P;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef vector<P> vp;

#define rep(i,a,n) for(ll i = (a);i < (n);i++)

#define per(i,a,n) for(ll i = (a);i > (n);i--)

#define lep(i,a,n) for(ll i = (a);i <= (n);i++)

#define pel(i,a,n) for(ll i = (a);i >= (n);i--)

#define clr(a,b) memset((a),(b),sizeof(a))

#define pb push_back

#define mp make_pair

#define all(c) (c).begin(),(c).end()

#define sz size()

#define print(X) cout << (X) << endl

const ll INF = 1e+9+7;

ll n,m,l;

string s,t;

ll d[200010],dp[550][550];



int main(){

  cin >> n;

  clr(d,0);

  rep(i,0,n){

    cin >> s;

    if(s[0] == 'M')d[0]++;

    if(s[0] == 'A')d[1]++;

    if(s[0] == 'R')d[2]++;

    if(s[0] == 'C')d[3]++;

    if(s[0] == 'H')d[4]++;

  }

  l = 0;

  rep(i,0,5){

    rep(j,i+1,5){

      rep(k,j+1,5){

        l += d[i] * d[j] * d[k];

      }

    }

  }

  print(l);

  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <algorithm>

#include <functional>

#include <vector>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <bitset>

#include <cassert>

#include <exception>

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<ll,ll> P;

typedef vector<int> vi;

typedef vector<ll> vll;

typedef vector<string> vs;

typedef vector<P> vp;

#define rep(i,a,n) for(ll i = (a);i < (n);i++)

#define per(i,a,n) for(ll i = (a);i > (n);i--)

#define lep(i,a,n) for(ll i = (a);i <= (n);i++)

#define pel(i,a,n) for(ll i = (a);i >= (n);i--)

#define clr(a,b) memset((a),(b),sizeof(a))

#define pb push_back

#define mp make_pair

#define all(c) (c).begin(),(c).end()

#define sz size()

#define print(X) cout << (X) << endl

const ll INF = 1e+9+7;

ll n,m,l;

string s,t;

ll d[200010],dp[550][550];



int main(){

  cin >> n;

  rep(i,0,n){

    cin >> s;

    if(s[0] == 'M')d[0]++;

    if(s[0] == 'A')d[1]++;

    if(s[0] == 'R')d[2]++;

    if(s[0] == 'C')d[3]++;

    if(s[0] == 'H')d[4]++;

  }

  l = 0;

  rep(i,0,5){

    rep(j,i+1,5){

      rep(k,j+1,5){

        l += d[i] * d[j] * d[k];

      }

    }

  }

  print(l);

  return 0;

}

// Fastest known solution for this problem: