FIRESC Submission RE

I am unable to figure out why my solution - CodeChef: Practical coding for everyone - for FIRESC is giving RE. Hope someone will help point out the error!