Language: C++

// Gear4        
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;
using ld = long double;
using ll = long long;
#define endl '\n'
const int inf = 1e9, mod = 1e9 + 7;
const ll INF = 9e18;
const ld EPS = 1e-9, PI = acosl(-1.0);
string s; int k;
int main() {
    SYNC
    cin >> s >> k;
    set<string> st;
    FOR(len, 1, min(7, (int)s.length() + 1)) {
        FOR0(i, (int)s.length()-len+1) {
            st.insert(s.substr(i, len));
            
        }
    }

    k--;
    while(k--) {
        st.erase(st.begin());
    }
    cout << *(st.begin());
}
// Gear4        
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
template<typename T> using V = vector<T>;
template<typename T, typename U> using P = pair<T,U>;
using ld = long double;
using ll = long long;
#define endl '\n'
const int inf = 1e9, mod = 1e9 + 7;
const ll INF = 9e18;
const ld EPS = 1e-9, PI = acosl(-1.0);
string s; int k;
int main() {
    SYNC
    cin >> s >> k;
    set<string> st;
    FOR(len, 1, min(7, (int)s.length() + 1)) {
        FOR0(i, (int)s.length()-len+1) {
            st.insert(s.substr(i, len));
            
        }
    }

    k--;
    while(k--) {
        st.erase(st.begin());
    }
    cout << *(st.begin());
}


Compiler output:
a.cc:62:11: error: redefinition of 'const int inf'
   62 | const int inf = 1e9, mod = 1e9 + 7;
      |           ^~~
a.cc:21:11: note: 'const int inf' previously defined here
   21 | const int inf = 1e9, mod = 1e9 + 7;
      |           ^~~
a.cc:62:22: error: redefinition of 'const int mod'
   62 | const int inf = 1e9, mod = 1e9 + 7;
      |                      ^~~
a.cc:21:22: note: 'const int mod' previously defined here
   21 | const int inf = 1e9, mod = 1e9 + 7;
      |                      ^~~
a.cc:63:10: error: redefinition of 'const ll INF'
   63 | const ll INF = 9e18;
      |          ^~~
a.cc:22:10: note: 'const ll INF' previously defined here
   22 | const ll INF = 9e18;
      |          ^~~
a.cc:64:10: error: redefinition of 'const ld EPS'
   64 | const ld EPS = 1e-9, PI = acosl(-1.0);
      |          ^~~
a.cc:23:10: note: 'const ld EPS' previously defined here
   23 | const ld EPS = 1e-9, PI = acosl(-1.0);
      |          ^~~
a.cc:64:22: error: redefinition of 'const ld PI'
   64 | const ld EPS = 1e-9, PI = acosl(-1.0);
      |                      ^~
a.cc:23:22: note: 'const ld PI' previously defined here
   23 | const ld EPS = 1e-9, PI = acosl(-1.0);
      |                      ^~
a.cc:65:8: error: redefinition of 'std::string s'
   65 | string s; int k;
      |        ^
a.cc:24:8: note: 'std::string s' previously declared here
   24 | string s; int k;
      |        ^
a.cc:65:15: error: redefinition of 'int k'
   65 | string s; int k;
      |               ^
a.cc:24:15: note: 'int k' previously declared here
   24 | string s; int k;
      |               ^
a.cc:66:5: error: redefinition of 'int main()'
   66 | int main() {
      |     ^~~~
a.cc:25:5: note: 'int main()' previously defined here
   25 | int main() {
      |     ^~~~