func_code_string: #include <bits/stdc++.h>   using namespace std;   char c[503][503];   vector<pair<int, int> > v[503][503];   int main() {     int n, m, k;     cin >> n >> m >> k;     int s = 0;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         cin >> c[i][j];         if (c[i][j] ==  . ) s++;       }     }     pair<int, int> st;     for (int i = 1; i <= n; i++) {       for (int j = 1; j <= m; j++) {         if (c[i][j] ==  . ) {           st.first = i;           st.second = j;           if (c[i - 1][j] == c[i][j]) {             v[i][j].push_back(make_pair(i - 1, j));           }           if (c[i + 1][j] == c[i][j]) {             v[i][j].push_back(make_pair(i + 1, j));           }           if (c[i][j - 1] == c[i][j]) {             v[i][j].push_back(make_pair(i, j - 1));           }           if (c[i][j + 1] == c[i][j]) {             v[i][j].push_back(make_pair(i, j + 1));           }         }       }     }     queue<pair<int, int> > q;     q.push(st);     int num = s - k;     if (num) {       c[st.first][st.second] =  q ;       num--;     }     while (!q.empty()) {       pair<int, int> tp = q.front();       q.pop();       for (pair<int, int> kom : v[tp.first][tp.second]) {         if (c[kom.first][kom.second] ==  .  && num > 0) {           c[kom.first][kom.second] =  q ;           num--;           q.push(make_pair(kom.first, kom.second));         }       }     }     for (int i = 1; i < n + 1; i++) {       for (int j = 1; j <= m; j++) {         if (c[i][j] ==  q )           cout <<  . ;         else if (c[i][j] ==  .  && k)           cout <<  X ;         else           cout << c[i][j];       }       cout << endl;     }   }   