func_code_string: #include <bits/stdc++.h>   using namespace std;   const int ppr = 257;   const long long INF = 2e18;   const int inf = 2e9;   const int mod = 1e9 + 7;   const int N = 1e6 + 123;   const long double pi = 3.141592653589793238462643;   const int dx[] = {1, 0, -1, 0};   const int dy[] = {0, 1, 0, -1};   int n, dp[55][55][55][55], a[55][55], p[55][55];   bool u[55][55][55][55];   inline int get(int x1, int aza_ibagaliev, int x2, int y2) {     return p[x2][y2] - p[x2][aza_ibagaliev - 1] - p[x1 - 1][y2] +            p[x1 - 1][aza_ibagaliev - 1];   }   int calc(int x1, int aza_ibagaliev, int x2, int y2) {     if (u[x1][aza_ibagaliev][x2][y2]) return dp[x1][aza_ibagaliev][x2][y2];     u[x1][aza_ibagaliev][x2][y2] = 1;     dp[x1][aza_ibagaliev][x2][y2] = max((x2 - x1 + 1), (y2 - aza_ibagaliev + 1)) *                                     (get(x1, aza_ibagaliev, x2, y2) > 0);     for (int i = x1; i < x2; i++) {       dp[x1][aza_ibagaliev][x2][y2] = min(           dp[x1][aza_ibagaliev][x2][y2],           calc(x1, aza_ibagaliev, i, y2) + calc(i + 1, aza_ibagaliev, x2, y2));     }     for (int i = aza_ibagaliev; i < y2; i++) {       dp[x1][aza_ibagaliev][x2][y2] =           min(dp[x1][aza_ibagaliev][x2][y2],               calc(x1, aza_ibagaliev, x2, i) + calc(x1, i + 1, x2, y2));     }     return dp[x1][aza_ibagaliev][x2][y2];   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n;     for (int i = 1; i <= n; i++)       for (int j = 1; j <= n; j++) {         char c;         cin >> c;         a[i][j] = (c ==  # );         p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + a[i][j];       }     cout << calc(1, 1, n, n);     return 0;   }   