move = 10 ** 9 / 2 + 10000 border = move count_list = {} 100.times do puts "? #{border}" STDOUT.flush res = gets.to_i == 1 ? 1 : -1 move = [move/2, 1].max border += res * move count_list[border] ||= 0 count_list[border] += 1 end puts count_list.map{|k,v| v}.sort()[0..1].min