Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  short a;cin>>a;
  set<string>S;
  for(int i=0;i<s.size();i++)
    for(int j=i+1;j<min(i+k+1,int(s.size()));j++)
      S.insert(s.begin()+i,s.begin()+j);
  vector<string>A(S.size());
  for(int i=0;i<A.size();i++){
    A[i]=S.top();
    S.pop();
  }
  sort(A.begin(),A.end());
  cout<<A[a]<<endl;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:8:27: error: 'k' was not declared in this scope
    8 |     for(int j=i+1;j<min(i+k+1,int(s.size()));j++)
      |                           ^
a.cc:12:12: error: 'class std::set<std::__cxx11::basic_string<char> >' has no member named 'top'
   12 |     A[i]=S.top();
      |            ^~~
a.cc:13:7: error: 'class std::set<std::__cxx11::basic_string<char> >' has no member named 'pop'
   13 |     S.pop();
      |       ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
                 from /usr/include/c++/14/bits/allocator.h:46,
                 from /usr/include/c++/14/string:43,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::__cxx11::basic_string<char>; _Args = {char&}; _Tp = std::_Rb_tree_node<std::__cxx11::basic_string<char> >]':
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::__cxx11::basic_string<char>; _Args = {char&}; _Tp = std::_Rb_tree_node<std::__cxx11::basic_string<char> >; allocator_type = std::allocator<std::_Rb_tree_node<std::__cxx11::basic_string<char> > >]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:593:32:   required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(_Link_type, _Args&& ...) [with _Args = {char&}; _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Identity<std::__cxx11::basic_string<char> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; _Link_type = std::_Rb_tree_node<std::__cxx11::basic_string<char> >*]'
  593 |               _Alloc_traits::construct(_M_get_Node_allocator(),
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
  594 |                                        __node->_M_valptr(),
      |                                        ~~~~~~~~~~~~~~~~~~~~
  595 |                                        std::forward<_Args>(__args)...);
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:610:21:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {char&}; _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Identity<std::__cxx11::basic_string<char> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; _Link_type = std::_Rb_tree_node<std::__cxx11::basic_string<char> >*]'
  610 |           _M_construct_node(__tmp, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1633:32:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Auto_node::_Auto_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, _Args&& ...) [with _Args = {char&}; _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Identity<std::__cxx11::basic_string<char> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]'
 1633 |             _M_node(__t._M_create_node(std::forward<_Args>(__args)...))
      |                     ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:2432:13:   required from 'std::pair<std::_Rb_tree_iterator<_Val>, bool> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_unique(_Args&& ...) [with _Args = {char&}; _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Identity<std::__cxx11::basic_string<char> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]'
 2432 |         _Auto_node __z(*this, std::forward<_Args>(__args)...);
      |                    ^~~
/usr/include/c++/14/bits/stl_tree.h:1108:23:   required from 'std::__enable_if_t<((bool)(! std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value))> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Identity<std::__cxx11::basic_string<char> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; std::__enable_if_t<((bool)(! std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value))> = void; typename std::iterator_traits<_InputIterator>::value_type = char]'
 1108 |             _M_emplace_unique(*__first);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:569:31:   required from 'void std::set<_Key, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = __gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >; _Key = std::__cxx11::basic_string<char>; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::basic_string<char> >]'
  569 |         { _M_t._M_insert_range_unique(__first, __last); }
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:9:15:   required from here
    9 |       S.insert(s.begin()+i,s.begin()+j);
      |       ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'std::__cxx11::basic_string<char>::basic_string(char&)'
  191 |         { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:800:9: note: candidate: 'template<class _Tp, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Tp&, const _Alloc&) [with <template-parameter-2-2> = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  800 |         basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())
      |         ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:800:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = void]':
/usr/include/c++/14/bits/basic_string.h:149:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = char; _Res = void; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
/usr/include/c++/14/bits/basic_string.h:797:30:   required from 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::__cxx11::basic_string<char>; _Args = {char&}; _Tp = std::_Rb_tree_node<std::__cxx11::basic_string<char> >]'
  797 |       template<typename _Tp, typename = _If_sv<_Tp, void>>
      |                              ^~~~~~~~
/usr/include/c++/14/bits/alloc_traits.h:575:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::__cxx11::basic_string<char>; _Args = {char&}; _Tp = std::_Rb_tree_node<std::__cxx11::basic_string<char> >; allocator_type = std::allocator<std::_Rb_tree_node<std::__cxx11::basic_string<char> > >]'
  575 |           __a.construct(__p, std::forward<_Args>(__args)...);
      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:593:32:   required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(_Link_type, _Args&& ...) [with _Args = {char&}; _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Identity<std::__cxx11::basic_string<char> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; _Link_type = std::_Rb_tree_node<std::__cxx11::basic_string<char> >*]'
  593 |               _Alloc_traits::construct(_M_get_Node_allocator(),
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
  594 |                                        __node->_M_valptr(),
      |                                        ~~~~~~~~~~~~~~~~~~~~
  595 |                                        std::forward<_Args>(__args)...);
      |                                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:610:21:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {char&}; _Key = std::__cxx11::basic_string<char>; _Val = std::__cxx11::basic_string<char>; _KeyOfValue = std::_Ident