A powerful, automated toolkit for competitive programming that streamlines your workflow from problem fetching to testing. Built with Python and C++, this setup handles everything so you can focus on solving problems.
- Automatically fetch sample test cases from Codeforces
- Parse time limits and metadata
- Ready-to-test environment in seconds
- Parallel test execution with custom timeouts
- Detailed diff output for wrong answers
- Color-coded results (PASSED, FAILED, TLE)
- Smart executable detection (Windows/Linux compatible)
- Comprehensive debug template with colored output
- Variable inspection with type-aware printing
- Performance timing for code sections
- Support for complex STL containers
- Optimized compilation flags (
-O3,-std=c++2b) - Debug builds with full error checking
- Automatic dependency management
- Windows and Linux compatible
| File | Purpose | Key Features |
|---|---|---|
MakeFile |
Build automation & workflow management | Cross-platform, contest fetching, testing pipeline |
cf_fetch.py |
Codeforces sample test downloader | Auto-detection, HTML parsing, metadata extraction |
run_tests.py |
Test runner with advanced verification | Timeout handling, detailed diffs, color output |
debug.cpp |
Advanced debugging template | STL container printing, timers, colored output |
cpp.json |
VS Code Snippet | Instant template generation with timestamp & debug setup |
# Fetch problem and run tests (most used!)
make -f makefile test CONTEST=1789 PROBLEM=C
# For gym contests
make -f makefile test GYM=104114 PROBLEM=A
# Test existing downloaded samples
make -f makefile test-only PROBLEM=B
# Compile and run with input.txt
make -f makefile run
# Debug build with full error checking
make -f makefile debugThis setup includes a custom VS Code snippet (cpp.json) that instantly generates your competitive programming template with the current timestamp and debug configurations. (and also any other templates you would like to add).
To make the snippet work, you must place the cpp.json file in your VS Code User Snippets directory:
Required Path:
C:\Users\(username)\AppData\Roaming\Code\User\snippets
make -f makefile fetch CONTEST=2139 PROBLEM=BWhat happens:
- π Fetches from
https://codeforces.com/contest/2139/problem/B - π Parses HTML to extract sample inputs/outputs
- β±οΈ Extracts time limit (e.g., "2 seconds")
- π Creates
tests/B1.in,tests/B1.out,tests/B_metadata.json
make -f makefile test-only PROBLEM=BOutput Example:
π΅ Using time limit: 2.0 seconds (from tests/B_metadata.json)
π‘ Running tests for problem B...
β
B1: ACCEPTED
β
B2: ACCEPTED
β B3: WRONG ANSWER
Expected:
1: 42
2: 13
Got:
1: 41
2: 13
Differences:
Line 1: Expected '42', Got '41'
β
2 / 3 tests passed β
This debug template is mainly by: Anshul_Johri, you can find the full blog on codeforces here and was modified by me to add LabeledTimer
Include debug.cpp in your solution:
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#define TIME_BLOCK(name) \
if (bool _once = false) \
{ \
} \
else \
for (__DEBUG_UTIL__::LabeledTimer _t(name); !_once; _once = true)
#else
#define debug(...)
#define debugArr(...)
#define TIME_BLOCK(name) if (true)
#endif // Debugging locallyvector<int> arr{1, 2, 3};
map<string, int> mp;
mp["hello"] = 5;
mp["world"] = 3;
debug(arr, mp);Debug Output:
π΅ 42: [arr = {1,2,3} || mp = {("hello",5),("world",3)}]
TIME_BLOCK ("sorting")
{
sort(arr.begin(), arr.end());
}
// Timers print automatically when destroyedOutput:
π΄ [TIMER] sorting took: 0.000123 s
- Windows: Auto-adds
.exeextension, handles Windows paths - Linux: Native Unix commands and paths
- Both: Color support detection, proper encoding handling
# 1. Write your solution in Code.cpp
# 2. Fetch and Test
make -f makefile test CONTEST=1847 PROBLEM=D
# 3. For subsequences testing (no need to fetch again)
make -f makefile test-only PROBLEM=D
# 5. Submit when all tests pass!Add your own test cases:
# Add tests/D4.in and tests/D4.out
make test-only PROBLEM=D # Will run all tests including custom ones- Fetch and test a problem in under 5 seconds
- No manual copy-pasting of test cases
- Instant feedback with detailed error analysis
- Exact time limit enforcement from problem metadata
- Precise output comparison with whitespace handling
- Catches edge cases other setups miss
- Works with any Codeforces contest (contest/gym/problemset)
- Supports custom test cases
- Cross-platform compatibility
- Focus on algorithm, not setup
- Visual debugging with colored output
- Automated build optimization
# Required tools
g++ # C++ compiler with C++2b support
python3 # Python 3.6+
# Optional but recommended
make # For using the Makefile commandsWith this setup, you can:
- β Fetch and test a problem: < 10 seconds
- β Debug complex data structures: Visual colored output
- β Handle 100+ test cases: Automated with timeouts
- β Work on any platform: Windows/Linux/Mac compatible
"Competitive programming is about solving problems, not fighting tools. This setup gets you there faster."