i copy pasted example input of https://mirror.codeforces.com/contest/1391/problem/B but the output is not coming out after input of each test case, it gets mixed with input of other test cases.see image attached(/predownloaded/f4/74/f474c2cc870524573e76898948efc08138eb4198.png).
But this is the general case since both streams (input and output) are linked with the monitor.
The best one would be to use input output redirection. But you can also try using
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
in main function as it breaks and delays immediate buffer flushing.Disclaimer: The code snippet sucks while debugging using print statements