KACTL (KTH Algorithm Competition Template Library)
KTH's open ICPC team reference document: about 25 pages of short, tested, copy-pasteable C++ for data structures, graphs, number theory, geometry and strings, kept within the World Finals notebook limit. Teams around the world print it as is or use it as the starting point for their own notebook.
3.5k (kth-competitive-programming/kactl)
GitHub · Sept 2026
25 pages plus a cover page
GitHub · Sept 2026
GitHub repo
Other
KTH Royal Institute of Technology
Reference: study one algorithm at a time
Advanced
Free
What KACTL is
KACTL is the ICPC team reference document of KTH Royal Institute of Technology in Stockholm. Its README describes it as "25 pages of copy-pasteable C++ code, for use in ICPC-style programming competitions." A team reference document, or team notebook, is the set of printed notes an ICPC team may use during a contest; at the World Finals it is limited to a PDF of up to 25 pages, which is why KACTL is kept to exactly that length.
The repository holds the source of every algorithm, the LaTeX that builds the PDF, and stress tests that compare many implementations against slower reference solutions on random inputs, run automatically on every commit.
What is inside
A short contest template, then chapters of compact implementations: data structures (segment trees, Fenwick trees, ordered sets and more), numerical methods, number theory, combinatorics, graphs (flows, matchings, strongly connected components, trees), geometry and strings. The authors aim for code that is "useful, short, fast enough, well tested", and deliberately leave out algorithms that are very common and simple, such as Dijkstra, or very rare.
Each algorithm has a header with its author, a description, its complexity and its testing status. Each also carries a short hash, so after typing it in from paper you can check you copied it correctly.
Who it is for
Teams preparing for ICPC regionals and beyond, and individual contestants rated roughly 1600 and above who want reliable implementations of harder structures. Beginners get less from it: the code is terse on purpose, with macros such as rep and sz, and it assumes you already understand the algorithm.
How to use it well
- Do not print it and hope. Pick the algorithms your team actually uses, practise each on real problems, and know how to call it.
- Build your own notebook from it: the README explains how to change the contents, the team name and the layout.
- Check your regional's rules on printed material. They differ from the World Finals rules and change between seasons.
- Learn the idea from cp-algorithms or a textbook first; use KACTL for the tested implementation.
Free or paid?
Free. The README notes that the licensing situation is "a bit unclear", as is common for contest code: the authors try to use CC0 where files are marked, and each file names its source and author.
Common questions
Can I use it on Codeforces? Codeforces allows code written before the contest, so a personal library based on it is common. Check each platform's current rules.
Should our team use it unchanged? Many teams start with it, then swap in what they know best. A notebook you have practised with beats a perfect one you have not.
Best for: ICPC teams building or refreshing their notebook, and advanced contestants who want tested C++ for harder algorithms.
Ready to start?
Opens on KTH Royal Institute of Technology in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.