Debugging Practices β
Debugging is a core skill in competitive programming. Writing a correct algorithm is only half the work β you also need to make sure your code actually runs as expected, and be able to correct it if a mistake is found.
π Key Advices β
- Always try the problem on paper first before coding.
- Have a clear idea of your algorithm and used data structures. If possible, write an outline on paper before implementing (avoid blind coding).
- Test on small and extremal cases that you can check manually.
- Be careful with fast I/O and watch out for integer overflow.
- Use
cerrinstead ofcoutfor debugging (since graders usually ignorecerr). - A debugger is often more powerful than console output.
- Learn to use
assertto verify assumptions in your code. - Compare your solution with a bruteforce solution on small cases to locate discrepancies.
- Train your debugging skills: donβt immediately read the editorial just because your mistake seems βdumbβ β solving it yourself is part of the training.
π Useful Resources β
- USACO Guide β How to Debug
- USACO Guide β Basic Debugging
- USACO Guide β Debugging C++
- Debug C++ in Visual Studio Code
- π₯ VS Code Debugging a Simple C++ Program (YouTube)
- π₯ Debugging C++ Program in Visual Studio Code (YouTube)
- π₯ Debugging C/C++ with Visual Studio Code Explained in Less Than 6 Minutes! (YouTube)
β‘ Debugging is not wasted time β itβs part of solving the problem.

