please can anyone explain the approach for this question?
https://www.codechef.com/ICPCIN19/problems/PENS
Codeforces Round 945 Solution Discussion (with myself)
Atcoder ABC #354 Solution Discussion