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

using namespace std;



#define REP(i,s,n) for(int i=s; i<n; ++i)

#define rep(i,n) REP(i,0,n)

#define SORT(c) sort((c).begin(),(c).end())

#define IINF INT_MAX

#define LLINF LLONG_MAX



typedef long long ll;

typedef pair<int, int> ii;



/*

class Node {

public:

  int num;

  int index;

  bool operator<(const Node& b) const {

    if(num < b.num) return (num < b.num);

    else return index > b.index;

  }



  Node(){

    num=0; index=0;

  }

  Node(int n, int i) : num(n), index(i){

  }

};

*/



int main(){



  int n, a, b;

  cin >> n >>a>>b;

  string s;

  cin >> s;



  int cnta = 0, cntb = 0;



  rep(i, s.size()){

    if(s[i] == 'a'){

      if(cnta + cntb < a + b){

        cout << "Yes" <<endl;

        cnta++;

      }

      else cout << "No" <<endl;

    }

    else if(s[i] == 'b'){

      if(cnta + cntb < a + b && cntb < b){

        cout << "Yes" <<endl;

        cntb++;

      }

      else cout << "No" <<endl;

    }

    else cout << "No" <<endl;





  }



  return 0;

}


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

 

const int N = 100500;

 

char buf[N];

 

int main() {

    int n, a, b;

    scanf("%d %d %d", &n, &a, &b);

    scanf("%s", buf);

    int ab = a + b, ca = 0, cb = 0;

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

        if (buf[i] == 'a') {

            if (ca + cb < ab) {

                ca++;

                puts("Yes");

            } else {

                puts("No");

            }

        } else if (buf[i] == 'b') {

            if (ca + cb < ab && cb < b) {

                cb++;

                puts("Yes");

            } else {

                puts("No");

            }

        } else{

        	puts("No");

        }

    }

}

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

using namespace std;

 

#define REP(i,s,n) for(int i=s; i<n; ++i)

#define rep(i,n) REP(i,0,n)

#define SORT(c) sort((c).begin(),(c).end())

#define IINF INT_MAX

#define LLINF LLONG_MAX

 

typedef long long ll;

typedef pair<int, int> ii;

 

int main(){

 

  int n, a, b;

  cin >> n >> a >> b;

  string s;

  cin >> s;

 

  int ab = a + b, sum = 0, cnt = 0;

 

  rep(i, s.size()){

    if(s[i] == 'a'){

      if(sum < ab){

        cout << "Yes" <<endl;

        sum++;

      }

      else cout << "No" <<endl;

    }

    else if(s[i] == 'b'){

      if(sum < ab && cnt < b){

        cout << "Yes" <<endl;

        sum++;

        cnt++;

      }

      else cout << "No" <<endl;

    }

    else cout << "No" <<endl;

 

  }

 

  return 0;

}

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

 

const int N = 100500;

 

char buf[N];

 

int main() {

    int n, a, b;

    scanf("%d %d %d", &n, &a, &b);

    scanf("%s", buf);

    int ab = a + b, ca = 0, cb = 0;

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

        if (buf[i] == 'a') {

            if (ca + cb < ab) {

                ca++;

                puts("Yes");

            } else {

                puts("No");

            }

        } else if (buf[i] == 'b') {

            if (ca + cb < ab && cb < b) {

                cb++;

                puts("Yes");

            } else {

                puts("No");

            }

        } else{

        	puts("No");

        }

    }

}

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



using namespace std;



int N, A, B, sum, cnt;

string s, ans[101010];



int main() {

  cin >> N >> A >> B >> s;



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

    if (s[i] == 'a') {

      if (sum < A + B) {

        sum++;

        ans[i] = "Yes";

      }

    } else if (s[i] == 'b') {

      if (sum < A + B && cnt < B) {

        sum++;

        cnt++;

        ans[i] = "Yes";

      }

    }



    if (ans[i] != "Yes") ans[i] = "No";

  }



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

    cout << ans[i] << endl;

  }



  return 0;

}

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



using namespace std;



int main() {

  int n, a, b;

  string s;

  cin >> n >> a >> b >> s;

  int aa = 0, bb = 0;

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

    if (s[i] == 'a') {

      if (aa + bb < a + b) {

        cout << "Yes" << endl;

        aa++;

        continue;

      }

    } else if (s[i] == 'b') {

      if (aa + bb < a + b && bb < b) {

        cout << "Yes" << endl;

        bb++;

        continue;

      }

    }

    cout << "No" << endl;

  }



  return 0;

}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)





int main()

{

	int64_t N, A, B,aCount=0,bCount=0;

	char M;



	cin >> N >> A >> B;

	

	vector<int64_t> S(100000);

	rep(i, N) {

		cin >> M;

		if (M=='a'&& A+B>0)

		{

			A--;

			cout << "Yes" << endl;



		}

		else if (M == 'b' && B>0 && A+B>0) {

			B--;

			cout << "Yes" << endl;

		}

		else {

			cout << "No" << endl;

		}

		

	}

}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)n;i++)

using Graph = vector<vector<int> >;

using GraphC = vector<vector<char> >;

typedef pair<int, int> P;

const int MAX_N = 10000;

const int MAX_L = 100000000;

const int MAX_SQRT_B = 10000;

const int INF = 1000000000;

typedef int64_t ll;

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







int main() {

	int N, A, B;

	string S;

	cin >> N >> A >> B >> S;

	int AB = A + B;

	rep(i, N) {

		if (S.at(i) == 'a') {

			

			if(AB>0){

				

				cout << "Yes" << endl;

				AB--;

			}

			else {

				cout << "No" << endl;

			}

			

		}

		else if (S.at(i) == 'b') {

			if (AB > 0 && B > 0) {

				cout << "Yes" << endl;

				AB--;

				B--;

			}

			else {

				cout << "No" << endl;

			}

			

		}

		else {

			cout << "No" << endl;

		}

	}



}

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

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

#define repb(i,a,b) for(int i=a;i>=b;i--)

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

#define o(a) cout<<a<<endl

#define int long long

using namespace std;

typedef vector<int> vi;

typedef vector<vi> vvi;

typedef pair<int,int> pii;



signed main(){

	int n;

	while(cin>>n && n!=0){

		vi d(n);

		rep(i,0,n) cin>>d[i];



		bool f[100000];

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



		rep(i,0,n){

			f[i]=d[i];

			if(i%2 && f[i-1]!=d[i]){

				repb(j,i-1,0){

					if(f[j]==d[i]) break;

					f[j]=d[i];

				}

			}

		}



		int ans=0;

		rep(i,0,n) if(!f[i]) ans++;

		o(ans);

	}

}

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

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

#define repb(i,a,b) for(int i=a;i>=b;i--)

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

#define o(a) cout<<a<<endl

#define int long long

#define fi first

#define se second

using namespace std;

typedef vector<int> vi;

typedef vector<vi> vvi;

typedef pair<int,int> pii;



signed main(){

	int n;

	while(cin>>n && n!=0){

		vector<pii> d(n+1);

		int num;

		rep(i,1,n+1){

			cin>>num;

			d[i].fi=num;

		}

		d[0].fi=-1;

		d[0].se=0;

		d[1].se=1;



		rep(i,2,n+1){

			if(!(i%2)){

				if(d[i].fi==d[i-1].fi) d[i].se=d[i-1].se+1;

				else{

					d[i].se=d[i-1].se+d[i-1-d[i-1].se].se+1;

				}

			}else{

				if(d[i].fi==d[i-1].fi) d[i].se=d[i-1].se+1;

				else d[i].se=1;

			}

		}



		int ans=0;

		int i=n;

		while(i>0){

			if(d[i].fi==0) ans+=d[i].se;

			i-=d[i].se;

		}

		o(ans);

	}

}

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

#include<string>

using namespace std;



int main(){

	int n;

	cin>>n;

	

	string s[100000];

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

	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;

	

	return 0;

}

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

#define REP(i,n) for(int i=0;i<(n);++i)

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

#define debug(x) cerr<<#x<<": "<<(x)<<endl

#define INF      (int)1e9

#define EPS      (double)1e-9

#define MOD      ((int)1e9+7)

using namespace std;

typedef long long     llong;

typedef vector<int>   vi;

typedef vector<vi >   vvi;

typedef vector<vvi >  vvvi;

typedef pair<int,int> pii;

template<class Type_a,class Type_b> bool chmax(Type_a &a,const Type_b &b){if(a<b){a=b;return true;}return false;}

template<class Type_a,class Type_b> bool chmin(Type_a &a,const Type_b &b){if(a>b){a=b;return true;}return false;}

template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}



int main(){

	string key="MARCH";

	

	int n;

	cin>>n;

	

	map<char,int> mp;

	REP(i,n){

		string s;

		cin>>s;

		mp[s[0]]++;

	}

	

	llong ans=0;

	REP(i,3)for(int j=i+1;j<4;++j)for(int k=j+1;k<5;++k){

		ans+=(llong)mp[key[i]]*mp[key[j]]*mp[key[k]];

	}

	

	cout<<ans<<endl;

}

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

#include<string>

#include <cmath>

#include <algorithm>

#include <vector>

#include <cstdint>

#include <map>

#define MOD 1000000007

using namespace std;

typedef long long ll;



int main(){



int n;

cin >> n;



string s[100010];

ll MARCH[5] = {};



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

cin >> s[i];

}



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

 switch ( s[i][0] )  {  

case 'M':  

MARCH[0]++;  

break;  

case 'A':  

MARCH[1]++;  

break;  

case 'R':  

MARCH[2]++;  

break;  

case 'C':  

MARCH[3]++;  

break;  

case 'H':  

MARCH[4]++;  

break;  

      } 

}



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

  }

 }

}



cout << ans << endl;



return 0;

}

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

#include<string>

#include <cmath>

#include <algorithm>

#include <vector>

#include <cstdint>

#include <map>

#define MOD 1000000007

using namespace std;

typedef long long ll;

 

int main(){

 

int n;

cin >> n;

 

ll MARCH[5] = {};

 

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

string s;

cin >> s;

 switch ( s[0] )  {  

case 'M':  

MARCH[0]++;  

break;  

case 'A':  

MARCH[1]++;  

break;  

case 'R':  

MARCH[2]++;  

break;  

case 'C':  

MARCH[3]++;  

break;  

case 'H':  

MARCH[4]++;  

break;  

      } 

}

 

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

  }

 }

}

 

cout << ans << endl;

 

return 0;

}

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

#include<string>

#include<vector>

#include<cmath>

#include<algorithm>

#include<functional>

#include<iomanip>

#include<queue>

#include<ciso646>

using namespace std;

const int MOD = 1000000007;

typedef long long ll;

const ll INF = (ll)1000000007*1000000007;

typedef pair<int, int> P;

typedef unsigned int ui;

int main(){

	int n;

	ll sum = 0;

	ll a[5] = {};

	string s;

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

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

			}

		}

	}

	cout << sum << endl;

	char nyaa;

	cin >> nyaa;

	return 0;

}


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



int main(void)

{

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

  int i,num;

  long answer;

  scanf("%d", &num);

  char array[10];

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

  {

    scanf("%s", array);

    if(array[0]=='M')m++;

    if(array[0]=='A')a++;

    if(array[0]=='R')r++;

    if(array[0]=='C')c++;

    if(array[0]=='H')h++;

  }

  

   answer=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*c*h+r*c*h+a*r*h;

   printf("%ld", answer);

  

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

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

    #include<cstring>

    #include<algorithm>

    #include<iostream>

    #include<string>

    #include<vector>

    #include<stack>

    #include<bitset>

    #include<cstdlib>

    #include<cmath>

    #include<set>

    #include<list>

    #include<deque>

    #include<map>

    #include<queue>

    using namespace std;

    typedef long long ll;

    const double PI = acos(-1.0);

    const double eps = 1e-6;

    const int INF = 0x3f3f3f3f;

     

    const int MAXN =1e5+10;

     

    char s[MAXN][10+10];

    long long int march[5+5];

    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;

    }

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;



    }

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
/*   _/                _/                 _/_/_/   _/

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

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

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

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

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

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem: