Problem:
Score : 100 points

Problem Statement

There are H rows and W columns of white square cells.

You will choose h of the rows and w of the columns, and paint all of the cells contained in those rows or columns.

How many white cells will remain?

It can be proved that this count does not depend on what rows and columns are chosen.

Constraints

All values in input are integers.

1 \leq H, W \leq 20

1 \leq h \leq H

1 \leq w \leq W

Input

Input is given from Standard Input in the following format:

H W
h w

Output

Print the number of white cells that will remain.

Sample Input 1

3 2
2 1

Sample Output 1

1

There are 3 rows and 2 columns of cells. When two rows and one column are chosen and painted in black, there is always one white cell that remains.

Sample Input 2

5 5
2 3

Sample Output 2

6

Sample Input 3

2 4
2 4

Sample Output 3

0

Solution in C# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Linq;
class Proplem
{
    static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int M = int.Parse(input[1]);
        long[] a = new long[N];
        long[] b = new long[N];
        int i;

        for (i = 0; i < N; i++)
        {
            input = Console.ReadLine().Split(' ');
            a[i] = long.Parse(input[0]);
            b[i] = long.Parse(input[1]);
        }

        long sum = 0;
        long ans=0;
        long x=1;

        do
        {
            i = Array.IndexOf(a, a.Min());
            sum += b[i];
            ans = ans+ a[i] * b[i];
            if (sum >= M)
            {
                x = a[i];
            }
            a[i] = a.Max();
        } while (sum < M);

        ans = ans - (sum - M) * x;
        Console.WriteLine(ans);
    }
}