Testcase generation for random inputs.
Hello, Codeforces!
Here I introduce tgen, a single-header C++ library (similar to jngen) for generating random and adversarial testcases for competitive programming problems.
Header link · Documentation
Tgen supports lists, permutations, graphs, trees, strings, math, geometry, and more. Here are some examples:
There is a robust framework for distinct generation:
Another important feature is adversarial generation, that is, worst-case generation (a.k.a. hacks).
Most of which inspired by Codeforces blogs. There is a feature/time comparison against jngen here.
Give it a try next time you are prepairing a problem! If there are any issues or feature requests, please open an issue on GitHub, and I will sort it out as soon as I can.
Extra: tgen miniblogs
Over the next few weeks, I will post a series of miniblogs discussing interesting mathematical and algorithmic problems that came up during the development of tgen. Stay tuned!
Acknowledgments
I would like to thank Roberio for encouraging me to work on this project, and some friends for the help in discussions: emaneru, bernardo_amorim, rafaelgo, kobus, VinnySJ. Finally, I want to thank ifsmirnov for the inspiring jngen project.








prono is on fire 🔥
Haven't try it yet but I can say that this will be sooo good
>- Hey bro! What are you doing?
- I'm just vibecoding something.
POV the code: 8k lines