For this Question: Given a <b> N X M matrix</b> and a <b>target</b>, return the number of non- empty submatrices that sum to target.

A submatrix x1, y1, x2, y2 is the set of all cells matrix[x][y] with x1 <= x <= x2 and y1 <= y <= y2.

Two submatrices (x1, y1, x2, y2) and (x1', y1', x2', y2') are different if they have some coordinate that is different: for example, if x1 != x1'.First line contains two integers N and M.
Next N lines will contain M integers each denoting the matrix.
Next line contains a single integer target

Constraints:
1 <= N, M <= 100
-1000 <= matrix[i][j] <= 1000
-10^8 <= target <= 10^8A single integer denoting the answer.Input:
3 3 
0 1 0
1 1 1 
0 1 0
0

Output:
4, I have written this Solution Code: import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
       
        int n=Integer.parseInt(in.next());
        int m=Integer.parseInt(in.next());

        long mat[][] = new long[n][m];
       
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                mat[i][j]=Long.parseLong(in.next());
            }
        }

        long target=Long.parseLong(in.next());
        long ans=0;
        for(int x1=0;x1<n;x1++){

            long sum[]=new long[m];
            Arrays.fill(sum, 0);

            for(int x2=x1;x2<n;x2++){
                for(int y=0;y<m;y++){
                    sum[y] += mat[x2][y];
                }
                ans += subArraySum(sum,target);
            }
        }
        out.print(ans);
        out.close();
    }

    private static long subArraySum(long sum[],long target){
        long ans=0;
        HashMap<Long,Long> mp = new HashMap<Long,Long>();
        long cur_sum=0;
        mp.put((long)0, (long)1);
        for(int i=0;i<sum.length;i++){
            cur_sum += sum[i];
            long req_sum=cur_sum-target;
            if(mp.containsKey(req_sum)){
                ans += mp.get(req_sum);
            }
            if(!mp.containsKey(cur_sum)){
                mp.put(cur_sum , (long)0);
            }
           mp.put(cur_sum, mp.get(cur_sum)+1);
        }
        return ans;
    }
    
    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;
        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void print(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                if (i != 0) {
                    writer.print(' ');
                }
                writer.print(objects[i]);
            }
        }

        public void println(Object... objects) {
            print(objects);
            writer.println();
        }

        public void close() {
            writer.close();
        }

        public void println(int i) {
            writer.println(i);
        }

    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?