SPOJ problems solutions