Competitive Programmer's Handbook
Antti Laaksonen's free book on competitive programming: C++ techniques, complexity, sorting, greedy, dynamic programming, range queries, graph algorithms and advanced topics, explained compactly with examples. It is the standard first book for students heading into Codeforces, olympiads or ICPC, and it pairs chapter by chapter with the CSES Problem Set.
296 (PDF, July 2018 draft)
cses.fi · Sept 2026
30 in three parts
cses.fi · Sept 2026
3.5k (pllk/cphb)
GitHub · Sept 2026
Book
Other
Antti Laaksonen
About 300 pages; a few weeks per part alongside practice
Beginner
Free
What the book is
The Competitive Programmer's Handbook is a free book by Antti Laaksonen, who also develops the CSES judge. Its preface says its purpose is "to give you a thorough introduction to competitive programming", assuming you already know the basics of programming but no previous contest background. It was written with students heading for the IOI or the ICPC in mind, and suits anyone curious about competitive programming.
The PDF is free to download from the CSES site. Its source is on GitHub under a Creative Commons BY-NC-SA 4.0 licence.
What it covers
About 300 pages in 30 chapters and three parts:
- Basic techniques: introduction and C++ tricks, time complexity, sorting and binary search, data structures, complete search, greedy algorithms, dynamic programming, amortised analysis (including two pointers), range queries and bit manipulation.
- Graph algorithms: graph basics, traversal, shortest paths, tree algorithms, spanning trees, directed graphs, strong connectivity, tree queries, paths and circuits, flows and cuts.
- Advanced topics: number theory, combinatorics, matrices, probability, game theory, string algorithms, square root algorithms, segment trees revisited, geometry and sweep line algorithms.
Why it is the usual first book
It is short for what it covers. Each chapter explains an idea with a small example, shows compact C++ and moves on, so you can read a chapter in an evening and then practise. Its order also matches the CSES Problem Set closely, which makes the pair a complete free course: read a chapter, solve the matching CSES section.
How long does it take?
Reading is quick; practising is what takes time. Many students spend a few weeks on Part I while solving problems alongside it, then use Parts II and III over the following months.
Prerequisites
Comfort with one programming language, loops, functions and arrays. The examples are in C++, so knowing a little C++ helps, and the first chapter covers the contest-specific parts.
Free or paid?
The PDF is free. Springer publishes a printed book by the same author, Guide to Competitive Programming, which the CSES page says is based on the handbook "but also discusses more advanced topics."
Common questions
Is the 2018 date a problem? Not really. The core algorithms have not changed. Check your judge's current C++ version for newer language features.
Handbook or cp-algorithms? Start with the handbook for a first pass; use cp-algorithms when you want a deeper article on one topic.
Best for: students starting competitive programming who want one clear, free book that covers the whole path.
Ready to start?
Opens on Antti Laaksonen 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.