Why am i getting this code wrong ,someone please guide whats wrong basically from auto loop

My issue

My code

#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--){
		int n,cnt=0;
		cin>>n;
		//number of strings input.
		int a[6];
		map<char,int> m;
		//string input.
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			//counting frequency of letters.
		for(int j=0;j<s.size();j++){
			char x =s[j];
			m[x]++;
		}
		}				for(auto it : m){
			if(it.first =='o' || it.first =='d' || it.first =='h' || it.first =='f'){
				a[cnt] = it.second;
				cnt++;
			}
			else if(it.first == 'c' || it.first =='e'){
				a[cnt] = it.second/2;
				cnt++;
			}
            else{
                continue;
            }
		}
		sort(a,a+cnt);
		cout<<a[0]<<endl;

}
}

Problem Link: CFMM Problem - CodeChef

@anidave09
your code right but u have to initialize each “codehf” character with 0 inside map;
i have corrected in your code .

#include <bits/stdc++.h>
using namespace std;
int main() {
    int t;
    cin>>t;
    while(t--){
		int n,cnt=0;
		cin>>n;
		//number of strings input.
		int a[6];
		map<char,int> m;
		m['c']=0;
		m['o']=0;
		m['d']=0;
		m['e']=0;
		m['h']=0;
		m['f']=0;
		//string input.
		for(int i=0;i<n;i++){
			string s;
			cin>>s;
			//counting frequency of letters.
		for(int j=0;j<s.size();j++){
			char x =s[j];
			m[x]++;
		}
		}				for(auto it : m){
			if(it.first =='o' || it.first =='d' || it.first =='h' || it.first =='f'){
				a[cnt] = it.second;
				cnt++;
			}
			else if(it.first == 'c' || it.first =='e'){
				a[cnt] = it.second/2;
				cnt++;
			}
            else{
                continue;
            }
		}
		sort(a,a+cnt);
		cout<<a[0]<<endl;

}
}