Language: C++

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000

ll gcm(ll a,ll b);

int main(){
  string s;
  int N;
  cin >> s >> N;
  int k = s.length();
  vstring A(k);
  rep(i,k){
    A[i] = s.substr(i,(k-i));
  }
  sort(A.begin(),A.end());
  rep(i,k) cout << A[i] << endl;
  vstring ans(10000000);
  int judge = 0;
  int last = 0;
  bool ans = false;
  rep(i,k){
    rep(j,A[i].length()){
      bool ok = false;
      if(i == 0){
        ans[judge] = A[i].substr(0,(j+1));
        judge++;
        last++;
      }
      else{
        if(last < (j+1)){
          ans[judge] = A[i].substr(0,(j+1));
          judge++;
          last = j + 1;
        }
        else if(A[i-1][j] != A[i][j]){
          //cout << "i" << i << "j" << j << endl;
          ok = true;
          for(int t = j;t<A[i].length();t++){
            //cout << "t" << t << endl;
            //cout << judge << endl;
            ans[judge] = A[i].substr(0,(t+1));
            judge++;
          }
          if(ok){
            last = A[i].length();
            break;
          }
        }
      }
      if(judge > 5){
        ans = true;
        break;
      }
      //cout <<"last" <<  last << endl;
      //cout <<"judge"<< judge << endl;
    }
    if(ans) break;
  }
  cout << ans[N-1] << endl;
}






Compiler output:
a.cc: In function 'int main()':
a.cc:30:8: error: conflicting declaration 'bool ans'
   30 |   bool ans = false;
      |        ^~~
a.cc:27:11: note: previous declaration as 'std::vector<std::__cxx11::basic_string<char> > ans'
   27 |   vstring ans(10000000);
      |           ^~~
a.cc:61:15: error: no match for 'operator=' (operand types are 'std::vector<std::__cxx11::basic_string<char> >' and 'bool')
   61 |         ans = true;
      |               ^~~~
In file included from /usr/include/c++/14/vector:72,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]'
  210 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note:   no known conversion for argument 1 from 'bool' to 'const std::vector<std::__cxx11::basic_string<char> >&'
  211 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note:   no known conversion for argument 1 from 'bool' to 'std::vector<std::__cxx11::basic_string<char> >&&'
  766 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]'
  788 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note:   no known conversion for argument 1 from 'bool' to 'std::initializer_list<std::__cxx11::basic_string<char> >'
  788 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:67:8: error: could not convert 'ans' from 'std::vector<std::__cxx11::basic_string<char> >' to 'bool'
   67 |     if(ans) break;
      |        ^~~
      |        |
      |        std::vector<std::__cxx11::basic_string<char> >