func_code_string: #include <bits/stdc++.h>   using namespace std;   int dp[41][1 << 7][1 << 7], num[1 << 7], vis[3][30], n, m;   void init() {     int i, j, k;     for (i = 0; i <= 40; i++) {       for (j = 0; j < 1 << 7; j++) {         for (k = 0; k < 1 << 7; k++) {           dp[i][j][k] = -11111111;         }       }     }   }   int get_zero(int x) {     int sum = 0, len = 0;     while (x) {       if (x % 2 == 0) sum++;       x /= 2;       len++;     }     return sum + m - len;   }   void gao(int index, int x) {     int ans = 0;     while (x) {       vis[index][ans++] = x % 2;       x /= 2;     }   }   int check(int up, int mid, int down, int a) {     int i, j, flag = 1;     memset(vis, 0, sizeof(vis));     gao(0, up), gao(1, mid), gao(2, down);     for (i = 0; i < m; i++) {       if (vis[1][i] == 1) continue;       if (i + 1 <= m - 1 && vis[1][i + 1] == 1) continue;       if (i - 1 >= 0 && vis[1][i - 1] == 1) continue;       if (vis[0][i] == 1) continue;       if (vis[2][i] == 1) continue;       flag = 0;       break;     }     return flag;   }   int main() {     init();     int up, mid, i, j, k, x;     scanf( %d %d , &n, &m);     if (n < m) swap(n, m);     for (i = 0; i <= (1 << m); i++) {       dp[0][0][i] = 0;       num[i] = get_zero(i);     }     int r = (1 << m);     for (i = 0; i < n; i++) {       for (j = 0; j < r; j++) {         for (k = 0; k < r; k++) {           for (x = 0; x < r; x++) {             if (check(j, k, x, i)) {               dp[i + 1][k][x] = max(dp[i + 1][k][x], dp[i][j][k] + num[k]);             }           }         }       }     }     int maxnum = -1;     for (i = 0; i < r; i++) {       maxnum = max(maxnum, dp[n][i][0]);     }     printf( %d n , maxnum);     return 0;   }   