func_code_string: #include <bits/stdc++.h>   const long long maxm = 1e5 + 100;   long long n, m;   struct node {     long long col[maxm * 4], tag[maxm * 4], sum[maxm * 4], siz[maxm * 4];     inline void pushup(long long o) {       sum[o] = sum[(o << 1)] + sum[(o << 1) | 1];       col[o] = col[(o << 1)] == col[(o << 1) | 1] ? col[(o << 1)] : 0;     }     inline void pushdown(long long o) {       if (tag[o]) {         tag[(o << 1)] += tag[o];         tag[(o << 1) | 1] += tag[o];         sum[(o << 1)] += siz[(o << 1)] * tag[o];         sum[(o << 1) | 1] += siz[(o << 1) | 1] * tag[o];         col[(o << 1)] = col[(o << 1) | 1] = col[o];         tag[o] = 0;       }     }     void build(long long o, long long l, long long r) {       siz[o] = (r - l + 1);       if (l >= r) {         col[o] = l;         return;       }       long long mid = (l + r) >> 1;       build((o << 1), l, mid), build((o << 1) | 1, mid + 1, r);       pushup(o);     }     void cover(long long o, long long l, long long r, long long ql, long long qr,                long long c) {       if (ql > r || qr < l) return;       if ((ql <= l) && (r <= qr) && col[o]) {         tag[o] += abs(col[o] - c);         sum[o] += abs(col[o] - c) * siz[o];         col[o] = c;         return;       }       pushdown(o);       long long mid = (l + r) >> 1;       cover((o << 1), l, mid, ql, qr, c),           cover((o << 1) | 1, mid + 1, r, ql, qr, c);       pushup(o);     }     long long ask(long long o, long long l, long long r, long long ql,                   long long qr) {       if (ql > r || qr < l) return 0;       if ((ql <= l) && (r <= qr)) return sum[o];       pushdown(o);       long long mid = (l + r) >> 1;       return ask((o << 1), l, mid, ql, qr) +              ask((o << 1) | 1, mid + 1, r, ql, qr);     }   } st;   signed main() {     scanf( %I64d%I64d , &n, &m);     st.build(1, 1, n);     for (long long i = 1; i <= m; i++) {       long long opt, l, r, x;       scanf( %I64d%I64d%I64d , &opt, &l, &r);       if (opt == 1)         scanf( %I64d , &x), st.cover(1, 1, n, l, r, x);       else         printf( %I64d n , st.ask(1, 1, n, l, r));     }     return 0;   }   