#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--, r = x; else if(response == "survived") l = x + 1; } return 0; }