func_code_string: #include <bits/stdc++.h>   using namespace std;   using ll = long long;   using ld = long double;   using pii = pair<int, int>;   const int N = 1000 + 20;   int n, m, q, part[N][N];   string s[N];   inline int get(int x) { return (__builtin_popcount(x) & 1 ? -1 : +1); }   inline int get(int x, int y) { return get(x) * get(y); }   inline pii calc(int x) {     int a = x / 2, b = x / 2;     if (x & 1) {       if (get(x - 1) == 1)         a++;       else         b++;     }     return pii(a, b);   }   inline pii calc(int x, int y) {     pii p1 = calc(x), p2 = calc(y);     return pii(p1.first * p2.first + p1.second * p2.second,                p1.first * p2.second + p1.second * p2.first);   }   inline int f(int x, int y) {     int res = 0;     int X = x / n, Y = y / m;     x %= n, y %= m;     pii p = calc(X, Y);     res += part[n][m] * p.first + (n * m - part[n][m]) * p.second;     p = calc(X);     if (get(Y) == -1) swap(p.first, p.second);     res += part[n][y] * p.first + (n * y - part[n][y]) * p.second;     p = calc(Y);     if (get(X) == -1) swap(p.first, p.second);     res += part[x][m] * p.first + (x * m - part[x][m]) * p.second;     if (get(X, Y) == 1)       res += part[x][y];     else       res += (x * y - part[x][y]);     return res;   }   int32_t main() {     ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);     cin >> n >> m >> q;     for (int i = 0; i < n; i++) {       cin >> s[i];       for (int j = 0; j < m; j++) {         part[i + 1][j + 1] =             (s[i][j] ==  1 ) + part[i][j + 1] + part[i + 1][j] - part[i][j];       }     }     while (q--) {       int x1, hlkhjl, x2, y2;       cin >> x1 >> hlkhjl >> x2 >> y2;       x1--, hlkhjl--;       cout << f(x2, y2) - f(x1, y2) - f(x2, hlkhjl) + f(x1, hlkhjl) <<   n ;     }   }   