Hong Kong · Olympiad in Informatics · Secondary students

C++ for olympiad students in Hong Kong

Every Hong Kong student who reaches the HKOI Final spends three hours writing programs that a judge compiles and tests on hidden data. The rules name C++ as the contest language, and the results show what that means in practice. This page explains which C++ an olympiad student needs, the habits that separate a working program from a scoring one, and how we coach it: live, online, one to one, in English.

Teaching since 2020 · 10,000+ students worldwide · 4.9 from 547 Google reviews · Hong Kong lessons are one to one

The short answer

For the Hong Kong Olympiad in Informatics, learn C++: HKOI's rules ask for solutions in C++20 and call Python a second-class language that cannot solve every task, and in the 2025/26 Heat C++ takers reached the Final far more often than Python takers. An olympiad student needs modern C++ with the standard library, complexity analysis and contest habits more than the whole language. Modern Age Coders coaches it over live video, one to one with a single coach, in English, at whatever hour fits a Hong Kong school week, and the opening lesson costs nothing.

Courses first

Which C++ course fits an olympiad student?

Three courses in order of depth. A student joins where the first lesson shows they belong, with one mentor throughout.

The rules and the results

Why is C++ the language for HKOI?

Two reasons, both published by HKOI. The rules make C++ the main language, and the Heat statistics show the gap between C++ and Python entrants.

What the rules say

HKOI's competition rules state: "Contestants shall implement their solutions in C++ (C++20). Python (3.10 or above) is also available as a 2nd-class programming language. Not all tasks and subtasks are solvable using Python."

The Final is a "3-hour practical test" (HKOI introduction), and "The paper shall consist of 4 programming tasks, each carrying 100 points." Time and memory limits are set with C++ in mind, which is why some subtasks are out of Python's reach.

Who can enter

HKOI "is open strictly to registered day secondary schools in Hong Kong", so students enter through their school, and the organiser says there is no entry fee. We cannot enter anyone; a family should speak to the school's computer teacher.

For the contest's structure and calendar, see our HKOI training page; younger secondary students should read HKOI Junior preparation.

HKOI 2025/26 Heat: entrants and finalists by language
Group, languageTook the HeatReached the FinalPer 100 entrants (our arithmetic)
Senior, C++1587547
Senior, Python292248
Junior, C++1997337
Junior, Python2162512

Source: HKOI 2026 statistics PDF (assets.hkoi.org/ref/2026stats.pdf), read 23 November 2026, rows taken from the extracted text. The last column is our own rounding of finalists divided by entrants. Part of the gap reflects who chooses C++: stronger, longer-trained students tend to.

Not the whole language

Which parts of C++ does an olympiad student need?

C++ is a very large language, and most of it never appears in a contest. HKOI's syllabus and training pages point to a much smaller core, and the Online Judge tells you which standards you can practise in.

Contest C++: what to learn, and the HKOI page behind each item
AreaWhat HKOI publishesWhat we teach
Language standardFinal: C++20 (rules). Online Judge: "C++ (C++14, C++17, C++20)"C++17 as the everyday base, plus the C++20 features that help in contests
Standard libraryJunior syllabus: "Built-in libraries of the relevant data structures"vector, string, pair, sort, map, set, queue, priority_queue
ComplexitySenior syllabus: "Algorithm analysis (time and memory complexity)"Estimating operations from input limits before writing a line
SearchSenior syllabus: "Exhaustion and optimization", recursion, depth-first searchBrute force for small subtasks, then pruning and memory
Mathematics"Discrete mathematics (primes, permutation and combination, modular arithmetic)"Integer types, overflow, modulo arithmetic, sieves
Training topicsTraining Team 2026: Level B began with "Programming in C++"; Level A covered "Dynamic Programming (II)"Dynamic programming from the first term onwards

Sources: HKOI competition rules; HKOI Online Judge page; HKOI competition syllabus (which says it "serves as a guide only"); HKOI Training Materials 2026. All read 23 November 2026. The third column is our teaching plan.

What we leave out

Inheritance hierarchies, templates written from scratch, operator overloading beyond comparisons, exceptions, and most of object-oriented design. They matter for software engineering; they rarely matter in a three-hour contest.

A student who later wants the rest of the language can take a full C++ course. Our general C++ for competitive programming page compares the two goals.

Linux and the judge

HKOI's FAQ notes that "the virtual machine that the students use for developing their solutions is based on Linux". We practise compiling from a terminal as well as in an editor, so the contest machine holds no surprises.

It also says contestants generally need not validate input: "You don't need to write extra code to check for invalid input unless the problem explicitly states otherwise." That saves minutes students often waste.

Working is not scoring

Where do olympiad students lose points in C++?

A program that prints the right answer on the sample can still score little. HKOI's FAQ explains that "you can score points for a subtask if you pass all test cases in that subtask", so one failing case can cost a whole subtask. These are the slips we see most often, from our own teaching.

Overflow

An int holds about two billion. Sums, products and counts in larger subtasks go past that silently. We teach students to check every variable against the input limits and reach for long long early.

Too slow

An algorithm that is fine for a hundred items times out for a hundred thousand. Students learn to estimate operations from the limits before choosing a method.

Slow input

Reading large inputs with default stream settings can waste a noticeable share of the time limit. We show the standard speed-ups and when they matter.

Non-standard headers

A header such as bits/stdc++.h works with GCC but is not standard C++. When we compiled this page's lesson with Apple clang, that line was refused. Learn the real headers.

Off by one

Array bounds and loop ends. In C++ reading past an array does not always crash; it can give a wrong answer that looks plausible.

Uninitialised values

A local variable with no starting value holds whatever was in memory. Compiler warnings catch many of these, so we compile with warnings on.

Calculators are not allowed at the Final (HKOI 2026/27 Final Event page), and neither is outside help, so these checks have to become habits rather than things a student looks up. Our competitive programming page explains how an online judge marks each submission.

An original lesson

What does an olympiad C++ lesson look like? Greedy against dynamic programming

Dynamic programming appears in HKOI's own training list, and the cleanest way into it is to watch a tempting shortcut fail. In this lesson of ours, a student must make an amount from coins worth 4, 3 and 1 using as few coins as possible.

  1. Try the obvious rule. Always take the largest coin that fits. For 7 that gives 4 + 3, two coins, which is right.
  2. Hunt for a counterexample. Try 6. Greedy takes 4 + 1 + 1, three coins, but 3 + 3 uses two. One counterexample is enough to reject a rule.
  3. Build a table. For every amount from 0 upwards, the fewest coins is one more than the fewest for that amount minus some coin. Fill the table from the bottom.
  4. Write both in C++. One function for each method, with vectors and range-based loops.
  5. Let the computer test the rule. Compare both methods on every amount from 1 to 100 and count the disagreements.
Fewest coins: greedy against a dynamic programming tableC++
// Fewest coins to make an amount: greedy versus dynamic programming. Our own lesson; the coin set is invented.
#include <iostream>
#include <vector>
using namespace std;

int greedy(const vector<int>& coins, int amount) {   // coins sorted largest first
    int used = 0;
    for (int c : coins) { used += amount / c; amount %= c; }
    return amount == 0 ? used : -1;
}

int dp(const vector<int>& coins, int amount) {
    const int INF = 1e9;
    vector<int> fewest(amount + 1, INF);
    fewest[0] = 0;
    for (int a = 1; a <= amount; a++)
        for (int c : coins)
            if (c <= a && fewest[a - c] + 1 < fewest[a]) fewest[a] = fewest[a - c] + 1;
    return fewest[amount] >= INF ? -1 : fewest[amount];
}

int main() {
    vector<int> coins = {4, 3, 1};
    for (int amount : {6, 7, 10}) {
        cout << "amount " << amount << ": greedy " << greedy(coins, amount)
             << ", dp " << dp(coins, amount) << "\n";
    }
    int wrong = 0;
    for (int amount = 1; amount <= 100; amount++)
        if (greedy(coins, amount) != dp(coins, amount)) wrong++;
    cout << "amounts 1 to 100 where greedy is wrong: " << wrong << "\n";
}

Our own lesson; the coin values are invented. Compiled with c++ -std=c++17 -Wall and run, it prints exactly the four lines below.

OutputOutput
amount 6: greedy 3, dp 2
amount 7: greedy 2, dp 2
amount 10: greedy 4, dp 3
amounts 1 to 100 where greedy is wrong: 24

Greedy is right for 7 but wrong for 6 (3 coins against 2) and for 10 (4 against 3). Across the first hundred amounts it gives a worse answer 24 times. The table never does, because it tries every last coin for every amount.

The contest lesson

Greedy methods are fast and short, and in a contest they are tempting. The habit we teach is to test a greedy idea against a brute-force or table solution on small inputs before trusting it on large ones.

That habit fits HKOI's subtask scoring well: the slow but correct method often earns the small subtasks, and it doubles as a checker for the fast method.

The C++ lesson

The table is a vector sized from the input, the constant INF stands in for "impossible", and the comparison is written so that adding one to INF cannot overflow a 32-bit int here. Each of those choices is a small piece of contest craft.

Notice too that the function names say what they do. HKOI's FAQ observes that code is not judged on style, but clear code is far easier to debug under time pressure.

  1. Extend. Change the coins to 1, 5, 10 and 25. Does greedy ever fail now? Use the program to check, then explain why.
  2. Reconstruct. Store which coin was used last for each amount, and print the actual coins, not only how many.
  3. Scale. Make the amount a million. Which part of the program needs a bigger type, and how much memory does the table use?

A route to the Heat and the Final

How long does it take to learn C++ for HKOI?

It depends on where a student starts. Here is our 12-week plan for a student who already programs a little in any language. A complete beginner adds a first stage of plain C++ before it.

Our 12-week C++ plan for an HKOI student who can already program a little
WeeksFocusBy the end the student can
1 to 2C++ for someone who knows another languageRead input, use vectors and strings, compile with warnings on
3 to 4Sorting, searching and the standard librarySort with a custom order, use map and set, binary search
5 to 6Complexity and brute forceEstimate operations from limits; write exhaustive search for small subtasks
7 to 8Recursion and greedy methodsWrite recursive search; test a greedy idea against brute force
9 to 10Dynamic programmingDefine states, fill tables, reconstruct answers
11 to 12Graphs and timed practiceUse depth-first and breadth-first search; sit a full three-hour practice paper

This plan is ours. It is not set or endorsed by HKOI. Practice tasks are written by us; we do not reproduce HKOI papers, and we point students to HKOI's own past-problem pages for official material.

The 2026/27 calendar

HKOI gives the 2026/27 Final as Saturday 5 December 2026, with the Senior Group from 9:30 am to 12:30 pm and the Junior Group from 2:30 pm to 5:30 pm (HKOI Final Event page). The 2026/27 Heat was held on 7 November 2026.

A student starting now is preparing for the 2027/28 Heat. Twelve weeks of steady work, then regular practice, is a realistic run-up.

What comes after a medal

HKOI's Training Team FAQ says that "only Training Team members who are invited to the team by winning a Gold/Silver/Bronze medal in HKOI may be selected to the IOI", and its 2026 general information page says "only Permanent HKID holders may participate in inter-territory external competitions such as IOI, EGOI, NOI and APIO".

We prepare students for the Heat and Final. Medals and any team selection are decided by HKOI alone, and we promise neither. Hong Kong ranked sixth at IOI 2026, according to a government press release of 19 August 2026; see our IOI training page for the international contest.

Progress

How do we measure an olympiad student's C++?

Our own stages, assessed on original tasks with hidden tests. They are not HKOI levels and say nothing about medals.

Olympiad C++: our stages
StageWhat the student doesOur check
1. Compiles cleanWrites C++ that compiles with warnings on and no warnings leftTen short tasks, zero warnings
2. Library fluentUses vector, map, set and sort without looking them upA timed library drill
3. EstimatesPredicts whether a method fits the time limit from the input sizeWritten estimate before coding
4. SubtasksScores the small subtasks of a hard task with brute forcePartial scores on our task set
5. TablesSolves standard dynamic programming problems unaidedThree DP tasks in a session
6. Three hoursManages a full practice paper: order, time, partial marksA mock Final on our own tasks

For students

Partial marks are real marks. Take them.

Test the fast idea against the slow one.

For parents

Stage 3 is where contest thinking begins.

Monthly notes show the scores on each stage's tasks.

Around olympiad C++

Nine more courses for contest-minded students

Each runs as private live lessons in English, the way every Hong Kong booking does.

I

Starting out

About 9 to 13

CPPO / START / 01

Scratch Coding for Kids

Logic first, for primary pupils eyeing HKPSOI.

Open the syllabus

CPPO / START / 02

Python and AI for Kids

A gentle typed language before C++.

Open the syllabus

CPPO / START / 03

Maths Through Coding

Number sense for contest arithmetic.

Open the syllabus
II

Contest years

13 to 18

CPPO / CONTEST / 01

Python for Teens

For school work beside contest C++.

Open the syllabus

CPPO / CONTEST / 02

Olympiad Mathematics

Combinatorics and number theory.

Open the syllabus

CPPO / CONTEST / 03

HKDSE ICT: Programming and Exam Prep

C++ or Python for the DSE too.

Open the syllabus
III

Beyond school

18 and over

CPPO / UNI / 01

Data Structures and Algorithms

University-level algorithms.

Open the syllabus

CPPO / UNI / 02

C++ Masterclass

The full language, systems and modern C++.

Open the syllabus

CPPO / UNI / 03

Java Course for College

A second contest language for university.

Open the syllabus

Timing

What hours suit olympiad coaching in Hong Kong?

Any day, any time, flexible: one to one at the hour that suits your family, weekdays or weekends. Coaches sit in India, where the clock reads 150 minutes earlier than Hong Kong's whatever the season, so lessons after school or on a weekend afternoon are easy to place.

After school

A 5:30 pm lesson in Hong Kong begins at 3 pm in India.

Evening

8 pm in Hong Kong is 5:30 pm for the mentor.

Saturday

3 pm in Hong Kong, 12:30 pm in India, the slot many contest students prefer.

Terminal and editor

Compiling the way the contest machine does.

Original tasks

Written by us, with hidden tests and subtasks.

Estimate first

Every solution starts with a complexity check.

Warnings on

The compiler as a second pair of eyes.

One coach

The same mentor through the contest year.

Honest reports

Stage scores each month, no medal promises.

Student work

Work from our programming students

Projects from learners on our longer courses; the student labs page has more.

NutriLife AI nutrition coach project screenshot

AI and ML

NutriLife

An AI nutrition coach that reads what you eat and works you toward a target.

by Bhavya · Open it

Misti AI chatbot for maths and coding screenshot

AI and ML

Misti

A chatbot that answers mathematics and programming questions, built and deployed by a student.

by Harshit · Open it

GuardianX AI internet safety assistant screenshot

AI and ML

GuardianX

An assistant that helps a young person recognise unsafe situations online.

by Vivaan · Open it

SkyCast weather forecast application screenshot

Web app

SkyCast

A weather forecasting site with live conditions for any location.

by Krish

Fees

Olympiad C++ coaching fees

You settle each month separately, in the Hong Kong dollars printed on the card, which suits a contest plan that may change after the Heat. Where your payment method carries a gateway charge, it is shown before you confirm.

Free first class

Free

no card required

  • A free first C++ lesson, one to one
  • A short diagnosis on a contest-style task
  • No card to book
Book it

One to one

$1,200 HKD

a month, eight live classes

  • One student, one coach
  • Contest C++ from the right starting point
  • Times around school and training
Start here

What families say

Rated 4.9 across 547 Google reviews

Parents' and students' Google reviews, shown as written.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

Olympiad C++ in Hong Kong

C++ for HKOI: questions and answers

Should my child learn C++ or Python for HKOI?

C++. HKOI's rules ask for solutions in C++20 and say not every task can be solved in Python, and in the 2025/26 Heat C++ entrants reached the Final far more often. Python is still a fine first language for a younger child.

Which version of C++ does HKOI use?

The rules name C++20 for the Final. HKOI's Online Judge accepts C++14, C++17 and C++20. We teach C++17 as a base and add the C++20 features that help in contests.

Can you enter my child for HKOI?

No. HKOI is open only to registered day secondary schools in Hong Kong, which nominate their own students, and the organiser charges no fee. Ask the school's computer teacher.

Do you guarantee a medal or team place?

No. We prepare students for the Heat and Final. Medals and any team selection are decided by HKOI, and only medallists invited to the Training Team may be selected for the IOI.

Do you use past HKOI papers?

We write our own practice tasks and point students to HKOI's published past problems for official material. We do not reproduce the organiser's problems or solutions.

How long does it take to be ready?

For a student who already programs a little, our 12-week plan covers the core. A beginner needs a few extra weeks of plain C++ first. Contest strength then grows with regular practice.

Are lessons in English?

Yes. Every lesson is live and taught in English by mentors based in India. We do not teach in Cantonese or Mandarin.

Are lessons one to one?

Yes. In Hong Kong every C++ lesson is one to one, with the same coach each week.

What times are possible?

Any day, any time, flexible: one to one at the hour that suits your family, weekdays or weekends. A 5:30 pm lesson in Hong Kong is 3 pm in India, all year round.

How are fees paid?

Monthly, in Hong Kong dollars, with no lump sum. Any payment-gateway charge is shown before you pay, and the first lesson is free.

Related

More for Hong Kong olympiad students

Pages on the contest, its junior group and the wider sport.

HKOI training

The Training Team and the contest year.

HKOI Junior preparation

For younger secondary students.

HKOI Heat papers explained

What the written round tests.

Competitive programming for teens

Judges, contests and practice.

IOI training

The international olympiad.

Coding classes in Hong Kong

Every Hong Kong page.

More pages for Hong Kong

Part of the guide: Every Hong Kong page

More guides: Coding and AI classes in Hong Kong · 中文:英文授課編程課程 · Start here: Online coding for kids · AI, vibe coding and AI agents: AI agents course · Coding subjects and courses: App development · By age and school level: Adults · HKDSE ICT and maths: DSE ICT elective guide · IB, IGCSE, A-level and SAT: A level Computer Science tutor · Guides for families: After-school coding · School holidays: AI summer course · Districts and areas: Causeway Bay

Start here

Book a free first C++ lesson

The coach sets a short contest-style task of our own, watches how your child approaches it, and tells you plainly where to start, whether that is plain C++, the library or algorithms.

Want the outline first? See Competitive Programming for Teens.

WhatsApp us · +91 91233 66161 · connect@modernagecoders.com

Live, online, one to one, in English, with coaches based in India. WhatsApp is fastest.

Free first lesson; no card required.

Want a class sooner? Book a priority demo

A priority demo is a full class of about 45 to 60 minutes. After the class the mentor sends a written skill report and a personal learning roadmap on WhatsApp. If you enrol, the demo fee is adjusted against your first month's fee. Share your demo Order ID with us on WhatsApp and we take it off.

Book a priority demo

Keep exploring Modern Age Coders

More maths tuition

Learn more

Free resources

From the blog

Start here

Free classPriority demoCall us