func_code_string: #include <bits/stdc++.h>   using namespace std;   const double PI = 2.0 * acos(0.0);   const int INF = 1000 * 1000 * 1000;   const int maxn = 1100;   int W, H, N, M, cnt, tot;   char g[maxn][maxn];   int upp[maxn][maxn], lf[maxn][maxn];   bool can;   void play(int x, int y) {     if (x == N || y == M) return;     bool r, d;     if (y + 1 < M && upp[x][y + 1] >= H)       r = true;     else       r = false;     if (x + 1 < N && lf[x + 1][y] >= W)       d = true;     else       d = false;     if (r && d)       can = false;     else if (r) {       cnt += H;       play(x, y + 1);     } else if (d) {       cnt += W;       play(x + 1, y);     }   }   int solve(int maxVal, int coefh, int coefw, int sx, int sy) {     for (int len = 1; len <= maxVal; len++) {       W += (coefw);       H += (coefh);       bool all = true;       for (int k = 0; k < H && all; k++)         for (int t = 0; t < W && all; t++) {           if (g[k + sx][t + sy] !=  X ) all = false;         }       if (!all) continue;       can = true;       cnt = H * W;       play(sx + H - 1, sy + W - 1);       if (can && cnt == tot) return H * W;     }     return -1;   }   int main() {     ios_base::sync_with_stdio(false);     int i, j, k;     cin >> N >> M;     int sx = -1, sy;     tot = 0;     W = H = 0;     for (int i = 0; i < N; i++)       for (int j = 0; j < M; j++) {         cin >> g[i][j];         if (g[i][j] ==  X ) tot++;         if (g[i][j] ==  X  && sx == -1) {           sx = i, sy = j;         }       }     memset(upp, 0, sizeof upp);     memset(lf, 0, sizeof lf);     for (int i = 0; i < M; i++) upp[0][i] = (g[0][i] ==  X  ? 1 : 0);     for (int i = 0; i < N; i++) lf[i][0] = (g[i][0] ==  X  ? 1 : 0);     for (int i = 0; i < N; i++)       for (int j = 0; j < M; j++) {         if (i != 0 && g[i][j] ==  X ) upp[i][j] = upp[i - 1][j] + 1;         if (j != 0 && g[i][j] ==  X ) lf[i][j] = lf[i][j - 1] + 1;       }     int w = 0, h = 0;     for (int i = sy; i < M && g[sx][i] ==  X ; i++) w++;     for (int i = sx; i < N && g[i][sy] ==  X ; i++) h++;     int coefh = 0, coefw = 0;     int ans;     W = w, H = 0;     ans = solve(h, 1, 0, sx, sy);     W = 0, H = h;     int ans2 = solve(w, 0, 1, sx, sy);     if (ans == -1 || (ans2 != -1 && ans2 < ans)) ans = ans2;     cout << ans << endl;     return 0;   }   