" Vim with all enhancements source $VIMRUNTIME/vimrc_example.vim set dir=$TEMP hi normal ctermfg=0 ctermbg=9 hi constant ctermfg=6 hi statement ctermfg=1 hi keyword ctermfg=1 hi type ctermfg=1 hi preproc ctermfg=6 hi comment ctermfg=2 hi linenr ctermfg=3 hi number ctermfg=10 hi string ctermfg=13 hi character ctermfg=13 hi def link error normal hi modemsg ctermfg=0 hi errormsg ctermfg=9 hi special ctermfg=10 hi matchparen ctermfg=9 ctermbg=3 hi search ctermbg=NONE set number set relativenumber set autoread autocmd InsertEnter * :set norelativenumber autocmd InsertLeave * :set relativenumber set nobackup set noundofile inoremap { {}"_ci{ set autoindent set smarttab set shiftwidth=4 set softtabstop=4 set tabstop=4 set belloff=all set guicursor=a:block set guicursor+=a:blinkon0 " Use the internal diff if available. " Otherwise use the special 'diffexpr' for Windows. if &diffopt !~# 'internal' set diffexpr=MyDiff() endif function MyDiff() let opt = '-a --binary ' if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif let arg1 = v:fname_in if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif let arg1 = substitute(arg1, '!', '\!', 'g') let arg2 = v:fname_new if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif let arg2 = substitute(arg2, '!', '\!', 'g') let arg3 = v:fname_out if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif let arg3 = substitute(arg3, '!', '\!', 'g') if $VIMRUNTIME =~ ' ' if &sh =~ '\ ' . arg3 if exists('l:shxq_sav') let &shellxquote=l:shxq_sav endif endfunction hi customSymbol ctermfg=3 autocmd FileType cuda,cpp,c syn match customSymbol display "[~!%^&()\-+=\[\]\|{},.<>?:;]" display autocmd FileType cuda,cpp,c syn match customSymbol display "\([\/*]\)\@:redraw\" elseif file_ext == 'cu' execute "normal! :!color 09 & cls & nvcc -D __CUSTOM_DEFINE__ -o out.exe % && (echo BUILD SUCCESS & color 90 & start cmd /k out.exe ^& echo[ ^& pause ^& exit) || (echo[ & echo BUILD FAILED & pause & color 90)\:redraw\" else echo "FILE EXTENSION NOT FOUND" endif endfunction if !filereadable(expand("%")) let g:bf1 = [] else let g:bf1 = readfile(expand("%")) endif if len(g:bf1) > 0 let g:bf1 = g:bf1[len(g:bf1)-1] else let g:bf1 = "" endif if len(g:bf1) > 3 let g:bf1 = strpart(g:bf1, 3) else let g:bf1 = "" endif function! GenerateRandomStuff() let g:bf1 = '' for i in range(1,37) let g:bf1 = g:bf1 . "----------xX||"[rand() % 14] endfor let g:bf1 = g:bf1 . ">" endfunction function! Global(arg) let bf = g:bf1 let brh_id = synIDtrans(hlID("Normal")) let ctermfg = synIDattr(brh_id, "fg", "cterm") let ctermbg = synIDattr(brh_id, "bg", "cterm") let rnd = "____" let strbruh = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890" let cf = '' for i in range(1,38) let cf = cf . strbruh[rand() % len(strbruh)] endfor for i in range(1,50) let rnd = rnd . strbruh[rand() % len(strbruh)] endfor let rnd = rnd . ";" let cmdogheight = &cmdheight . "" let oth2 = "Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\" let initcmd = "normal! :silent vsp\:silent q!\:silent set cmdheight=69420\a" . rnd . "\gg:call search(\"" . rnd . "\")\AA\\gg:call search(\"" . bf . "\")\jO\\\" let delcmd = "normal! Aa\bruh\\\\" . cf . "\ggGggGggGgg:silent call search(\".\")\ggGggARANDOM :::\\\\\\\\\\\ABEE\\\\:silent call search(\"Congratulations! You have found a text that nobody cares about! Finding out this text means that you have no life, and are will take countless hours just to do something so meaningless. Nobody will congratulate you for what you have discovered. Its just another easter egg amongst the thousands awaiting to be discovered. But there's no purpose. So, I guess congratulations to you. Good job for discovering this easter egg.\")\" . oth2 . "IARE\\\\GASLASH\\\\\\gg:silent call search(\"" . bf . "\")\A\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\gg:silent call search(\"" . cf . "\")\A\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ // " . bf . "\gg:silent call search(\"" . rnd . "\")\54la\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\zz:set cmdheight=" . cmdogheight . "\:redraw\" let curpos=getpos('.') if a:arg == 'caseless' || a:arg == 'cases' call GenerateRandomStuff() let bf = g:bf1 let chars = ["5","8","9","A"] let rand_char = chars[rand() % len(chars)] let bruh123 = "cin>>t;while(C++!=t)cerr<\#define int long long\#ifndef __CUSTOM_DEFINE__\#define cerr __othrstream__\#endif\using namespace std;templateusing __pair__=pair;\mt19937_64 __rng__([](){system(\"color 0".rand_char."\");ios_base::sync_with_stdio(0);cin.tie(0);return chrono::system_clock::now().time_since_epoch();}().count());\inline unsigned int __rand__(){return __rng__();}\stringstream __othcstream__,__othrstream__;inline void flush(){fputs(__othcstream__.str().c_str(),stdout);__othcstream__.str(\"\");fflush(stdout);}void solve();\signed main(){unsigned int t=1,C=26;string d;while(--C)d+=\"-\";" . bruh123 . "solve();cerr<#define pair __pair__\#define cout __othcstream__\#define rand __rand__\\kA // " . bf . "\ji\\void solve()\{\(---------- solve(); ----------)\}\\100o\" let date = strftime("%Y/%m/%d %H:%M:%S") let fname = expand("%:t") execute "normal! AFILE NAME : " . fname . ";\TEMPLATE CREATED AT : " . date . ";\\kI// \kI// \jjGA// " . bf . "\" execute "normal! ?(---------- solve(); ----------)\\"_cc\zb" elseif a:arg == 'inverse' if search("#ifndef __INVERSE__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! A#ifndef __INVERSE__\#define __INVERSE__\inline unsigned int inverse(unsigned int num, unsigned int mod=18446744073709551557ULL)\{\unsigned int res=1;\unsigned int pw=mod-2;\num %= mod;\while(pw)\{\if(pw&1)\{\if(mod > UINT32_MAX)\res = (unsigned int)((unsigned __int128)(res)*num % mod);\else\res = (res*num)%mod;\}\pw >>= 1;\if(mod > UINT32_MAX)\num = (unsigned int)((unsigned __int128)(num)*num % mod);\else\num = (num*num)%mod;\}\return res;\}\#endif" execute delcmd elseif a:arg=="fibonacci" if search("#ifndef __FIBONACCI__")!=0 call setpos(".", curpos) return endif execute initcmd execute "normal! aA\A\#ifndef __FIBONACCI__\#define __FIBONACCI__\unordered_map>__fibonacci_default_mp__;\inline unsigned int fibonacci(unsigned int idx, unsigned int mod=18446744073709551557ULL)\{\vector&ref = __fibonacci_default_mp__[mod];\if(ref.size() == 0)\ref.push_back(0ULL), ref.push_back(1ULL%mod);\while(ref.size() <= idx)\if(*ref.rbegin() >= mod-*(++ref.rbegin()))\ref.push_back(*ref.rbegin()+*(++ref.rbegin())-mod);\else\ref.push_back(*ref.rbegin()+*(++ref.rbegin()));\return *(ref.begin()+idx);\}\#endif" execute delcmd elseif a:arg=='dsu' if search("#ifndef __DSU__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! A#ifndef __DSU__\#define __DSU__\class dsu\{\size_t*vals, sz;\public:\<size_t find(size_t val)\{\stackprev;\while(*(vals+val) != val)\prev.push(val), val=*(vals+val);\while(!prev.empty())\*(vals+prev.top())=val, prev.pop();\return val;\}\void unite(size_t a, size_t b){*(vals+find(a)) = find(b);}\bool united(size_t a, size_t b){return find(a)==find(b);}\dsu():vals(nullptr){};\dsu(size_t n):vals(new size_t[n]),sz(n)\{\for(size_t*it=vals, *en=vals+sz; it!=en; ++it)\*it=it-vals;\}\dsu(const dsu&oth):vals(new size_t[oth.sz]),sz(oth.sz){copy(oth.vals, oth.vals+sz, vals);}\dsu(dsu&&oth):vals(oth.vals),sz(oth.sz){oth.vals=nullptr, oth.sz=0;}\~dsu(){delete[]vals;}\void build(size_t n)\{\delete[]vals;\sz=n, vals=new size_t[sz];\for(size_t*it=vals, *en=vals+sz; it!=en; ++it)\*it=it-vals;\}\void build(const dsu&oth)\{\delete[]vals;\vals = new size_t[oth.sz], sz=oth.sz;\copy(oth.vals, oth.vals+sz, vals);\}\void build(dsu&&oth)\{\vals=oth.vals, sz=oth.sz;\oth.vals=nullptr, oth.sz=0;\}\dsu&operator=(const dsu&oth){build(oth);return *this;}\dsu&operator=(dsu&&oth){build(oth);return *this;}\size_t size()const{return sz;}\};\#endif" execute delcmd elseif a:arg=='segtree' if search("#ifndef __SEGTREE__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! A#ifndef __SEGTREE__\#define __SEGTREE__\templatestruct __segtree_default_fn__\{\type operator()(const type&a, const type&b)const{return min(a,b);}\};\templatestruct __segtree_default_lz__\{\type operator()(const type&a, const type&b, size_t t)const{return t?min(a,b):min(a,b);}\};\template, typename lazy=__segtree_default_lz__>class segtree\{\struct tree\{\tree*a, *b;\type val, lz;\bool islazy=false;\}\*tr;\func fn;\lazy lz;\size_t sz;\type runfn(const type&a, const type&b)const{return fn(a,b);}\type runlz(const type&a, const type&b, size_t t)const{return lz(a,b,t);}\size_t prev;\bool isprev = false;\size_t id;\templatevoid constructIt(tree*tr, size_t l, size_t r, iter&it)\{\if(l==r)\{\tr->val = *it;\advance(it,1);\return;\}\size_t mid = (l+r)>>1;\constructIt(tr->a=new tree(), l, mid, it);\constructIt(tr->b=new tree(), mid+1, r, it);\tr->val = runfn(tr->a->val, tr->b->val);\}\void construct(tree*tr, size_t l, size_t r, const type&val)\{\if(l==r)\{\tr->val = val;\return;\}\size_t mid = (l+r)>>1;\construct(tr->a=new tree(), l, mid, val);\construct(tr->b=new tree(), mid+1, r, val);\tr->val = runfn(tr->a->val, tr->b->val);\}\void construct(tree*tr, size_t l, size_t r)\{\if(l==r)\return;\size_t mid = (l+r)>>1;\construct(tr->a=new tree(), l, mid);\construct(tr->b=new tree(), mid+1, r);\tr->val = runfn(tr->a->val, tr->b->val);\}\void destruct(tree*tr, size_t l, size_t r)\{\if(l==r)\{\delete tr;\return;\}\size_t mid = (l+r)>>1;\destruct(tr->a, l, mid);\destruct(tr->b, mid+1, r);\delete tr;\}\void copy(tree*tr, tree*oth, size_t l, size_t r)\{\tr->val = oth->val;\tr->lz = oth->lz;\tr->islazy = oth->islazy;\if(l==r)\return;\size_t mid = (l+r)>>1;\copy(tr->a, oth->a, l, mid);\copy(tr->b, oth->b, mid+1, r);\}\void push(tree*tr, size_t sz)\{\tr->val = runlz(tr->val, tr->lz, sz);\if(sz!=1)\{\if(tr->a->islazy)\tr->a->lz = runlz(tr->a->lz, tr->lz, 1);\else\tr->a->islazy=true, tr->a->lz=tr->lz;\if(tr->b->islazy)\tr->b->lz = runlz(tr->b->lz, tr->lz, 1);\else\tr->b->islazy=true, tr->b->lz=tr->lz;\}\tr->islazy = false;\}\tree*get(tree*tr, size_t l, size_t r, size_t idx)\{\if(tr->islazy)\push(tr, (r-l)+1);\if(l==r)\return tr;\size_t mid = (l+r)>>1;\if(idx <= mid)\return get(tr->a, l, mid, idx);\return get(tr->b, mid+1, r, idx);\}\void update(tree*tr, size_t l, size_t r, size_t ul, size_t ur, const type&val)\{\if(tr->islazy)\push(tr, (r-l)+1);\if(l>ur || rreturn;\if(l>=ul && r<=ur)\{\tr->lz = val;\push(tr, (r-l)+1);\return;\}\size_t mid = (l+r)>>1;\update(tr->a, l, mid, ul, ur, val);\update(tr->b, mid+1, r, ul, ur, val);\tr->val = runfn(tr->a->val, tr->b->val);\}\void update(tree*tr, size_t l, size_t r)\{\if(tr->islazy)\push(tr, (r-l)+1);\if(prevr)\return;\if(l==r)\return;\size_t mid = (l+r)>>1;\update(tr->a, l, mid);\update(tr->b, mid+1, r);\tr->val = runfn(tr->a->val, tr->b->val);\}\type query(tree*tr, size_t l, size_t r, size_t ql, size_t qr)\{\if(tr->islazy)\push(tr, (r-l)+1);\if(l>=ql && r<=qr)\return tr->val;\size_t mid = (l+r)>>1;\if(mid >= ql)\{\if(mid < qr)\return runfn(query(tr->a, l, mid, ql, qr), query(tr->b, mid+1, r, ql, qr));\return query(tr->a, l, mid, ql, qr);\}\return query(tr->b, mid+1, r, ql, qr);\}\public:\<segtree():fn(func()),lz(lazy()){sz=0;}\segtree(func fn1, lazy lz1=lazy()):fn(fn1),lz(lz1){sz=0;}\segtree(const segtree&oth):fn(oth.fn),lz(oth.lz),sz(oth.sz),prev(oth.prev),isprev(oth.isprev)\{\if(sz)\{\construct(tr=new tree(), 0, sz-1);\copy(tr, oth.tr, 0, sz-1);\}\}\segtree(segtree&&oth):tr(oth.tr),fn(oth.fn),lz(oth.lz),sz(oth.sz),prev(oth.prev),isprev(oth.isprev){oth.tr=nullptr,oth.sz=0,oth.isprev=false;}\segtree(size_t n, func fn1=func(), lazy lz1=lazy()):fn(fn1),lz(lz1),sz(n)\{\if(sz)\construct(tr=new tree(), 0, sz-1);\}\segtree(size_t n, lazy lz1):segtree(n,func(),lz1){}\segtree(size_t n, const type&defval, func fn1=func(), lazy lz1=lazy()):fn(fn1),lz(lz1),sz(n)\{\if(sz)\construct(tr=new tree(), 0, sz-1, defval);\}\segtree(size_t n, const type&defval, lazy lz1):segtree(n,defval,func(),lz1){}\templatesegtree(iter begin, iter end, func fn1=func(), lazy lz1=lazy()):fn(fn1),lz(lz1),sz(distance(begin,end))\{\if(sz)\constructIt(tr=new tree(), 0, sz-1, begin);\}\templatesegtree(iter begin, iter end, lazy lz1):segtree(begin,end,func(),lz1){}\segtree(initializer_listtmp, func fn1=func(), lazy lz1=lazy()):segtree(tmp.begin(),tmp.end(),fn1,lz1){}\segtree(initializer_listtmp, lazy lz1):segtree(tmp.begin(),tmp.end(),func(),lz1){}\~segtree()\{\if(sz)\destruct(tr, 0, sz-1);\}\void build(size_t n)\{\if(sz)\destruct(tr, 0, sz-1);\sz=n;\isprev=false;\if(sz)\construct(tr=new tree(), 0, sz-1);\}\void build(const segtree&oth)\{\if(sz)\destruct(tr, 0, sz-1);\sz=oth.sz;\isprev = oth.isprev, prev = oth.prev;\if(sz)\{\construct(tr=new tree(), 0, sz-1);\copy(tr, oth.tr, 0, sz-1);\}\}\void build(segtree&&oth)\{\if(sz)\destruct(tr, 0, sz-1);\sz=oth.sz;\isprev = oth.isprev, prev = oth.prev;\tr = oth.tr;\oth.tr = nullptr;\oth.sz = 0;\oth.isprev = false;\}\void build(size_t n, const type&defval)\{\if(sz)\destruct(tr, 0, sz-1);\sz=n;\isprev=false;\if(sz)\construct(tr=new tree(), 0, sz-1, defval);\}\templatevoid build(it begin, it end)\{\if(sz)\destruct(tr, 0, sz-1);\sz=distance(begin,end);\isprev = false;\if(sz)\constructIt(tr=new tree(), 0, sz-1, begin);\}\void build(initializer_listtmp){build(tmp.begin(),tmp.end());}\segtree&operator=(const segtree&oth)\{\build(oth);\return *this;\}\segtree&operator=(segtree&&oth)\{\build(oth);\return *this;\}\type&operator[](size_t idx)\{\if(isprev)\update(tr, 0, sz-1);\else\isprev=true;\prev = idx;\return get(tr, 0, sz-1, idx)->val;\}\const type&operator[](size_t idx)const\{\segtree*cur = const_cast(this);\if(isprev)\cur->update(tr, 0, sz-1), cur->isprev=false;\return cur->get(tr, 0, sz-1, idx)->val;\}\void update(size_t idx, const type&val)\{\if(isprev)\update(tr, 0, sz-1), isprev=false;\update(tr, 0, sz-1, idx, idx, val);\}\void update(size_t ul, size_t ur, const type&val)\{\if(isprev)\update(tr, 0, sz-1), isprev = false;\update(tr, 0, sz-1, ul, ur, val);\}\type query(size_t ql, size_t qr)const\{\segtree*cur = const_cast(this);\if(isprev)\cur->update(tr, 0, sz-1), cur->isprev = false;\return cur->query(tr, 0, sz-1, ql, qr);\}\size_t size()const{return sz;}\};\#endif" execute delcmd elseif a:arg=="prime" if search("#ifndef __PRIME__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! A#ifndef __PRIME__\#define __PRIME__\class prime\{\static vectorprimes;\static bool*sieve;\static size_t sz;\static void push()\{\if(sz==0)\{\sz=1;\sieve = new bool[1]();\*sieve = true;\primes = {3};\return;\}\delete[]sieve;\sieve = new bool[sz<<1]();\bool*ptrBeg = sieve;\sz<<=1;\bool*ptrEnd = sieve+(sz/3+1);\bool*ptrTrueEnd = sieve+sz;\size_t prmNum=0;\while(ptrBeg != ptrEnd)\{\if(!(*ptrBeg))\{\size_t dist = ptrBeg-sieve+1;\size_t prm = (dist<<1)|1;\if(prmNum == primes.size())\primes.push_back(prm);\++prmNum;\for(bool*ptr = ptrBeg+prm; ptr*ptr = true;\}\++ptrBeg;\}\}\public:\<static unsigned int get(size_t num)\{\if(num==0)\return 2ULL;\while(primes.size() < num)\push();\return primes[num-1];\}\static bool isprime(unsigned int num)\{\if(num < 2)\return false;\if(num < 4)\return true;\if(!(num&1))\return false;\num = (num>>1)-1;\while(sz <= num)\push();\return !(*(sieve+num));\}\static vector>factor(unsigned int num)\{\if(num <= 1)\return vector>();\vector>res;\size_t idx=0;\unsigned int prd=2;\while(prd<=num/prd && !isprime(num) && num!=1)\{\prd = get(idx);\++idx;\if(num%prd == 0)\{\unsigned int count=0;\while(num%prd == 0)\{\num /= prd;\++count;\}\res.push_back(pair(prd,count));\}\}\if(num != 1)\res.push_back(pair(num,1));\return res;\}\};\size_t prime::sz=0;\bool*prime::sieve=nullptr;\vectorprime::primes;\#endif" execute delcmd elseif a:arg=="factor" if search("#ifndef __FACTOR__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! A#ifndef __FACTOR__\#define __FACTOR__\vectorfactor(unsigned int num)\{\if(num==0)\return vector();\vectorres;\stackaft;\unsigned int n=1;\while(n <= (num-1)/n)\{\if(num%n == 0){\res.push_back(n);\aft.push(num/n);\kkA\\jA\,\jA\++n;\}\if(num%n == 0)\res.push_back(n);\while(!aft.empty()){\res.push_back(aft.top());\aft.pop();\kkA\\jA\,\jA\return res;\}\#endif" execute delcmd elseif a:arg=="graph" if search("#ifndef __GRAPH__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! A#ifndef __GRAPH__\#define __GRAPH__\templateclass graph\{\struct custType{};\typedef typename conditional::value,custType,patht>::type pathtype;\value*vals;\vector*path;\vector>*pathNoVoid;\size_t sz;\vector&pathsVoid(size_t idx){return *(path+idx);}\vector>&pathsNoVoid(size_t idx){return *(pathNoVoid+idx);}\const vector&pathsVoid(size_t idx)const{return *(path+idx);}\const vector>&pathsNoVoid(size_t idx)const{return *(pathNoVoid+idx);}\public:\<graph():vals(nullptr),path(nullptr),pathNoVoid(nullptr){}\graph(const graph&oth):sz(oth.sz)\{\vals = new value[sz]();\if(is_same::value)\{\path = new vector[sz]();\pathNoVoid = nullptr;\copy(oth.path, oth.path+sz, path);\}\else\{\pathNoVoid = new vector>[sz]();\path = nullptr;\copy(oth.pathNoVoid, oth.pathNoVoid+sz, pathNoVoid);\}\copy(oth.vals, oth.vals+sz, vals);\}\graph(graph&&oth):vals(oth.vals),path(oth.path),pathNoVoid(oth.pathNoVoid),sz(oth.sz)\{\oth.vals = nullptr;\oth.path = nullptr;\oth.pathNoVoid = nullptr;\oth.sz = 0;\}\graph(size_t n):sz(n)\{\vals = new value[n]();\if(is_same::value)\path = new vector[n](), pathNoVoid=nullptr;\else\pathNoVoid = new vector>[n](), path=nullptr;\}\~graph()\{\delete[]vals;\delete[]path;\delete[]pathNoVoid;\}\void build(size_t n)\{\delete[]vals;\delete[]path;\delete[]pathNoVoid;\vals = new value[n]();\if(is_same::value)\path = new vector[n](), pathNoVoid=nullptr;\else\pathNoVoid = new vector>[n](), path=nullptr;\sz = n;\}\graph&operator=(const graph&oth)\{\sz = oth.sz;\delete[]vals;\delete[]path;\delete[]pathNoVoid;\vals = new value[sz]();\if(is_same::value)\{\path = new vector[sz]();\pathNoVoid = nullptr;\copy(oth.path, oth.path+sz, path);\}\else\{\pathNoVoid = new vector>[sz]();\path = nullptr;\copy(oth.pathNoVoid, oth.pathNoVoid+sz, pathNoVoid);\}\copy(oth.vals, oth.vals+sz, vals);\return*this;\}\graph&operator=(graph&&oth)\{\sz = oth.sz;\delete[]vals;\delete[]path;\delete[]pathNoVoid;\vals = oth.vals;\path = oth.path;\pathNoVoid = oth.pathNoVoid;\oth.vals = nullptr;\oth.path = nullptr;\oth.pathNoVoid = nullptr;\return*this;\}\void build(const graph&oth){(*this)=oth;}\void build(graph&&oth){(*this)=oth;}\size_t size()const{return sz;}\value&operator[](size_t idx){return *(vals+idx);}\const value&operator[](size_t idx)const{return *(vals+idx);}\typename conditional::value,vector,vector>>::type&paths(size_t idx)\{\if constexpr(is_same::value)\return pathsVoid(idx);\else\return pathsNoVoid(idx);\}\const typename conditional::value,vector,vector>>::type&paths(size_t idx)const\{\if constexpr(is_same::value)\return pathsVoid(idx);\else\return pathsNoVoid(idx);\}\void connect(size_t a, size_t b, bool isbidirectional=true)\{\if constexpr(is_same::value)\{\path[a].push_back(b);\if(isbidirectional)\path[b].push_back(a);\}\else\{\pathNoVoid[a].push_back(pair(b,pathtype()));\if(isbidirectional)\pathNoVoid[b].push_back(pair(a,pathtype()));\}\}\void connect(size_t a, size_t b, bool isbidirectional, const typename conditional::value,char,pathtype>::type&val)\{\pathNoVoid[a].push_back(pair(b,val));\if(isbidirectional)\pathNoVoid[b].push_back(pair(a,val));\}\};\#endif" execute delcmd elseif a:arg=="tree" if search("#ifndef __GRAPH__")==0 execute "normal! :C graph\" else call setpos('.', curpos) endif if search("#ifndef __TREE__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! a#ifndef __TREE__\#define __TREE__\templateclass tree\{\struct custType{};\typedef typename conditional::value,custType,patht>::type pathtype;\static const constexpr bool isVoid = is_same::value;\struct node\{\size_t*parent;\pair*parentNoVoid;\vector>*childrenNoVoid;\vector*children;\value val;\size_t height, size;\node()\{\height=size=0;\if(isVoid)\children = new vector(), parent=new size_t(), childrenNoVoid=nullptr, parentNoVoid=nullptr;\else\childrenNoVoid = new vector>(), parentNoVoid=new pair(), children=nullptr, parent=nullptr;\}\node&operator=(const node&oth)\{\if(isVoid)\{\delete parent;\delete children;\children = new vector(*oth.children);\parent = new size_t(*oth.parent);\}\else\{\delete childrenNoVoid;\delete parentNoVoid;\childrenNoVoid = new vector>(*oth.childrenNoVoid);\parentNoVoid = new pair(*oth.parentNoVoid);\}\val = oth.val;\height = oth.height;\size = oth.size;\return*this;\}\~node()\{\if(isVoid)\delete children,delete parent;\else\delete childrenNoVoid,delete parentNoVoid;\}\};\node*nodes;\size_t sz, root1;\void change1(bool*vsted, size_t val, size_t tfirst)\{\if(*(vsted+val))\(nodes+tfirst)->size += (nodes+val)->size;\}\void change1(bool*vsted, const pair&val, size_t tfirst)\{\if(*(vsted+val.first))\(nodes+tfirst)->size += (nodes+val.first)->size;\}\void change2(bool*vsted, size_t val, size_t tfirst, stack>&st)\{\if(!*(vsted+val))\{\(nodes+tfirst)->children->push_back(val);\*(vsted+val) = true;\st.push(pair(val,false));\(nodes+val)->height = (nodes+tfirst)->height+1;\*((nodes+val)->parent) = tfirst;\}\}\void change2(bool*vsted, const pair&val, size_t tfirst, stack>&st)\{\if(!*(vsted+val.first))\{\(nodes+tfirst)->childrenNoVoid->push_back(val);\*(vsted+val.first) = true;\st.push(pair(val.first,false));\(nodes+val.first)->height = (nodes+tfirst)->height+1;\*((nodes+val.first)->parentNoVoid) = pair(tfirst,val.second);\}\}\void dfs(const graph&oth)\{\stack>st;\st.push(pair(root1,false));\bool*vsted = new bool[sz]();\*(vsted+root1) = true;\while(!st.empty())\{\pair&t = st.top();\if(t.second)\{\(nodes+t.first)->size = 1;\for(decltype(oth.paths(t.first).begin()) it=oth.paths(t.first).begin(), en=oth.paths(t.first).end(); it!=en; ++it)\change1(vsted,*it,t.first);\st.pop();\}\else\{\t.second = true;\for(decltype(oth.paths(t.first).begin()) it=oth.paths(t.first).begin(), en=oth.paths(t.first).end(); it!=en; ++it)\change2(vsted,*it,t.first,st);\}\}\delete[]vsted;\for(size_t i=0; i(nodes+i)->val = oth[i];\}\const vector&childrenVoid(size_t idx)const{return *((nodes+idx)->children);}\const vector>&childrenNoVoid(size_t idx)const{return *((nodes+idx)->childrenNoVoid);}\const size_t&parentVoid(size_t idx)const{return *((nodes+idx)->parent);};\const pair&parentNoVoid(size_t idx)const{return *((nodes+idx)->parentNoVoid);};\public:\<tree():nodes(nullptr){}\tree(const tree&oth):sz(oth.sz),root1(oth.root1)\{\nodes = new node[sz]();\copy(oth.nodes, oth.nodes+sz, nodes);\}\tree(tree&&oth):sz(oth.sz),root1(oth.root1),nodes(oth.nodes){oth.nodes=nullptr,oth.sz=oth.root1=0;}\tree(const graph&oth, size_t root2):sz(oth.size()),root1(root2){nodes = new node[sz](), dfs(oth);}\~tree(){delete[]nodes;}\void build(const tree&oth)\{\sz = oth.sz;\root1 = oth.root1;\delete[]nodes;\nodes = new node[sz]();\copy(oth.nodes, oth.nodes+sz, nodes);\}\void build(tree&&oth)\{\sz = oth.sz;\root1 = oth.root1;\delete[]nodes;\nodes = oth.nodes;\oth.nodes = nullptr;\oth.sz=oth.root1=0;\}\void build(const graph&oth, size_t root1)\{\sz = oth.size();\delete[]nodes;\nodes = new node[sz]();\this->root1 = root1;\dfs(oth);\}\tree&operator=(const tree&oth)\{\build(oth);\return*this;\}\tree&operator=(tree&&oth)\{\build(oth);\return*this;\}\size_t size()const{return sz;}\value&operator[](size_t idx){return (nodes+idx)->val;}\const value&operator[](size_t idx)const{return (nodes+idx)->val;}\const typename conditional,vector>>::type&children(size_t idx)const\{\if constexpr(isVoid)\return childrenVoid(idx);\else\return childrenNoVoid(idx);\}\const typename conditional>::type&parent(size_t idx)const\{\if constexpr(isVoid)\return parentVoid(idx);\else\return parentNoVoid(idx);\}\size_t root()const{return root1;}\size_t height(size_t idx)const{return (nodes+idx)->height;}\size_t subtree(size_t idx)const{return (nodes+idx)->size;}\};\#endif" execute delcmd elseif a:arg=="binary_lifting" if search("#ifndef __TREE__")==0 execute "normal! :C tree\" else call setpos('.', curpos) endif if search("#ifndef __BINARY_LIFTING__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! a#ifndef __BINARY_LIFTING__\#define __BINARY_LIFTING__\class binary_lifting\{\struct node\{\vectorparents;\size_t height;\};\node*nodes;\size_t sz, root1;\void change(stack&st, size_t val){st.push(val);}\templatevoid change(stack&st, const pair&val){st.push(val.first);}\size_t getParent(size_t val){return val;}\templatesize_t getParent(const pair&val){return val.first;}\templatevoid startBuild(const tree&tr)\{\stackst;\st.push(root1);\while(!st.empty())\{\size_t tp = st.top();\st.pop();\(nodes+tp)->height = tr.height(tp);\for(decltype(tr.children(tp).begin()) it=tr.children(tp).begin(), en=tr.children(tp).end(); it!=en; ++it)\change(st,*it);\size_t nxt = tp;\if(nxt != root1)\{\nxt = getParent(tr.parent(tp));\(nodes+tp)->parents.push_back(nxt);\size_t idx = 0;\while((nodes+nxt)->parents.size() > idx)\{\nxt = (nodes+nxt)->parents[idx];\++idx;\(nodes+tp)->parents.push_back(nxt);\}\}\}\}\public:\<binary_lifting():nodes(nullptr),sz(0),root1(0){}\binary_lifting(const binary_lifting&oth):nodes(new node[oth.sz]()),sz(oth.sz),root1(oth.root1){copy(oth.nodes, oth.nodes+sz, nodes);}\binary_lifting(binary_lifting&&oth):nodes(oth.nodes),sz(oth.sz),root1(oth.root1){oth.nodes=nullptr, oth.sz=oth.root1=0;}\templatebinary_lifting(const tree&tr):nodes(new node[tr.size()]()),sz(tr.size()),root1(tr.root()){startBuild(tr);}\~binary_lifting(){delete[]nodes;}\void build(const binary_lifting&oth)\{\sz = oth.sz;\root1 = oth.root1;\delete[]nodes;\nodes = new node[sz]();\copy(oth.nodes, oth.nodes+sz, nodes);\}\void build(binary_lifting&&oth)\{\sz = oth.sz;\root1 = oth.root1;\delete[]nodes;\nodes = oth.nodes;\oth.nodes = nullptr;\oth.sz=oth.root1 = 0;\}\binary_lifting&operator=(const binary_lifting&oth)\{\build(oth);\return *this;\}\binary_lifting&operator=(binary_lifting&&oth)\{\build(oth);\return *this;\}\templatevoid build(const tree&tr)\{\delete[]nodes;\sz = tr.size();\nodes = new node[sz]();\startBuild(tr);\}\size_t ancestor(size_t a, size_t k)const\{\size_t idx=0;\while(k)\{\if((nodes+a)->parents.size() <= idx)\return root1;\if(k&1)\a = (nodes+a)->parents[idx];\++idx;\k >>= 1;\}\return a;\}\templatesize_t binary_search(size_t a, const fn&func=fn())const\{\size_t res=a;\while(func(res) && res!=root1)\{\size_t idx=1;\node*ptr = nodes+res;\while(ptr->parents.size() > idx)\{\if(!func(ptr->parents[idx]))\break;\++idx;\}\res = ptr->parents[--idx];\}\return res;\}\size_t lca(size_t a, size_t b)const\{\if(b==root1 || a==root1)\return root1;\if((nodes+a)->height>(nodes+b)->height)\a = ancestor(a, (nodes+a)->height - (nodes+b)->height);\else if((nodes+b)->height>(nodes+a)->height)\b = ancestor(b, (nodes+b)->height - (nodes+a)->height);\size_t idx = 0;\do\{\idx = 0;\while((nodes+a)->parents[idx] != (nodes+b)->parents[idx])\{\++idx;\if((nodes+a)->parents.size() <= idx)\break;\}\if(idx != 0)\a = (nodes+a)->parents[--idx], b = (nodes+b)->parents[idx];\}\while(idx != 0);\if(a == b)\return a;\return *((nodes+a)->parents.begin());\}\size_t size()const{return sz;}\size_t root()const{return root1;}\};\#endif\" execute delcmd elseif a:arg=="factorial" if search("#ifndef __FACTORIAL__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! A#ifndef __FACTORIAL__\#define __FACTORIAL__\unordered_map>__factorial_default_mp__;\inline unsigned int factorial(unsigned int idx, unsigned int mod=18446744073709551557ULL)\{\vector&ref = __factorial_default_mp__[mod];\if(ref.size() == 0)\ref.push_back(1ULL%mod);\if(mod > UINT32_MAX)\while(ref.size() <= idx)\ref.push_back((unsigned int)(((unsigned __int128)(ref.back())*ref.size()) % mod));\else\while(ref.size() <= idx)\ref.push_back(ref.back()*ref.size() % mod);\return ref[idx];\}\#endif" execute delcmd elseif a:arg=="ncr" if search("#ifndef __MINT__")==0 execute "normal! :C mint\" let curpos=getpos('.') else call setpos('.', curpos) endif if search("#ifndef __FACTORIAL__")==0 execute "normal! :C factorial\" else call setpos('.', curpos) endif if search("#ifndef __NCR__")!=0 call setpos('.', curpos) return endif execute initcmd execute "normal! a#ifndef __NCR__\#define __NCR__\inline unsigned int ncr(unsigned int n, unsigned int r, unsigned int mod=18446744073709551557ULL)\{\if(nreturn 0ULL;\if(n==r)\return 1ULL%mod;\if(mod > UINT32_MAX)\return (unsigned int)(((unsigned __int128)factorial(n,mod)) * inverse(factorial(r,mod), mod) % mod * inverse(factorial(n-r,mod), mod) % mod);\return factorial(n,mod) * inverse(factorial(r,mod), mod) % mod * inverse(factorial(n-r,mod), mod) % mod;\}\inline unsigned int npr(unsigned int n, unsigned int r, unsigned int mod=18446744073709551557ULL)\{\if(r==0)\return 1ULL%mod;\if(r==1)\return n%mod;\if(mod > UINT32_MAX)\return (unsigned int)(((unsigned __int128)factorial(n,mod)) * inverse(factorial(n-r,mod), mod) % mod);\return factorial(n,mod) * inverse(factorial(n-r,mod), mod) % mod;\}\#endif" execute delcmd elseif a:arg=="space" if search("#ifndef __SPACE__")!=0 call setpos('.', curpos) return endif exec initcmd exec "normal! A#ifndef __SPACE__\#define __SPACE__\template>class space\{\public:\<class less\{\const size_t*order;\comp cmp1;\public:\<less(const size_t*o,comp cmp):order(o),cmp1(cmp){}\bool operator()(const axisType*a, const axisType*b)const\{\for(const size_t*it=order, *en=order+k; it!=en; ++it)\{\bool eq = cmp1(*(a+*it), *(b+*it));\if(eq != cmp1(*(b+*it), *(a+*it)))\return eq;\}\return false;\}\};\private:\<comp cmp;\struct hsh\{\size_t operator()(const size_t*ptr)const\{\size_t res=0;\__i__=0;\for(const size_t*en=ptr+k; ptr!=en; ++ptr)\res = res*__p__()+(*ptr);\return res;\}\};\struct iseq\{\bool operator()(const size_t*a, const size_t*b)const\{\for(const size_t*ea=a+k; ea!=a; ++a,++b)\if(*a != *b)\return false;\return true;\}\};\vector>>order;\axisType*updated=nullptr;\unordered_map>,hsh,iseq>pts;\pair>*axises;\pair>*axisesSzes;\size_t*defptr, sz;\void deleteNoDestroy()\{\for(decltype(pts.begin()) it=pts.begin(), en=pts.end(); it!=en; ++it)\delete[]it->first;\if(updated != nullptr)\delete[]updated;\for(decltype(order.begin()) it=order.begin(), en=order.end(); it!=en; ++it)\delete[]it->second.first;\for(pair>*it=axises, *en=axises+k; it!=en; ++it)\it->~pair>();\for(pair>*it=axisesSzes, *en=axisesSzes+k; it!=en; ++it)\it->~pair>();\free(axises);\free(axisesSzes);\}\public:\<space(comp c=comp()):cmp(c),sz(0)\{\axises = static_cast>*>(malloc(k*sizeof(pair>)));\for(pair>*it=axises, *en=axises+k; it!=en; ++it)\new(it)pair>(0,set(cmp));\axisesSzes = static_cast>*>(malloc(k*sizeof(pair>)));\for(pair>*it=axisesSzes, *en=axisesSzes+k; it!=en; ++it)\new(it)pair>(0,map(cmp));\defptr = new size_t[k];\for(size_t*it=defptr, *en=defptr+k, idx=0; it!=en; ++it,++idx)\*it = idx;\pts.insert(pair>>(defptr,pair>(0,map(less(defptr,cmp)))));\}\space(const space&oth):cmp(oth.cmp),sz(oth.sz)\{\defptr = new size_t[k];\for(size_t*it=defptr, *en=defptr+k, idx=0; it!=en; ++it,++idx)\*it = idx;\axises = static_cast>*>(malloc(k*sizeof(pair>)));\for(pair>*it=axises, *en=axises+k; it!=en; ++it)\new(it)pair>(0,set(cmp));\axisesSzes = (pair>*)malloc(k*sizeof(pair>));\for(pair>*it=axisesSzes, *en=axisesSzes+k; it!=en; ++it)\new(it)pair>(0,map(cmp));\decltype(oth.pts.at(defptr)) found = oth.pts.at(defptr);\map&ref = pts.insert(pair>>(defptr,pair>(found.second.size(),map(less(defptr,cmp))))).first->second.second;\for(decltype(found.second.begin()) it=found.second.begin(), en=found.second.end(); it!=en; ++it)\{\axisType*nw = new axisType[k];\for(axisType*ft=nw, *gt=it->first, *fn=nw+k; ft!=fn; ++ft,++gt)\*ft=*gt;\pairtmp = pair(nw,it->second);\ref.insert(tmp);\order.push_back(pair>(1,tmp));\}\}\space(space&&oth):cmp(oth.cmp),order(move(oth.order)),pts(move(oth.pts)),sz(oth.sz),axises(oth.axises),axisesSzes(oth.axisesSzes),defptr(oth.defptr)\{\oth.sz = 0;\oth.axises = static_cast>*>(malloc(k*sizeof(pair>)));\for(pair>*it=axises, *en=axises+k; it!=en; ++it)\new(it)pair>(0,set(cmp));\axisesSzes = (pair>*)malloc(k*sizeof(pair>));\for(pair>*it=axisesSzes, *en=axisesSzes+k; it!=en; ++it)\new(it)pair>(0,map(cmp));\for(size_t*it=oth.defptr, *en=oth.defptr+k, idx=0; it!=en; ++it,++idx)\*it = idx;\oth.pts.insert(pair>>(oth.defptr,pair>(0,map(less(oth.defptr,cmp)))));\}\~space(){deleteNoDestroy();}\void build(const space&oth)\{\deleteNoDestroy();\order.clear();\pts.clear();\updated = nullptr;\sz = oth.sz;\defptr = new size_t[k];\for(size_t*it=defptr, *en=defptr+k, idx=0; it!=en; ++it,++idx)\*it = idx;\axises = static_cast>*>(malloc(k*sizeof(pair>)));\for(pair>*it=axises, *en=axises+k; it!=en; ++it)\new(it)pair>(0,set(cmp));\axisesSzes = (pair>*)malloc(k*sizeof(pair>));\for(pair>*it=axisesSzes, *en=axisesSzes+k; it!=en; ++it)\new(it)pair>(0,map(cmp));\decltype(oth.pts.at(defptr)) found = oth.pts.at(defptr);\map&ref = pts.insert(pair>>(defptr,pair>(found.second.size(),map(less(defptr,cmp))))).first->second.second;\for(decltype(found.second.begin()) it=found.second.begin(), en=found.second.end(); it!=en; ++it)\{\axisType*nw = new axisType[k];\for(axisType*ft=nw, *gt=it->first, *fn=nw+k; ft!=fn; ++ft,++gt)\*ft=*gt;\pairtmp = pair(nw,it->second);\ref.insert(tmp);\order.push_back(pair>(1,tmp));\}\}\void build(space&&oth)\{\deleteNoDestroy();\order = move(oth.order);\pts = move(oth.pts);\sz = oth.sz;\updated = nullptr;\axises = oth.axises;\axisesSzes = oth.axisesSzes;\defptr = oth.defptr;\oth.sz = 0;\oth.axises = static_cast>*>(malloc(k*sizeof(pair>)));\for(pair>*it=axises, *en=axises+k; it!=en; ++it)\new(it)pair>(0,set(cmp));\axisesSzes = (pair>*)malloc(k*sizeof(pair>));\for(pair>*it=axisesSzes, *en=axisesSzes+k; it!=en; ++it)\new(it)pair>(0,map(cmp));\for(size_t*it=oth.defptr, *en=oth.defptr+k, idx=0; it!=en; ++it,++idx)\*it = idx;\oth.pts.insert(pair>>(oth.defptr,pair>(0,map(less(oth.defptr,cmp)))));\}\void clear()\{\deleteNoDestroy();\order.clear();\pts.clear();\updated = nullptr;\sz = 0;\axises = static_cast>*>(malloc(k*sizeof(pair>)));\for(pair>*it=axises, *en=axises+k; it!=en; ++it)\new(it)pair>(0,set(cmp));\axisesSzes = static_cast>*>(malloc(k*sizeof(pair>)));\for(pair>*it=axisesSzes, *en=axisesSzes+k; it!=en; ++it)\new(it)pair>(0,map(cmp));\defptr = new size_t[k];\for(size_t*it=defptr, *en=defptr+k, idx=0; it!=en; ++it,++idx)\*it = idx;\pts.insert(pair>>(defptr,pair>(0,map(less(defptr,cmp)))));\}\space&operator=(const space&oth){build(oth);return*this;}\space&operator=(space&&oth){build(oth);return*this;}\void insert(initializer_listlst,const val&v=val()){insert(lst.begin(),v);}\templatevoid insert(iter begin, const val&v=val())\{\pair>&ref = pts.at(defptr);\if(updated != nullptr)\order.push_back(pair>(2,pair(updated,ref.second.at(updated)))), updated=nullptr;\axisType*tmp = new axisType[k];\for(axisType*en=tmp+k; tmp!=en; ++tmp,++begin)\*tmp = *begin;\tmp-=k;\bool res = ref.second.insert(pair(tmp,v)).second;\if(res)\order.push_back(pair>(1,pair(tmp,v))), ++sz;\else\delete[]tmp;\++ref.first;\}\void erase(initializer_listlst){erase(lst.begin());}\templatevoid erase(iter begin)\{\pair>&ref = pts.at(defptr);\if(updated != nullptr)\order.push_back(pair>(2,pair(updated,ref.second.at(updated)))), updated=nullptr;\axisType*tmp = new axisType[k];\for(axisType*en=tmp+k; tmp!=en; ++tmp,++begin)\*tmp = *begin;\tmp-=k;\if(ref.second.erase(tmp))\order.push_back(pair>(0,pair(tmp,val()))), --sz;\else\delete[]tmp;\++ref.first;\}\const map&points(initializer_listlst){return points(lst.begin());}\templateconst map&points(iter begin)\{\if(updated != nullptr)\order.push_back(pair>(2,pair(updated,pts.at(defptr).second.at(updated)))), updated=nullptr;\size_t*tmp = new size_t[k];\pair>*ref;\for(size_t*en=tmp+k; tmp!=en; ++tmp,++begin)\*tmp = *begin;\tmp -= k;\decltype(pts.find(tmp)) tmpit=pts.find(tmp);\if(tmpit == pts.end())\ref = &(pts.insert(pair>>(tmp,pair>(0,map(less(tmp,cmp))))).first->second);\else\{\ref = &(tmpit->second);\delete[]tmp;\}\for(decltype(order.begin()+ref->first) it=order.begin()+ref->first, en=order.end(); it!=en; ++it)\if(it->first == 1)\ref->second.insert(it->second);\else if(it->first == 0)\ref->second.erase(it->second.first);\else\ref->second.at(it->second.first) = it->second.second;\ref->first = order.size();\return ref->second;\}\const set&axis(size_t idx)\{\const map&ref = pts.at(defptr).second;\if(updated != nullptr)\order.push_back(pair>(2,pair(updated,ref.at(updated)))), updated=nullptr;\pair>*found = axises+idx;\pair>*foundSz = axisesSzes+idx;\if(found->first <= order.size())\for(decltype(order.begin()+found->first) it=order.begin()+found->first, en=order.end(); it!=en; ++it)\{\if(it->first == 1)\{\if(found->second.find(*(it->second.first+idx)) == found->second.end())\found->second.insert(*(it->second.first+idx)), foundSz->second.insert(pair(*(it->second.first+idx),0));\else\++foundSz->second.find(*(it->second.first+idx))->second;\}\else if(it->first == 0)\{\decltype(foundSz->second.find(*(it->second.first+idx))) pos = foundSz->second.find(*(it->second.first+idx));\if(pos->second)\--pos->second;\else\found->second.erase(*(it->second.first+idx)), foundSz->second.erase(pos);\}\}\found->first = order.size();\return found->second;\}\val&operator[](initializer_listlst){return operator[](lst.begin());}\templateval&operator[](iter begin)\{\map&ref = pts.at(defptr).second;\if(updated != nullptr)\order.push_back(pair>(2,pair(updated,ref.at(updated))));\axisType*tmp = new axisType[k];\for(axisType*en=tmp+k; tmp!=en; ++tmp,++begin)\*tmp = *begin;\tmp-=k;\decltype(ref.find(tmp)) found;\updated = tmp;\if((found=ref.find(tmp)) != ref.end())\return found->second;\++sz;\axisType*tmp2 = new axisType[k];\for(axisType*en=tmp2+k; tmp2!=en; ++tmp2,++tmp)\*tmp2 = *tmp;\tmp2 -= k;\order.push_back(pair>(1,pair(tmp2,val())));\val&res = ref.insert(pair(tmp2,val())).first->second;\return res;\}\size_t size()const{return sz;}\};\#endif" exec delcmd elseif a:arg=="array_hash" if search("#ifndef __ARRAY_HASH__")!=0 call setpos('.', curpos) return endif exec initcmd exec "normal! A#ifndef __ARRAY_HASH__\#define __ARRAY_HASH__\class array_hash\{\size_t sz;\unsigned int*hsh,*pws;\const constexpr static unsigned __int128 mod = static_cast(18446744073709551557ULL);\static time_t tminms;\void initialize(size_t fact)\{\size_t*order = new size_t[fact];\for(size_t*it=order, *en=order+fact; it!=en; ++it)\*it = it-order;\mt19937 rng(static_cast(tminms));\shuffle(order,order+fact,rng);\unsigned int*ptr=hsh, *ptrPw=pws;\unsigned int*en=hsh+sz;\*pws = 1;\while(ptr != en)\{\*ptr = static_cast(static_cast((*(order+static_cast(*ptr))))%mod);\if(ptr != hsh)\{\unsigned int*prev=ptr, *prev2=ptrPw;\*ptrPw = static_cast((static_cast(fact)*static_cast(*(--prev2)))%mod);\*ptr = static_cast((static_cast(*ptr)*static_cast(*ptrPw)%mod+static_cast(*(--prev)))%mod);\}\++ptr, ++ptrPw;\}\delete[]order;\}\public:\<array_hash():sz(0),hsh(nullptr),pws(nullptr){}\template>array_hash(initializer_listlst, const comp&cmp=comp()):array_hash(lst.begin(),lst.end(),cmp){}\template::value_type>>array_hash(it begin, it end, const comp&cmp=comp()):sz(distance(begin,end)),hsh(new unsigned int[sz]),pws(new unsigned int[sz])\{\if(sz == 0)\return;\typename iterator_traits::value_type*tmp = new typename iterator_traits::value_type[sz];\copy(begin, end, tmp);\typename iterator_traits::value_type*en = tmp+sz;\sort(tmp, en, cmp);\en = unique(tmp, en);\for(decltype(hsh)iter=hsh, end=hsh+sz; iter!=end; ++iter,++begin)\*iter = static_cast(distance(tmp,lower_bound(tmp, en, *begin, cmp)));\initialize(distance(tmp,en));\delete[]tmp;\}\array_hash(const array_hash&oth):sz(oth.sz),hsh(new unsigned int[sz]),pws(new unsigned int[sz]){copy(oth.hsh, oth.hsh+sz, hsh),copy(oth.pws, oth.pws+sz, pws);}\array_hash(array_hash&&oth):sz(oth.sz),hsh(oth.hsh),pws(oth.pws){oth.sz=0,oth.hsh=nullptr,oth.pws=nullptr;}\~array_hash(){delete[]hsh;delete[]pws;}\template>void build(initializer_listlst, const comp&cmp=comp()){build(lst.begin(),lst.end().cmp);}\template::value_type>>void build(it begin, it end, const comp&cmp=comp())\{\sz=distance(begin,end);\delete[]hsh;\delete[]pws;\pws = new unsigned int[sz];\hsh = new unsigned int[sz];\if(sz == 0)\return;\typename iterator_traits::value_type*tmp = new typename iterator_traits::value_type[sz];\copy(begin, end, tmp);\typename iterator_traits::value_type*en = tmp+sz;\sort(tmp, en, cmp);\en = unique(tmp, en);\for(decltype(hsh)iter=hsh, end=hsh+sz; iter!=end; ++iter,++begin)\*iter = static_cast(distance(tmp,lower_bound(tmp, en, *begin, cmp)));\initialize(distance(tmp,en));\delete[]tmp;\}\void build(const array_hash&oth){delete[]hsh;delete[]pws;sz=oth.sz;hsh=new unsigned int[sz];pws=new unsigned int[sz];copy(oth.hsh,oth.hsh+sz,hsh);copy(oth.pws,oth.pws+sz,pws);}\void build(array_hash&&oth){delete[]hsh;delete[]pws;sz=oth.sz;hsh=oth.hsh;pws=oth.pws;oth.sz=0;oth.hsh=nullptr;oth.pws=nullptr;}\array_hash&operator=(const array_hash&oth){build(oth);return*this;}\array_hash&operator=(array_hash&&oth){build(oth);return*this;}\unsigned int hash(size_t l, size_t r)const\{\unsigned int res = l?*(hsh+r)<*(hsh+(l-1))?static_cast(mod)-*(hsh+(l-1))+*(hsh+r):*(hsh+r)-*(hsh+(l-1)):*(hsh+r);\return static_cast((static_cast(res) * static_cast(*(pws+(sz-l-1)))) % mod);\}\unsigned int max_hash()const{return 18446744073709551556ULL;}\unsigned int size()const{return sz;}\};\time_t array_hash::tminms = chrono::system_clock::now().time_since_epoch().count();\#endif" exec delcmd elseif a:arg=="mint" if search("#ifndef __INVERSE__")==0 execute "normal! :C inverse\" else call setpos('.', curpos) endif if search("#ifndef __MINT__")!=0 call setpos('.', curpos) return endif exec initcmd exec "normal! A#ifndef __MINT__\#define __MINT__\templateclass mint\{\unsigned int val;\public:\<mint():val(0){}\mint(const mint&oth):val(oth.val){}\templatemint(const ty&oth):val(static_cast(oth)%mod){}\templateoperator ty()const{return static_cast(val);}\bool operator<(const mint&oth){return valtemplatebool operator<(const ty&oth){return static_cast(val)bool operator>(const mint&oth){return val>oth.val;}\templatebool operator>(const ty&oth){return static_cast(val)>oth;}\bool operator==(const mint&oth){return val==oth.val;}\templatebool operator==(const ty&oth){return static_cast(val)==oth;}\bool operator!=(const mint&oth){return val!=oth.val;}\templatebool operator!=(const ty&oth){return static_cast(val)!=oth;}\bool operator<=(const mint&oth){return val<=oth.val;}\templatebool operator<=(const ty&oth){return static_cast(val)<=oth;}\bool operator>=(const mint&oth){return val>=oth.val;}\templatebool operator>=(const ty&oth){return static_cast(val)>=oth;}\mint&operator=(const mint&oth){val=oth.val;return*this;}\templatemint&operator=(const ty&oth){val=static_cast(oth),val%=mod;return*this;}\mint&operator+=(const mint&oth){val=valtemplatemint&operator+=(const ty&oth){return(*this)+=mint(oth);}\mint&operator-=(const mint&oth){val=valtemplatemint&operator-=(const ty&oth){return(*this)-=mint(oth);}\mint&operator*=(const mint&oth){val=mod>UINT32_MAX?static_cast(static_cast(val)*static_cast(oth.val)%static_cast(mod)):val*oth.val%mod;return*this;}\templatemint&operator*=(const ty&oth){return(*this)*=mint(oth);}\mint&operator/=(const mint&oth){val/=oth.val;return*this;}\templatemint&operator/=(const ty&oth){return(*this)/=mint(oth);}\mint&operator%=(const mint&oth){val%=oth.val;return*this;}\templatemint&operator%=(const ty&oth){return(*this)%=mint(oth);}\mint operator+(const mint&oth)const{return mint(*this)+=oth;}\templatemint operator+(const ty&oth)const{return mint(*this)+=oth;}\mint operator-(const mint&oth)const{return mint(*this)-=oth;}\templatemint operator-(const ty&oth)const{return mint(*this)-=oth;}\mint operator*(const mint&oth)const{return mint(*this)*=oth;}\templatemint operator*(const ty&oth)const{return mint(*this)*=oth;}\mint operator/(const mint&oth)const{return mint(*this)/=oth;}\templatemint operator/(const ty&oth)const{return mint(*this)/=oth;}\mint operator%(const mint&oth)const{return mint(*this)%=oth;}\templatemint operator%(const ty&oth)const{return mint(*this)%=oth;}\mint&operator++(){return(*this)+=mint(1);}\mint&operator--(){return(*this)-=mint(1);}\mint operator++(signed){mint tmp(*this);++(*this);return tmp;}\mint operator--(signed){mint tmp(*this);--(*this);return tmp;}\mint operator+(){return mint(*this);}\mint operator-(){return mint()-(*this);}\friend ostream&operator<<(ostream&os,const mint&oth){return os<friend istream&operator>>(istream&is,mint&oth){is>>oth.val;oth.val%=mod;return is;}\templatefriend ty&operator+=(ty&val,const mint&oth){return val+=static_cast(oth.val);}\templatefriend ty&operator-=(ty&val,const mint&oth){return val-=static_cast(oth.val);}\templatefriend ty&operator*=(ty&val,const mint&oth){return val*=static_cast(oth.val);}\templatefriend ty&operator/=(ty&val,const mint&oth){return val/=static_cast(oth.val);}\templatefriend ty&operator%=(ty&val,const mint&oth){return val%=static_cast(oth.val);}\templatefriend ty operator+(const ty&val,const mint&oth){return val+static_cast(oth.val);}\templatefriend ty operator-(const ty&val,const mint&oth){return val-static_cast(oth.val);}\templatefriend ty operator*(const ty&val,const mint&oth){return val*static_cast(oth.val);}\templatefriend ty operator/(const ty&val,const mint&oth){return val/static_cast(oth.val);}\templatefriend ty operator%(const ty&val,const mint&oth){return val%static_cast(oth.val);}\templatefriend bool operator<(const ty&val,const mint&oth){return val(oth.val);}\templatefriend bool operator>(const ty&val,const mint&oth){return val>static_cast(oth.val);}\templatefriend bool operator==(const ty&val,const mint&oth){return val==static_cast(oth.val);}\templatefriend bool operator!=(const ty&val,const mint&oth){return val!=static_cast(oth.val);}\templatefriend bool operator<=(const ty&val,const mint&oth){return val<=static_cast(oth.val);}\templatefriend bool operator>=(const ty&val,const mint&oth){return val>=static_cast(oth.val);}\};\templateinline mintinverse(const mint&val){return mint(inverse(static_cast(val),mod));}\#endif" exec delcmd elseif a:arg=="hld" if search("#ifndef __BINARY_LIFTING__")==0 execute "normal! :C binary_lifting\" let curpos=getpos('.') else call setpos('.', curpos) endif if search("#ifndef __SEGTREE__")==0 execute "normal! :C segtree\" let curpos=getpos('.') else call setpos('.', curpos) endif if search("#ifndef __HLD__")!=0 call setpos('.', curpos) return endif execute initcmd exec "normal! a#ifndef __HLD__\#define __HLD__\template, typename lazy=__segtree_default_lz__>class hld\{\binary_lifting lca;\func fn;\lazy lz;\struct node\{\node*prev;\segtree*tr;\size_t dpth;\node():tr(nullptr){}\node(const node&oth):tr(oth.tr==nullptr?nullptr:new segtree(*oth.tr)),dpth(oth.dpth){}\~node(){delete tr;}\};\value runfn(const value&a,const value&b)const{return fn(a,b);}\value runlz(const value&a,const value&b,size_t sz)const{return fn(a,b,sz);}\node*arr;\size_t sz, root1;\size_t checkParent(size_t val, const tree&oth){return oth.parent(val);}\templatesize_t checkParent(size_t val, const tree&oth){return oth.parent(val).first;}\size_t getValue(size_t val){return val;}\templatesize_t getValue(const pair&val){return val.first;}\templatevoid dfs(const tree&oth)\{\stack>st;\st.push(pair(root1,root1));\vector*vt = new vector[sz]();\vectorsegtrees;\while(!st.empty())\{\pairt=st.top();\st.pop();\node*cur = arr+t.first;\cur->prev = arr+t.second;\cur->dpth = oth.height(t.first);\(vt+t.second)->push_back(oth[t.first]);\if(t.first == t.second)\cur->prev = arr+checkParent(t.first,oth), segtrees.push_back(t.first);\if(oth.children(t.first).size()==0)\continue;\decltype(oth.children(t.first).begin())start=oth.children(t.first).begin();\size_t mxSubtree = getValue(*start);\for(decltype(start)it=start, en=oth.children(t.first).end(); it!=en; ++it)\if(oth.subtree(mxSubtree) < oth.subtree(getValue(*it)))\mxSubtree = getValue(*it);\for(decltype(start)en=oth.children(t.first).end(); start!=en; ++start)\if(getValue(*start) == mxSubtree)\st.push(pair(getValue(*start),t.second));\else\st.push(pair(getValue(*start),getValue(*start)));\}\for(size_t i:segtrees)\(arr+i)->tr = new segtree((vt+i)->begin(),(vt+i)->end(),fn,lz);\delete[]vt;\}\void initArr()\{\arr = (node*)malloc(sizeof(node) * sz);\for(node*it=arr, *en=arr+sz; it!=en; ++it)\new(it)node();\}\void initArr(node*oth)\{\arr = (node*)malloc(sizeof(node) * sz);\for(node*it=arr, *en=arr+sz, ft=oth; it!=en; ++it,++ft)\{\new(it)node(*ft);\it->prev = arr+(ft->prev-oth);\}\}\void deleteArr()\{\for(node*it=arr, *en=arr+sz; it!=en; ++it)\it->~node();\free(arr);\}\public:\<hld(func fn=func(), lazy lz=lazy()):lca(binary_lifting()),fn(fn),lz(lz),arr(nullptr),sz(0),root1(0){}\hld(lazy lz):hld(func(),lz){}\templatehld(const tree&tr, func fn=func(), lazy lz=lazy()):lca(tr),fn(fn),lz(lz),sz(tr.size()),root1(tr.root()){initArr(),dfs(tr);}\templatehld(const tree&tr, lazy lz):lca(tr,func(),lz){}\hld(const hld&oth):lca(oth.lca),fn(oth.fn),lz(oth.lz),sz(oth.sz),root1(oth.root1){initArr(oth.arr);}\hld(hld&&oth):lca(move(oth.lca)),fn(oth.fn),lz(oth.lz),arr(oth.arr),sz(oth.sz),root1(oth.root1){oth.arr=nullptr,oth.sz=oth.root1=0;}\templatevoid build(const tree&tr)\{\deleteArr();\lca.build(tr);\sz = tr.size();\root1 = tr.root();\initArr();\dfs(tr);\}\void build(const hld&oth)\{\deleteArr();\lca.build(oth.lca);\sz = oth.sz;\root1 = oth.root1;\initArr(oth.arr);\}\void build(hld&&oth)\{\deleteArr();\lca.build(move(oth.lca));\sz = oth.sz;\root1 = oth.root1;\arr = oth.arr;\oth.sz=oth.arr=0;\oth.arr=nullptr;\}\value query(size_t a, size_t b)const\{\node*ca = arr+a, *cb = arr+b;\if(a==b)\{\if(ca->tr == nullptr)\{\size_t pos = ca->dpth-ca->prev->dpth;\return ca->prev->tr->query(pos, pos);\}\return ca->tr->query(0,0);\}\size_t dpth = (arr+lca.lca(a,b))->dpth;\if(ca->dpth < cb->dpth)\swap(ca,cb);\value res;\bool initialized=false, prevLight=true;\caLabel:\if(ca->tr == nullptr)\{\prevLight = false;\size_t end = ca->dpth - ca->prev->dpth;\ca = ca->prev;\size_t begin = ca->dpthdpth:0;\if(initialized)\res = runfn(res, ca->tr->query(begin,end));\else\initialized = true, res = ca->tr->query(begin,end);\if(ca->dpth > dpth)\goto caLabel;\}\else\{\if(!initialized)\initialized = true, res = ca->tr->query(0,0);\else if(prevLight)\res = runfn(res, ca->tr->query(0,0));\prevLight = true;\ca = ca->prev;\if(ca->dpth >= dpth)\goto caLabel;\}\prevLight=true;\if(cb->dpth == dpth)\return res;\++dpth;\cbLabel:\if(cb->tr == nullptr)\{\prevLight = false;\size_t end = cb->dpth - cb->prev->dpth;\cb = cb->prev;\size_t begin = cb->dpthdpth:0;\if(initialized)\res = runfn(res, cb->tr->query(begin,end));\else\initialized = true, res = cb->tr->query(begin,end);\if(cb->dpth > dpth)\goto cbLabel;\}\else\{\if(!initialized)\initialized = true, res = ca->tr->query(0,0);\else if(prevLight)\res = runfn(res, ca->tr->query(0,0));\prevLight = true;\cb = cb->prev;\if(cb->dpth >= dpth)\goto cbLabel;\}\return res;\}\void update(size_t a, size_t b, const value&val)\{\node*ca = arr+a, *cb = arr+b;\if(a==b)\{\if(ca->tr == nullptr)\{\size_t pos = ca->dpth-ca->prev->dpth;\ca->prev->tr->update(pos, pos, val);\}\else\ca->tr->update(0,0,val);\return;\}\size_t dpth = (arr+lca.lca(a,b))->dpth;\if(ca->dpth < cb->dpth)\swap(ca,cb);\bool prevLight=true;\caLabel:\if(ca->tr == nullptr)\{\prevLight = false;\size_t end = ca->dpth - ca->prev->dpth;\ca = ca->prev;\size_t begin = ca->dpthdpth:0;\ca->tr->update(begin,end,val);\if(ca->dpth > dpth)\goto caLabel;\}\else\{\if(prevLight)\ca->tr->update(0,0,val);\prevLight = true;\ca = ca->prev;\if(ca->dpth >= dpth)\goto caLabel;\}\prevLight=true;\if(cb->dpth == dpth)\return;\++dpth;\cbLabel:\if(cb->tr == nullptr)\{\prevLight = false;\size_t end = cb->dpth - cb->prev->dpth;\cb = cb->prev;\size_t begin = cb->dpthdpth:0;\cb->tr->update(begin,end,val);\if(cb->dpth > dpth)\goto cbLabel;\}\else\{\if(prevLight)\ca->tr->update(0,0,val);\prevLight = true;\cb = cb->prev;\if(cb->dpth >= dpth)\goto cbLabel;\}\}\void update(size_t idx, const value&val)\{\node*ca = arr+idx;\if(ca->tr == nullptr)\ca->prev->tr.update(ca->dpth - ca->prev->dpth, val);\else\ca->tr->update(0,val);\}\value&operator[](size_t idx)\{\node*ptr = arr+idx;\if(ptr->tr == nullptr)\return ptr->prev->tr->operator[](ptr->dpth - ptr->prev->dpth);\return ptr->tr->operator[](0);\}\const value&operator[](size_t idx)const\{\node*ptr = arr+idx;\if(ptr->tr == nullptr)\return ptr->prev->tr->operator[](ptr->dpth - ptr->prev->dpth);\return ptr->tr->operator[](0);\}\size_t size()const{return sz;}\size_t root()const{return root1;}\};\#endif" exec delcmd elseif a:arg=="wavelettree" if search("#ifndef __WAVLETTREE__")!=0 call setpos('.', curpos) return endif exec initcmd exec "normal! A#ifndef __WAVLETTREE__\#define __WAVLETTREE__\templatestruct __wavlettree_def_build__\{\container operator()(const container&first,const container&second)const\{\container res(first.size()+second.size());\decltype(res.begin())st=res.begin();\for(decltype(first.begin())it=first.begin(), en=first.end(); it!=en; ++it)\{\*st = *it;\++st;\}\for(decltype(second.begin())it=second.begin(), en=second.end(); it!=en; ++it)\{\*st = *it;\++st;\}\sort(res.begin(), res.end());\return res;\}\};\templatestruct __wavlettree_def_init__\{\templatecontainer operator()(const value&element)const\{\container tmp(1);\*tmp.begin() = element;\return tmp;\}\};\templatestruct __wavlettree_def_convert__\{\templatesize_t operator()(const container&cont, const value&val)const\{\return upper_bound(cont.begin(), cont.end(), val) - lower_bound(cont.begin(), cont.end(), val);\}\};\templatestruct __wavlettree_def_combine__\{\size_t operator()(size_t a, size_t b)const{return a+b;}\};\template, typename init=__wavlettree_def_init__, typename buildType=__wavlettree_def_build__, typename convert=__wavlettree_def_convert__, typename combine=__wavlettree_def_combine__>class wavelettree\{\init in;\buildType bl;\convert cn;\combine cm;\struct node\{\container*cnt;\node*a, *b;\node():cnt(nullptr),a(nullptr),b(nullptr){}\~node(){delete cnt;}\};\node*root;\size_t sz;\container runBuild(const container&a, const container&b)const{return bl(a,b);}\container runInit(const value&b)const{return in(b);}\templateretval runConvert(const container&cont, const val1&val)const{return cn(cont,val);}\retval runCombine(const retval&va, const retval&vb)const{return cm(va,vb);}\templatevoid buildBruh(node*nd, size_t l, size_t r, iter&begin)\{\if(l==r)\{\nd->cnt = new container(runInit(*begin));\++begin;\return;\}\size_t mid = (l+r)>>1;\buildBruh(nd->a=new node(), l, mid, begin);\buildBruh(nd->b=new node(), mid+1, r, begin);\nd->cnt = new container(runBuild(*(nd->a->cnt), *(nd->b->cnt)));\}\void copy(node*nd, size_t l, size_t r, node*oth)\{\nd->cnt = new container(*(oth->cnt));\if(l==r)\return;\size_t mid = (l+r)>>1;\copy(nd->a=new node(), l, mid, oth->a);\copy(nd->b=new node(), mid+1, r, oth->b);\}\void destroy(node*nd, size_t l, size_t r)\{\if(l==r)\{\delete nd;\return;\}\size_t mid = (l+r)>>1;\destroy(nd->a, l, mid);\destroy(nd->b, mid+1, r);\delete nd;\}\templateretval query(node*tr, size_t l, size_t r, size_t ql, size_t qr, const val1&val)const\{\if(l>=ql && r<=qr)\return runConvert(*(tr->cnt), val);\size_t mid = (l+r)>>1;\if(mid >= ql)\{\if(mid < qr)\return runCombine(query(tr->a, l, mid, ql, qr, val), query(tr->b, mid+1, r, ql, qr, val));\return query(tr->a, l, mid, ql, qr, val);\}\return query(tr->b, mid+1, r, ql, qr, val);\}\public:\<wavelettree(init in, buildType bl, convert cn, combine cm):in(in),bl(bl),cn(cn),cm(cm),root(nullptr),sz(0){}\wavelettree():wavelettree(buildType(),init(),convert(),combine()){}\wavelettree(initializer_listlst, init in, buildType bl, convert cn, combine cm):wavelettree(lst.begin(),lst.end(),in,bl,cn,cm){}\wavelettree(initializer_listlst):wavelettree(lst.begin(),lst.end(),buildType(),init(),convert(),combine()){}\templatewavelettree(iter begin, iter end, init in, buildType bl, convert cn, combine cm):in(in),bl(bl),cn(cn),cm(cm),root(new node()),sz(distance(begin,end)){buildBruh(root, 0, sz-1, begin);}\templatewavelettree(iter begin, iter end):wavelettree(begin,end,init(),buildType(),convert(),combine()){}\wavelettree(const wavelettree&oth):in(oth.in),bl(oth.bl),cn(oth.cn),cm(oth.cm),sz(oth.sz)\{\if(sz)\copy(root=new node(), 0, sz-1, oth.root);\else\root = nullptr;\}\wavelettree(wavelettree&&oth):in(oth.in),bl(oth.bl),cn(oth.cn),cm(oth.cm),root(oth.root),sz(oth.sz)\{\oth.root=nullptr;\oth.sz=0;\}\~wavelettree(){if(sz!=0)destroy(root,0,sz-1);}\void build(){if(sz!=0)destroy(root,0,sz-1);root=nullptr,sz=0;}\void build(const wavelettree&oth){if(oth.root==root)return;if(sz!=0)destroy(root,0,sz-1);sz=oth.sz;if(sz){root=new node();copy(root,0,sz-1,oth.root);}else root=nullptr;}\void build(wavelettree&&oth){if(oth.root==root)return;if(sz!=0)destroy(root,0,sz-1);sz=oth.sz,root=oth.root,oth.sz=0,oth.root=nullptr;}\wavelettree&operator=(const wavelettree&oth){build(oth);return*this;}\wavelettree&operator=(wavelettree&&oth){build(oth);return*this;}\templateretval query(size_t begin, size_t end, const val1&val)const{return query(root, 0, sz-1, begin, end, val);}\size_t size()const{return sz;}\};\#endif" exec delcmd elseif a:arg == "base" if search("#ifndef __BASE__")!=0 call setpos('.', curpos) return endif exec initcmd exec "normal! A#ifndef __BASE__\#define __BASE__\inline string base(int n, size_t base=10, const string&charset=string(\"0123456789ABCDEF\"))\{\bool isNeg = n<0;\if(base < 2)\throw new invalid_argument(\"base cannot be lower than 2\");\if(n == 0)\return string(charset[0], 1);\string res;\while(n > 0)\{\res += charset[n%base];\n /= base;\}\if(isNeg)\res += '-';\reverse(res.begin(), res.end());\return res;\}\#endif\" exec delcmd elseif a:arg=="binary_search" if search("#ifndef __BINARY_SEARCH__")!=0 call setpos('.', curpos) return endif exec initcmd exec "normal! A#ifndef __BINARY_SEARCH__\#define __BINARY_SEARCH__\templateinline unsigned int __binary_search__(unsigned int begin, unsigned int end, func fn=func())\{\while(begin < end)\{\size_t mid = begin+((end-begin)>>1);\if(fn(mid))\begin = mid+1;\else\end = mid;\}\return begin;\}\templateinline double __binary_search__(double begin, double end, double accuracy, func fn=func())\{\while(end-begin > accuracy)\{\double mid = (end+begin) * 0.5L;\if(fn(mid))\begin = mid;\else\end = mid;\}\return begin;\}\template::value_type>>\inline bool __binary_search__(iter begin, iter end, const val&v, comp cmp=comp()){return binary_search(begin,end,v,cmp);}\#endif" . g:bf1 . "\ggo#define binary_search __binary_search__\G?" . g:bf1 . "\v$\"_d" exec delcmd elseif a:arg == "base" if search("#ifndef __BASE__")!=0 call setpos('.', curpos) return endif exec initcmd exec "normal! A#ifndef __BASE__\#define __BASE__\inline string base(int n, size_t base=10, const string&charset=string(\"0123456789ABCDEF\"))\{\bool isNeg = n<0;\if(base < 2)\throw new invalid_argument(\"base cannot be lower than 2\");\if(n == 0)\return string(charset[0], 1);\string res;\while(n > 0)\{\res += charset[n%base];\n /= base;\}\if(isNeg)\res += '-';\reverse(res.begin(), res.end());\return res;\}\#endif\" exec delcmd elseif a:arg == "sparse_table" if search("#ifndef __SPARSE_TABLE__")!=0 call setpos('.', curpos) return endif exec initcmd exec "normal! A#ifndef __SPARSE_TABLE__\#define __SPARSE_TABLE__\templatestruct __sparse_table_def_query_min__{ty operator()(const ty&a,const ty&b)const{return min(a,b);};};\templatestruct __sparse_table_def_query_max__{ty operator()(const ty&a,const ty&b)const{return max(a,b);};};\template>class sparse_table\{\static size_t countl_zero(unsigned long long b){return __builtin_clzll(b);}\static size_t countl_zero(unsigned long b){return __builtin_clzl(b);}\static size_t countl_zero(unsigned b){return __builtin_clz(b);}\func fn;\size_t sz,log2;\ty**table;\ty runfn(const ty&a, const ty&b)const{return fn(a,b);}\void constructFwd()\{\for(size_t j=1; jfor(ty**it=table, **en=table+sz-(static_cast(1)<*((*it)+j) = runfn(*((*it)+(j-1)), *((*(it+(static_cast(1)<<(j-1))))+(j-1)));\}\void construct()\{\log2 = sizeof(size_t)*8-countl_zero(sz)-1;\size_t cpy=log2, dist=sz;\for(ty**it=table, **en=table+sz; it!=en; ++it,--dist)\{\*it = new ty[log2+1]();\if((static_cast(1)<--log2;\}\log2=cpy+1;\constructFwd();\}\void construct(const ty&fill)\{\log2 = sizeof(size_t)*8-countl_zero(sz)-1;\size_t cpy=log2, dist=sz;\for(ty**it=table, **en=table+sz; it!=en; ++it,--dist)\{\*it = new ty[log2+1]();\*(*it) = fill;\if((static_cast(1)<--log2;\}\log2=cpy+1;\constructFwd();\}\void construct(const sparse_table&oth)\{\log2 = sizeof(size_t)*8-countl_zero(sz)-1;\size_t cpy=log2, dist=sz;\for(ty**it=table, **en=table+sz, **othIt=oth.table; it!=en; ++it,--dist,++othIt)\{\*it = new ty[log2+1]();\*(*it) = *(*othIt);\if((static_cast(1)<--log2;\}\log2=cpy+1;\constructFwd();\}\templatevoid construct(iter begin)\{\log2 = sizeof(size_t)*8-countl_zero(sz)-1;\size_t cpy=log2, dist=sz;\for(ty**it=table, **en=table+sz; it!=en; ++it,--dist,++begin)\{\*it = new ty[log2+1]();\*(*it) = *begin;\if((static_cast(1)<--log2;\}\log2=cpy+1;\constructFwd();\}\void destruct()\{\for(ty**it=table, **en=table+sz; it!=en; ++it)\delete[](*it);\delete[]table;\}\public:\<sparse_table(func fn=func()):fn(fn),sz(0),table(nullptr){}\sparse_table(size_t sz, func fn=func()):fn(fn),sz(sz),table(new ty*[sz]){construct();}\sparse_table(size_t sz, const ty&fill, func fn=func()):fn(fn),sz(sz),table(new ty*[sz]){construct(fill);}\sparse_table(initializer_listlst, func fn=func()):sparse_table(lst.begin(),lst.end(),fn){}\templatesparse_table(iter begin, iter end, func fn=func()):fn(fn),sz(distance(begin,end)),table(new ty*[sz]){construct(begin);}\sparse_table(const sparse_table&oth):fn(oth.fn),sz(oth.sz),table(new ty*[sz]){construct(oth);}\sparse_table(sparse_table&&oth):fn(oth.fn),sz(oth.sz),table(oth.table){oth.sz=0,oth.table=nullptr;}\~sparse_table(){destruct();}\void build(size_t sz)\{\destruct();\this->sz = sz;\table = new ty*[sz];\construct();\}\void build(size_t sz, const ty&fill)\{\destruct();\this->sz = sz;\table = new ty*[sz];\construct(fill);\}\templatevoid build(iter begin, iter end)\{\destruct();\this->sz = distance(begin,end);\table = new ty*[sz];\construct(begin);\}\void build(initializer_listlst){build(lst.begin(),lst.end());}\void build(const sparse_table&oth)\{\destruct();\sz = oth.sz;\table = new ty*[sz];\construct(oth);\}\void build(sparse_table&&oth)\{\destruct();\sz = oth.sz;\table = oth.table;\oth.sz=0;\oth.table=nullptr;\}\size_t size()const{return sz;}\sparse_table&operator=(const sparse_table&oth){build(oth);return*this;}\sparse_table&operator=(sparse_table&&oth){build(oth);return*this;}\sparse_table&operator=(initializer_listlst){build(lst);return*this;}\ty query(size_t left, size_t right)const\{\size_t dist = right-left+1;\size_t log2 = sizeof(size_t)*8-countl_zero(dist)-1;\if(dist == static_cast(1)<return *(*(table+left)+log2);\return runfn(*(*(table+left)+log2), *(*(table+right-(static_cast(1)<}\const ty&operator[](size_t idx)const{return *(*(table+idx));}\};\templateusing min_sparse_table=sparse_table>;\templateusing max_sparse_table=sparse_table>;\#endif" exec delcmd elseif a:arg=="prefix_array" if search("#ifndef __PREFIX_ARRAY__")!=0 call setpos('.', curpos) return endif exec initcmd exec "normal! a#ifndef __PREFIX_ARRAY__\#define __PREFIX_ARRAY__\templatestruct __prefix_array_def_fwd__{ty operator()(const ty&a,const ty&b)const{return a+b;}};\templatestruct __prefix_array_def_bwd__{ty operator()(const ty&a,const ty&b)const{return b-a;}};\template, typename bwd=__prefix_array_def_bwd__>class prefix_array\{\size_t sz;\fwd f1;\bwd f2;\ty runfwd(const ty&a, const ty&b)const{return f1(a,b);}\ty runbwd(const ty&a, const ty&b)const{return f2(a,b);}\ty*arr;\void pfx()\{\if(sz!=0)\for(ty*it=arr+1, *en=arr+sz; it!=en; ++it)\*it = runfwd(*it, *(it-1));\}\public:\<prefix_array(fwd f1=fwd(),bwd f2=bwd()):sz(0),f1(f1),f2(f2),arr(nullptr){}\prefix_array(bwd b1):prefix_array(fwd(),b1){}\prefix_array(size_t sz, fwd f1=fwd(), bwd f2=bwd()):sz(sz),f1(f1),f2(f2),arr(new ty[sz]()){}\prefix_array(size_t sz, bwd b1):prefix_array(sz, fwd(), b1){}\templateprefix_array(iter begin, iter end, fwd f1=fwd(), bwd f2=bwd()):sz(distance(begin,end)),f1(f1),f2(f2),arr(new ty[sz]()){copy(begin,end,arr),pfx();}\templateprefix_array(iter begin, iter end, bwd b1):prefix_array(begin,end,fwd(),b1){}\prefix_array(initializer_listlst, fwd f1=fwd(), bwd f2=bwd()):prefix_array(lst.begin(),lst.end(),f1,f2){}\prefix_array(initializer_listlst, bwd b1):prefix_array(lst.begin(),lst.end(),fwd(),b1){}\prefix_array(const prefix_array&oth):sz(oth.sz),f1(oth.f1),f2(oth.f2),arr(new ty[sz]()){copy(oth.arr,oth.arr+sz,arr);}\prefix_array(prefix_array&&oth):sz(oth.sz),f1(oth.f1),f2(oth.f2),arr(oth.arr){oth.arr=nullptr,oth.sz=0;}\~prefix_array(){delete[]arr;}\size_t size()const{return sz;}\const ty&operator[](size_t idx)const{return*(arr+idx);}\void build(size_t sz)\{\delete[]arr;\this->sz = sz;\arr = new ty[sz]();\}\templatevoid build(iter begin, iter end)\{\delete[]arr;\sz = distance(begin,end);\arr = new ty[sz]();\copy(begin,end,arr);\pfx();\}\void build(initializer_listlst){build(lst.begin(),lst.end());}\void build(const prefix_array&oth)\{\delete[]arr;\sz=oth.sz;\arr=new ty[sz]();\copy(oth.arr,oth.arr+sz,arr);\}\void build(prefix_array&&oth)\{\delete[]arr;\sz=oth.sz;\arr=oth.arr;\oth.sz=0;\oth.arr=nullptr;\}\prefix_array&operator=(const prefix_array&oth){build(oth);return*this;}\prefix_array&operator=(prefix_array&&oth){build(oth);return*this;}\prefix_array&operator=(initializer_listlst){build(lst);return*this;}\ty query(size_t l, size_t r)const{if(l==0)return*(arr+r);return runbwd(*(arr+(l-1)), *(arr+r));}\ty operator[](size_t idx){return query(idx,idx);}\};\#endif" exec delcmd elseif a:arg=="all" for item in g:completions if (item!='all') && (item!='cases') && (item!='caseless') exec 'normal! :C ' . item . "\" endif endfor else echo "NO TEMPLATE FOUND" return endif endfunction function! Hack(arg) let bf = g:bf1 let brh_id = synIDtrans(hlID("Normal")) let ctermfg = synIDattr(brh_id, "fg", "cterm") let ctermbg = synIDattr(brh_id, "bg", "cterm") let rnd = "____" let strbruh = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890" let cf = '' for i in range(1,38) let cf = cf . strbruh[rand() % len(strbruh)] endfor for i in range(1,50) let rnd = rnd . strbruh[rand() % len(strbruh)] endfor let rnd = rnd . ";" let cmdogheight = &cmdheight . "" let oth2 = "Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\Ajjj:::\\\\\\\" let initcmd = "normal! :silent vsp\:silent q!\:silent set cmdheight=69420\a" . rnd . "\gg:call search(\"" . rnd . "\")\AA\\gg:call search(\"" . bf . "\")\jO\\\" let delcmd = "normal! Aa\bruh\\\\" . cf . "\ggGggGggGgg:silent call search(\".\")\ggGggARANDOM :::\\\\\\\\\\\ABEE\\\\:silent call search(\"Congratulations! You have found a text that nobody cares about! Finding out this text means that you have no life, and are will take countless hours just to do something so meaningless. Nobody will congratulate you for what you have discovered. Its just another easter egg amongst the thousands awaiting to be discovered. But there's no purpose. So, I guess congratulations to you. Good job for discovering this easter egg.\")\" . oth2 . "IARE\\\\GASLASH\\\\\\gg:silent call search(\"" . bf . "\")\A\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\gg:silent call search(\"" . cf . "\")\A\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ // " . bf . "\gg:silent call search(\"" . rnd . "\")\54la\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\zz:set cmdheight=" . cmdogheight . "\:redraw\" let curpos=getpos('.') if a:arg=="c++17_ump" if search("#ifndef __HACK_CPP17_UMP__")!=0 call setpos('.', curpos) else exec initcmd exec "normal! a#ifndef __HACK_CPP17_UMP__\#define __HACK_CPP17_UMP__\inline vectorhack()\{\int cur=0;\vectorres(20000);\for(size_t i=0; i<20000; i++)\res[i] = cur+=26267;\mt19937 rng(17);\shuffle(res.begin(), res.end(), rng);\return res;\}\#endif" exec delcmd endif elseif a:arg=="c++20_ump" if search("#ifndef __HACK_CPP20_UMP__")!=0 call setpos('.', curpos) else exec initcmd exec "normal! a#ifndef __HACK_CPP20_UMP__\#define __HACK_CPP20_UMP__\inline vectorhack()\{\int cur=0;\vectorres(20000);\for(size_t i=0; i<20000; i++)\res[i] = cur+=20753;\mt19937 rng(20);\shuffle(res.begin(), res.end(), rng);\return res;\}\#endif" exec delcmd endif elseif a:arg=="c++23_ump" if search("#ifndef __HACK_CPP23_UMP__")!=0 call setpos('.', curpos) else exec initcmd exec "normal! a#ifndef __HACK_CPP23_UMP__\#define __HACK_CPP23_UMP__\inline vectorhack()\{\int cur=0;\vectorres(20000);\for(size_t i=0; i<20000; i++)\res[i] = cur+=20753;\mt19937 rng(23);\shuffle(res.begin(), res.end(), rng);\return res;\}\#endif" exec delcmd endif elseif a:arg=="java8_sort" if search("#ifndef __HACK_JAVA_8_SORT__")!=0 call setpos('.', curpos) else exec initcmd exec "normal! A#ifndef __HACK_JAVA_8_SORT__\#define __HACK_JAVA_8_SORT__\inline vectorhack(size_t n)\{\vectorres;\int subVal=n;\int addVal=1;\int mxVal = (int)n+1;\pair*a = (pair*)malloc(sizeof(pair)*n);\auto srt = [&](int left, int right, auto srt)->void\{\int length = right-left+1;\if(length < 47)\{\for(int i=left; i<=right; i++)\if(a[i].first==mxVal)\a[i].first = subVal--;\return;\}\int seventh = (length >> 3) + (length >> 6) + 1;\int e3 = (left + right) >> 1;\int e2 = e3 - seventh;\int e1 = e2 - seventh;\int e4 = e3 + seventh;\int e5 = e4 + seventh;\if(a[e5].first==mxVal)\a[e5].first = addVal++;\if(a[e3].first==mxVal)\a[e3].first = addVal++;\if(a[e1].first==mxVal)\a[e1].first = addVal++;\if(a[e4].first==mxVal)\a[e4].first = addVal++;\if(a[e2].first==mxVal)\a[e2].first = addVal++;\pairlst[] = {a[e1], a[e2], a[e3], a[e4], a[e5]};\sort(lst, lst+5);\a[e1]=lst[0], a[e2]=lst[1], a[e3]=lst[2], a[e4]=lst[3], a[e5]=lst[4];\int less = left;\int great = right;\pair pivot1 = a[e2], pivot2 = a[e4];\a[e2] = a[left];\a[e4] = a[right];\while(a[++less]while(a[--great]>pivot2);\for(int k=less-1; ++k<=great;)\{\if(a[k] < pivot1)\swap(a[less++], a[k]);\else\{\while(a[great] > pivot2)\if(great-- == k)\goto outer1;\pair tmp = a[k];\if(a[great] < pivot1)\{\a[k] = a[less];\a[less] = a[great];\++less;\}\else\a[k] = a[great];\a[great] = tmp;\--great;\}\}\outer1:\a[left] = a[less-1];\a[less-1] = pivot1;\a[right] = a[great+1];\a[great+1] = pivot2;\srt(left, less-2, srt);\srt(great+2, right, srt);\srt(less, great, srt);\};\for(size_t i=0; ia[i] = {mxVal, i};\for(size_t i=0; i<67; i++)\a[i*2+1].first = addVal++, a[i*2].first = addVal++;\sort(a, a+134);\srt(0,subVal-1,srt);\res.resize(n);\for(size_t i=0; ires[a[i].second] = a[i].first;\free(a);\return res;\}\#endif" exec delcmd endif elseif a:arg=="c_qsort" if search("#ifndef __HACK_C_QSORT__")!=0 call setpos('.', curpos) else exec initcmd exec "normal! A#ifndef __HACK_C_QSORT__\#define __HACK_C_QSORT__\inline vectorhack(size_t n)\{\vectorres(n*2+1);\for(size_t i=0; ires[i] = i+1;\for(size_t i=0; iswap(res[2*n-2*i-1], res[2*n-i-1]);\return res;\}\#endif" exec delcmd endif elseif a:arg==#"" else echo "NO HACKS FOUND" return endif new e D:\Vim\hacks.txt set readonly set nomodifiable if a:arg==#"" else exec "normal! gg\/".a:arg."\^zt" endif endfunction let g:types = ["dsu", "segtree", "graph", "tree", "binary_lifting", "array_hash", "hld", "mint", "wavelettree", "sparse_table", "prefix_array"] let g:subtypes = ["min_sparse_table", "max_sparse_table"] let g:functions = ["caseless", "cases", "inverse", "fibonacci", "prime", "factor", "factorial", "ncr", "base", "binary_search", "all"] let g:hacks = ["c++17_ump", "c++20_ump", "c++23_ump", "java8_sort", "c_qsort"] let tmp = copy(g:types) + copy(g:subtypes) hi CustomDefine ctermfg=2 let pattern = '' . join(tmp, ' ') . '' autocmd FileType cpp execute "syn keyword CustomDefine " . pattern . "" autocmd FileType cuda execute "syn keyword CustomDefine " . pattern . "" let g:completions = g:types + g:functions call sort(g:completions) function! CustomCompletion(A,L,P) abort let filtered_completions = [] for option in g:completions if stridx(option, a:A) == 0 call add(filtered_completions, option) endif endfor return filtered_completions endfunction function! CustomHackLetion(A,L,P) abort let filtered_completions = [] for option in g:hacks if stridx(option, a:A) == 0 call add(filtered_completions, option) endif endfor return filtered_completions endfunction function! MCommand() exec "normal! A\\\\\\\\\\\\\^lllllllllllli\\\\\\\\\\\\\^" endfunction set more command! -nargs=1 -complete=customlist,CustomCompletion Construct call Global() command! -nargs=? -complete=customlist,CustomHackLetion Hack call Hack() command! Build call Build() function! Run_command(...) let l:bruh = copy(a:000) for i in range(len(l:bruh)) let l:bruh[i]='"' . l:bruh[i] . '"' endfor let l:args = join(l:bruh, ' ') exec '!@echo off & color 09 & cls & cfThief submit ' . l:args . '' endfunction function! Contest(...) let l:bruh = copy(a:000) for i in range(len(l:bruh)) let l:bruh[i] = '"' . l:bruh[i] . '"' endfor let l:args = join(l:bruh, ' ') exec '!@echo off & color 09 & cls & cfThief problem ' . l:args . '' endfunction command! -nargs=* Submit call Run_command() command! -nargs=* Problem call Contest() autocmd VimEnter * execute 'delcommand Sexplore' autocmd VimEnter * execute 'delcommand Pexplore' autocmd VimEnter * execute 'delcommand Texplore' autocmd VimEnter * execute 'delcommand TOhtml' autocmd VimEnter * execute 'delcommand Hexplore' let gbruhf = v:false let timer = 0 let isF = v:true function! Pause(timer) let g:isF = v:true endfunction set updatetime=3000 autocmd CmdLineLeave * exec 'let g:isF = v:false | call timer_start(3000, "Pause")' autocmd CmdLineEnter * exec 'let g:isF = v:false' let jobId = 0 let cont1 = [' '] function! ConstantEcho(...) if g:isF let cont = readfile('D:/Vim/out.txt') if len(cont)>0 let g:cont1 = cont endif let lineNum = len(g:cont1)-1 while lineNum != -1 if g:cont1[lineNum] != '' echom g:cont1[lineNum] break endif let lineNum = lineNum-1 endwhile endif endfunction function! JobComplete(...) call timer_stop(g:timer) call job_stop(g:jobId) let g:gbruhf = v:false execute 'call ConstantEcho()' endfunction function! StartTimer(...) let tmp = g:gbruhf if !tmp echom 'STARTED' let bruh = copy(a:000) for j in range(len(l:bruh)) let bruh[j] = '"' . bruh[j] . '"' endfor let l:args = join(l:bruh, ' ') let g:jobId = job_start('cfthief -f "D:/Vim/out.txt" standings ' . l:args, {'close_cb':function('JobComplete')}) let g:timer = timer_start(500, 'ConstantEcho', {'repeat': -1}) let g:gbruhf = v:true else echom 'STOPPED' call timer_stop(g:timer) call job_stop(g:jobId) let g:gbruhf = v:false endif endfunction command! -nargs=* Thread call StartTimer()