func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = (1 << 18) + 10;   int n, m;   long long tree[N], add[N];   int same[N];   int col[N];   void build(int x, int l, int r) {     tree[x] = same[x] = col[x] = add[x] = 0;     if (l == r) {       same[x] = 1;       col[x] = l + 1;       return;     }     int s = (l + r) / 2;     build(x + x + 1, l, s);     build(x + x + 2, s + 1, r);   }   int push(int x, int l, int r) {     if (add[x]) {       tree[x] += (long long)(r - l + 1) * add[x];       if (l != r) {         add[x * 2 + 1] += add[x];         add[x * 2 + 2] += add[x];       }       add[x] = 0;     }     if (same[x]) {       if (l != r) {         same[x * 2 + 1] = same[x * 2 + 2] = 1;         col[x * 2 + 1] = col[x * 2 + 2] = col[x];       }     }     return 0;   }   long long upd(int x, int l, int r, int lc, int rc, int y) {     push(x, l, r);     if (r < lc || l > rc) return tree[x];     if (lc <= l && r <= rc) {       if (same[x]) {         add[x] += abs(col[x] - y);         col[x] = y;         push(x, l, r);         return tree[x];       } else         same[x] = 1, col[x] = y;     } else if (same[x] && col[x] != y)       col[x] = same[x] = 0;     int s = (l + r) / 2;     return tree[x] = upd(x + x + 1, l, s, lc, rc, y) +                      upd(x + x + 2, s + 1, r, lc, rc, y);   }   long long get(int x, int l, int r, int lc, int rc) {     push(x, l, r);     if (r < lc || l > rc) return 0;     if (lc <= l && r <= rc) return tree[x];     int s = (l + r) / 2;     return get(x + x + 1, l, s, lc, rc) + get(x + x + 2, s + 1, r, lc, rc);   }   int main() {     scanf( %d%d , &n, &m);     build(0, 0, n - 1);     int t, l, r, x;     for (int i = 0; i < m; i++) {       scanf( %d , &t);       if (t == 1) {         scanf( %d%d%d , &l, &r, &x);         l--;         r--;         upd(0, 0, n - 1, l, r, x);       } else {         scanf( %d%d , &l, &r);         l--;         r--;         printf( %I64d n , get(0, 0, n - 1, l, r));       }     }     return 0;   }   