Solutions to Spoj problems