Help on a question

https://codeforces.com/blog/entry/76922
Anyone please share code or effective approach