#include using namespace std; typedef long long ll; typedef pair p_ll; template void debug(T itr1, T itr2) { auto now = itr1; while(now=0; i--) const ll MOD = pow(10,9)+7; const ll LLINF = pow(2,61)-1; const int INF = pow(2,30)-1; vector fac; void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; } ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; } ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; } ll gcd(ll a, ll b) { if (a val; vector ope; LazySegTree(ll N) { size = 1; depth = 0; while(size=1; i--) val[i] = f_back(i*2, i*2+1); } color operator[](ll x) { return query(x,x+1); } void propagation(ll x, ll y) { bool px = false, py = false; vector order; for (x+=size, y+=size; x||y; x>>=1, y>>=1) { px |= x&1; py |= y&1; if (px) order.push_back(x); if (py&&!(px&&x==y)) order.push_back(y); } for (auto itr=rbegin(order); itr!=rend(order); ++itr) { if (*itr>=size) break; ope[*itr*2] = g(ope[*itr*2] , ope[*itr]); ope[*itr*2+1] = g(ope[*itr*2+1], ope[*itr]); ope[*itr] = ope_e; } } void update_operator(ll x, ll y, ll v) { for (x+=size, y+=size; x>=1, y>>=1) { if (x&1) { ope[x] = g(ope[x],v); x++; } if (y&1) { y--; ope[y] = g(ope[y],v); } } } void back_propagation(ll x, ll y) { bool px = false, py = false; vector order; for (x+=size, y+=size; x||y; x>>=1, y>>=1) { if (x>=1, y>>=1) { if (x&1) { L = f(L,h(val[x],ope[x])); x++; } if (y&1) { y--; R = f(h(val[y],ope[y]),R); } } return f(L,R); } void operate(ll i) { val[i] = f(val[i*2], val[i*2+1]); } color f(color x, color y) { return x + y; } color f_back(ll x, ll y) { return f(h(val[x],ope[x]),h(val[y],ope[y])); } // 要素同士の演算 ll g(ll x, ll y) { return y==-1 ? x : y; } // 作用素同士の演算 color h(color x, ll y) { ll sum = x.z+x.a+x.b; if (y==-1) return x; else if (y==0) return {sum,0,0}; else if (y==1) return {0,sum,0}; else if (y==2) return {0,0,sum}; return val_e; } // 要素に作用素を書ける void output() { rep(i,size*2) cout << i << ": " << val[i].z << "," << val[i].a << "," << val[i].b << " " << ope[i] << endl; // rep(i,size) { // color c = query(i,i+1); // cout << c.z << "," << c.a << "," << c.b << " "; cout << endl; // } } }; // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- int main() { ll N, Q; cin >> N >> Q; ll ra = 0, rb = 0; LazySegTree lst(N); rep(_,Q) { ll x, l, r; cin >> x >> l >> r; if (x==0) { color now = lst.query(l,r+1); if (now.a>now.b) ra += now.a; else if (now.a