Consider a matrix M with dimensions width height, such that every cell has value 0 or 1, and any square sub-matrix of M of size sideLength sideLength has at most maxOnes ones. Return the maximum possible number of ones that the matrix M can have.