func_code_string: #include <bits/stdc++.h>   using namespace std;   int dp[10][300];   int s[10][10];   int main() {     int n, m;     cin >> n >> m;     for (int i = 0; i < int(n); ++i)       for (int j = 0; j < int(m); ++j) cin >> s[i][j];     int *cur = dp[0], *next = dp[1];     for (int i = n - 1; i >= 0; --i) {       for (int j = m - 1; j >= 0; --j) {         for (int used = 0; used < int(1 << m); ++used) {           if (used & (1 << j)) {             next[used] = cur[used & ~(1 << j)];           } else {             int best = 0;             if (j + 1 < m && !(used & (1 << (j + 1))))               best = max(best,                          cur[used | (1 << (j + 1))] + (s[i][j] == s[i][j + 1]));             if (i + 1 < n)               best = max(best, cur[used | (1 << j)] + (s[i][j] == s[i + 1][j]));             next[used] = best;           }         }         swap(cur, next);       }     }     cout << n * m / 2 - cur[0] << endl;   }   