Solution to some of the SPOJ problems