stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int maxn=5005;

string ch[maxn*6];

char s[maxn];

int n,k,cnt;

int main(){

    scanf("%s%d",s,&k),n=strlen(s);

    for(int i=0,T;i<n;i++){

        ch[++cnt]=s[i];

        T=min(k,n-i);

        for(int j=1;j<T;j++,cnt++) ch[cnt+1]=ch[cnt]+s[i+j];

    }

     

    sort(ch+1,ch+cnt+1);

    unique(ch+1,ch+cnt+1);

    cout<<ch[k]<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.9700852673484475x):
#include <iostream>

#include <fstream>

#include <cmath>

#include <algorithm>

#include <vector>

#include <set>

#include <map>

#include <stack>

#include <queue>

#include <cstdlib>

#include <cstdio>

#include <string>

#include <cstring>

#include <cassert>

#include <utility>

#include <iomanip>

#include <chrono>

#include <random>

#include <bitset>



using namespace std;



#define sz(x) (int) x.size()

#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())

#define all(a) a.begin(), a.end()

#define sqr(x) ((x) * (x)) 

#define y1 aksjdaskdjksjfksdjf

#define left kdnvldvoiwejifejg

#define right lkdsjflksdjfdjfk

#define prev asdasfsadjkjsdfjs

#define tm aklsjdasjdasjdkdjjf

#define lcm hddalkwjeidjjhasda

#define random_shuffle asdasdd



string s;

int k;

set <string> st;



int main() { 



  getline(cin, s);

  cin >> k;



  for (int i = 0; i < sz(s); i++) {

    for (int j = i; j < min(i + 5, sz(s)); j++) {

      string cur = s.substr(i, j - i + 1);

      st.insert(cur);

      if (sz(st) > k) {

        st.erase(*st.rbegin());

      }

    }

  }



  cout << *st.rbegin() << endl;



  return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int k,L,l;

string S,s[100005];

int main()

{

	cin>>S>>k; 

	L=S.size();

	for(int i=1;i<=5;i++)

	  for(int j=0;j<=L-i;j++)

		s[l++]=S.substr(j,i);

	sort(s,s+l);

	l=unique(s,s+l)-s;

	cout<<s[k-1];

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.371340441146545x):
#include <cstdio>

#include <algorithm>

#include <utility>

#include <vector>

#include <queue>

#include <functional>

#include <stack>

#include <set>

#include <map>

#include <ctype.h>

#include <cstring>

#include <string>

#include <iostream>



#define fi first

#define se second

#define sz(x) ((int)x.size())



using namespace std;



typedef long long lli;

typedef pair<int,int> pii;

typedef pair<lli,int> pli;

typedef pair<lli,lli> pll;



int n,m;

char str[5010],tmp[5010];



void make(int l) {

	vector<char> arr;

	for(int i=0;i<n-l && m>0;i++) {

		int f=1;

		for(int j=0;j<l;j++) if(str[i+j]!=tmp[j]) {

			f=0;

			break;

		}

		if(f) arr.push_back(str[i+l]);

	}

	if(arr.empty() || !m) return;

	

	sort(arr.begin(),arr.end());

	for(int i=0;i<sz(arr) && m>0;i++) {

		if(i!=0 && arr[i]==arr[i-1]) continue;

		tmp[l] = arr[i];

		m--;

		if(!m) printf("%s\n",tmp);

		else make(l+1);

		tmp[l] = 0;

	}

}



int main() {

	scanf("%s",str);

	scanf("%d",&m);

	n=strlen(str);



	make(0);

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int k,L,l;

string S,s[100005];

int main()

{

	cin>>S>>k; 

	L=S.size();

	for(int i=1;i<=5;i++)

	  for(int j=0;j<=L-i;j++)

		s[l++]=S.substr(j,i);

	sort(s,s+l);

	l=unique(s,s+l)-s;

	cout<<s[k-1];

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.25380781417779x):
#include <bits/stdc++.h>



using namespace std;



typedef long long ll;

typedef long double ld;

typedef vector<int> vi;

typedef vector<vector<int> > vvi;

typedef pair<int, int> pii;



#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)

#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)

#define all(v) ((v).begin()), ((v).end())

#define sz(v) ((int)((v).size()))

#define mod(n, m) ((n%m + m) % m)

#define reset(n, m) memset(n, m, sizeof n)

#define endl '\n'



int main()

{

	ios_base::sync_with_stdio(0);

	cin.tie(0);



	string x;

	cin >> x;

	map<string, bool> mp;



	int k;

	cin >> k;

	rep(i, 0, sz(x))

	{

		string y = "";

		rep(j, i, sz(x))

		{

			y += x[j];

			if (sz(y) > k)

				break;

			mp[y] = 1;

		}

	}



	for(auto i : mp)

	{

		k--;

		if (!k)

		{

			cout << i.first;

			break;

		}

	}



	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int k,L,l;

string S,s[100005];

int main()

{

	cin>>S>>k; 

	L=S.size();

	for(int i=1;i<=5;i++)

	  for(int j=0;j<=L-i;j++)

		s[l++]=S.substr(j,i);

	sort(s,s+l);

	l=unique(s,s+l)-s;

	cout<<s[k-1];

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.244083236458849x):
#include <bits/stdc++.h>



#define ll long long



using namespace std;



string s;



int main() {



	ios_base::sync_with_stdio(0);

	cin.tie(0);

	int k;

	cin >> s >> k;

	set<string> sett;

	for (int i = 0; i < s.size(); i++) {

		string temp = "";

		for (int j = i; j < s.size(); j++) {

			temp += s[j];



			sett.insert(temp);

			auto it = sett.find(*sett.rbegin());

			

			if (sett.size() > k)

				sett.erase(it);



			if (temp.size() > k)

				break;

		}

	}



	cout << *sett.rbegin() << endl;



	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int k,L,l;

string S,s[100005];

int main()

{

	cin>>S>>k; 

	L=S.size();

	for(int i=1;i<=5;i++)

	  for(int j=0;j<=L-i;j++)

		s[l++]=S.substr(j,i);

	sort(s,s+l);

	l=unique(s,s+l)-s;

	cout<<s[k-1];

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.235915928115121x):
#include<bits/stdc++.h>

using namespace std;

void FastInputOutput()

{

    ios_base :: sync_with_stdio( 0 ) ;

    cin.tie( 0 ) ;

    cout.tie( 0 ) ;

}

set < string > subStrings(string s, int n)

{

    set < string > st ;

	for (int i = 0; i < n; i++){

            string tp = "";

		for (int j = i ; j < n && j <= i + 5 ; ++j){

            tp += s[j] ;

			st.insert(tp);

	}

	}

        return st ;

}

int main()

{

    FastInputOutput() ;

	string s ;

	cin >> s ;

	int k ;

	cin >> k ;

	set < string > Sub = subStrings(s , s.size());

	set < string > :: iterator it = Sub.begin();

	int out = 1 ;

	for( ; it != Sub.end() ; ++it){

        if(out == k ){

           cout << *it << endl ;

           break ;

        }

        out++ ;

        }



	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<string>

#include<algorithm>

using namespace std;

int k,L,l;

string S,s[100005];

int main()

{

	cin>>S>>k; 

	L=S.size();

	for(int i=1;i<=5;i++)

	  for(int j=0;j<=L-i;j++)

		s[l++]=S.substr(j,i);

	sort(s,s+l);

	l=unique(s,s+l)-s;

	cout<<s[k-1];

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.2949402804694445x):
#include <bits/stdc++.h>

using namespace std;

const int maxn = 3e5+7;

string s;

int k;

set<string> ans;

int main()

{

    cin >> s >> k;

    int len = s.length();

    for(int i = 0; i < len; ++i) {

        for(int j = 1; j <= 5; ++j) {

            if(i+j-1 >= len) continue;

            ans.insert(s.substr(i, j));

        }

    }

    set<string>::iterator iter = ans.begin();

    int i = 1;

    for(; i != k; ++iter, ++i);

    cout << *iter << endl;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string a[30000];

bool my_cmp(string a,string b)

{

    return a<b;

}

int main()

{

    string s;

    int n,l,count=0,i,j;

    cin>>s;

    l=s.length();

    scanf("%d",&n);

    for(i=1;i<=5;i++)

    {

        for(j=0;j<l;j++)

        {

            a[count++]=s.substr(j,i);

        }

    }

    sort(a,a+count,my_cmp);

    unique(a,a+count);

    cout<<a[n-1]<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 2.0015495133557195x):
#include <bits/stdc++.h>

using namespace std;

set<string> s1;

set<string>::iterator it;

string s_kth,minstr,tmp;

char sz[5001];

void broken(string str_c)

{

	int i,j,k;

	k=str_c.length();

	for(i=1;i<=k;i++)

	{

		for(j=0;j<k-i+1;j++)

		{

			tmp=str_c.substr(j,i);

			s1.insert(tmp);

		}

	}

	return;

}

int main()

{

	int i,l,k;

	scanf("%s",sz);

	s_kth=sz;

	l=s_kth.length();

	scanf("%d",&k);

	minstr=s_kth;

	if(k>l)

	{

		broken(s_kth);

	}

	else

	{

		for(i=0;i<l-k;i++)

		{

			tmp=s_kth.substr(i,k);

			if(tmp<minstr)

			{

				broken(tmp);

				minstr=tmp;

			}

		}

		tmp=s_kth.substr(l-k,k);

		broken(tmp);

	}

	it=s1.begin();

	for(i=0;i<k-1;i++)

	{

		it++;

	}

	printf("%s",(*it).c_str());

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

string a[30000];

bool my_cmp(string a,string b)

{

	return a<b;

}

int main()

{

	string s;

    	int n,l,count=0,i,j;

    	cin>>s;

    	l=s.length();

    	scanf("%d",&n);

    	for(i=1;i<=min(n,l);i++)

    	{

    		for(j=0;j<l-i+1;j++)

    		{

    			a[count++]=s.substr(j,i);

    		}

    	}

    	sort(a,a+count,my_cmp);

    	unique(a,a+count);

    	cout<<a[n-1]<<endl;

    	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.9972113211808937x):
#include <bits/stdc++.h>

using namespace std;

set<string> s1;

set<string>::iterator it;

string s_kth,minstr,tmp;

char sz[5001];

void broken(string str_c)

{

	int i,j,k;

	k=str_c.length();

	for(i=1;i<=k;i++)

	{

		for(j=0;j<k-i+1;j++)

		{

			tmp=str_c.substr(j,i);

			s1.insert(tmp);

		}

	}

	return;

}

int main()

{

	int i,l,k;

	scanf("%s",sz);

	s_kth=sz;

	l=s_kth.length();

	scanf("%d",&k);

	minstr=s_kth;

	if(k>l)

	{

		broken(s_kth);

	}

	else

	{

		for(i=0;i<l-k;i++)

		{

			tmp=s_kth.substr(i,k);

			if(tmp<minstr)

			{

				broken(tmp);

				minstr=tmp;

			}

		}

		tmp=s_kth.substr(l-k,k);

		broken(tmp);

	}

	it=s1.begin();

	for(i=0;i<k-1;i++)

	{

		it++;

	}

	printf("%s",(*it).c_str());

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int maxn=5005;

string ch[maxn*6];

char s[maxn];

int n,k,cnt;

int main()

{

    scanf("%s%d",s,&k),n=strlen(s);

    for(int i=0,T;i<n;i++)

    {

        ch[++cnt]=s[i];T=min(k,n-i);

        for(int j=1;j<T;j++,cnt++) ch[cnt+1]=ch[cnt]+s[i+j];

    }

    sort(ch+1,ch+cnt+1);unique(ch+1,ch+cnt+1);

    cout<<ch[k]<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.9481976547770607x):
/**************/

/* Author : Mahmoud Tarek

/*************/



#include <bits/stdc++.h>

#define dbg(v) cerr << #v << " = " << v ;



using namespace std ;



int main(){

  string st ;

  int k ;

  cin >> st >> k ;

  set < deque < char > > in ;

  deque < char > ck ;

  for( int i = 1 ; i <= min( (int)st.size() , 100 ) ; i++ ){

     ck.clear() ;

     for( int j = 0 ; j < i ; j++ ){

        ck.push_back( st[ j ] ) ;

     }

     int j = i ;

     if( j <= st.size() ){

         while( j <= st.size() ){

            in.insert( ck ) ;

            ck.pop_front() ;

            ck.push_back( st[ j ] ) ;

            j++;/*

            for( auto c : ck ){

                cout << c << " " ;

            }

            cout << "\n" ;*/

         }

     } else in.insert( ck ) ;

  }



  int j = 1 ;

  for( auto i : in ){

        if( j == k ){

        for( auto c : i ){

            cout << c ;

        }

        cout << "\n" ;

        return 0 ;

        }

        j++ ;

  }



}
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int maxn=5005;

string ch[maxn*6];

char s[maxn];

int n,k,cnt;

int main()

{

    scanf("%s%d",s,&k),n=strlen(s);

    for(int i=0,T;i<n;i++)

    {

        ch[++cnt]=s[i];T=min(k,n-i);

        for(int j=1;j<T;j++,cnt++) ch[cnt+1]=ch[cnt]+s[i+j];

    }

    sort(ch+1,ch+cnt+1);unique(ch+1,ch+cnt+1);

    cout<<ch[k]<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.965768453826712x):
#include <bits/stdc++.h>

using namespace std;

const long long N = 1e6;

int d()

{

    int ret;

    scanf("%d", &ret);

    return ret;

}

long long lld()

{

    long long ret;

    scanf("%lld", &ret);

    return ret;

}

int main()

{

    int k;

    string s;

    cin>>s>>k;

    set<string>se;

    for(int i=0; i<s.length(); i++)

    {

        string s1="";

        for(int j=i; j< i + 5 && j < s.size(); j++)

        {

            s1+=s[j];

            se.insert(s1);

        }

    }

    int i=1;

    for(auto v:se)

    {

        if(i==k)

        {

            cout<<v<<endl;

        }

        i++;

    }

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int maxn=5005;

string ch[maxn*6];

char s[maxn];

int n,k,cnt;

int main()

{

    scanf("%s%d",s,&k),n=strlen(s);

    for(int i=0,T;i<n;i++)

    {

        ch[++cnt]=s[i];T=min(k,n-i);

        for(int j=1;j<T;j++,cnt++) ch[cnt+1]=ch[cnt]+s[i+j];

    }

    sort(ch+1,ch+cnt+1);unique(ch+1,ch+cnt+1);

    cout<<ch[k]<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.9808602329914806x):
#include <iostream>

#include <string>

#include <set>

using namespace std;





int main () {

    string str;

  	int m;

    cin >> str;

    cin >> m;

  	int n = str.length();

  	set <string> st;

    for (int i = 0; i < n; i++)

        for (int j = 1; i + j <= n && j <= 5; j++)

            st.insert(str.substr(i, j));

    auto itr = st.begin();

    cout << *next(itr, m-1) << endl;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define ll long long

using namespace std;

const int maxn=5005;

string ch[maxn*6];

char s[maxn];

int n,k,cnt;

int main()

{

    scanf("%s%d",s,&k),n=strlen(s);

    for(int i=0,T;i<n;i++)

    {

        ch[++cnt]=s[i];T=min(k,n-i);

        for(int j=1;j<T;j++,cnt++) ch[cnt+1]=ch[cnt]+s[i+j];

    }

    sort(ch+1,ch+cnt+1);unique(ch+1,ch+cnt+1);

    cout<<ch[k]<<endl;

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.9595693737393196x):
#include<bits/stdc++.h>

using namespace std;

#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

string s,p;

set<string>v;

int main()

{

    ft

    int t,i,j,n,m,x=0,k;

    cin>>s>>k;

    n=s.size();

    for(i=0; i<n; i++)

    {

        p.clear();

        m=min(i+k,n);

        for(j=i; j<m; j++)

        {

            p+=s[j];

            v.insert(p);

        }

    }

    for(auto cc:v)

    {

        x++;

        if(x==k)

        {

            cout<<cc<<"\n";

            break;

        }

    }

    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int main(){

    string s, temp;

    int K;

    cin >> s >> K;

    vector<string> sub(10000);

    

    for(int i=0; i<s.size(); i++){

        for(int j=1; j<=K; j++){

            temp = s.substr(i,j);

            sub.push_back(temp);

        }

    }

    sort(sub.begin(), sub.end());

    sub.erase(unique(sub.begin(),sub.end()),sub.end());



    cout << sub.at(K) << endl;

}

// Faster C++ solution for the same problem (measured speedup: 2.422649831759836x):
#include "bits/stdc++.h"

using namespace std;



int main() {

	int K, i=1;

	string s;

	set<string> S;



	cin >> s >> K;



	for (int i = 0; i < s.size(); i++) {

		for (int j = 1; j <= K; j++) {

			S.insert(s.substr(i, j));

		}

	}



	for (set<string>::iterator it = S.begin(); it != S.end(); it++) {

		if(i == K)

			cout << (*it) << " ";

		i++;

	}

	cout << endl;



	return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <iostream>

using namespace std;

const int mx = 5500;

string str;

string num[mx*5];

bool cmp(string a,string b)

{

    int len=min(a.length(),b.length());

    for(int i=0;i<len;i++){

        if(a[i]!=b[i])

            a[i]<b[i];

    }

    if(a.length()<b.length())

        return a<b;

    else

        return a>b;

}

int main()

{

    int k;

    while(cin>>str){

        cin>>k;

        int len=str.length();

//        char sign='z';

//        for(int i=0;i<len;i++)

//            if(str[i]<sign)

//                sign=str[i];

        int cont=0;

        for(int i=0;i<len;i++){

            string s="";

            s=s+str[i];

            num[cont++]=s;

            for(int j=1;j<=4;j++){

                if(i+j<len){

                    s=s+str[i+j];

                    num[cont++]=s;

                }

            }

        }

//        cout<<cont<<endl;

        sort(num,num+cont);

//        for(int i=0;i<cont;i++)

//            cout<<num[i]<<endl;

        int tmp=unique(num,num+cont)-num;

//        for(int i=0;i<cont;i++)

//            cout<<"       "<<num[i]<<endl;

        cout<<num[k-1]<<endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.9037378622472774x):
#include<iostream>

#include<cstdio>

#include<string.h>

#include<algorithm>

using namespace std;



int main()

{

    string str;

    cin>>str;

    int k; cin>>k;

    int len=str.length();

    string a="";

    string b="";

    string c="";

    string d="";

    string e="";

    for (int i=0; i<len; i++)

    {

        string tmp="";

        for (int j=i; j<len; j++)

        {

            string tt=str.substr(j,1);

            tmp+=tt;

            //cout<<"tmp="<<tmp<<endl;

            //cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;

            if (tmp==a || tmp==b || tmp==c || tmp==d ||tmp==e) continue;

            if (tmp<a || a=="")

            {

                e=d; d=c;c=b;b=a; a=tmp;

                //cout<<"1"<<endl;

            }else if (tmp<b || b=="")

            {

                e=d; d=c; c=b;b=tmp;

                //cout<<"2"<<endl;

            }else if (tmp<c || c=="")

            {

                e=d;d=c;c=tmp;

                //cout<<"3"<<endl;

            }else if (tmp<d || d=="")

            {

                e=d;d=tmp;

                //cout<<"4"<<endl;

            }else if (tmp<e || e=="")

            {

                e=tmp;

                //cout<<"5"<<endl;

            }

        }

    }

    //cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;

    if (k==1) cout<<a<<endl;

    else if (k==2) cout<<b<<endl;

    else if (k==3) cout<<c<<endl;

    else if (k==4) cout<<d<<endl;

    else if (k==5) cout<<e<<endl;

    return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <iostream>

using namespace std;

const int mx = 5500;

string str;

string num[mx*5];

bool cmp(string a,string b)

{

    int len=min(a.length(),b.length());

    for(int i=0;i<len;i++){

        if(a[i]!=b[i])

            a[i]<b[i];

    }

    if(a.length()<b.length())

        return a<b;

    else

        return a>b;

}

int main()

{

    int k;

    while(cin>>str){

        cin>>k;

        int len=str.length();

//        char sign='z';

//        for(int i=0;i<len;i++)

//            if(str[i]<sign)

//                sign=str[i];

        int cont=0;

        for(int i=0;i<len;i++){

            string s="";

            s=s+str[i];

            num[cont++]=s;

            for(int j=1;j<=4;j++){

                if(i+j<len){

                    s=s+str[i+j];

                    num[cont++]=s;

                }

            }

        }

//        cout<<cont<<endl;

        sort(num,num+cont);

//        for(int i=0;i<cont;i++)

//            cout<<num[i]<<endl;

        int tmp=unique(num,num+cont)-num;

//        for(int i=0;i<cont;i++)

//            cout<<"       "<<num[i]<<endl;

        cout<<num[k-1]<<endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.8621491041519753x):
#include <bits/stdc++.h>

using namespace std ;

#define ll long long

void FastInputOutput(){

    ios_base :: sync_with_stdio( 0 ) ;

    cin.tie( 0 ) ;

    cout.tie( 0 ) ;

}



inline int D(){

    int t ;

    scanf( "%d" , &t ) ;

    return t ;

}

inline ll LLD(){

    ll t ;

    scanf( "%lld" , &t ) ;

    return t ;

}

inline ll power(ll x, ll p, ll m){

    ll res = 1;

    while(p){

        if(p & 1)

            res = ((res % m) * (x % m)) % m;

        x = ((x % m) * (x % m)) % m;

        p >>= 1;

    }

    return res % m;

}

long double ModLog(long double base, long double x) {

    return (logl(x) / logl(base));

}

int gcd (int a, int b) {

    while (b) {

        a %= b;

        swap(a, b);

    }

    return a;

}

int lcm(int a, int b){

    return a / gcd(a, b) * b;

}

const ll P = 1e9 + 9;

const int N = 15 * 1e6 + 1, NN = 4e3 + 5;

int ans, n;

bool vst[NN];

int p[NN], idx;

void seive(){

    for(int i = 2; i < NN; ++i){

        if(vst[i])

            continue;

        p[idx++] = i;

        for(int j = i * i; j < NN; j += i)

            vst[j] = 1;

        

    }

}

inline int getInt(){

    char c;

    int ret = 0;

    while (isdigit(c = getchar())) {

        if(c == '\n')

            break;

        ret = (ret << 3) + ret + ret;

        ret += (c - '0');

    }

    return ret;

}

int main(){

    FastInputOutput();

    string s;

    cin >> s;

    set<string> st;

    int k;

    cin >> k;

    for(int i = 0; i < s.size(); ++i){

        string t;

        for(int j = i; j < s.size() && j <= i + 5; ++j){

            t.push_back(s[j]);

            st.insert(t);

        }

    }

    

    --k;

    vector<string> v(st.begin(), st.end());

    cout << v[k] << endl;

}
// Slower C++ solution:
#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <iostream>

using namespace std;

const int mx = 5500;

string str;

string num[mx*5];

bool cmp(string a,string b)

{

    int len=min(a.length(),b.length());

    for(int i=0;i<len;i++){

        if(a[i]!=b[i])

            a[i]<b[i];

    }

    if(a.length()<b.length())

        return a<b;

    else

        return a>b;

}

int main()

{

    int k;

    while(cin>>str){

        cin>>k;

        int len=str.length();

//        char sign='z';

//        for(int i=0;i<len;i++)

//            if(str[i]<sign)

//                sign=str[i];

        int cont=0;

        for(int i=0;i<len;i++){

            string s="";

            s=s+str[i];

            num[cont++]=s;

            for(int j=1;j<=4;j++){

                if(i+j<len){

                    s=s+str[i+j];

                    num[cont++]=s;

                }

            }

        }

//        cout<<cont<<endl;

        sort(num,num+cont);

//        for(int i=0;i<cont;i++)

//            cout<<num[i]<<endl;

        int tmp=unique(num,num+cont)-num;

//        for(int i=0;i<cont;i++)

//            cout<<"       "<<num[i]<<endl;

        cout<<num[k-1]<<endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.8928098405669394x):
# include <iostream>

# include <algorithm>

# include <vector>

# include <map>

using namespace std;



string s;

int K;

map<string, bool> visited;

vector<string> vstring;



int main()

{

    cin>>s;

    cin>>K;



    for (int i=0; i<s.size(); i++)

    {

        for (int j=1; j<=min((int)s.size()-i, K); j++)

        {

            if (!visited[s.substr(i,j)])

            {

                vstring.push_back(s.substr(i,j));

                visited[s.substr(i,j)]=true;

            }

        }

    }



    sort(vstring.begin(), vstring.end());



    cout<<vstring[K-1]<<endl;

}