#include using namespace std; #if __has_include() #include using namespace atcoder; #endif using ll = long long; using ld = long double; using ull = unsigned long long; #define endl "\n" typedef pair Pii; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REP3(i, m, n) for (int i = (m); (i) < int(n); ++ (i)) #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(x) begin(x), end(x) #define rrep(i,a,b) for(int i=a;i>=b;i--) #define fore(i,a) for(auto &i:a) #define all(s) (s).begin(),(s).end() #define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i) #define drep(i, n) drep2(i, n, 0) #define rever(vec) reverse(vec.begin(), vec.end()) #define sor(vec) sort(vec.begin(), vec.end()) #define fi first #define FOR_(n) for (ll _ = 0; (_) < (ll)(n); ++(_)) #define FOR(i, n) for (ll i = 0; (i) < (ll)(n); ++(i)) #define se second #define pb push_back #define P pair #define PQminll priority_queue, greater> #define PQmaxll priority_queue,less> #define PQminP priority_queue, greater

> #define PQmaxP priority_queue,less

> #define NP next_permutation #define die(a) {cout<void vcin(vector &n){for(int i=0;i>n[i];} templatevoid vcin(vector &n,vector &m){for(int i=0;i>n[i]>>m[i];} templatevoid vcout(vector &n){for(int i=0;ivoid vcin(vector> &n){for(int i=0;i>n[i][j];}}} templatevoid vcout(vector> &n){for(int i=0;i= 0; --(i)) //templateauto min(const T& a){ return *min_element(all(a)); } //templateauto max(const T& a){ return *max_element(all(a)); } templatevoid print(pair a){cout<bool chmax(T &a,const T b) { if (abool chmin(T &a,const T b) { if (b void ifmin(T t,T u){if(t>u){cout<<-1< void ifmax(T t,T u){if(t>u){cout<<-1<>=1;v>>=1;}else if(eu&&!ev){u>>=1;}else if(!eu&&ev){v>>=1;}else if(u>=v){u=(u-v)>>1;}else{ll tmp=u;u=(v-u)>>1;v=tmp;}}return !u?v<>= 1; } return ret; } vector divisor(ll x){ vector ans; for(ll i = 1; i * i <= x; i++){ if(x % i == 0) {ans.push_back(i); if(i*i!=x){ ans.push_back(x / ans[i]);}}}sor(ans); return ans; } ll pop(ll x){return __builtin_popcountll(x);} ll poplong(ll x){ll y=0;while(x){x/=2;y++;}return y;} P hyou(P a){ll x=fastgcd(abs(a.fi),abs(a.se));a.fi/=x;a.se/=x;if(a.se<0){a.fi*=-1;a.se*=-1;}return a;} P Pplus(P a,P b){ return hyou({a.fi*b.se+b.fi*a.se,a.se*b.se});} P Ptimes(P a,ll b){ return hyou({a.fi*b,a.se});} P Ptimes(P a,P b){ return hyou({a.fi*b.fi,a.se*b.se});} P Pminus(P a,P b){ return hyou({a.fi*b.se-b.fi*a.se,a.se*b.se});} P Pgyaku(P a){ return hyou({a.se,a.fi});} void cincout(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout<< fixed << setprecision(15); } constexpr int msb(unsigned int n){return n==0?-1:31-__builtin_clz(n);} constexpr int msb(int n){return n==0?-1:31-__builtin_clz(n);} constexpr int msb(unsigned long long n){return n==0?-1:63-__builtin_clzll(n);} constexpr int msb(long long n){return n==0?-1:63-__builtin_clzll(n);} template std::vectormonotone_minima(int n,int m,const Func&f){ std::vectorres(n); std::vector>st(msb(n)*2+5); int p=0; st[p++]=std::make_tuple(0,n,0,m); while(p>0){ auto [lx,rx,ly,ry]=st[--p]; if(lx==rx)continue; if(lx+1==rx){ res[lx]=ly; for(int i=ly+1;i>1; res[mid]=ly; for(int i=ly+1;i std::vectormin_plus_convolution(const std::vector&a,const std::vector&b){ int n=a.size(),m=b.size(); auto f=[&](int i,int j,int k)->bool { if(i=n)return true; if constexpr(MIN)return a[i-j]+b[j]>a[i-k]+b[k]; else return a[i-j]+b[j]argmin=monotone_minima(n+m-1,m,f); std::vectorres(n+m-1); for(int i=0;i>n>>q; vector a(n),b(n); vcin(a); vcin(b); ll d=2000; vector> f(q); for(int i=0;i x(3); vcin(x); x[0]--; x[2]-=2; f[i]=x; } while(f.size()%d){ f.pb({0,0,0}); } vector id(d); vector c; vector a2; for(int i=0;i