1 #define getc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++) 2 char buf[1<<21],*p1=buf,*p2=buf; 3 char obuf[1<<24],*o=obuf;int wt[30]; 4 struct IO_Tp 5 { 6 7 bool is_digit(const char ch) 8 { 9 return '0' <= ch && ch <= '9'; 10 } 11 12 IO_Tp& operator>>(int& res) 13 { 14 res = 0; 15 char ch; 16 bool neg(false); 17 while (ch = getc(), !is_digit(ch)) 18 neg = ch == '-'; 19 do 20 (res *= 10) += ch & 15; 21 while (ch = getc(), is_digit(ch)); 22 neg ? res = -res : res; 23 return *this; 24 } 25 26 IO_Tp& operator<<(int x){ 27 if(!x) {*o++='0';return *this;} 28 if(x<0) *o++='-',x=-x; 29 int l=0; 30 while(x) wt[++l]=x%10,x/=10; 31 while(l) *o++=wt[l--]+'0'; 32 return *this; 33 } 34 IO_Tp& operator<<(char ch) 35 { 36 *o++ = ch; 37 return *this; 38 } 39 40 } IO;
fwrite(obuf,o-obuf,1,stdout);