func_code_string: #include <bits/stdc++.h>   using namespace std;   const int ma = 35;   int n, m, mat[ma][ma];   int main() {     int t;     scanf( %d , &t);     int ans, one, zero;     int sum, temp;     int l, r;     while (t--) {       scanf( %d%d , &n, &m);       one = zero = 0;       for (int i = 1; i <= n; i++)         for (int j = 1; j <= m; j++) {           scanf( %d , &mat[i][j]);           if (mat[i][j])             one++;           else             zero++;         }       ans = min(zero, one);       zero = one = sum = 0;       if (m > n) {         l = 1, r = m;         while (1) {           temp = one = zero = 0;           while ((1 + temp <= n) && (l - temp >= 1)) {             if (mat[1 + temp][l - temp])               one++;             else               zero++;             temp++;           }           temp--;           if ((1 + temp == n) && (l - temp == r)) break;           temp = 0;           while ((n - temp >= 1) && (r + temp <= m)) {             if (mat[n - temp][r + temp])               one++;             else               zero++;             temp++;           }           sum += min(zero, one);           if ((l + 1) == r + temp - 1) break;           l++, r--;         }       } else {         l = 1, r = n;         while (1) {           temp = one = zero = 0;           while (l - temp >= 1 && 1 + temp <= m) {             if (mat[l - temp][1 + temp])               one++;             else               zero++;             temp++;           }           temp--;           if (l - temp == r && 1 + temp == m) break;           temp = 0;           while (r + temp <= n && m - temp >= 1) {             if (mat[r + temp][m - temp])               one++;             else               zero++;             temp++;           }           sum += min(zero, one);           if (l + 1 == r + temp - 1) break;           l++, r--;         }       }       printf( %d n , min(ans, sum));     }     return 0;   }   