Solutions for Spoj problems