For this Question: Given a binary square matrix of size N*N and an integer K, your task is to print the maximum side of sub square matrix containing at most K 1's.The first line of input contains two integers N and K, Next N lines contain N space-separated integers depicting the values of the matrix.

<b>Constraints:</b>
1 < = N < = 500
1 < = K < = 100000 
0 < = Matrix[][] < = 1Print the maximum side.Sample Input:-
3 2
1 1 1
1 0 1
1 1 0 

Sample Output:-
2

Explanation:-
0 1
1 0 
is the required sub matrix.

Sample Input:-
2 1
1 0
0 1

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



class Main {
	public static void main (String[] args)throws IOException {

					BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
                      String ar[] = br.readLine().split(" ");
                      int n = Integer.parseInt(ar[0]);
                      int k = Integer.parseInt(ar[1]);
					  int a[][] = new int[n][n];
					  int sum=0,one_c=0;
                      for(int i=0;i<n;i++)
                      {
                          String arr[] = br.readLine().split(" ");
						  sum=0;
                          for(int j=0;j<n;j++)
                          {
                             int value=Integer.parseInt(arr[j]);
							 if(value==1)
							 one_c++;
							 sum=sum+value;
							 a[i][j]=sum;
                          }
                      }
					  for(int j=0;j<n;j++)
					  {
						  sum=0;
                          for(int i=0;i<n;i++)
						  {
                            sum=sum+a[i][j];
							a[i][j]=sum;
						  }
					  }

					if(k>=one_c)
					  {

						  System.out.println(n);

					  }
					else {
						int ans = 1;
						for(int len=1;len<=n;len++)
						{
							boolean flag= false;
						for(int i=len;i<n;i++)
						{
							for(int j=len;j<n;j++)
							{
								if(j-i==0)
								{
                                  if(a[i][j]<=k)
								  {
									  ans = Math.max(ans,ans+1);
									  flag=true;
									  break;
								  }

								}
								else if(j>i)
								{
									if(i==ans)
									{
										if(a[i][j]-a[i][j-ans-1]<=k)
										{
											ans=Math.max(ans,ans+1);
											flag = true;
											break;
										}
									}
									else {
										if(a[i][j]-a[i][j-ans-1]-a[i-ans-1][j]+a[i-ans-1][j-ans-1] <=k)
                                         {
											 ans = Math.max(ans,ans+1);
											 flag=true;
											 break;
										 }
									}
								}
								 if(i>ans) {

									if(j==ans)
									{
										if(a[i][j]-a[i-ans-1][j]<=k)
										{
											ans=Math.max(ans,ans+1);
											flag = true;
											break;
										}
									}
									else {
										if(a[i][j]-a[i-ans-1][j]-a[i][j-ans-1]+a[i-ans-1][j-ans-1] <=k)
                                         {
											 ans = Math.max(ans,ans+1);
											 flag=true;
											 break;
										 }
									}

								}
							}
							if(flag==true) break;
						}
						if(flag==false) break;
					}
					System.out.println(ans);
				}

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