Hello Codeforces!
I made a VS Code extension that automatically generates cerr debug print statements for any C++ variable with a single shortcut Ctrl+Shift+D.
Why I made this
I was tired of manually writing:
cerr << "adj: "; for(auto& [k,v]: adj){ cerr << k << "->["; for(auto& x: v) cerr << x << " "; cerr << "] "; } cerr << "\n";
every time I wanted to debug a map<int,vector>. So I built an extension that does it in one keypress.
How it works:
1) Place cursor on any variable (or select it) 2) Press Ctrl+Shift+D 3) The correct debug print is inserted below automatically
Supports all CP templates Every competitive programmer has their own template with custom aliases like ll, pii, vpii, vll or whatever they prefer. The extension automatically reads your using and typedef definitions and fully resolves them — no configuration needed.
TLE Warning — and the fix
As some of you might know, cerr inside loops can cause TLE on submission even if the output is ignored. The fix is to add this at the top of your file:
#ifdef ONLINE_JUDGE #define cerr if(false) cerr #endif
ONLINE_JUDGE is automatically defined on Codeforces, AtCoder and most judges — so debug prints are completely eliminated at compile time via dead code optimization. Zero runtime cost, no need to manually remove anything before submitting.
I'm adding a shortcut in the next version to auto-insert this guard automatically.
Video Demo
Check out a full demo here:https://www.linkedin.com/posts/aviraj-singh-3b996133a_competitiveprogramming-competitivecoding-activity-7436713693985427456-LFrx?utm_source=share&utm_medium=member_desktop&rcm=ACoAAFU2-v0B8PGT34EOco4AlE3Wjx-eenAQjjc
Install
Search CP Debug Printer in the VS Code extensions marketplace or install directly:
https://marketplace.visualstudio.com/items?itemName=Aviraj29.cp-debug-printer







