#include"library/algebra/monoid/Concepts.hpp"#pragma once
template<monoidM>classSegmentTree{usingX=typenameM::value_type;std::vector<X>dat;intn,log,size;voidupdate(inti){dat[i]=M::op(dat[2*i],dat[2*i+1]);}public:SegmentTree():SegmentTree(0){}SegmentTree(intn):SegmentTree(std::vector<X>(n,M::unit())){}SegmentTree(std::vector<X>v):n(v.size()){for(log=1;(1<<log)<n;log++){}size=1<<log;dat.assign(size<<1,M::unit());for(inti=0;i<n;++i)dat[size+i]=v[i];for(inti=size-1;i>=1;--i)update(i);}Xoperator[](inti)const{returndat[size+i];}voidset(inti,constX&x){assert(0<=iandi<n);dat[i+=size]=x;while(i>>=1)update(i);}voidmultiply(inti,constX&x){set(i,M::op(dat[i+size],x));}Xprod(intL,intR)const{assert(0<=LandL<=RandR<=n);Xvl=M::unit(),vr=M::unit();L+=size,R+=size;while(L<R){if(L&1)M::Rchop(vl,dat[L++]);if(R&1)M::Lchop(dat[--R],vr);L>>=1,R>>=1;}returnM::op(vl,vr);}Xprod_all()const{returndat[1];}template<classF>intmax_right(F&check,intL){assert(0<=L&&L<=n&&check(M::unit()));if(L==n)returnn;L+=size;Xsm=M::unit();do{while(L%2==0)L>>=1;if(!check(M::op(sm,dat[L]))){while(L<size){L<<=1;if(check(M::op(sm,dat[L])))M::Rchop(sm,dat[L++]);}returnL-size;}M::Rchop(sm,dat[L++]);}while((L&-L)!=L);returnn;}template<classF>intmin_left(F&check,intR){assert(0<=R&&R<=n&&check(M::unit()));if(R==0)return0;R+=size;Xsm=M::unit();do{--R;while(R>1&&(R%2))R>>=1;if(!check(M::op(dat[R],sm))){while(R<size){(R<<=1)++;if(check(M::op(dat[R],sm)))M::Lchop(dat[R--],sm);}returnR+1-size;}M::Lchop(dat[R],sm);}while((R&-R)!=R);return0;}// モノイドが可換なら、prod_{l<=i<r}A[i^x] が計算可能// https://codeforces.com/contest/1401/problem/FXXor_prod(intl,intr,intxor_val){assert(M::commute);Xx=M::unit();for(intk=0;k<log+1;++k){if(l>=r)break;if(l&1){M::Rchop(x,dat[(size>>k)+((l++)^xor_val)]);}if(r&1){M::Rchop(x,dat[(size>>k)+((--r)^xor_val)]);}l/=2,r/=2,xor_val/=2;}returnx;}friendstd::ostream&operator<<(std::ostream&os,constSegmentTree&seg){os<<"(";for(intL=1;L<=seg.size;L<<=1){os<<"[";for(intj=L;j<(L<<1);j++){os<<seg.dat[j];if(j+1<(L<<1))os<<",";}os<<"]";}os<<")";returnos;}};
Traceback(mostrecentcalllast):File"/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/onlinejudge_verify/documentation/build.py",line71,in_render_source_code_statbundled_code=language.bundle(stat.path,basedir=basedir,options={'include_paths':[basedir]}).decode()~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^File"/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/onlinejudge_verify/languages/cplusplus.py",line187,inbundlebundler.update(path)~~~~~~~~~~~~~~^^^^^^File"/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py",line312,inupdateraiseBundleErrorAt(path,i+1,"#pragma once found in a non-first line")onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt:library/segtree/SegmentTree.hpp:line3:#pragmaoncefoundinanon-firstline