func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 1e3 + 5;   const long long Q = 3e5 + 5;   char w[N][N];   char x[Q];   long long l[Q], r[Q];   long long u[Q], d[Q];   long long f[N][N];   long long c[N][N][26];   signed main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     long long n;     cin >> n;     long long m;     cin >> m;     long long k;     cin >> k;     for (long long i = 1; i <= n; ++i)       for (long long j = 1; j <= m; ++j) cin >> w[i][j];     for (long long i = 1; i <= k; ++i) {       cin >> l[i] >> u[i];       cin >> r[i] >> d[i];       cin >> x[i];       x[i] -=  a ;       ++r[i];       ++d[i];       c[l[i]][u[i]][x[i]]++;       c[l[i]][d[i]][x[i]]--;       c[r[i]][u[i]][x[i]]--;       c[r[i]][d[i]][x[i]]++;     }     for (long long i = 1; i <= n; ++i)       for (long long j = 1; j <= m; ++j)         for (long long t = 0; t < 26; ++t)           c[i][j][t] -= c[i - 1][j - 1][t], c[i][j][t] += c[i - 1][j][t],               c[i][j][t] += c[i][j - 1][t];     for (long long i = 1; i <= n; ++i)       for (long long j = 1; j <= m; ++j) {         c[i][j][w[i][j] -  a ] = k;         for (long long t = 0; t < 26; ++t)           if (t != w[i][j] -  a ) c[i][j][w[i][j] -  a ] -= c[i][j][t];         for (long long t = 0; t < 26; ++t)           f[i][j] += c[i][j][t] * abs(w[i][j] -  a  - t);       }     for (long long i = 1; i <= n; ++i)       for (long long j = 1; j <= m; ++j) {         f[i][j] -= f[i - 1][j - 1];         f[i][j] += f[i - 1][j];         f[i][j] += f[i][j - 1];         for (long long t = 0; t < 26; ++t)           c[i][j][t] -= c[i - 1][j - 1][t], c[i][j][t] += c[i - 1][j][t],               c[i][j][t] += c[i][j - 1][t];       }     long long ans = 1e18;     for (long long i = 1; i <= k; ++i) {       l[i]--;       r[i]--;       u[i]--;       d[i]--;       long long cur = f[n][m];       cur -= f[r[i]][d[i]];       cur += f[r[i]][u[i]];       cur += f[l[i]][d[i]];       cur -= f[l[i]][u[i]];       for (long long t = 0; t < 26; ++t)         cur += (c[r[i]][d[i]][t] - c[r[i]][u[i]][t] - c[l[i]][d[i]][t] +                 c[l[i]][u[i]][t]) *                abs(x[i] - t);       ans = min(ans, cur);     }     cout << ans << endl;   }   