Language: C++

#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<functional>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int n;
	char k;
	vector< pair<string,int> >m;//stringを出てきた回数順に並べるための連想配列
	vector<string>words;//まずは出てきた単語をすべて格納
	while(cin>>n,n){//13と入力された場合、13がnに入り、次の改行は、getlineに行ってしまう
	cin.ignore();//
	for(int i=0;i<n;i++){
		string now,tmp;
		now.clear();tmp.clear();
		getline(cin,now);
		for(int j=0;j<now.size();j++){
			if(now[j]!=' ')tmp+=now[j];
			else {
				words.push_back(tmp);
				tmp.clear();
			}
			if(j==now.size()-1)words.push_back(tmp);
		}
}
	cin>>k;
	for(int i=0;i<words.size();i++){
		if(words[i][0]==k){
			bool flag=false;
			for(int j=0;j<m.size();j++){
				if(m[j].first==words[i]){
				m[j].second--;
				flag=true;
				}
			}
		if(flag==false)m.push_back(pair<string,int>(words[i],-1));
		}
	}
	//sort(m.begin(),m.end(),greater<pair< string,int> >());
	for(int i=0;i<m.size();i++){
		for(int j=0;j<m.size();j++){
			if(m[i].second<m[j].second)swap(m[i],m[j]);
		}
	}
	//for(int i=0;i<m.size();i++)cout<<m[i].first<<" "<<m[i].second<<endl;
	
	for(int i=0;i<m.size();i++){
		for(int j=0;j<m.size();j++){
			if(m[i].first<m[j].first&&m[i].second==m[j].second)swap(m[i],m[j]);
		}
	}
		unsigned int x=5;
	if(m.size()==0)cout<<"NA"<<endl;

	else{
		for(int i=0;i<std::min(m.size(),x);i++){
			if(i!=std::min(m.size(),x)-1)cout<<m[i].first<<" ";
			else 	cout<<m[i].first<<endl;
		}
	}
	m.clear();words.clear();
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:59:39: error: no matching function for call to 'min(std::vector<std::pair<std::__cxx11::basic_string<char>, int> >::size_type, unsigned int&)'
   59 |                 for(int i=0;i<std::min(m.size(),x);i++){
      |                               ~~~~~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:59:39: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'unsigned int')
   59 |                 for(int i=0;i<std::min(m.size(),x);i++){
      |                               ~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:59:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   59 |                 for(int i=0;i<std::min(m.size(),x);i++){
      |                               ~~~~~~~~^~~~~~~~~~~~
a.cc:60:39: error: no matching function for call to 'min(std::vector<std::pair<std::__cxx11::basic_string<char>, int> >::size_type, unsigned int&)'
   60 |                         if(i!=std::min(m.size(),x)-1)cout<<m[i].first<<" ";
      |                               ~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:60:39: note:   deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'unsigned int')
   60 |                         if(i!=std::min(m.size(),x)-1)cout<<m[i].first<<" ";
      |                               ~~~~~~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:60:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int'
   60 |                         if(i!=std::min(m.size(),x)-1)cout<<m[i].first<<" ";
      |                               ~~~~~~~~^~~~~~~~~~~~