Unable to figure out error

I have converted 3-D coordinates to 1-D and applied Fenwick tree but it is giving the wrong answers. Please help me where I am going wrong.

@tilakparth123
I dont think your mapping from 3D to 1D is correct
I request you to once dry run it on the sample cases
You will need up update certain segments in the 1D array and not a contiguous segment