How to take fast I/O in C++? - Codeforces

PHOTO EMBED

Wed Jul 08 2020 10:31:27 GMT+0000 (Coordinated Universal Time)

Saved by @htrap

int next_int() {
  char c;
  do { c = getchar(); } while( c != '-' && !isdigit(c) );
  bool neg = (c == '-');
  int result = neg ? 0 : c - '0';
  while( isdigit(c = getchar()) )
    result = 10 * result + (c - '0');
  return neg ? -result : result;
}
content_copyCOPY

https://codeforces.com/blog/entry/21562?