func_code_string: #include <bits/stdc++.h>   using namespace std;   int arr[2505][2505], sum[2505][2505], n, m;   int get_sum(int x1, int y1, int x2, int y2) {     x2 = min(x2, n);     y2 = min(y2, m);     assert(x1 <= x2);     assert(y1 <= y2);     return sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1];   }   int main() {     ios::sync_with_stdio(false);     ;     cin.tie(0);     ;     int i, j, k, ans = 100000000, ones, zeroes;     string s;     cin >> n >> m;     for (i = 1; i <= n; i++) {       cin >> s;       s =     + s;       for (j = 1; j <= m; j++) arr[i][j] = s[j] -  0 ;     }     for (i = 1; i <= n; i++) {       for (j = 1; j <= m; j++)         sum[i][j] = sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1] + arr[i][j];     }     for (k = 2; k <= max(n, m); k++) {       int got = 0;       for (i = 1; i <= n; i = i + k) {         for (j = 1; j <= m; j = j + k) {           ones = get_sum(i, j, i + k - 1, j + k - 1);           zeroes = k * k - ones;           got += min(ones, zeroes);         }       }       ans = min(ans, got);     }     cout << ans;     return 0;   }   