Solution of SPOJ problems