LOC July 2018

Can anyone tell me the algorithm for LOC July (Chef and College) question? Please!

PLease wait till today midnight. The contest will end soon.

Soln CodeChef: Practical coding for everyone .

You should be thankful to me now. xD