Language: C++

#include <string>
 
using namespace std;
 
int N;
string tmp;
 
void check(int start, int num, string value, int count){
    cout<<start + num / 2 <<endl;
    cin>>tmp;
 
    if(count == 0){
        return;
    }else if(num % 2 == 0){
        if(tmp == value){
            check(start, num / 2, value, count-1);
        }else{
            check(start + num / 2, num - num / 2, tmp, count-1);
        }
    }else{//num % 2 == 1
        if(tmp == value){
            check(start + num / 2, num - num / 2, tmp, count-1);
        }else{
            check(start, num / 2, value, count-1);
        }
    }
}
 
void check2(int start, int goal, string value, int count){
    int num = (start + goal)/2.0;
    cout<< num <<endl;
    cout.flush();
    cin>>tmp;
 
    if(tmp == "Vacant") return;
 
    if(count == 0){
        return;
    }else if((num - start) % 2 == 0){
        if(tmp == value){
            check2(num, goal, tmp, count-1);
        }else{
            check2(start, num , value,count-1);
        }
    }else{//num % 2 == 1
        if(tmp == value){
            check2(start, num , value,count-1);
        }else{
            check2(num, goal, tmp, count-1);
        }
    }
 
}
 
int main(void){
    cin>>N;
 
    cout<<0<<endl;
  cout.flush();
    cin>>tmp;
    //check(0, N, tmp, 20);
    check2(0, N-1, tmp, 21);
 
    return 0;
}

Compiler output:
a.cc: In function 'void check(int, int, std::string, int)':
a.cc:9:5: error: 'cout' was not declared in this scope
    9 |     cout<<start + num / 2 <<endl;
      |     ^~~~
a.cc:2:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include <string>
  +++ |+#include <iostream>
    2 | 
a.cc:9:29: error: 'endl' was not declared in this scope
    9 |     cout<<start + num / 2 <<endl;
      |                             ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include <string>
  +++ |+#include <ostream>
    2 | 
a.cc:10:5: error: 'cin' was not declared in this scope
   10 |     cin>>tmp;
      |     ^~~
a.cc:10:5: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc: In function 'void check2(int, int, std::string, int)':
a.cc:31:5: error: 'cout' was not declared in this scope
   31 |     cout<< num <<endl;
      |     ^~~~
a.cc:31:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:31:18: error: 'endl' was not declared in this scope
   31 |     cout<< num <<endl;
      |                  ^~~~
a.cc:31:18: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
a.cc:33:5: error: 'cin' was not declared in this scope
   33 |     cin>>tmp;
      |     ^~~
a.cc:33:5: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc: In function 'int main()':
a.cc:56:5: error: 'cin' was not declared in this scope
   56 |     cin>>N;
      |     ^~~
a.cc:56:5: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:58:5: error: 'cout' was not declared in this scope
   58 |     cout<<0<<endl;
      |     ^~~~
a.cc:58:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:58:14: error: 'endl' was not declared in this scope
   58 |     cout<<0<<endl;
      |              ^~~~
a.cc:58:14: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'