func_code_string: #include <bits/stdc++.h>   using namespace std;   const int di[] = {-1, 0, 1, 0};   const int dj[] = {0, 1, 0, -1};   const long long MOD = 1e9 + 7;   const long long INF = 1e9;   const double EPS = 1e-11;   int main() {     ios::sync_with_stdio(false), cin.tie(0);     int n, q, c;     cin >> n >> q >> c;     vector<pair<int, int> > pos(n);     vector<int> s(n);     vector<vector<vector<int> > > cnt(         101, vector<vector<int> >(101, vector<int>(c + 1)));     for (int i = 0; i < n; ++i) {       cin >> pos[i].first >> pos[i].second >> s[i];       cnt[pos[i].first][pos[i].second][s[i]]++;     }     for (int i = 0; i < 101; ++i) {       for (int j = 0; j < 101; ++j) {         for (int k = 0; k < c + 1; ++k) {           if (i > 0) cnt[i][j][k] += cnt[i - 1][j][k];           if (j > 0) cnt[i][j][k] += cnt[i][j - 1][k];           if (i > 0 && j > 0) cnt[i][j][k] -= cnt[i - 1][j - 1][k];         }       }     }     while (q--) {       int t, x1, y1, x2, y2;       cin >> t >> x1 >> y1 >> x2 >> y2;       vector<vector<int> > cum(4, vector<int>(11));       cum[0] = cnt[x2][y2];       cum[1] = cnt[x2][y1 - 1];       cum[2] = cnt[x1 - 1][y1 - 1];       cum[3] = cnt[x1 - 1][y2];       vector<int> cur(11), cur2(11);       for (int i = 0; i < c + 1; ++i)         cur[i] = cum[0][i] - cum[1][i] - cum[3][i] + cum[2][i];       for (int i = 0; i < c + 1; ++i) cur2[(i + t) % (c + 1)] = cur[i];       int r = 0;       for (int i = 0; i < c + 1; ++i) r += i * cur2[i];       cout << r << endl;     }   }   