Language: C++

//#include <bits/stdc++.h>

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  string s;
  int k;
  cin >> s >> k;
  set<char> ana;
  for(const char& c : s) ana.insert(c);

  vector<string> subset;
  for(const char c : ana)
  {
    for(int i = 0; i < s.length(); ++i)
    {
      if (s[i] == c)
      {
        for(int j = 1; i + j <= min((int)s.length(), i + k); ++j)
        {
          subset.emplace_back(s.substr(i, j));
        }
      }
    }
    if (subset.size() >= k)
    {
      sort(subset.begin(), subset.end());
      subset.erase( unique(subset.begin(), subset.end()), subset.end() );

      if (subset.size() >= k)
      {
        cout << subset[k - 1];
        return;
      }
    }
  }



}

int main()
{
  fastio;
  solve();

  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:14:3: error: 'string' was not declared in this scope
   14 |   string s;
      |   ^~~~~~
a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>'
  +++ |+#include <string>
    1 | //#include <bits/stdc++.h>
a.cc:16:3: error: 'cin' was not declared in this scope
   16 |   cin >> s >> k;
      |   ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
  +++ |+#include <iostream>
    1 | //#include <bits/stdc++.h>
a.cc:16:10: error: 's' was not declared in this scope
   16 |   cin >> s >> k;
      |          ^
a.cc:17:3: error: 'set' was not declared in this scope
   17 |   set<char> ana;
      |   ^~~
a.cc:1:1: note: 'std::set' is defined in header '<set>'; this is probably fixable by adding '#include <set>'
  +++ |+#include <set>
    1 | //#include <bits/stdc++.h>
a.cc:17:7: error: expected primary-expression before 'char'
   17 |   set<char> ana;
      |       ^~~~
a.cc:18:26: error: 'ana' was not declared in this scope
   18 |   for(const char& c : s) ana.insert(c);
      |                          ^~~
a.cc:20:3: error: 'vector' was not declared in this scope
   20 |   vector<string> subset;
      |   ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
  +++ |+#include <vector>
    1 | //#include <bits/stdc++.h>
a.cc:20:18: error: 'subset' was not declared in this scope
   20 |   vector<string> subset;
      |                  ^~~~~~
a.cc:21:22: error: 'ana' was not declared in this scope
   21 |   for(const char c : ana)
      |                      ^~~
a.cc:27:33: error: 'min' was not declared in this scope
   27 |         for(int j = 1; i + j <= min((int)s.length(), i + k); ++j)
      |                                 ^~~
a.cc:35:7: error: 'sort' was not declared in this scope; did you mean 'short'?
   35 |       sort(subset.begin(), subset.end());
      |       ^~~~
      |       short
a.cc:36:21: error: 'unique' was not declared in this scope
   36 |       subset.erase( unique(subset.begin(), subset.end()), subset.end() );
      |                     ^~~~~~
a.cc:40:9: error: 'cout' was not declared in this scope
   40 |         cout << subset[k - 1];
      |         ^~~~
a.cc:40:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc: In function 'int main()':
a.cc:3:16: error: 'ios_base' has not been declared
    3 | #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
      |                ^~~~~~~~
a.cc:52:3: note: in expansion of macro 'fastio'
   52 |   fastio;
      |   ^~~~~~
a.cc:3:49: error: 'cin' was not declared in this scope
    3 | #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
      |                                                 ^~~
a.cc:52:3: note: in expansion of macro 'fastio'
   52 |   fastio;
      |   ^~~~~~
a.cc:3:49: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
      |                                                 ^~~
a.cc:52:3: note: in expansion of macro 'fastio'
   52 |   fastio;
      |   ^~~~~~
a.cc:3:57: error: 'NULL' was not declared in this scope
    3 | #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
      |                                                         ^~~~
a.cc:52:3: note: in expansion of macro 'fastio'
   52 |   fastio;
      |   ^~~~~~
a.cc:1:1: note: 'NULL' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | //#include <bits/stdc++.h>
a.cc:3:63: error: 'cout' was not declared in this scope
    3 | #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
      |                                                               ^~~~
a.cc:52:3: note: in expansion of macro 'fastio'
   52 |   fastio;
      |   ^~~~~~
a.cc:3:63: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    3 | #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
      |                                                               ^~~~
a.cc:52:3: note: in expansion of macro 'fastio'
   52 |   fastio;
      |   ^~~~~~