Problem:
Score : 100 points

Problem Statement

We have an N \times N square grid.

We will paint each square in the grid either black or white.

If we paint exactly A squares white, how many squares will be painted black?

Constraints

1 \leq N \leq 100

0 \leq A \leq N^2

Inputs

Input is given from Standard Input in the following format:

N
A

Outputs

Print the number of squares that will be painted black.

Sample Input 1

3
4

Sample Output 1

5

There are nine squares in a 3 \times 3 square grid.
Four of them will be painted white, so the remaining five squares will be painted black.

Sample Input 2

19
100

Sample Output 2

261

Sample Input 3

10
0

Sample Output 3

100

As zero squares will be painted white, all the squares will be painted black.

Solution in Java (OpenJDK 11.0.6) (judge verdict: Runtime Error)


import java.io.*;
import java.lang.*;
import java.math.*;
import java.util.*;

public class Main {
	 static InputReader in = new InputReader(System.in);
	 static PrintWriter out = new PrintWriter(System.out);
	 
	 public static void main(String[] args) throws Exception {
		 int a = in.nextInt()*100;
		 int b = in.nextInt()*100;
		 int c = in.nextInt();
		 int d = in.nextInt();
		 int e = in.nextInt();
		 int max = in.nextInt();
		 int sw = 0;
		 int sugar = 0;
		 
		 int min_w=Math.min(a,b);
		 int min_s=Math.min(c,d);
		 int max_w=Math.max(a,b);
		 //water 
		 if (min_w+min_s > max) {}
		 
		 else if ((min_w*e)/100 >= min_s)
		 {
				 sw=min_w + min_s;
				 sugar = min_s;	 
		
		 }
		 else if (max_w+min_s <= max && max_w*e/100 >= min_s )
		 {
			 sw = max_w + min_s;
			 sugar = min_s;
		 }
		 else 
		 {
			 sw=min_w;
		 }
		 
		 out.println(sw+" "+sugar);
		 
		 
	 
	 
	 }
	 static class InputReader {
	        public BufferedReader reader;
	        public 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());
	        }
	 
	        public long nextLong() {
	            return Long.parseLong(next());
	        }
	 
	        public double nextDouble() {
	            return Double.parseDouble(next());
	        }
	 
	        public String nextLine() {
	            try {
	                return reader.readLine();
	            } catch (Exception e) {
	                e.printStackTrace();
	            }
	            return null;
	        }
	 
	        public boolean hasNext() {
	            String next = null;
	            try {
	                next = reader.readLine();
	            } catch (Exception e) {
	            }
	            if (next == null) {
	                return false;
	            }
	            tokenizer = new StringTokenizer(next);
	            return true;
	        }
	 
	        public BigInteger nextBigInteger() {
	            return new BigInteger(next());
	        }
	        public int[] intArr() throws Exception {
	            String[] strarray = reader.readLine().trim().split(" ");
	            int[] intarray = new int[strarray.length];
	            for (int i = 0; i < intarray.length; i++) {
	                intarray[i] = Integer.parseInt(strarray[i]);
	            }
	            return intarray;
	        }
	     
	        /* long Array*/
	        public long[] longArr() throws Exception {
	            String[] strarray = reader.readLine().trim().split(" ");
	            long[] longarray = new long[strarray.length];
	            for (int i = 0; i < longarray.length; i++) {
	                longarray[i] = Long.parseLong(strarray[i]);
	            }
	            return longarray;
	    }
	}
}