Everything that you output is considered for the solution. This will cause wrong answer.
Also, it's not required for you to verify the input constraints. If the problem statement states that the input will be a two digit number you can take that for granted (unless it's not correct in which case there will typically be a ton of comments stating otherwise)
Finally, you don't need to take all input and then deliver output. You can read, output, read, output, ... until you're done. It is awkward when you're testing via the console but the console is actually working with two separate streams, stdin and stdout. The judge sends all input on stdin and reads output on stdout. If you're going to continue on any judge, it is worthwhile to set up your environment so that you can redirect stdin and stdout to files for testing so that you can avoid the cumbersome console.
Cheers!