Language: C++

#include <bits/stdc++.h>
using namespace std;

const int L = 128;

int main() {
    string alphabet;
    for (int i = 0; i < 26; i++) alphabet.push_back('a' + i);
    for (int i = 0; i < 26; i++) alphabet.push_back('A' + i);
    for (int i = 0; i < 10; i++) alphabet.push_back('0' + i);
    auto query = [&](string s) {
        cout << "? " << s << endl; fflush(stdout);
        int x; cin >> x; return x;
    };
    vector<string> ans;
    int len = 0;
    for (char c : alphabet) {
        int tmp = L - query(string(L, c));
        len += tmp;
        if (tmp) ans.push_back(string(tmp, c));
    }
    auto chk = [&](string s) {
        return query(s) == len - s.length();
    };
    while (ans.size() > 1) {
        stable_sort(ans.begin(), ans.end(), [&](vector<int> x, vector<int> y) {
            return x.size() < y.size();
        });
        string s1 = ans[0], s2 = ans[1], s3;
        ans.erase(ans.begin()), ans.erase(ans.begin());
        int pos1 = 0, pos2 = 0;
        while (pos1 < s1.length() && pos2 < s2.length()) {
            string tmp = s3; tmp.push_back(s1[pos1]);
            for (int i = pos2; i < s2.length(); i++) tmp.push_back(s2[i]);
            if (chk(tmp)) s3.push_back(s1[pos1++]);
            else s3.push_back(s2[pos2++]);
        }
        while (pos1 < s1.length()) s3.push_back(s1[pos1++]);
        while (pos2 < s2.length()) s3.push_back(s2[pos2++]);
        ans.push_back(s3);
    }
    cout << "! " << ans[0] << endl; fflush(stdout);
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char>*, std::vector<std::__cxx11::basic_string<char> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char>*, std::vector<std::__cxx11::basic_string<char> > >; _Compare = main()::<lambda(std::vector<int>, std::vector<int>)>]':
/usr/include/c++/14/bits/stl_algo.h:1777:14:   required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(vector<int>, vector<int>)> >]'
 1777 |           if (__comp(__i, __first))
      |               ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2748:25:   required from 'void std::__inplace_stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(vector<int>, vector<int>)> >]'
 2748 |           std::__insertion_sort(__first, __last, __comp);
      |           ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4956:28:   required from 'void std::__stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(vector<int>, vector<int>)> >]'
 4956 |         std::__inplace_stable_sort(__first, __last, __comp);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5030:36:   required from 'void std::stable_sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Compare = main()::<lambda(vector<int>, vector<int>)>]'
 5030 |       _GLIBCXX_STD_A::__stable_sort(__first, __last,
      |                                    ^
a.cc:26:20:   required from here
   26 |         stable_sort(ans.begin(), ans.end(), [&](vector<int> x, vector<int> y) {
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   27 |             return x.size() < y.size();
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   28 |         });
      |         ~~          
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(main()::<lambda(std::vector<int>, std::vector<int>)>) (std::__cxx11::basic_string<char>&, std::__cxx11::basic_string<char>&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
a.cc:26:45: note: candidate: 'main()::<lambda(std::vector<int>, std::vector<int>)>'
   26 |         stable_sort(ans.begin(), ans.end(), [&](vector<int> x, vector<int> y) {
      |                                             ^
a.cc:26:45: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'std::vector<int>'
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char>*, std::vector<std::__cxx11::basic_string<char> > >; _Iterator2 = std::__cxx11::basic_string<char>*; _Compare = main()::<lambda(std::vector<int>, std::vector<int>)>]':
/usr/include/c++/14/bits/stl_algo.h:2258:14:   required from 'void std::__move_merge_adaptive(_InputIterator1, _InputIterator1, _InputIterator2, _InputIterator2, _OutputIterator, _Compare) [with _InputIterator1 = __cxx11::basic_string<char>*; _InputIterator2 = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _OutputIterator = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(vector<int>, vector<int>)> >]'
 2258 |           if (__comp(__first2, __first1))
      |               ~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2368:30:   required from 'void std::__merge_adaptive(_BidirectionalIterator, _BidirectionalIterator, _BidirectionalIterator, _Distance, _Distance, _Pointer, _Compare) [with _BidirectionalIterator = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Distance = long int; _Pointer = __cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(vector<int>, vector<int>)> >]'
 2368 |           std::__move_merge_adaptive(__buffer, __buffer_end, __middle, __last,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2369 |                                      __first, __comp);
      |                                      ~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2708:28:   required from 'void std::__stable_sort_adaptive(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Pointer, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Pointer = __cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(vector<int>, vector<int>)> >]'
 2708 |       std::__merge_adaptive(__first, __middle, __last,
      |       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
 2709 |                             __middle - __first, __last - __middle,
      |                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 2710 |                             __buffer, __comp);
      |                             ~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4952:29:   required from 'void std::__stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(vector<int>, vector<int>)> >]'
 4952 |         std::__stable_sort_adaptive(__first,
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
 4953 |                                     __first + _DistanceType(__buf.size()),
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 4954 |                                     __last, __buf.begin(), __comp);
      |                                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:5030:36:   required from 'void std::stable_sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Compare = main()::<lambda(vector<int>, vector<int>)>]'
 5030 |       _GLIBCXX_STD_A::__stable_sort(__first, __last,
      |                                    ^
a.cc:26:20:   required from here
   26 |         stable_sort(ans.begin(), ans.end(), [&](vector<int> x, vector<int> y) {
      |         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   27 |             return x.size() < y.size();
      |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   28 |         });
      |         ~~          
/usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(main()::<lambda(std::vector<int>, std::vector<int>)>) (std::__cxx11::basic_string<char>&, std::__cxx11::basic_string<char>&)'
  158 |         { return bool(_M_comp(*__it1, *__it2)); }
      |                       ~~~~~~~^~~~~~~~~~~~~~~~
a.cc:26:45: note: candidate: 'main()::<lambda(std::vector<int>, std::vector<int>)>'
   26 |         stable_sort(ans.begin(), ans.end(), [&](vector<int> x, vector<int> y) {
      |                                             ^
a.cc:26:45: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>' to 'std::vector<int>'
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = std::__cxx11::basic_string<char>*; _Iterator2 = __gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char>*, std::vector<std::__cxx11::basic_string<char> > >; _Compare = main()::<lambda(std::vector<int>, std::vector<int>)>]':
/usr/include/c++/14/bits/stl_algo.h:2297:14:   required from 'void std::__move_merge_adaptive_backward(_BidirectionalIterator1, _BidirectionalIterator1, _BidirectionalIterator2, _BidirectionalIterator2, _BidirectionalIterator3, _Compare) [with _BidirectionalIterator1 = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _BidirectionalIterator2 = __cxx11::basic_string<char>*; _BidirectionalIterator3 = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(vector<int>, vector<int>)> >]'
 2297 |           if (__comp(__last2, __last1))
      |               ~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:2374:39:   required from 'void std::__merge_adaptive(_BidirectionalIterator, _BidirectionalIterator, _BidirectionalIterator, _Distance, _Distance, _Pointer, _Compare) [with _BidirectionalIterator = __gnu_cxx::__normal_iterator<__cxx11::basic_string<char>*, vector<__cxx11::basic_string<char> > >; _Distance = long int; _Pointer = __cxx11::basic_string<char>*; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(vector<int>, vector<int>)> >]'
 2374 |           std::__move_merge_adaptive_backward(__first, __middle, __buffer,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~