#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair P; typedef pair Pi; template struct LazySegmentTree{ using F=function; using G=function; using H=function; int sz; vector data; vector lazy; const F f; const G g; const H h; const Monoid e1; const OperatorMonoid e0; LazySegmentTree(int n, const F f, const G g, const H h, const Monoid &e1, const OperatorMonoid &e0): f(f), g(g), h(h), e1(e1), e0(e0){ sz=1; while(sz v){ for(int i=0; i=0; i--) data[i]=f(data[2*i+1], data[2*i+2]); } void eval(int k, int l, int r){ if(lazy[k]!=e0){ data[k]=g(data[k], lazy[k], r-l); if(k>n>>q; auto f=[](Pi p, Pi q){ int c=p.second+q.second; if(p.first.second!=q.first.first) c++; return Pi(P(p.first.first, q.first.second), c); }; auto g=[](Pi p, ll x, int len){ return Pi(P(p.first.first+x, p.first.second+x), p.second);}; auto h=[](ll x, ll y){ return x+y;}; LazySegmentTree seg(n+2, f, g, h, Pi(P(0, 0), 0), 0); vector a(n+2); for(int i=0; i>ai; a[i+1]=Pi(P(ai, ai), 0); } seg.build(a); for(int i=0; i>t; if(t==1){ int l, r, x; cin>>l>>r>>x; seg.update(l, r+1, x); }else{ int l, r; cin>>l>>r; cout<