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;
class MainClass
{
    public static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int x = int.Parse(input[1]);
        string[] inputa = Console.ReadLine().Split(' ');
        int ans = 0;

        for (int i = 0; i < n-1;i++)
        {
            for (int j = n-1;j > i;j--)
            {
                if(int.Parse(inputa[j]) <=int.Parse(inputa[j-1]))
                {
                    string t = inputa[j];
                    inputa[j] = input[j - 1];
                    inputa[j - 1] = t;
                }
            }
        }
        for (int i = 0; i < n;i++)
        {
            if(int.Parse(inputa[i]) <= x )
            {
                ans++;
                x -= int.Parse(inputa[i]);
            }
            else
            {
                break;
            }
        }

        Console.WriteLine(ans);
    }
}