Stage 1 · Lesson 3 of 7
Your template and fast input and output
A template is the short file you start every problem from: one header that includes the whole standard library, a long long alias, two lines for , and a loop over test cases. Fast IO matters because reading 10^6 numbers with default cin settings can be slow enough to exceed the .
Printing a newline character instead of endl matters too, since endl flushes the output every line. Many problems start with t test cases, so the template reads t and solves each one. Keep it short enough to type from memory, because at an site you may start from a blank editor.
Common trapcopying a long template full of macros from a strong contestant and not understanding half of it.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with· follow one of these
- CourseFreeLearnCpp.com
LearnCpp.com · Beginner
Free and thorough: read the chapters on vectors, references, lambdas and the standard library if C++ is new to you
- BookFreeCompetitive Programmer's Handbook
Antti Laaksonen · Beginner
Chapter 1 covers C++ for contests, input and output and working with numbers; Chapter 2 covers complexity
Practise
Keep handy
Also worth your time
A clear walk through time and space complexity, the language you need to read constraints
- USACO GuideGo deeper
The General section has practical pages on choosing a language, fast input and output and debugging