func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, a[2001][2001], s1[2001], s2[2001], res = 0, d[2001];   string s;   int main() {     scanf( %d n , &n);     for (int i = 0; i < n; ++i) {       cin >> s;       for (int j = 0; j < n; ++j)         if (s[j] ==  0 )           a[i][j] = 0;         else           a[i][j] = 1;     }     memset(s1, 0, sizeof s1);     memset(s2, 0, sizeof s2);     memset(d, 0, sizeof d);     for (int J = n - 1; J > 0; --J) {       int i = 0, j = J;       while (j < n) {         if ((a[i][j] + s1[i] + s2[j]) % 2 == 1) {           s1[i] = (s1[i] + 1) % 2;           s2[j] = (s2[j] + 1) % 2;           d[i] = (d[i] + 1) % 2;           d[j] = (d[j] + 1) % 2;           a[i][j] = (a[i][j] + 1) % 2;           ++res;         }         ++i;         ++j;       }     }     memset(s1, 0, sizeof s1);     memset(s2, 0, sizeof s2);     for (int I = n - 1; I > 0; --I) {       int i = I, j = 0;       while (i < n) {         if ((a[i][j] + s1[i] + s2[j]) % 2 == 1) {           s1[i] = (s1[i] + 1) % 2;           s2[j] = (s2[j] + 1) % 2;           d[i] = (d[i] + 1) % 2;           d[j] = (d[j] + 1) % 2;           a[i][j] = (a[i][j] + 1) % 2;           ++res;         }         ++i;         ++j;       }     }     for (int i = 0; i < n; ++i)       if ((a[i][i] + d[i]) % 2) ++res;     cout << res;     return 0;   }   