Skip to content

Instantly share code, notes, and snippets.

@Chillee
Last active April 16, 2019 00:12
Show Gist options
  • Select an option

  • Save Chillee/9f11313ebe0f42f59db09cdfb4ac0076 to your computer and use it in GitHub Desktop.

Select an option

Save Chillee/9f11313ebe0f42f59db09cdfb4ac0076 to your computer and use it in GitHub Desktop.
Fast IO
struct GC {
char buf[1 << 16 | 1];
int bc = 0, be = 0;
char operator()() {
if (bc >= be) {
be = fread(buf, 1, sizeof(buf) - 1, stdin);
buf[be] = bc = 0;
}
return buf[bc++];
}
};
GC gc;
char gc() {
#ifdef _WIN32
return _getchar_nolock();
#else
return getchar_unlocked();
#endif
}
void read_float() {}
template <class T, class... S> inline void read_float(T &a, S &... b) {
int c, s = 1, fp = 0, fpl = 1;
while (isspace(c = gc()));
if (c == '-') s = -1, c = gc();
for (a = c - '0'; isdigit(c = gc()); a = a * 10 + c - '0');
a *= s;
if (c == '.')
for (; isdigit(c = gc()); fp = fp * 10 + c - '0', fpl *= 10);
a += (double)fp / fpl;
read_float(b...);
}
char gc() {
#ifdef _WIN32
return _getchar_nolock();
#else
return getchar_unlocked();
#endif
}
void read_int() {}
template <class T, class... S> inline void read_int(T &a, S &... b) {
char c, s = 1;
while (isspace(c = gc()));
if (c == '-') s = -1, c = gc();
for (a = c - '0'; isdigit(c = gc()); a = a * 10 + c - '0');
a *= s;
read_int(b...);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment