Solving Spoj Problems