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 C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Linq;
public class c
{
  public static void Main()
  {
    int[] abcdef = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    int sumwater = 0;
    int sumsuger=0;
    double maxwater=(double)abcdef[5]*100/(100+abcdef[4]);
    double maxsuger=(double)abcdef[5]*abcdef[4]/(100+abcdef[4]);
    double maxpercent=maxsuger/(maxsuger+maxwater);
    double percent=0;
    int answater=0;
    int anssuger=0;
    int i,j,k,l;
    for(i=0;i*abcdef[0]*100<=maxwater;i++)
    {
      for(j=0;j*abcdef[1]*100<=maxwater;j++)
      {
        for(k=0;k*abcdef[2]<=maxsuger;k++)
        {
          for(l=0;l*abcdef[3]<=maxsuger;l++)
          {
            sumsuger=(abcdef[2]*k+abcdef[3]*l);
            sumwater=(abcdef[0]*i+abcdef[1]*j)*100;
            if(sumsuger+sumwater==0||sumwater==0)break;
            if(sumsuger<=maxpercent*(sumsuger+sumwater)&&sumsuger>percent*(sumsuger+sumwater)&&sumsuger+sumwater<abcdef[5])
            {
              percent=(double)sumsuger/(sumsuger+sumwater);
              answater=sumwater;
              anssuger=sumsuger;     
            }
          }
        }
      }
    }
    Console.WriteLine((anssuger+answater)+" "+anssuger);
  }
}