Solution to a few SPOJ problems