func_code_string: #include <bits/stdc++.h>   using namespace std;   long long sum[100010 << 2], tag[100010 << 2];   int num[100010 << 2], n, m;   bool is[100010 << 2], Tag[100010 << 2];   void build(int p, int l, int r) {     if (l == r) {       is[p] = true, num[p] = l;       return;     }     build(p << 1, l, (l + r) >> 1), build(p << 1 | 1, ((l + r) >> 1) + 1, r);     sum[p] = sum[p << 1] + sum[p << 1 | 1];     if (is[p << 1] && is[p << 1 | 1] && num[p << 1] == num[p << 1 | 1])       num[p] = num[p << 1], is[p] = true;     else       num[p] = 0, is[p] = false;   }   void pushdown(int p, int l, int r) {     if (l == r) return;     int mid = (l + r) >> 1;     if (tag[p]) {       tag[p << 1] += tag[p], sum[p << 1] += 1ll * (mid - l + 1) * tag[p];       tag[p << 1 | 1] += tag[p], sum[p << 1 | 1] += 1ll * (r - mid) * tag[p],           tag[p] = 0;     }     if (Tag[p])       num[p << 1] = num[p], num[p << 1 | 1] = num[p],                Tag[p << 1] = Tag[p << 1 | 1] = true, Tag[p] = false;   }   void change(int p, int l, int r, int x, int y, int z) {     if (x <= l && r <= y && is[p] && num[p]) {       sum[p] += 1ll * abs(z - num[p]) * (r - l + 1);       tag[p] += abs(z - num[p]), Tag[p] = true, num[p] = z;       return;     }     int mid = (l + r) >> 1;     pushdown(p, l, r);     if (x <= mid) change(p << 1, l, mid, x, y, z);     if (y > mid) change(p << 1 | 1, mid + 1, r, x, y, z);     sum[p] = sum[p << 1] + sum[p << 1 | 1];     if (is[p << 1] && is[p << 1 | 1] && num[p << 1] == num[p << 1 | 1])       num[p] = num[p << 1], is[p] = true;     else       num[p] = 0, is[p] = false;   }   long long find(int p, int l, int r, int x, int y) {     if (x <= l && r <= y) return sum[p];     int mid = (l + r) >> 1;     long long tmp = 0;     pushdown(p, l, r);     if (x <= mid) tmp += find(p << 1, l, mid, x, y);     if (y > mid) tmp += find(p << 1 | 1, mid + 1, r, x, y);     return tmp;   }   int main() {     scanf( %d%d , &n, &m), build(1, 1, n);     for (int i = 1, kind, l, r, col; i <= m; i++) {       scanf( %d%d%d , &kind, &l, &r);       if (kind == 1)         scanf( %d , &col), change(1, 1, n, l, r, col);       else         printf( %I64d n , find(1, 1, n, l, r));     }   }   