func_code_string: #include <bits/stdc++.h>   using namespace std;   int a[41][1001][1001];   int bir(int n) {     int s = 0;     while (n > 0) {       s += n % 2;       n /= 2;     }     return s;   }   bool fun(int x, int i) {     if (i < 0) return 0;     return ((x >> i) & 1);   }   bool funk(int a, int b, int c, int m) {     for (int i = 0; i < m; i++) {       if (!(fun(a, i) || fun(b, i) || fun(c, i) || fun(b, i - 1) ||             fun(b, i + 1)))         return 1;     }     return 0;   }   int main() {     int n, m, i, j, msk, pmsk, tmsk, ans = 1e9;     cin >> n >> m;     if (n < m) swap(n, m);     for (i = 0; i <= n; i++) {       for (pmsk = 0; pmsk < (1 << m); pmsk++) {         for (msk = 0; msk < (1 << m); msk++) {           a[i][pmsk][msk] = 1e9;         }       }     }     for (i = 0; i < (1 << m); i++) a[0][0][i] = bir(i);     for (i = 1; i <= n; i++) {       for (pmsk = 0; pmsk < (1 << m); pmsk++) {         for (msk = 0; msk < (1 << m); msk++) {           for (tmsk = 0; tmsk < (1 << m); tmsk++) {             if (funk(tmsk, pmsk, msk, m)) continue;             a[i][pmsk][msk] =                 min(a[i][pmsk][msk], a[i - 1][tmsk][pmsk] + bir(msk));           }         }       }     }     for (i = 0; i < (1 << m); i++) {       ans = min(ans, a[n][i][0]);     }     cout << n * m - ans;   }   