神速输入

const int MAXSIZE = 1 << 20;
char buf[MAXSIZE], *p1, *p2;
#define gc()                                                               
  (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin), p1 == p2) 
       ? EOF                                                               
       : *p1++)
inline int read(){
	int x = 0;char c = gc();
	while(!isdigit(c)) c = gc();
	while(isdigit(c)) x=(x<<3)+(x<<1)+(c^48),c=gc();
	return x;
}
inline void write(int x) {
	static int sta[35];
	int top = 0;
	do {
		sta[top++] = x % 10, x /= 10;
  	} while (x);
  	while (top) putchar(sta[--top] + 48);
}      
char buf[1000001],*ptr=buf-1;
inline int read(){
	int x=0,c=*++ptr;
	while(c<48) c=*++ptr;
	while(c>47) x=(x<<3)+(x<<1)+(c^48),c=*++ptr;
	return x;
}
int main(){
      fread(buf,1,sizeof(buf),stdin)[buf]=0;
}
原文地址:https://www.cnblogs.com/shikeyu/p/13737697.html