#include <bits/stdc++.h>   #pragma GCC target( avx,tune=native )   using namespace std;   template <class T>   ostream &operator<<(ostream &os, vector<T> V) {     os <<  [ ;     for (auto const &vv : V) os << vv <<  , ;     os <<  ] ;     return os;   }   template <class L, class R>   ostream &operator<<(ostream &os, pair<L, R> P) {     os <<  (  << P.first <<  ,  << P.second <<  ) ;     return os;   }   template <typename T>   inline void print_128(T num) {     if (!num) return;     print_128(num / 10);     cout.put((num % 10) +  0 );   }   inline int fstoi(const string &str) {     auto it = str.begin();     bool neg = 0;     int num = 0;     if (*it ==  - )       neg = 1;     else       num = *it -  0 ;     ++it;     while (it < str.end()) num = num * 10 + (*it++ -  0 );     if (neg) num *= -1;     return num;   }   inline void getch(char &x) {     while (x = getchar_unlocked(), x < 33) {       ;     }   }   inline void getstr(string &str) {     str.clear();     char cur;     while (cur = getchar_unlocked(), cur < 33) {       ;     }     while (cur > 32) {       str += cur;       cur = getchar_unlocked();     }   }   template <typename... Args>   inline void getstr(string &str, Args &...arg) {     str.clear();     char cur;     while (cur = getchar_unlocked(), cur < 33) {       ;     }     while (cur > 32) {       str += cur;       cur = getchar_unlocked();     }     getstr(arg...);   }   template <typename T>   inline bool sc(T &num) {     bool neg = 0;     int c;     num = 0;     while (c = getchar_unlocked(), c < 33) {       if (c == EOF) return false;     }     if (c ==  - ) {       neg = 1;       c = getchar_unlocked();     }     for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48;     if (neg) num *= -1;     return true;   }   template <typename T, typename... Args>   inline void sc(T &num, Args &...args) {     bool neg = 0;     int c;     num = 0;     while (c = getchar_unlocked(), c < 33) {       ;     }     if (c ==  - ) {       neg = 1;       c = getchar_unlocked();     }     for (; c > 47; c = getchar_unlocked()) num = num * 10 + c - 48;     if (neg) num *= -1;     sc(args...);   }   template <typename T>   inline T mod(T i, T n) {     return (i % n + n) % n;   }   inline void chkmax(int &a, const int &b) {     if (b > a) a = b;   }   inline void chkmin(int &a, const int &b) {     if (b < a) a = b;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     int n, l, r, k, t;     int posa[100001];     int posb[100001];     memset(posa, 127, sizeof posa);     memset(posb, 127, sizeof posb);     sc(n);     while (n--) {       sc(t, l, r);       --r;       if (t == 1) {         sc(k);         if (k > 0) {           int count = r - l + 1;           int n = (count + 7) >> 3;           int i = l;           switch (count % 8) {             case 0:               do {                 chkmin(posa[i], k);                 ++i;                 case 7:                   chkmin(posa[i], k);                   ++i;                 case 6:                   chkmin(posa[i], k);                   ++i;                 case 5:                   chkmin(posa[i], k);                   ++i;                 case 4:                   chkmin(posa[i], k);                   ++i;                 case 3:                   chkmin(posa[i], k);                   ++i;                 case 2:                   chkmin(posa[i], k);                   ++i;                 case 1:                   chkmin(posa[i], k);                   ++i;               } while (--n > 0);           }         } else {           k = -k;           int count = r - l + 1;           int n = (count + 7) >> 3;           int i = l;           switch (count % 8) {             case 0:               do {                 chkmin(posb[i], k);                 ++i;                 case 7:                   chkmin(posb[i], k);                   ++i;                 case 6:                   chkmin(posb[i], k);                   ++i;                 case 5:                   chkmin(posb[i], k);                   ++i;                 case 4:                   chkmin(posb[i], k);                   ++i;                 case 3:                   chkmin(posb[i], k);                   ++i;                 case 2:                   chkmin(posb[i], k);                   ++i;                 case 1:                   chkmin(posb[i], k);                   ++i;               } while (--n > 0);           }         }       } else {         long long ans = 0;         int count = r - l + 1;         int i = l;         int n = (count + 7) >> 3;         switch (count % 8) {           case 0:             do {               if (posa[i] < 0x7F7F7F7F && posb[i] < 0x7F7F7F7F)                 ans += posa[i] + posb[i];               ++i;               case 7:                 if (posa[i] < 0x7F7F7F7F && posb[i] < 0x7F7F7F7F)                   ans += posa[i] + posb[i];                 ++i;               case 6:                 if (posa[i] < 0x7F7F7F7F && posb[i] < 0x7F7F7F7F)                   ans += posa[i] + posb[i];                 ++i;               case 5:                 if (posa[i] < 0x7F7F7F7F && posb[i] < 0x7F7F7F7F)                   ans += posa[i] + posb[i];                 ++i;               case 4:                 if (posa[i] < 0x7F7F7F7F && posb[i] < 0x7F7F7F7F)                   ans += posa[i] + posb[i];                 ++i;               case 3:                 if (posa[i] < 0x7F7F7F7F && posb[i] < 0x7F7F7F7F)                   ans += posa[i] + posb[i];                 ++i;               case 2:                 if (posa[i] < 0x7F7F7F7F && posb[i] < 0x7F7F7F7F)                   ans += posa[i] + posb[i];                 ++i;               case 1:                 if (posa[i] < 0x7F7F7F7F && posb[i] < 0x7F7F7F7F)                   ans += posa[i] + posb[i];                 ++i;             } while (--n > 0);         }         cout << ans <<   n ;       }     }   }