func_code_string: #include <bits/stdc++.h>   using namespace std;   const int INF = 1000 * 1000 * 1000 + 9;   const long long MOD = 1000 * 1000 * 1000 + 7;   const double EPS = 1e-9;   const int di[] = {-1, 0, 1, 0};   const int dj[] = {0, -1, 0, 1};   const int N = 505;   int n, k;   int a[N][N];   int b[N][N];   int s[N][N];   int q;   int f[N * N];   int g[N * N];   int ans;   int mod;   void dfs(int x, int y, int c) {     b[x][y] = c;     g[c]++;     for (int i = 0; i < 4; ++i) {       int xx = x + di[i];       int yy = y + dj[i];       if (a[xx][yy] && !b[xx][yy]) {         dfs(xx, yy, c);       }     }   }   int main() {     scanf( %d%d , &n, &k);     for (int i = 0; i < n; ++i) {       for (int j = 0; j < n; ++j) {         char c;         scanf(  %c , &c);         a[i + 1][j + 1] = c ==  . ;       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         if (a[i][j] && !b[i][j]) {           dfs(i, j, ++q);         }       }     }     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= n; ++j) {         s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];       }     }     for (int i = 1; i + k - 1 <= n; ++i) {       for (int r = 0; r <= q; ++r) {         f[r] = 0;       }       mod = 0;       for (int u = i - 1; u <= i + k; ++u) {         for (int v = 0; v <= k + 1; ++v) {           if ((u == i - 1 || u == i + k) && (v == 0 || v == k + 1)) {             continue;           }           if (f[b[u][v]] == 0) {             mod += g[b[u][v]];           }           f[b[u][v]]++;         }       }       for (int j = 1; j + k - 1 <= n; ++j) {         ans = max(ans,                   mod + (k * k - (s[i + k - 1][j + k - 1] - s[i - 1][j + k - 1] -                                   s[i + k - 1][j - 1] + s[i - 1][j - 1])));         if (j + k - 1 < n) {           for (int u = i - 1; u <= i + k; ++u) {             int x = b[u][j - 1 + (u == i - 1 || u == i + k)];             --f[x];             if (f[x] == 0) {               mod -= g[x];             }           }           for (int u = i - 1; u <= i + k; ++u) {             int x = b[u][j + k + 1 - (u == i - 1 || u == i + k)];             if (f[x] == 0) {               mod += g[x];             }             ++f[x];           }         }       }     }     printf( %d n , ans);     return 0;   }   