link to the problem : https://www.hackerearth.com/practice/math/combinatorics/inclusion-exclusion/practice-problems/algorithm/gadget-fan/description/
I am only able to get 68 points when i submitted an O(n) solution. I am not able to optimize it further. I read the editorial as well but i wasn't able to understand it. So, if anyone could explain me the editorial or provide an alternate efficient approach to this problem.