#pragma once #define isspace_fast(x) ((x) == ' ' || (x) == '\t' || (x) == '\n' || (x) == '\v' || (x) == '\f' || (x) == '\r') int fast_atoi(const char *b) { int res = 0; // Initialize result // Skip whitespace for (; isspace_fast(*b); ++b); if (*b == '-') { ++b; // Iterate through all characters of input string and update result for (; ; ++b) { unsigned d = static_cast(*b) - '0'; if (d > 9) { return res; } res = res * 10 - d; } } else if (*b == '+') { ++b; } // Iterate through all characters of input string and update result for (; ; ++b) { unsigned d = static_cast(*b) - '0'; if (d > 9) { return res; } res = res * 10 + d; } // unreachable return res; }