Recently, I’ve been reorganizing my algorithm templates, which include some data structures and graph algorithms. Since my coding style tends to favor using std::vector instead of C-style arrays, I want my templates to be more encapsulated. I admit I’m not very familiar with this style of templates, so I thought of using AI to help me refine them. Below is a template for finding the LCA using Heavy-Light Decomposition:
My previous templates looked like this:
Meanwhile, I also directly generated the following template using ChatGPT-5:
As we can see, this template doesn’t really have any issues. In fact, in terms of readability, it is already better than most beginners’ code — or at least easier to maintain.
The above examples illustrate that AI has indeed proven to be very effective in maintaining algorithm templates (perhaps partly because such templates already appear in its training data). Whether it is using AI to polish existing templates, assist in modifying them, or directly generate a new one, AI shows strong usability.
Of course, in theory, using AI-generated code during contests is clearly not allowed. But my real question lies in the boundary of using such “templates generated by AI in advance.” On one hand, they are indeed produced by AI; on the other hand, they are prepared before the contest, just like how most participants maintain their own template libraries to bring into competitions.
As a beginner, I would also like to emphasize that AI has lowered the barrier to learning. With AI tools, we can more easily obtain high-quality reference code, and even detect and correct subtle mistakes we might otherwise overlook. At the very least, outside of contests, they can serve as effective learning tools.
Therefore, I started this discussion to hear opinions from the Codeforces community:
Should we allow the use of AI-generated templates?
- Absolutely not
- Allow polishing or debugging templates with AI
- Allow directly using AI-generated templates
If AI templates are allowed, in which scenarios should they be acceptable?
- Only in pre-contest preparation (AI-assisted template maintenance)
- Also during contests (AI-generated or AI-debugged templates)
Should templates indicate when they are generated or refined by AI?
For options not covered above, share it in the comments.



