##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######

testlib.h is the industry-standard C++ library for competitive programming problem development, used by Codeforces, ICPC, IOI, and thousands of problemsetters worldwide. This single-header library provides a comprehensive toolkit for creating, validating, and evaluating competitive programming problems. Four Core Components: 1. GENERATORS - Create test cases programmatically • Cross-platform deterministic random: rnd.next() guarantees identical output across all compilers • Pattern-based generation: rnd.next("[a-z]{1,100}") for regex-like string generation • Weighted distributions: rnd.wnext() for non-uniform randomness (useful for trees/graphs) • Built-in permutation generation: rnd.perm(size, first) 2. VALIDATORS - Ensure test data quality • Strict input validation: readInt(), readEoln(), readEof() enforce precise formatting • Constraint checking with meaningful error messages • Mandatory for Codeforces problems 3. CHECKERS - Compare participant output against jury answers • Handle problems with multiple correct solutions • Standardized verdicts: _ok, _wa, _pe, _fail • Unified quitf() function abstracts system-dependent return codes 4. INTERACTORS - Enable interactive problems • Manage bidirectional communication between judge and solution • Control input/output streams during execution Key Features: • Single #include "testlib.h" integration • Predefined stream objects: inf (input), ouf (participant output), ans (jury answer) • Compatible with Polygon problem preparation system • Supports C++11 and higher with g++, clang++, and MSVC • Extensive documentation and Codeforces blog tutorials Used in ROI (Russian National Olympiad), ICPC regionals and world finals, IOI, and all Codeforces rounds. With 1,600+ GitHub stars, testlib.h represents decades of refinement in competitive programming infrastructure.