challenge for most difficult problem codechef solution