Skip to content

My competitive programming setup. Features one-click scaffolding, integrated testing, and direct submission from VSCode.

License

Notifications You must be signed in to change notification settings

dantetemplar/competitive-programming

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Competitive Programming Setup

My competitive programming setup for contests, primarily from Codeforces.

Features

  • 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

Setup

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

Workflow

Automated Contest Scaffolding

Use these extensions to automatically scaffold problem sets:

  1. 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.

  2. Competitive Companion (Browser)

    • Install browser extension
    • Click extension logo on contest page
    • Files with test cases appear in your IDE
  3. 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:

  1. Open any problem file (e.g., A_Problem_Name.py)
  2. Use keyboard shortcuts:
    • Ctrl+Alt+B - Run all test cases
  3. View results in the CPH panel
  4. 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.

PyPy Usage

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.

Optimized I/O

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

Project Structure

.
├── _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

License

MIT License - see LICENSE file for details.

About

My competitive programming setup. Features one-click scaffolding, integrated testing, and direct submission from VSCode.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages