need help with MARBLEGF, fully line-by-line commented code included

I have the link to fully commented code.
It passes the sample input, but is incorrect. It’s only 60 lines of code and straightforward. Each line is commented.
http://www.codechef.com/viewsolution/4077941
http://www.codechef.com/viewplaintext/4077941 (plaintext)

Basically, you just need to find the sum of objects in an array from A to B, but you need to do it quickly. “Marbles” is the amount of each element in the array, and “Students” are the placeholders in the array.
I made a system where you save the total sum at each point in the array, so that you don’t need to add each number from A to B every time. Also, every time you change an object in the array, you make note of where and how much you changed that object, so that you can check of changes exist between A to B and add those changes.