#K13646. Uniform Rectangular Sub-grid Counter

    ID: 23959 Type: Default 1000ms 256MiB

Uniform Rectangular Sub-grid Counter

Uniform Rectangular Sub-grid Counter

Given a grid of characters, count the number of rectangular sub-grids (with at least 2 rows and 2 columns) in which all the characters are identical. A sub-grid is defined by choosing two distinct rows and two distinct columns, and considering the rectangle formed at their intersections.

Note: The grid is provided as N lines of input, where each line is a string of equal length. If the grid has less than 2 rows or less than 2 columns, the answer is 0.

Example:

Input:
3
aaa
aaa
aaa

Output: 9

Explanation: There are C(3,2)C(3,2) = 33 = 9 valid rectangular sub-grids in a 3x3 uniform grid.

</p>

inputFormat

The first line contains an integer N, the number of rows in the grid. Each of the next N lines contains a string representing a row of the grid. All rows have the same length.

outputFormat

Output a single integer representing the number of rectangular sub-grids with all identical characters and with at least 2 rows and 2 columns.

## sample
1
a
0