Prefix sum matrix is correct but sum of submatrix is coming a garbage value

pls help me with this code

you need to handle some side cases too in line 42, check this