@kuruma thanks for this question i learnt something new.
first tiny mistake is the output of second query type you should print find(x)+1 as your numbers are 0-based .
secondly you have used “ios_base::sync_with_stdio(false)” that seems to cause your output to be buffered and is printed together only when the program terminates.
this would have been correct had you used puts/printf in output of 2nd query as well. since you used cout that output is not buffered and printed instantly while the output of all first queries is printed in the end.
So what you can do:
1.use fflush(stdout) after puts statement
3.NOT use ios_base::sync_with_stdio(false);
4.use puts/printf in the output of 2nd query as well