#pragma once
#include"library/datastructure/FenwickTree.hpp"
#include"library/datastructure/WaveletMatrix.hpp"
#define REP_(i, n) for (int i = 0; i < (n); i++)
template<typenameT,groupG>classGroupWaveletMatrix:WaveletMatrix<T,true>{usingsuper=WaveletMatrix<T,true>;usingsuper::log,super::n,super::nxt,super::comp,super::data,super::high_bit,super::mat,super::zero_cnt;usingU=typenamesuper::U;usingFT=FenwickTree<G>;usingS=typenameG::value_type;std::vector<FT>ft;public:usingsuper::rank,super::select,super::kth_largest,super::kth_smallest,super::range_freq,super::lt,super::leq,super::gt,super::geq;GroupWaveletMatrix(std::vector<T>v):super::WaveletMatrix(v){ft.resize(log);for(auto&p:ft)p=FT(n);}GroupWaveletMatrix(std::vector<T>v,conststd::vector<S>&w):GroupWaveletMatrix(v){for(inti=0;i<n;i++)add(i,w[i]);}voidadd(intidx,constS&val){Ua=comp(data[idx]);REP_(h,log){idx=nxt(idx,h,a);ft[h].add(idx,val);}}Ssum(intl,intr,constT&upper){Ua=comp(upper);Sres=G::unit();REP_(h,log){if(high_bit(a,h)){intL=mat[h].rank(l,0),R=mat[h].rank(r,0);G::Rchop(res,ft[h].sum(L,R));}l=nxt(l,h,a);r=nxt(r,h,a);}returnres;}Ssum(intl,intr,constT&lower,constT&upper){returnG::op(sum(l,r,upper),G::inverse(sum(l,r,lower)));}Skth_largest_sum(intl,intr,intk){assert(0<=kandk<r-l);Sres=G::unit();REP_(h,log){intL=mat[h].rank(l);intR=mat[h].rank(r);if(R-L>k){l=L+zero_cnt[h];r=R+zero_cnt[h];}else{G::Rchop(res,ft[h].sum(L+zero_cnt[h],R+zero_cnt[h]));k-=R-L;l-=L;r-=R;}}returnres;}};#undef REP_
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",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