Hi,
I've tried with yours inputs and everything looks good for me !
I found exactly the same output.
Thinking that the problem could be the back space in the last line, i've changed a little my program.
But the judge says always 'Wrong Answer'.
Here is my code :
#ifndef ONLINE_JUDGE
#include ...