Language: C++

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;
const double EPS = 1e-10;

int main()
{
	int n;
	while(scanf("%d%*c", &n), n){
		char line[2048];
		map<string, int> dict;
		rep(i, n){
			fgets(line, sizeof(line), stdin);
			stringstream sstr(line);
			for(string word; sstr >> word;)
				dict[word]--;
		}
		
		vector<pair<int, string> > a;
		scanf("%s", line);
		for(map<string, int>::iterator itr=dict.begin(); itr!=dict.end(); ++itr){
			if(itr->first[0] == line[0])
				a.push_back(make_pair(itr->second, itr->first));
		}
		if(a.empty())
			puts("NA");
		else{
			sort(a.begin(), a.end());
			rep(i, min(5u, a.size()))
				printf("%s%s", i ? " " : "", a[i].second.c_str());
			puts("");
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:55:35: error: no matching function for call to 'min(unsigned int, std::vector<std::pair<int, std::__cxx11::basic_string<char> > >::size_type)'
   55 |                         rep(i, min(5u, a.size()))
      |                                ~~~^~~~~~~~~~~~~~
a.cc:21:40: note: in definition of macro 'reps'
   21 | #define reps(i,f,n) for(int i=f; i<int(n); ++i)
      |                                        ^
a.cc:55:25: note: in expansion of macro 'rep'
   55 |                         rep(i, min(5u, a.size()))
      |                         ^~~
In file included from /usr/include/c++/14/algorithm:60,
                 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:55:35: 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'})
   55 |                         rep(i, min(5u, a.size()))
      |                                ~~~^~~~~~~~~~~~~~
a.cc:21:40: note: in definition of macro 'reps'
   21 | #define reps(i,f,n) for(int i=f; i<int(n); ++i)
      |                                        ^
a.cc:55:25: note: in expansion of macro 'rep'
   55 |                         rep(i, min(5u, a.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:
/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:55:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
   55 |                         rep(i, min(5u, a.size()))
      |                                ~~~^~~~~~~~~~~~~~
a.cc:21:40: note: in definition of macro 'reps'
   21 | #define reps(i,f,n) for(int i=f; i<int(n); ++i)
      |                                        ^
a.cc:55:25: note: in expansion of macro 'rep'
   55 |                         rep(i, min(5u, a.size()))
      |                         ^~~