Triangles counting - MarisaOJ: Marisa Online Judge

Triangles counting

Time limit: 1000 ms
Memory limit: 256 MB
Given a coordinate grid of size $n \times m$, count the number of triplets of points on the grid such that the three points form a triangle. In other words, count the number of sets of points $A(x_A, y_A), B(x_B,y_B), C(x_C,y_C)$ where $1 \le x_i \le n$ and $1 \le y_i \le m$, and the three points form a triangle. ### Input - A single line containing two integers $n, m$. ### Output - Print the number of triplets of points. ### Constraints - $1 \le n,m \le 1000$. ### Sample test Input ``` 2 3 ``` Output: ``` 18 ```