The output format is not correct
In SPOJ the output format should match with the required format.
It should be
as required, that is every output should be in new line.
basic header file is also not included for the functionality of cin and cout i.e
I think that's the only corrections you need in this code.