Language: C++

#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
vector<string> Split(const string &s)
{
	vector<string> v;
	int i=0, j;
	while((j=s.find_first_of(' ',i)) !=string::npos)
	{
		v.push_back(s.substr(i,j-i));
		i=j+1;
	}
	if(i!=s.size()-1)
		v.push_back(s.substr(i));
	return v;
}
int main()
{
	int n;
	string s;
	vector<string>v;
	map<string,int>m;
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(cin>>n,n)
	{
		getline(cin,s);
		m.clear();
		while(n--)
		{
			getline(cin,s);
			v=Split(s);
			for(int i=0;i<v.size();++i)
				++m[v[i]];
		}
		getline(cin,s);
		vector<pair<int,string> >vp;
		for(map<string,int>::iterator ite=m.begin();ite!=m.end();++ite)
		{
			if(ite->first[0]!=s[0])continue;
			vp.push_back(make_pair(-ite->second,ite->first));
		}
		if(vp.empty())cout<<"NA"<<endl;
		else
		{
			sort(vp.begin(),vp.end());
			int end=min(5U,vp.size());
			for(int i=0; i<end; ++i)
				cout<<vp[i].second<<(i+1==end?"\n":" ");
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:50:36: error: no matching function for call to 'min(unsigned int, std::vector<std::pair<int, std::__cxx11::basic_string<char> > >::size_type)'
   50 |                         int end=min(5U,vp.size());
      |                                 ~~~^~~~~~~~~~~~~~
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:50:36: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::vector<std::pair<int, std::__cxx11::basic_string<char> > >::size_type' {aka 'long unsigned int'})
   50 |                         int end=min(5U,vp.size());
      |                                 ~~~^~~~~~~~~~~~~~
/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:5:
/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:50:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
   50 |                         int end=min(5U,vp.size());
      |                                 ~~~^~~~~~~~~~~~~~