stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<string>

#include<iostream>



using namespace std;

long long n,a[6],ans;

string s[200000];

int main()

{

    scanf("%lld",&n);

    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;

}

// Faster C++ solution for the same problem (measured speedup: 8.284875369715047x):
#include<bits/stdc++.h>

using namespace std;

int a[105];

long long n,cnt;

int main()

{

	string s,r="MARCH";

	scanf("%d",&n);

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

	{

		cin>>s;

		a[s[0]]++;

	}

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

	{

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

		{

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

			{

				cnt+=1ll*a[r[i]]*a[r[j]]*a[r[k]];	

			}	

		}	

	} 

	printf("%lld",cnt);

	return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<string>

#include<iostream>



using namespace std;

long long n,a[6],ans;

string s[200000];

int main()

{

    scanf("%lld",&n);

    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;

}

// Faster C++ solution for the same problem (measured speedup: 8.292650031679226x):
#include<iostream>

#include<cstdio>

#include<string>

#include<vector>

#include<queue>

#include<cmath>

#include<algorithm>

#include<iomanip>

#include<functional>

#include<set>

#include<map>

#include<climits>

#include<utility>

#define ul unsigned long long int

#define ll long long int

#define MAX 1000000+1

using namespace std;

#define F first

#define S second

#define pi 2*acos(0.0)

#define PB push_back

#define CL clear()















int main()

{

    ll arr[6];

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

        arr[i] = 0;

    ll n ;

    cin >> n;

    string d;

    map<string, bool> v;

    v.clear();

    while(n--)

    {



        cin >> d;







        switch(d[0])

        {

        case 'A' :

            arr[0]++;

            break;

        case 'C':

            arr[1]++;

            break;

        case 'H':

            arr[2]++;

            break;

        case 'M' :

            arr[3]++;

            break;

        case 'R':

            arr[4]++;

            break;



        }



    }

    ll e = 0;

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

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

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

                e += (arr[i]*arr[j]*arr[k]);

    cout << e;



    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<string>

#include<iostream>



using namespace std;

long long n,a[6],ans;

string s[200000];

int main()

{

    scanf("%lld",&n);

    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;

}

// Faster C++ solution for the same problem (measured speedup: 8.210539665739729x):
#include <bits/stdc++.h>

using namespace std;

int main()

{

    int n;

    while(cin>>n)

    {

        long long int ans=0;

        long long int ansm=0,ansa=0,ansr=0,ansc=0,ansh=0;

        string s;

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

        {

            cin>>s;

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

            else if(s[0]=='A') ansa++;

            else if(s[0]=='R') ansr++;

            else if(s[0]=='C') ansc++;

            else if(s[0]=='H') ansh++;

        }

        if(n<3)

        {

            ans=0;

        }

        else

        {

            ans+=ansm*ansa*ansr;

            ans+=ansm*ansa*ansc;

            ans+=ansm*ansa*ansh;



            ans+=ansm*ansr*ansc;

            ans+=ansm*ansr*ansh;



            ans+=ansm*ansc*ansh;



            ans+=ansa*ansr*ansc;

            ans+=ansa*ansr*ansh;



            ans+=ansa*ansc*ansh;

            ans+=ansr*ansc*ansh;

        }

        cout<<ans<<endl;



    }

}
// Slower C++ solution:
#include<iostream>

#include<algorithm>

#include<cmath>

#include<string>

using namespace std;

int main() {

  int n;

  cin >> n;

  long long m=0,a=0,r=0,c=0,h=0;

  string s[100000];

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

    }

  }

  cout << 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 << endl;

}

// Faster C++ solution for the same problem (measured speedup: 4.319043879218936x):
/*   _/                _/                 _/_/_/   _/

  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/

   _/     _/    _/   _/     _/    _/  _/_/_/     _/

  _/     _/    _/   _/     _/    _/  _/    _/   _/

   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */

#include<iostream>

#include<algorithm>

#include<cmath>

#include<iomanip>

#include<set>

#include<map>

#include<queue>

#include<vector>

using namespace std;

using ll=long long;

const int MOD=1e9+7;

const double pi=3.14159265358979323846;

const int inf=1e9;

const ll INF=1e18;

using P=pair<int,int>;

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

int main() {

  cin.tie(0),cout.tie(0);

  ios::sync_with_stdio(false);

  ll n,ans=0;

  string s;

  ll a[5]={};

  cin >> n;

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

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

    }

  }

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

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

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

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

      }

    }

  }

  cout << ans << endl;

}
// Slower C++ solution:
#include<cstdio>

#include<iostream>



using namespace std;

const int MAXN =1e5+10;



char s[MAXN][20];

long long int march[10];

int main(){

  int N =0;

  scanf("%d",&N);

  long long int ans =0;

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

    scanf("%s",&s[i]);

  }

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

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

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

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

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

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

  }



  ans=march[0]*march[1]*march[2]+march[0]*march[1]*march[3]+march[0]*march[1]*march[4]+march[0]*march[2]*march[3]+march[0]*march[2]*march[4]+march[0]*march[3]*march[4]+march[1]*march[2]*march[3]+march[1]*march[2]*march[4]+march[1]*march[3]*march[4]+march[2]*march[3]*march[4];



  printf("%lld",ans);

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.155381241164831x):
#include <stdio.h>



int calcpos(char c) {

    switch (c) {

        case 'M':

            return 0;

        case 'A':

            return 1;

        case 'R':

            return 2;

        case 'C':

            return 3;

        case 'H':

            return 4;

    }



    return -1;

}



char S[15];



int main()

{

    long long counts[5] = {0,0,0,0,0};

    int pos;



    int N;

    scanf("%d", &N);



    for (int i = 1; i <= N && !feof(stdin); ++i) {

        scanf("%s", S);



        pos = calcpos(S[0]);

        if (pos != -1) ++counts[pos];

    }



    long long res = 0;

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

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

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

                res += counts[i] * counts[j] * counts[x];

            }

        }

    }



    printf("%lld", res);



    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<iostream>



using namespace std;

const int MAXN =1e5+10;



char s[MAXN][20];

long long int march[10];

int main(){

  int N =0;

  scanf("%d",&N);

  long long int ans =0;

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

    scanf("%s",&s[i]);

  }

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

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

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

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

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

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

  }



  ans=march[0]*march[1]*march[2]+march[0]*march[1]*march[3]+march[0]*march[1]*march[4]+march[0]*march[2]*march[3]+march[0]*march[2]*march[4]+march[0]*march[3]*march[4]+march[1]*march[2]*march[3]+march[1]*march[2]*march[4]+march[1]*march[3]*march[4]+march[2]*march[3]*march[4];



  printf("%lld",ans);

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.153986203733096x):
#include <stdio.h>



int calcpos(char c) {

  switch (c) {

    case 'M':

      return 0;

    case 'A':

      return 1;

    case 'R':

      return 2;

    case 'C':

      return 3;

    case 'H':

      return 4;

  }



  return -1;

}



char S[15];



int main()

{

  int counts[5] = {0,0,0,0,0};

  int pos;



  int N;

  scanf("%d", &N);



  for (int i = 1; i <= N && !feof(stdin); ++i) {

    scanf("%s", S);



    pos = calcpos(S[0]);

    if (pos != -1) ++counts[pos];

  }



  long long res = 0;

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

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

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

        res += (long long)counts[i] * (long long)counts[j] * (long long)counts[x];

      }

    }

  }



  printf("%lld", res);



  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int calcpos(char c) {

  switch (c) {

    case 'M':

      return 0;

    case 'A':

      return 1;

    case 'R':

      return 2;

    case 'C':

      return 3;

    case 'H':

      return 4;

  }



  return -1;

}



char S[15];



int main()

{

  long long counts[5] = {0,0,0,0,0};

  int pos;



  int N;

  scanf("%d", &N);



  for (int i = 1; i <= N && !feof(stdin); ++i) {

    scanf("%s", S);



    pos = calcpos(S[0]);

    if (pos != -1) ++counts[pos];

  }



  long long res = 0;

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

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

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

        res += counts[i] * counts[j] * counts[x];

      }

    }

  }



  printf("%lld", res);



  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.15567771294634x):
#include <stdio.h>



int calcpos(char c) {

  switch (c) {

    case 'M':

      return 0;

    case 'A':

      return 1;

    case 'R':

      return 2;

    case 'C':

      return 3;

    case 'H':

      return 4;

  }



  return -1;

}



char S[15];



int main()

{

  int counts[5] = {0,0,0,0,0};

  int pos;



  int N;

  scanf("%d", &N);



  for (int i = 1; i <= N && !feof(stdin); ++i) {

    scanf("%s", S);



    pos = calcpos(S[0]);

    if (pos != -1) ++counts[pos];

  }



  long long res = 0;

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

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

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

        res += (long long)counts[i] * (long long)counts[j] * (long long)counts[x];

      }

    }

  }



  printf("%lld", res);



  return 0;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 4.277955791442632x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 4.392951276601111x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 4.408548243923546x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 8.27988439897975x):
#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);





}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 4.359890858035095x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.318404995845464x):
#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;

}