func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 100110;   const int maxm = 100010;   char s[maxn][5];   long long sum[maxm * 4][5][11];   int n;   void init() {     for (int i = 1; i < maxn; i++)       for (int z = 2; z <= 6; z++) {         int tp = i % (2 * (z - 1));         if (tp == 0)           s[i][z - 2] = 2;         else if (tp <= z)           s[i][z - 2] = tp;         else           s[i][z - 2] = 2 * z - tp;       }   }   void build(int pos, int l, int r) {     for (int i = 2; i <= 6; i++)       for (int j = 0; j <= 10; j++) sum[pos][i - 2][j] = 0;     if (l == r) return;     int mid = (l + r) >> 1;     build((pos << 1), l, mid);     build(((pos << 1) | 1), mid + 1, r);   }   void insert(int pos, int l, int r, int i, int a) {     if (i < l || i > r) return;     if (l == r) {       for (int z = 2; z <= 6; z++)         for (int j = 0; j <= 10; j++)           sum[pos][z - 2][j] = (long long)s[i + j][z - 2] * a;       return;     }     int mid = (l + r) >> 1;     insert((pos << 1), l, mid, i, a);     insert(((pos << 1) | 1), mid + 1, r, i, a);     for (int z = 2; z <= 6; z++)       for (int j = 0; j <= 10; j++)         sum[pos][z - 2][j] =             sum[(pos << 1)][z - 2][j] + sum[((pos << 1) | 1)][z - 2][j];   }   long long search(int pos, int l, int r, int x, int y, int z, int offset) {     if (y < l || r < x) return 0;     if (x <= l && r <= y) return sum[pos][z - 2][offset];     int mid = (l + r) >> 1;     return search((pos << 1), l, mid, x, y, z, offset) +            search(((pos << 1) | 1), mid + 1, r, x, y, z, offset);   }   int main() {     init();     while (~scanf( %d , &n)) {       build(1, 1, n);       for (int i = 1; i <= n; i++) {         int a;         scanf( %d , &a);         insert(1, 1, n, i, a);       }       int m;       scanf( %d , &m);       while (m-- > 0) {         int t, p, v, l, r, z;         scanf( %d , &t);         if (t == 1) {           scanf( %d%d , &p, &v);           insert(1, 1, n, p, v);         } else {           scanf( %d%d%d , &l, &r, &z);           int offset = 0;           if (s[l][z - 2] <= s[l + 1][z - 2]) {             if (s[l][z - 2] == 1)               offset = 0;             else               offset = z - s[l][z - 2] + z - 1;           } else {             offset = s[l][z - 2] - 1;           }           cout << search(1, 1, n, l, r, z, offset) << endl;         }       }     }     return 0;   }   