working/non working solutions to spoj questions