As you might know, stderr doesn't affect a judgement. Therefore, if you use stderr instead of stdout for debugging, you won't get WA even if you forget to delete (or comment out) the lines for debugging.

Of course, you can never get AC if your solution is wrong in the first place :)

the runtime of the above code would surely decrease if the cerr statements were removed. and if the recursion runs for nearly 106 nodes, it could easily result in the solution getting TLE instead of AC.

Oh, sorry. I completely forgot an effect on running time. Certainly, the effect of debugging statements in such a case cannot be ignored. Therefore, please think using stderr instead of stdout is only an insurance against WA.

Codeforces defines an ONLINE_JUDGE macro for C/C++ programs. Therefore it is possible to write a template where the debugging output works on a local machine, and turns into nothing on Codeforces. A very simple implementation:

Deleting cerr's when submitting can be done in a following way: 1. Replace (Ctrl+R in Kate)

cerr -> //cerr

:P

Defining own macros is a good idea, but sometimes we want something mote than just printing the value of a variable (for example additional comments written by us to make them readable). By the way if we have macro in our code like that LOG(x) and use it in a code, we should take care of line with that define in a replace method I explained earlier :P.