The project of a new city involves the construction of a grid of size $$$n \times m$$$ cells. A house with $$$t_{i,j}$$$ residents will be located at the intersection of the $$$i$$$-th row and the $$$j$$$-th column.
Three houses in cells $$$(i, j)$$$, $$$(i + a, j)$$$ and $$$(i, j + b)$$$ form a good triangle suitable for a public transportation line if:
You can change the construction plan by increasing or decreasing all $$$t_{i,j}$$$ by the same integer $$$d$$$. If $$$t_{i,j}$$$ should become less than zero, consider it to be equal to zero. Let $$$T + d$$$ denote the matrix of values $$$t_{i,j} + d$$$, and let $$$\triangle(T + d)$$$ be the number of good triangles when the city is constructed accordingly.
Find $$$$$$\sum\limits_{d=-\infty}^{+\infty} \triangle(T + d) \text{,}$$$$$$ or in other words, the total number of good triangles for all possible construction plans.
The first line of input contains two integers $$$n$$$ and $$$m$$$ separated by a space, representing the number of rows and columns of the grid, respectively ($$$1 \le n, m \le 1000$$$).
In the $$$i$$$-th of the following $$$n$$$ lines, there are $$$m$$$ integers $$$t_{i,j}$$$ listed, representing the number of residents in each house of the $$$i$$$-th row of the grid ($$$1 \le t_{i,j} \le 10^9$$$).
Output a single integer, the number of sets of three cells that satisfy the given conditions.
Points for each subtask are awarded only if all tests of this subtask and the necessary subtasks are successfully passed.
| Subtask | Points | Constraints | Required subtasks |
| 0 | – | examples from the statement | |
| 1 | 8 | $$$t_{i,j} \le 2$$$ for all $$$i$$$, $$$j$$$ | |
| 2 | 13 | $$$n \le 2$$$ | |
| 3 | 17 | $$$n, m \le 50$$$, $$$t_{i,j} \le 50$$$ | 0 |
| 4 | 17 | $$$n, m \le 500$$$ | 0, 3 |
| 5 | 20 | $$$t_{i,j}$$$ are generated randomly and uniformly | 0 |
| 6 | 25 | none | 0 – 5 |
3 33 1 11 2 11 1 1
2
2 45 4 3 24 3 2 1
6
In this problem the input data size is large so it may be useful to use fast IO.
| Name |
|---|


