#include using namespace std; int main() { int n, k; cin >> n >> k; // read the number of stories and eggs int l = 0, r = n; string response; while (response != "exit") { int x = (l + r) / 2; if(l < r) cout << "query " << x << "\n"; // can also use endl for newline else cout << "answer " << x << "\n"; cin >> response; if (response == "broke") k--, l = x + 1; else if(response == "survived") r = x; } return 0; }