My competitive programming setup for contests, primarily from Codeforces.
- Scaffolding workflow in one click:
- Test Cases right in your VSCode
- Templated code for the contest
- Submit button to submit your solution to Codeforces from VSCode
- PyPy 3.10 for JIT-compiled performance
- Optimized I/O for faster execution
This project uses uv for dependency management:
# Install uv if you don't have it
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install dependencies
uv sync
Use these extensions to automatically scaffold problem sets:
-
My version of Competitive Programming Helper (VSCode)
- Download VSIX from Releases
- Install in VSCode
- Set settings (CTRL+Shift+P -> "Preferences: Open Workspace Settings (JSON)"):
{ "cph.general.defaultLanguage": "python", "cph.general.saveLocation": "${group}/", "cph.general.menuChoices": "python", "cph.general.defaultLanguageTemplateFileLocation": "/home/USER/.../competitive-programming/_cph_template.py" }
Note: PR #582 submitted to upstream CPH repository.
-
Competitive Companion (Browser)
- Install browser extension
- Click extension logo on contest page
- Files with test cases appear in your IDE
-
Codeforces Submit add-on for Competitive Programming Helper (VSCode)
- Install browser extension
- In VSCode you will be able to click on the "Submit" button to submit your solution to Codeforces
This creates contest directories with templated files. See _cph_template.py for the default template.
Running test cases:
- Open any problem file (e.g.,
A_Problem_Name.py
) - Use keyboard shortcuts:
Ctrl+Alt+B
- Run all test cases
- View results in the CPH panel
- You can also use the "Submit" button to submit your solution to Codeforces
The extension automatically runs your solution against all parsed test cases and shows pass/fail status with execution time.
Solutions are run with PyPy 3.10 for significant performance gains over CPython. PyPy's JIT compiler provides 2-5x speedup on typical competitive programming problems.
On Codeforces, submit using the "PyPy 3-64" language option.
The template includes faster I/O functions to overcome Codeforces bottlenecks:
import sys
def input():
"""25x faster input on 1,000,000 lines"""
return sys.stdin.readline().strip()
def print(s, end="\n"):
"""2x faster output on 1,000,000 lines"""
return sys.stdout.write(str(s) + end)
Benchmark results:
- Standard
input()
: 3.372s - Optimized
input()
: 0.130s
.
├── _cph_template.py # Template for new problems
├── Codeforces - Round XXXX/ # Contest directories
│ ├── .cph/ # Test cases and metadata (generated by CPH)
| ├── A_Problem_Name.py
│ ├── B_Problem_Name.py
│ └── ...
└── README.md
MIT License - see LICENSE file for details.