Please share , Your Logic for solving INTERVAL feb17

I get TLE for tests 5 to 9 despite following an approach which is proven to give AC on those test cases too. The implementation follows the same approach explained by @gkcs in his video tutorial. Can someone tell me where I am going wrong? The link to my question on the codechef forums is here: https://discuss.codechef.com/questions/94571/codechef-february-long-2017-interval-why-am-i-getting-tle-for-some-test-cases