http://lx.lanqiao.cn/problem.page?gpid=T219
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e4+5;
//int v[maxn];
const int mod=999101;
signed main(){
int L;
string s;
cin>>L>>s;
map<string,int>mp;
vector<string>v;
for(int i=0;i<s.size();i++){
for(int j=i+L;j<s.size();j++){
v.push_back(s.substr(i,j-i));
mp[v.back()]++;
}
}
int ans=0;
for(int i=1;i<v.size();i++){
if(mp[v[i]]>mp[v[ans]] || (mp[v[i]]==mp[v[ans]]&&v[i].size()>v[ans].size()))
ans=i;
}
cout<<v[ans]<<endl;
return 0;
}