Language: C++

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <assert.h>
using namespace std;
// string s1 = "1000000";
// long v1 = 55;
bool get(){
    string str;
    cin >> str;
    return str=="Y";
}
bool ask(string str){
    // cout << "? " << str << endl;
    // return get();
    cout << "ASK " << str << " " << ((stol(str)<=v1) == (str<=s1)) << endl;
    return (stol(str)<=v1) == (str<=s1);
}
bool ret(string str){
    cout << "! " << str << endl;
}

int main() {
    
    std::ios::sync_with_stdio(false);
    long asks = 0;
    vector<string> nums;
    for(long i = 0; i<10; i++){
        string str = to_string(i);
        nums.push_back(str);
    }
    string prefix = "";
    while(true){
        string post = "00";
        if(prefix.length()==0){
            post = "10";
        }
        asks++;
        assert(asks<=64);
        
        if(!ask(prefix+post)){
            long low = 1;
                if(prefix.length()>0){
                    low = 0;
                }
                long high = 9;
                while(low<high){
                    long mid = (low+high)/2;
                    asks++;
                    assert(asks<=64);
                    if(ask(prefix + to_string(mid) + to_string(mid))){
                        high = mid;
                    }
                    else{
                        low = mid+1;
                    }
                }
                prefix += to_string(low);
                break;
        }
        else{
            bool askedFirst = false;
            bool firstRes = false;
            long low = 1;
            if(prefix.length()>0){
                low = 0;
            }
            asks++;
            assert(asks<=64);
            string x = ask(prefix+to_string(low);
            while(x.length()<15){
                x = x+"0";
            }
            if(ask(x))){
                asks++;
                assert(asks<=64);
                askedFirst = true;
                firstRes = false;
                if(ask(prefix+"5")){
                    prefix += to_string(low);
                    break;
                }
                else{
                    prefix += to_string(low);
                    continue;
                }
            }
            long high = 9;
            while(low<high){
                long mid = (low+high+1)/2;
                if(askedFirst){
                    askedFirst = false;
                    if(firstRes){
                        low = mid;
                    }
                    else{
                        high = mid-1;
                    }
                    continue;
                }
                asks++;
                assert(asks<=64);
                if(ask(prefix+to_string(mid))){
                    low = mid;
                }
                else{
                    high = mid-1;
                }
            }
            prefix += to_string(low);
        }
    }
    ret(prefix);
    return 0;
}

Compiler output:
a.cc: In function 'bool ask(std::string)':
a.cc:18:50: error: 'v1' was not declared in this scope; did you mean '__pstl::execution::v1'?
   18 |     cout << "ASK " << str << " " << ((stol(str)<=v1) == (str<=s1)) << endl;
      |                                                  ^~
      |                                                  __pstl::execution::v1
In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15,
                 from /usr/include/c++/14/algorithm:86,
                 from a.cc:5:
/usr/include/c++/14/pstl/execution_defs.h:19:18: note: '__pstl::execution::v1' declared here
   19 | inline namespace v1
      |                  ^~
a.cc:18:63: error: 's1' was not declared in this scope
   18 |     cout << "ASK " << str << " " << ((stol(str)<=v1) == (str<=s1)) << endl;
      |                                                               ^~
a.cc: In function 'bool ret(std::string)':
a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
   23 | }
      | ^
a.cc: In function 'int main()':
a.cc:72:49: error: expected ')' before ';' token
   72 |             string x = ask(prefix+to_string(low);
      |                           ~                     ^
      |                                                 )
a.cc:76:23: error: expected primary-expression before ')' token
   76 |             if(ask(x))){
      |                       ^