I have solved this question using segment trees. here is the link to it : https://repl.it/LrK9/0

please help me find the bug. It’s running fine on the test case.

Ok i figured out the bug line 84

if(a<=l && r<=b)

here since you are checking the condition for total overlap r must be take as r>=b not r<=b.

And now another shocking fact after correcting this your code gives SIGSEGV trying to figure that out-_-

Here link to my code similar to yours which got an AC

```
(https://www.codechef.com/viewsolution/15558735)
```

when i am checking for total overlap, i am checking whether l-r lies within a-b or coincides with it. So, condition r<=b is not false.

correct me if you feel i am wrong.

still did’nt got your point a is starting of query and b denotes ending of query interval now in order [a,b] to completely overlap [l,r] a<=l &&r>=b

Added link to my ac code which is almost similar to yours i just used pairs instead of 2-D array