Problem p03762 - Generation 2

Orig Description

Score : 500 points
Problem StatementOn a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.
Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.
Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.
For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.
That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.
Constraints
2 \leq n,m \leq 10^5
-10^9 \leq x_1 < ... < x_n \leq 10^9
-10^9 \leq y_1 < ... < y_m \leq 10^9
x_i and y_i are integers.
InputInput is given from Standard Input in the following format:
n m
x_1 x_2 ... x_n
y_1 y_2 ... y_m
OutputPrint the total area of the rectangles, modulo 10^9+7.
Sample Input 13 3
1 3 4
1 3 6
Sample Output 160
The following figure illustrates this input:
The total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.
Sample Input 26 5
-790013317 -192321079 95834122 418379342 586260100 802780784
-253230108 193944314 363756450 712662868 735867677
Sample Output 2835067060

Extracted Specification

An integer n (2 ≤ n ≤ 10^5), representing some quantity or size.
An integer m (2 ≤ m ≤ 10^5), representing some quantity or size.
A list of n integers \(x\), where each integer is between -10^9 and 10^9, in ascending order.
A list of m integers \(y\), where each integer is between -10^9 and 10^9, in ascending order.

### Example Input:
```
3 3
1 3 4
1 3 6
```

### Function Signature:
Write a function f(n, m, x, y) that takes in the input.
```python
def f(n: int, m: int, x: List[int], y: List[int]):
    '''
    n: an integer
    m: an integer
    x: a list of integers
    y: a list of integers
    '''
```

Test Case Generator

Sure, let's write a test case generator for the given problem statement. The key points to consider are generating random but sorted lists of x-coordinates and y-coordinates while ensuring the constraints are respected.

Below is the test case generator:

```python
import random

def tcgen():
    # Constants
    MOD = 10**9 + 7
    
    # Generate random values for n and m
    n = random.randint(2, 10**5)
    m = random.randint(2, 10**5)
    
    # Generate sorted list of x-coordinates
    x = sorted(random.randint(-10**9, 10**9) for _ in range(n))
    
    # Generate sorted list of y-coordinates
    y = sorted(random.randint(-10**9, 10**9) for _ in range(m))
    
    return n, m, x, y

# Example usage:
n, m, x, y = tcgen()
print(n, m)
print(" ".join(map(str, x)))
print(" ".join(map(str, y)))
```

### Explanation:

1. **Import the random module**: This is used to generate random integers.
2. **Define the `tcgen` function**: This function generates the test cases as per the given problem constraints.
3. **Generate `n` and `m`**: We generate random integers for `n` and `m` within the specified range [2, 10^5].
4. **Generate `x` and `y` lists**: We create lists of integers for `x` and `y` coordinates. The lists are generated using a comprehension, ensuring each coordinate is within the range [-10^9, 10^9]. The lists are then sorted to maintain the required order.
5. **Return the generated values**: The function returns the values of `n`, `m`, `x`, and `y`.

The `print` statements at the end show an example of how the generated test case can be printed. This is useful for quickly verifying the output format. Note that the generator ensures all constraints are respected, including the sorting of coordinates and the specified bounds.

You can call `tcgen()` to generate as many test cases as you need for testing your competitive programming problem.

Extract Arguments

def extract_arguments(fh):
    n, m = map(int, fh.readline().strip().split())
    x = list(map(int, fh.readline().strip().split()))
    y = list(map(int, fh.readline().strip().split()))
    return n, m, x, y