Solutions of the SPOJ problems