Case of different Outputs with same code and same input cases

Revision en1, by WarpSpeed, 2016-02-21 19:25:54

This is a very strange incident. And I'll not be exaggerating when I say this but, I truly am bewildered by it.

While solving the following question :

I got a WA on Test case 39. When I decided to run the same code on Ideone, this is what I found:

Case 1 : I run the code as it as :

Case 2 : I add an additional printf statement, leaving the entire remaining code unchanged. :

The change can be seen (addition of an extra printf statement) in line no. 31 of the code.

How can it be possible that a simple printf statement changes the output that follows, when nothing is changed anywhere else? Or is it some pretty big blunder that I'm making and am completely unaware of it?

Any help regarding this will be much appreciated.


  Rev. Lang. By When Δ Comment
en1 English WarpSpeed 2016-02-21 19:25:54 905 Initial revision (published)