l = 1 r = 10 ** 9 while l != (mid = (l + r) / 2) puts "? #{mid}" STDOUT.flush case gets.to_i when 1 l = mid when 0 r = mid end end puts "! #{l}" STDOUT.flush