Can anyone help me debug my code for chefina ranges

https://www.codechef.com/viewsolution/29075886

I first mapped the prefix sums to vector which stores all of the indexes whose prefix sum =sum. then I went through all n, and finding the number of indexes whose prefix sum =(sum-seq[i])/2 and less than i, then through all indexes whose sum =(sum+seq[i])/2 and index >=i. using a binary searchish method. Because i wasnt sure my binary search was correct, i used a while loop to correct it if it was inaccurate.

Just look at my number of submissions. I have spent forever trying to figure it out