-
Notifications
You must be signed in to change notification settings - Fork 0
/
fastio.cpp
104 lines (87 loc) · 3.46 KB
/
fastio.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// input reading in C (fastest)
#include <stdio.h>
#define INPUT_SIZE (4<<20)
int _i0=0;
char _,_n,_i[INPUT_SIZE+5];
#define su(x) do{for(x=_i[_i0++]-48;47<(_=_i[_i0++]);x=x*10+_-48);}while(0)
#define si(x) do{_n=_i[_i0++];if(_n-45)x=_n;else x=_i[_i0++];for(x-=48;47<(_=_i[_i0++]);x=x*10+_-48);if(_n<46)x=-x;}while(0)
#define su2(x) do{while((_=_i[_i0++])<48);for(x=_-48;47<(_=_i[_i0++]);x=x*10+_-48);}while(0)
#define si2(x) do{while((_n=_i[_i0++])<45);if(_n-45)x=_n;else x=_i[_i0++];for(x-=48;47<(_=_i[_i0++]);x=x*10+_-48);if(_n<46)x=-x;}while(0)
int main()
{
#ifdef NOT_DMOJ
freopen("data.txt","r",stdin);
#endif // NOT_DMOJ
fread(_i,1,INPUT_SIZE,stdin);
}
// input+output reading in C (fastest, merged arrays)
#include <stdio.h>
#include <string.h>
#define INPUT_SIZE (4<<20)
#define IO_SIZE (4<<20)
int _i0=0,_o0=0;
char _,_n,__[12],_i[IO_SIZE+5];
#define su(x) do{for(x=_i[_i0++]-48;47<(_=_i[_i0++]);x=x*10+_-48);}while(0)
#define si(x) do{_n=_i[_i0++];if(_n-45)x=_n;else x=_i[_i0++];for(x-=48;47<(_=_i[_i0++]);x=x*10+_-48);if(_n<46)x=-x;}while(0)
#define su2(x) do{while((_=_i[_i0++])<48);for(x=_-48;47<(_=_i[_i0++]);x=x*10+_-48);}while(0)
#define si2(x) do{while((_n=_i[_i0++])<45);if(_n-45)x=_n;else x=_i[_i0++];for(x-=48;47<(_=_i[_i0++]);x=x*10+_-48);if(_n<46)x=-x;}while(0)
void pu(int x) {_=0;do __[_++]=x%10;while(x/=10);while(_--)_i[_o0++]=__[_]+'0';}
void pi(int x) {if(x<0){_i[_o0++]='-';x=-x;}_=0;do __[_++]=x%10;while(x/=10);while(_--)_i[_o0++]=__[_]+'0';}
#define put(s) do{int t=strlen(s);memcpy(_i+_o0,s,t);_o0+=t;}while(0)
int main()
{
#ifdef NOT_DMOJ
freopen("data.txt","r",stdin);
#endif // NOT_DMOJ
fread(_i,1,INPUT_SIZE,stdin);
fwrite(_i,1,_o0,stdout);
}
// input+output reading in C (slower, unmerged i/o arrays)
#include <stdio.h>
#include <string.h>
#define INPUT_SIZE (4<<20)
#define OUTPUT_SIZE (2<<20)
int _i0=0,_o0=0;
char _,_n,__[12],_i[INPUT_SIZE+5],_o[OUTPUT_SIZE+5];
#define su(x) do{for(x=_i[_i0++]-48;47<(_=_i[_i0++]);x=x*10+_-48);}while(0)
#define si(x) do{_n=_i[_i0++];if(_n-45)x=_n;else x=_i[_i0++];for(x-=48;47<(_=_i[_i0++]);x=x*10+_-48);if(_n<46)x=-x;}while(0)
#define su2(x) do{while((_=_i[_i0++])<48);for(x=_-48;47<(_=_i[_i0++]);x=x*10+_-48);}while(0)
#define si2(x) do{while((_n=_i[_i0++])<45);if(_n-45)x=_n;else x=_i[_i0++];for(x-=48;47<(_=_i[_i0++]);x=x*10+_-48);if(_n<46)x=-x;}while(0)
void pu(int x) {_=0;do __[_++]=x%10;while(x/=10);while(_--)_o[_o0++]=__[_]+'0';}
void pi(int x) {if(x<0){_o[_o0++]='-';x=-x;}_=0;do __[_++]=x%10;while(x/=10);while(_--)_o[_o0++]=__[_]+'0';}
#define put(s) do{int t=strlen(s);memcpy(_o+_o0,s,t);_o0+=t;}while(0)
int main()
{
#ifdef NOT_DMOJ
freopen("data.txt","r",stdin);
#endif // NOT_DMOJ
fread(_i,1,INPUT_SIZE,stdin);
fwrite(_o,1,_o0,stdout);
}
// output in C (fastest), uncommon
#include <stdio.h>
#include <string.h>
#define OUTPUT_SIZE (2<<20)
int _o0=0;
char _,__[12],_o[OUTPUT_SIZE+5];
void pu(int x) {_=0;do __[_++]=x%10;while(x/=10);while(_--)_o[_o0++]=__[_]+'0';}
void pi(int x) {if(x<0){_o[_o0++]='-';x=-x;}_=0;do __[_++]=x%10;while(x/=10);while(_--)_o[_o0++]=__[_]+'0';}
#define put(s) do{int t=strlen(s);memcpy(_o+_o0,s,t);_o0+=t;}while(0)
int main()
{
#ifdef NOT_DMOJ
freopen("data.txt","r",stdin);
#endif // NOT_DMOJ
fwrite(_o,1,_o0,stdout);
}
// reading in C++ (slower)
#include <bits/stdc++.h>
using namespace std;
int main()
{
#ifdef NOT_DMOJ
freopen("data.txt","r",stdin);
#endif // NOT_DMOJ
cin.sync_with_stdio(0);
cin.tie(0);
}