#pragma once
#include"library/algebra/group/Add.hpp"
#include"library/algebra/group/Concepts.hpp"template<groupG=GroupAdd<longlong>>classFenwickTree{usingT=typenameG::value_type;intn;std::vector<T>dat,raw;public:FenwickTree(){assert(G::commute);}FenwickTree(intn):n(n){assert(G::commute);dat=raw=std::vector<T>(n,G::unit());}FenwickTree(conststd::vector<T>&v):n(v.size()),raw(v),dat(v){assert(G::commute);for(inti=1;i<=n;i++){intj=i+(i&-i);if(j<=n)G::Rchop(dat[j-1],dat[i-1]);}}Toperator[](intk)const{returnraw[k];}Tget(intk)const{returnraw[k];}voidmultiply(intk,constT&x){G::Rchop(raw[k],x);for(++k;k<=n;k+=k&-k)G::Rchop(dat[k-1],x);}voidadd(intk,constT&x){multiply(k,x);}voidset(intk,constT&x){multiply(k,G::op(x,G::inverse(raw[k])));}Tprod(intk)const{Tres=G::unit();while(k>0){G::Rchop(res,dat[k-1]);k-=k&-k;}returnres;}Tsum(intk)const{returnprod(k);}Tprod(intL,intR)const{Tpos=G::unit();while(L<R){G::Rchop(pos,dat[R-1]);R-=R&-R;}Tneg=G::unit();while(R<L){G::Rchop(neg,dat[L-1]);L-=L&-L;}returnG::op(pos,G::inverse(neg));}Tsum(intL,intR)const{returnprod(L,R);}template<classF>intmax_right(constFcheck)const{assert(check(G::unit()));intr=0;Tsum=G::unit();intk=1;while(2*k<=n)k<<=1;while(k){if(r+k-1<dat.size())if(check(G::op(sum,dat[r+k-1]))){G::Rchop(sum,dat[r+k-1]);r+=k;}k>>=1;}returnr;}intkth(Tk)const{returnmax_right([&k](Tx){returnx<=k;});}};
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",line401,inupdateself.update(self._resolve(pathlib.Path(included),included_from=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/algebra/group/Concepts.hpp:line3:#pragmaoncefoundinanon-firstline