Language: C++

#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

void input(){
    // fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
}


bool get_q(){
    char a;
    cin >> a;
    if(a=='Y') return true;
    return false;
}

bool throw_q(string t){
    cout << "? " << stol(t) << endl;
    return get_q();
}

bool throw_q(ll t){
    cout << "? " << t << endl;
    return get_q();
}



void throw_a(string t){
    cout << "! " << stol(t) << endl;
}

void throw_a(ll t){
    cout << "! " << t << endl;
}



int solve(){
    string N;
    for (int i = 0; i < 9; i++)
    {
        int ng=0,ok=10;
        if(i==0) ng=1;
        while(ok-ng>1){
            int mid=(ok+ng)/2;
            string t=N;
            t+=to_string(mid);
            t+=string((10-t.length()),'0');
            DBG(t)
            if(throw_q(t)) ok=mid;
            else ng = mid;
        }
        N += to_string(ng);
    }
    // int ng=0,ok=10;
    // while(ok-ng>1){
    //     int mid=(ok+ng)/2;
    //     string mi = N.substr(0,mid);
    //     ll m = stol(mi)+1;
    //     if(throw_q(m)) ok=mid;
    //     else ng = mid;
    // }
    // int j;
    // for (int i = N.length(); i > 0 ; i--)
    // {
    //     int m = stol(N.substr(0,i));
    //     m++;
    //     if(throw_q(m)) continue;
    //     else {j=i; break;}
    // }

    int j;
    ll ans=0;
    ll ans=stol(N);
    ans++;
    ans/=10;
    while(ans%10==0) ans/=10;

    // for (int i = N.length(); i > 0 ; i--)
    // {
    //     int m = stol(N.substr(0,i));
    //     m--;
    //     if(throw_q(m)) {ans=m++; break;}
    // }
    throw_a(ans);
    return 0;
}   

int main()
{
    // input();
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'int solve()':
a.cc:112:8: error: redeclaration of 'll ans'
  112 |     ll ans=stol(N);
      |        ^~~
a.cc:111:8: note: 'll ans' previously declared here
  111 |     ll ans=0;
      |        ^~~