Pair Programming to debug Nested segments solution

Hello guys,

I’m some problem with a problem on codeforce called Nested segments, my solution is failing on test 11 but I do not understand why

This is my solution for the problem

There is a better solution that uses the Fenwick tree to solve the problem?