#include using namespace std; #define ll long long #define FOR(i,n,m) for(int i=(n);i<(m);i++) #define REP(i,n) for(int i=0;i<(n);i++) #define REPR(i,n) for(int i=(n);i>=0;i--) #define all(vec) vec.begin(),vec.end() using vi=vector; using vvi=vector; using vl=vector; using vvl=vector; using P=pair; using PP=pair; using vp=vector

; using vpp=vector; using vs=vector; #define fi first #define se second #define pb push_back templatebool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;} templateistream&operator>>(istream&is,pair &p){is>>p.fi>>p.se;return is;} templateostream&operator<<(ostream&os,const pair &p){os<<"("<istream&operator>>(istream&is,vector &t){REP(i,t.size())is>>t[i];return is;} templateostream&operator<<(ostream&os,const vector&t){os<<"{";REP(i,t.size()){if(i)os<<",";os< struct LazySegTree{ //0-indexed 閉区間 using F=function; using G=function; using H=function; using P=function; int size; vector data; vector lazy; const F f; //要素同士の演算 const G g; //要素と作用素のマージ const H h; //作用素同士のマージ const P p; //作用素を下に降ろす const Monoid M1; //単位元 const OperatorMonoid OM0; //作用素の単位元 LazySegTree(int n,const F f,const G g,const H h,const P p,const Monoid &M1,const OperatorMonoid OM0) :f(f),g(g),h(h),p(p),M1(M1),OM0(OM0){ size=1; while(size=0;k--){ data[k]=f(data[2*k+1],data[2*k+2]); } } void propagate(int k,int len){ //長さlenのkから下へ伝播 if(lazy[k]!=OM0){ if(k=r){ //内部 lazy[k]=h(lazy[k],x); propagate(k,r-l+1); return data[k]; }else{ return data[k]=f(update(a,b,x,2*k+1,l,(l+r)/2), update(a,b,x,2*k+2,(l+r)/2+1,r)); } } Monoid update(int a,int b,const OperatorMonoid &x){ //[a,b]をxに変更 return update(a,b,x,0,0,size-1); } Monoid query(int a,int b,int k,int l,int r){ propagate(k,r-l+1); if(r=r){ return data[k]; }else{ return f(query(a,b,2*k+1,l,(l+r)/2), query(a,b,2*k+2,(l+r)/2+1,r)); } } Monoid query(int a,int b){ return query(a,b,0,0,size-1); } Monoid operator[](const int &k){ return query(k,k); } void debug(){ for(int i=0;i>n>>q; auto f=[](data a,data b){data t{a.l,b.r,a.x+b.x};if(a.r==b.l)t.x--;return t;}; auto g=[](data a,ll x){a.l+=x;a.r+=x;return a;}; auto h=[](ll x,ll y){return x+y;}; auto p=[](ll a,ll b){return a;}; LazySegTree a(n,f,g,h,p,{0,0,0},0ll); REP(i,n){ int t; cin>>t; a.set(i,{t,t,1}); } a.build(); REP(i,q){ int f; cin>>f; if(f==1){ int l,r;ll x; cin>>l>>r>>x; l--;r--; a.update(l,r,x); }else{ int l,r; cin>>l>>r; l--;r--; cout<