BLUEPRINT question AHAPH

can someone please help me out in this question CodeChef: Practical coding for everyone?
@vipulvikram
and also explain this solution: CodeChef: Practical coding for everyone
Thanks.