func_code_string: #include <bits/stdc++.h>   const int N = 1123;   const double eps = 1e-6;   const int inf = (int)1e9 + 123;   using namespace std;   int n, m;   char a[N][N];   int mini = inf;   int d[N][N];   int sum(int x, int y, int x2, int y2) {     return d[x2][y2] - d[x - 1][y2] - d[x2][y - 1] + d[x - 1][y - 1];   }   bool check(int x, int y, int sx, int sy) {     if (sum(sx, sy, sx + x - 1, sy + y - 1) != x * y) return 0;     int sz = sum(sx, sy, sx + x - 1, sy + y - 1);     while (1) {       if (sx + x <= n && sum(sx + x, sy, sx + x, sy + y - 1) == y) {         sx++;         sz += y;         continue;       }       if (sy + y <= m && sum(sx, sy + y, sx + x - 1, sy + y) == x) {         if (sum(sx, sy + y, sx + x - 1, sy + y) != x) return 0;         sy++;         sz += x;         continue;       }       break;     }     if (d[n][m] != sz) return 0;     return 1;   }   int main() {     cin >> n >> m;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= m; j++) {         cin >> a[i][j];         d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] +                   (a[i][j] ==  X  ? 1 : 0);       }     int x = -1, y = -1;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++)         if (a[i][j] ==  X ) {           x = i;           y = j;           break;         }       if (x != -1) break;     }     if (x == -1) {       cout << -1;       return 0;     }     int cnt = 0;     for (int i = x; i <= n; i++) {       if (a[i][y] ==  X )         cnt++;       else         break;     }     for (int i = 1; i <= m; i++)       if (y + i - 1 <= m && check(cnt, i, x, y) && mini > cnt * i) mini = cnt * i;     cnt = 0;     for (int i = y; i <= m; i++) {       if (a[x][i] ==  X )         cnt++;       else         break;     }     for (int i = 1; i <= n; i++)       if (x + i - 1 <= m && check(i, cnt, x, y) && mini > i * cnt) mini = i * cnt;     if (mini == inf) mini = -1;     cout << mini;     return 0;   }   