func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 505;   int cnt[N * N], par[N][N], sum[N][N], sz[N * N];   char grid[N][N];   int n, k;   int cur = 0;   void change(int id, int add) {     if (id == 0) return;     if (cnt[id]) cur -= sz[id];     cnt[id] += add;     if (cnt[id]) cur += sz[id];   }   void paint(int r, int c, int col) {     if (r < 1 || c < 1 || r > n || c > n) return;     if (grid[r][c] !=  . ) return;     if (par[r][c] != 0) return;     par[r][c] = col;     ++sz[col];     paint(r - 1, c, col);     paint(r + 1, c, col);     paint(r, c - 1, col);     paint(r, c + 1, col);   }   int inside(int r, int c) {     return sum[r + k - 1][c + k - 1] - sum[r - 1][c + k - 1] -            sum[r + k - 1][c - 1] + sum[r - 1][c - 1];   }   int main() {     cin >> n >> k;     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j) scanf(  %c , &grid[i][j]);     for (int i = 1; i <= n; ++i)       for (int j = 1; j <= n; ++j)         if (grid[i][j] ==  . ) {           if (par[i][j] == 0) {             paint(i, j, i * n + j);           }         }     for (int i = 1; i < N; ++i)       for (int j = 1; j < N; ++j)         sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] +                     (grid[i][j] !=  . );     int ans = 0;     for (int i = 1; i <= n - k + 1; ++i) {       memset(cnt, 0, sizeof(cnt));       cur = 0;       for (int r = i - 1; r <= i + k; ++r)         for (int c = 0; c <= k + 1; ++c) change(par[r][c], 1);       change(par[i - 1][k + 1], -1);       change(par[i + k][k + 1], -1);       ans = max(ans, cur + inside(i, 1));       for (int j = 2; j <= n - k + 1; ++j) {         for (int r = i - 1; r <= i + k; ++r) {           change(par[r][j + k], 1);         }         change(par[i - 1][j + k - 1], +1);         change(par[i + k][j + k - 1], +1);         change(par[i - 1][j - 2], +1);         change(par[i + k][j - 2], +1);         for (int r = i - 1; r <= i + k; ++r) {           change(par[r][j - 2], -1);         }         change(par[i - 1][j + k], -1);         change(par[i + k][j + k], -1);         change(par[i - 1][j - 1], -1);         change(par[i + k][j - 1], -1);         ans = max(ans, cur + inside(i, j));       }     }     cout << ans <<   n ;   }   