solve tougher problems in spoj