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;
using System.Collections.Generic;

class Cmondai
{
    static void Main()
    {
        var line = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
        var A = line[0];
        var B = line[1];
        var C = line[2];
        var D = line[3];
        var E = line[4];
        var F = line[5];
        
        double max = -1;
        double maxSugarWater =0;
        double maxSugar = 0;
        
        var waterAmax = F / (A * 100);
        for (int i = 0; i <= waterAmax; ++i)
        {
            var bCount = (F - (A * i * 100)) / (B * 100);
            for (int j = 0; j <= bCount; ++j)
            {
                if (i == 0 && j == 0) continue;
                if (F < (A * i + B * j) * 100) break;
                
                var cCount = (F - (A * i * 100 + B * j * 100)) / C;
                for (int k = 0; k < cCount; ++k)
                {
                    if (F < (A * i + B * j) * 100 + C * k) break;

                    var dCount = (F - ((A * i * 100 + B * j * 100) + C * k)) / D;
                    for (int l = 0; l < dCount; ++l)
                    {
                        if (F < (A * i + B * j) * 100 + C * k + D * l) break;

                        if ((C * k + D * l) <= (i*A + j*B) * E)
                        {
                            var sugarWater = (A * i)*100 + (B * j)*100 + C * k + D * l;
                            var sugar = C * k + D * l;

                            var concentration = sugar == 0 ? 0 : sugar / sugarWater * 100;

                            if (max < concentration)
                            {
                                max = concentration;
                                maxSugarWater = sugarWater;
                                maxSugar = sugar;
                            }
                        }
                    }
                }
            }
        }
        Console.WriteLine($"{maxSugarWater} {maxSugar}");
    }
}