Competitive Programming

This is the companion web site for a book: "Competitive Programming 4: The Lower Bound of Programming Contests in the 2020s" (click here for details) and its three past editions written by myself (Steven Halim - UVa status, Kattis status), my younger brother (Felix Halim - UVa status, Kattis status), and my friend (Suhendry Effendy - UVa status, Kattis status) in 2010 - present. This book is used in my course in School of Computing, National University of Singapore: CS3233 - Competitive Programming (2009-present) and available for wider audiences since 2010. This book contains a collection of competitive programming skills gained by solving more than 3500+ UVa (1999-present) plus Kattis (2015-present) online judge problems and being involved in the ICPCs (since 2001) and the IOIs (since 2009) in various roles: contestants (long ago), coaches, judges, ICPC Regional Contest Director (2015, 2018), and/or IOI International Committee member (2020-2021).


Our objective in writing this book is similar with the IOI objective+ICPC vision: to further improve humanity by training current students to be more competitive in programming contests. The possible long term effect is future Computer Science researchers who are well versed in problem solving skills. We use C++ (primary), Python (secondary), Java (tertiary), and OCaml (optional) code to illustrate the algorithmic concepts, i.e., we dislike vague pseudo-code commonly found in many other Computer Science textbooks. We also built and heavily use our-own visualization tool: VisuAlgo to help explain the data structure and algorithm concepts to our book readers and beyond.

Target Audiences

This Competitive Programming book, 4th edition (CP4) is a must have for every competitive programmer. Mastering the contents of this book is a necessary (but admittedly not sufficient) condition if one wishes to take a leap forward from being just another ordinary coder to being among one of the world's finest competitive programmers.

  • CP4, Book 1 (Chapter 1-4):
    • Secondary or High School Students who are competing in the annual International Olympiad in Informatics (IOI) (including the National or Provincial Olympiads) as Book 1 covers most of the current IOI Syllabus,
    • Casual University students who are using this book as supplementary material for typical Data Structures and Algorithms courses,
    • Anyone who wants to prepare for typical fundamental data structure/algorithm part of a job interview at top IT companies.
  • CP4, Book 1+2 (Chapter 1-9):
    • University students who are competing in the annual International Collegiate Programming Contest (ICPC) Regional Contests (including the World Finals) as Book 2 covers much more Computer Science topics that have appeared in the ICPCs,
    • Teachers or Coaches who are looking for comprehensive training materials,
    • Anyone who loves solving problems through computer programs. There are numerous programming contests for those who are no longer eligible for ICPC, including Google CodeJam, Facebook Hacker Cup, TopCoder Open, CodeForces contest, Internet Problem Solving Contest (IPSC), etc.

Forewords for CP4

Selected Testimonials for CP1/2/3

Authors' Profiles

Important News

Friday, 11 June 2021: After 1.5 more years of additional translations by Miguel Revilla Rodriquez (since 01 January 2020), CP4 Book 1 and 2 are now available in Spanish language. Here are the Amazon Book 1 link and Amazon Book 2 link.

Wednesday, 01 January 2020: CP3 (2013 edition with a bit of 2018 upgrade) is now available in Spanish language. If you are a Spanish-speaking programmer, we recommend that you get the Spanish version that has been translated over the past 1+ year by Miguel Revilla Rodriquez (the current admin of (UVa) Online Judge). Here is the Amazon Link, ISBN: 978-1711024813. [Updated remarks on 11 June 2021]: Now that CP4 version is fully available in Spanish, I suggest that you go for the latest version :).

Tuesday, 24 October 2017: CP3 is now available in Korean language. If you are Korean, we recommend that you get the Korean version that has been translated over the past 1+ year by lewha0. Here is the publisher link: Insight Book, Korea.

Buy Now!

Partner Links