Find the number of corner rectangles that can be formed from given Matrix

  #include using namespace std;  int countCornerRectangles(    vector& mat){        int count = 0;      int N = mat.size();    int M = mat[0].size();          map m;          for (int i = 0; i < N; i++) {                  for (int j = 0; j < M; j++) {            if (mat[i][j] == 1) {                                                  for (int k = j + 1;                     k < M; k++) {                    if (mat[i][k] == 1) {                        m[{ j, k }]++;                    }                }            }        }    }                  for (auto& it : m) {        count            += (it.second * (it.second - 1)) / 2;    }      return count;}  int main(){    vector mat        = { { 1, 1, 1 }, { 1, 1, 1 }, { 1, 1, 1 } };      cout