Why my code is not passing all the test cases?

Problem Link: https://www.codechef.com/problems/DIVSUBS

My Solution Link: https://ide.codingblocks.com/s/239936

It is not passing all the test cases.

@siddharth_1_3277
You forgot to clear map and vectors after output of each test case
So previous test case info is stored leading to WA

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.