stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef signed long long ll;



#undef _P

#define _P(...) (void)printf(__VA_ARGS__)

#define FOR(x,to) for(x=0;x<(to);x++)

#define FORR(x,arr) for(auto& x:arr)

#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)

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

#define ZERO(a) memset(a,0,sizeof(a))

#define MINUS(a) memset(a,0xff,sizeof(a))

//-------------------------------------------------------



int N,M;

int A[101010],B[101010];

vector<pair<int,int>> E[101010];

int did[101010];



int dfs(int cur,int tar) {

	if(cur==tar) return 1;

	

	FORR(r,E[cur]) if(did[r.second]==0) {

		did[r.second]=1;

		return dfs(r.first,tar);

	}

	return 0;

}



void solve() {

	int i,j,k,l,r,x,y; string s;

	

	cin>>N>>M;

	FOR(i,M) {

		cin>>A[i]>>B[i];

		A[i]--;

		B[i]--;

		

		E[A[i]].push_back({B[i],i});

		E[B[i]].push_back({A[i],i});

	}

	

	FOR(i,M) if(did[i]==0) {

		did[i]=1;

		if(dfs(A[i],B[i])==0) return _P("NO\n");

	}

	_P("YES\n");

}





int main(int argc,char** argv){

	string s;int i;

	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);

	FOR(i,argc-1) s+=argv[i+1],s+='\n';

	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);

	solve(); return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef signed long long ll;



#undef _P

#define _P(...) (void)printf(__VA_ARGS__)

#define FOR(x,to) for(x=0;x<(to);x++)

#define FORR(x,arr) for(auto& x:arr)

#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)

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

#define ZERO(a) memset(a,0,sizeof(a))

#define MINUS(a) memset(a,0xff,sizeof(a))

//-------------------------------------------------------



int N,M;



int num[101010];



void solve() {

	int i,j,k,l,r,x,y; string s;

	

	cin>>N>>M;

	FOR(i,M) {

		cin>>x>>y;

		num[x-1]^=1;

		num[y-1]^=1;

	}

	FOR(i,N) if(num[i]) return _P("NO\n");

	_P("YES\n");

}





int main(int argc,char** argv){

	string s;int i;

	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);

	FOR(i,argc-1) s+=argv[i+1],s+='\n';

	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);

	solve(); return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstring>

using namespace std;

int pd[100010],arr[100010];

int main()

{

    int n,m,i,ans=0,T=1;

    memset(pd,0,sizeof(pd));

    cin>>n>>m;

    

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

    {

        int x,y;

        cin>>x>>y;

        pd[x]++;

        pd[y]++;

    }

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

    {

        if(pd[i]%2==1){

            T=0;

            break;

        }

    }

    //if(m%2==0) T=1;

    if(T==1) cout<<"YES"<<endl;

    else cout<<"NO"<<endl;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h> //Ithea Myse Valgulious

namespace chtholly{

typedef long long ll;

#define re0 register int

#define rec register char

#define rel register ll

#define gc getchar

#define pc putchar

#define p32 pc(' ')

#define pl puts("")

/*By Citrus*/

inline int read(){

  int x=0,f=1;char c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return f?x:-x;

  }

template <typename mitsuha>

inline bool read(mitsuha &x){

  x=0;int f=1;char c=gc();

  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';

  if (!~c) return 0;

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return x=f?x:-x,1;

  }

template <typename mitsuha>

inline int write(mitsuha x){

  if (!x) return 0&pc(48);

  if (x<0) x=-x,pc('-');

  int bit[20],i,p=0;

  for (;x;x/=10) bit[++p]=x%10;

  for (i=p;i;--i) pc(bit[i]+48);

  return 0;

  }

inline char fuhao(){

  char c=gc();

  for (;isspace(c);c=gc());

  return c;

  }

}using namespace chtholly;

using namespace std;

const int yuzu=1e5;

typedef int fuko[yuzu|10];

fuko cnt;

int main(){

int n=read(),m=read(),i;

for (;m--;) cnt[read()]++,cnt[read()]++;

for (i=1;i<=n;++i) if (cnt[i]&1) return puts("NO"),0;

puts("YES");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



const int N = 1e5 + 10;



int cnt[N];



int main(){

	int n, m, u, v;

	scanf("%d %d",&n,&m);

	memset(cnt, 0, sizeof(cnt));

	for (int i = 1; i <= m; i++){

		scanf("%d %d",&u,&v);

		cnt[u]++; cnt[v]++;

	}

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

		if (cnt[i] & 1){

			printf("NO\n");

			return 0;

		}

	}

	printf("YES\n");

	return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <fstream>

#include <sstream>

#include <iomanip>

#include <algorithm>

#include <numeric>

#include <vector>

#include <string>

#include <set>

#include <map>

#include <queue>

#include <stack>

#include <climits>

#include <cmath>

#include <cstring>

#include <unordered_set>

#include <unordered_map>

using namespace std;



#define pb push_back

#define fst first

#define snd second



typedef long long ll;

typedef pair<int,int> pii;

template<typename T> using min_queue=priority_queue<T,vector<T>,greater<T>>;



const ll MOD=1e9+7;



int N,M;

int d[100100];



int main(){

  ios::sync_with_stdio(0);cin.tie(0);



  cin>>N>>M;



  int a,b;

  while (M --> 0) cin>>a>>b, d[a]++,d[b]++;



  bool good=1;

  for (int i=1;i<=N;i++) if (d[i]&1) {

      good=0;break;

    }



  cout << (good ? "YES\n" : "NO\n");



  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstring>

using namespace std;

int main() {

	int n, m, x, y;

	bool flag = true;

	int sw[100000];

	memset(sw, 0, sizeof(sw));

	cin >> n >> m;

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

		cin >> x >> y;

		sw[x] += 1;

		sw[y] += 1;

	}

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

		if (sw[i] % 2 == 1) {

			flag = false;

			break;

		}

	}

	if (flag == true) {

		cout << "YES" << endl;

	}

	else {

		cout << "NO" << endl;

	}

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

#define HANI (1000001)

int n,m;

int x[HANI];

int main(){

    cin>>n>>m;

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

        int a,b;

        cin>>a>>b;

        x[a]++;

        x[b]++;

    }

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

        if(x[i]%2!=0){

            cout<<"NO"<<endl;

            return 0;

        }

    }

    cout<<"YES"<<endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

using namespace std;



int main() {

	string s;

	int K;

	cin >> s >> K;

	string line[25005];

	int k = 0;

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

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

			if (i + j <= s.length()) {

				line[k] = s.substr(i, j);

				k++;

			} else {

				break;

			}

		}

	}



	sort(line, line + k);

	s = line[0];

	int num = 1;

	if (K != 1) {

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

		if (line[i] != s) {

			s = line[i];

			num++;

			if (num == K)

				break;	

		}

	}

	}

	

	cout << s << endl;

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

const int MAXL = 1e4 + 10;

using namespace std;

char str[MAXL];

char substr[5 * MAXL][10];

int id[5 * MAXL];

int m;

bool cmp(int a, int b) {

	return strcmp(substr[a], substr[b]) < 0;

}

int main() {

	while (scanf("%s", str) != EOF) {

		int L = strlen(str);

		scanf("%d", &m);

		int cnt = 0;

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

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

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

					substr[cnt][k] = str[i + k];

				}

				substr[cnt++][j + 1] = 0;

			}

		}



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

			id[i] = i;

		}



		sort(id, id + cnt, cmp);



		int t = 0;

		while (m  > 1 && t < cnt) {

			while (t + 1 < cnt && strcmp(substr[id[t]], substr[id[t + 1]]) == 0)

				t++;

			m--;

			t++;

		}

		printf("%s\n", substr[id[t]]);

	}

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<double,int> pdi;

const int N = 50005;

string str[N];

int main()

{

    string a;

    cin >> a;

    int k, cnt = 0;

    scanf("%d",&k);

    int siz = a.size();

    int mini;

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

    {

        str[++cnt] = a[i];

        mini =min(k,siz-i);

        for(int j = 1 + i; j < mini + i; j ++,cnt++)

            str[cnt + 1] = str[cnt] + a[j];

    }

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

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

    cout<< str[k] <<endl;

    return 0;

}
















// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<cmath>

#include<algorithm>

#include<queue>

#include<stack>

#include<vector>

#include<set>

#include<map>

#include<iostream>

using namespace std;

int k,tol=0,cnt=0;

char ch;

string s,p[30000],ans,note[5001];

int main(){

	while(1){

		scanf("%c",&ch);

		if(ch=='\n') break;

		tol++;

		for(int i=1;i<=tol;i++){

			if(tol-i+1<=5){

			    note[i]+=ch;

			    p[++cnt]=note[i];

			}

		}

	}scanf("%d",&k);

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

	cout<<p[k];

	return 0;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}

// Optimized solution to the same problem (faster):
#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;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#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;

}


// Optimized solution to the same problem (faster):
#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;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

#include<algorithm>

#include<cstring>

using namespace std;

int k,l,cnt;

char s[5005];

string ch[5005*6];

int main(){

	scanf("%s%d",s,&k);

	l=strlen(s);

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

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

		T=min(k,l-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];

}

// Optimized solution to the same problem (faster):
#include<set>

#include<cstdio>

#include<cstring>

using namespace std;

struct str{

	char a[5];

	bool operator < (const str &p) const

	{

		int i;

		for (i=0;i<5 && a[i]==p.a[i];i++) ;

		return a[i]<p.a[i];

	}

}p;

set <str> que;

char s[5001];

int main()

{

	set <str> :: iterator it;

	int l,k;

	bool b=false;

	scanf("%s",s);

	scanf("%d",&k);

 	l=strlen(s);

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

 	{

 		for (int j=0;j<k;j++) p.a[j]='\0';

 		for (int j=0;j<k && i+j<l;j++)

 		{

 			p.a[j]=s[i+j];

 			if (!que.count(p)) 

			{

				que.insert(p);

				it=que.end();

				if (b) que.erase(*(--it));

 				else if (que.size()>=k) b=true;

			}

 		}

 	}

	 it=que.end();

	printf("%s",(*(--it)).a);

	return 0;

}

// Fastest known solution for this problem: