โ† Competitive Programming learning path
Competitive Programming ยท Module 3 of 10

Fast input/output and templates

Read big inputs fast and keep a clean starting template.

๐Ÿ“– Key ideas

  1. In C++, ios::sync_with_stdio(false) and cin.tie(nullptr) speed up cin/cout.
  2. Use \n instead of endl to avoid flushing every line.
  3. In Python, read all input with sys.stdin.readline or sys.stdin.buffer.
  4. A template holds includes, fast IO and common helpers.
  5. Handle multiple test cases with an outer loop over t.
๐Ÿ’ก Real-life example: Fast IO is like using a conveyor belt instead of carrying boxes one by one.
sync_with_stdio(false)Unties C and C++ streams for speed
endlNewline plus flush
sys.stdin.readlineFast line reading in Python
TemplateReusable starting code