#include using namespace std; namespace fastIO{ #define BUF_SIZE 100000 #define OUT_SIZE 100000 //fread->read bool IOerror=0; //inline char nc(){char ch=getchar();if(ch==-1)IOerror=1;return ch;} inline char nc(){ static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE; if(p1==pend){ p1=buf;pend=buf+fread(buf,1,BUF_SIZE,stdin); if(pend==p1){IOerror=1;return -1;} } return *p1++; } inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';} template inline bool read(T &x){ bool sign=0;char ch=nc();x=0; for(;blank(ch);ch=nc()); if(IOerror)return false; if(ch=='-')sign=1,ch=nc(); for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0'; if(sign)x=-x; return true; } inline bool read(double &x){ bool sign=0;char ch=nc();x=0; for(;blank(ch);ch=nc()); if(IOerror)return false; if(ch=='-')sign=1,ch=nc(); for(;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0'; if(ch=='.'){ double tmp=1; ch=nc(); for(;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0'); } if(sign)x=-x; return true; } inline bool read(char *s){ char ch=nc(); for(;blank(ch);ch=nc()); if(IOerror)return false; for(;!blank(ch)&&!IOerror;ch=nc())*s++=ch; *s=0; return true; } inline bool read_line(char *s){ char ch=nc(); for(;blank(ch);ch=nc()); if(IOerror)return false; for(;ch!='\n'&&!IOerror;ch=nc())*s++=ch; *s=0; return true; } inline bool read(char &c){ for(c=nc();blank(c);c=nc()); if(IOerror){c=-1;return false;} return true; } templatebool read(T& h,U&... t){return read(h)&&read(t...);} #undef OUT_SIZE #undef BUF_SIZE }; using namespace fastIO; /************* debug begin *************/ string to_string(string s){return '"'+s+'"';} string to_string(const char* s){return to_string((string)s);} string to_string(const bool& b){return(b?"true":"false");} templatestring to_string(T x){ostringstream sout;sout<string to_string(pair p){return "("+to_string(p.first)+", "+to_string(p.second)+")";} templatestring to_string(const vector v){ int f=1;string res="{";for(const auto x:v){if(!f)res+= ", ";f=0;res+=to_string(x);}res+="}"; return res; } void debug_out(){puts("");} templatevoid debug_out(const T& h,const U&... t){cout<<" "< PII; typedef pair PLL; typedef pair PIL; typedef pair PLI; typedef vector VI; typedef vector VL; typedef vector VPII; typedef vector VPLL; typedef vector VS; typedef vector VVI; typedef vector VVL; typedef vector VVS; typedef vector VVPII; /************* define end *************/ #include #include #include using namespace __gnu_pbds; /********* gp_hash_table end **********/ void read(int *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);} void read(ll *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);} void read(double *x,int l,int r){for(int i=l;i<=r;i++) read(x[i]);} void println(VI x){for(int i=0;i=ans) break; } if(now