Problem I have solved on codechef.