Comments

or when your correct submission fails, because you have defined mod = 10^9+7 and problem has weird mod XO

I love using this in linux.

Your problem distribution says it all. Using this extension, you can see that out of your 157 solved problems, 142 are rated 800. I highly suggest that you start solving more difficult problems. There are many posts addressing how to train for competitive programming. Personally, I think you should solve problems rated 300-700 points higher than your current rating — or even more, depending on how comfortable you feel. The problems shouldn't be unrealistically hard for you.

Participate in as many contests as you can, but after each contest, make sure to solve the problems you couldn't solve during the contest. Using the editorial wisely for guidance is okay. While participating in many contests has its advantages (e.g., improving speed, revisiting concepts, etc.), solving only problems with ratings lower than yours will eventually limit your growth. You'll reach a point where you can no longer surpass your current peak rating.

That's why it's important to consistently challenge yourself by solving problems JUST BEYOND your current skill level.

during contest i had some trouble implementing C (i had same idea as described in approach 1) and using segment trees seemed easier to me. Idea is identical as described in approach 1 but it was easier for me to implement this way, so i thought of sharing it: code.