Changed algorithms and a solution of codechef.