Lucky Boundaries

i am trying to solve this problem but i am getting timelimit exceeded error. Someone please help me in solving this.
problem statement link: https://www.codechef.com/problems/ICM0013?tab=statement

same bro if you get it please tell me

The most common reason that you would get a TLE is because your program is too slow. If a problem tells you that N <= 100000, and your program has nested loops each which go up to N, your program will never be fast enough. Read the bounds in the input carefully before writing your program, and try to figure out which inputs will cause your program to run the slowest.

If you are still not able to figure out how to solve this problem, you can read the solution here.