Concepts6
Debugging Strategies for CP
Systematic debugging beats guesswork: always re-read the statement, re-check constraints, and verify the output format before touching code.
Fast I/O and Optimization Tricks
Fast I/O reduces overhead from C and C++ stream synchronization and avoids unnecessary flushes, which can cut runtime by multiples on large inputs.
Harmonic Lemma
The Harmonic Lemma says that the values of \lfloor n/i \rfloor only change about 2\sqrt{n} times, so you can iterate those value blocks in O(\sqrt{n}) instead of O(n).
Interval DP
Interval DP solves problems where the optimal answer for a segment [i, j] depends on answers of its subsegments.
Merge Sort Tree
A Merge Sort Tree is a segment tree where every node stores the sorted list of values in its segment.
Monotonic Deque
A monotonic deque is a double-ended queue that keeps elements in increasing or decreasing order so that the front always holds the current optimum (min or max).