Time limit
2s
Memory limit
128 MB
A triangle is isosceles if two of its side lengths are equal.
There are lattice points arranged in N rows and M columns. The three vertices of a triangle must be distinct lattice points, and three collinear points do not form a triangle.
Two triangles are different if at least one vertex position differs. Count how many different isosceles triangles can be formed from the given lattice points.
The first line contains two positive integers N and M separated by a space. Both N and M are at most 200.
Print the number of different isosceles triangles.
For a 2 by 3 grid of lattice points, the following 10 arrangements are possible.
XX. XX. .X. X.. X.XX.. .X. XX. XX. .X.
.XX .XX ..X .X. .X..X. ..X .XX .XX X.XXX. XX. .X. X.. X.XX.. .X. XX. XX. .X.
.XX .XX ..X .X. .X..X. ..X .XX .XX X.X