I am solving some problem and was testing with sample test case which prints 2*106 integers.
On initial run, I used cout<<ans;
and it took 0.602s
for giving output.
I realized that I wasn't printing each output in a new line. So changed it to cout<<ans<<endl;
. This time it took 2.052s
!
Why does just printing a new line character after each line takes so long time?