Problem:
Score : 500 points

Problem Statement

We have a grid of squares with N rows and M columns. Let (i, j) denote the square at the i-th row from the top and j-th column from the left. We will choose K of the squares and put a piece on each of them.

If we place the K pieces on squares (x_1, y_1), (x_2, y_2), ..., and (x_K, y_K), the cost of this arrangement is computed as:

\sum_{i=1}^{K-1} \sum_{j=i+1}^K (|x_i - x_j| + |y_i - y_j|)

Find the sum of the costs of all possible arrangements of the pieces. Since this value can be tremendous, print it modulo 10^9+7.

We consider two arrangements of the pieces different if and only if there is a square that contains a piece in one of the arrangements but not in the other.

Constraints

2 \leq N \times M \leq 2 \times 10^5

2 \leq K \leq N \times M

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M K

Output

Print the sum of the costs of all possible arrangements of the pieces, modulo 10^9+7.

Sample Input 1

2 2 2

Sample Output 1

8

There are six possible arrangements of the pieces, as follows:

((1,1),(1,2)), with the cost |1-1|+|1-2| = 1

((1,1),(2,1)), with the cost |1-2|+|1-1| = 1

((1,1),(2,2)), with the cost |1-2|+|1-2| = 2

((1,2),(2,1)), with the cost |1-2|+|2-1| = 2

((1,2),(2,2)), with the cost |1-2|+|2-2| = 1

((2,1),(2,2)), with the cost |2-2|+|1-2| = 1

The sum of these costs is 8.

Sample Input 2

4 5 4

Sample Output 2

87210

Sample Input 3

100 100 5000

Sample Output 3

817260251

Be sure to print the sum modulo 10^9+7.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <iostream>

using namespace std;

const int MOD = 1e9 + 7, MAX_N = 2e5 + 5;
long long factorial[MAX_N + 1], inverse_factorial[MAX_N + 1];

long long power_mod(long long x, long long power)
{
    long long result = 1;

    while(power > 0)
    {
        if(power%2)
            result = (result*x)%MOD;

        x = (x*x)%MOD;
        power = power >> 1;
    }

    return result;
}

long long inverse(long long n)
{
    return power_mod(n, MOD - 2);
}

void precompute_factorial()
{
    factorial[0] = 1;
    for(int i = 1; i <= MAX_N; i++)
        factorial[i] = (i*factorial[i - 1])%MOD;

    inverse_factorial[MAX_N] = inverse(factorial[MAX_N]);
    for(int i = MAX_N - 1; i >= 0; i--)// i (i - 1)! = i! => (i!)^ = i^ (i - 1)^ => (i!)^ i = (i - 1)^
        inverse_factorial[i] = ((i + 1)*inverse_factorial[i + 1])%MOD;
}

long long combinations(long long n, long long r)
{
    long long numerator = factorial[n];
    long long inverse_denominator = (inverse_factorial[r]*inverse_factorial[n - r])%MOD;

    return (numerator*inverse_denominator)%MOD;
}

int main()
{
    precompute_factorial();

    long long rows, columns, k;
    cin >> rows >> columns >> k;

    long long no_of_times_each_pair_is_counted = combinations(rows*columns - 2, k - 2);

    long long x_contribution = 0;
    for(int i = 1; i <= rows; i++)
    {
        long long x = i;

        long long one_x_contribution = (columns*(i - 1)*x - columns*(rows - i)*x)%MOD;

        x_contribution += (columns*one_x_contribution)%MOD;// cout << " X = " << x_contribution << endl;
    }

    long long y_contribution = 0;
    for(int i = 1; i <= columns; i++)
    {
        long long y = i;

        long long one_y_contribution = (rows*(i - 1)*y - rows*(columns - i)*y)%MOD;

        y_contribution += (rows*one_y_contribution)%MOD; //cout << " Y = " << y_contribution << endl;
    }

    long long sum_pair_distance = (x_contribution + y_contribution)%MOD;// cout << "N = " << no_of_times_each_pair_is_counted << " S = " << sum_pair_distance << endl;

    long long answer = (no_of_times_each_pair_is_counted*sum_pair_distance)%MOD;

    cout << answer;
    return 0;
}