Skip to main content

A fast Codeforces CLI tool for fetching problems and testing competitive programming solutions

Project description

cfmate — Fast Codeforces CLI for Competitive Programming

cfmate is a fast, developer-friendly CLI tool for Codeforces that lets you fetch problems, view them in a clean format, and test your solutions directly from the terminal.

It is designed to eliminate context switching and streamline the competitive programming workflow.


🚀 Why cfmate?

Competitive programming usually involves:

  • switching between browser and editor
  • manually copying test cases
  • repeatedly fetching problem statements

cfmate solves this by bringing everything into your terminal.

With cfmate, you can:

  • fetch problems instantly
  • run solutions with sample tests
  • cache problems locally for speed
  • stay fully inside your development environment

✨ Features

🔍 Problem Fetching

Fetch any Codeforces problem directly:

cf get 1829A
  • Displays formatted problem statement
  • Includes input/output format
  • Shows sample test cases
  • Uses clean terminal rendering

🧪 Solution Testing

Run your solution against sample tests:

cf run solution.py --problem 1829A
  • Executes all sample test cases
  • Shows pass/fail results
  • Displays clear output differences
  • Returns proper exit codes (useful for scripting)

⚡ Smart Caching System

  • Problems are stored locally in .cf_cache/
  • Eliminates repeated network requests
  • Provides instant access after first fetch

🧠 Smart Problem Detection

You don’t always need to specify the problem:

cf run 1829A.py
  • Automatically extracts problem ID from filename
  • Reduces command verbosity

🌐 Multi-language Support

Supports multiple programming languages:

Language Execution
Python python3 file.py
C++ g++ -O2 then run
C gcc -O2 then run
Java javac + java
JavaScript node file.js
TypeScript ts-node file.ts
Go go run file.go
Rust rustc -O then run
Ruby ruby file.rb

🎯 Clean Developer Experience

  • Minimal and readable terminal output
  • No unnecessary clutter
  • Fast execution and feedback loop

📦 Installation

Install directly from PyPI:

pip install cfmate

⚡ Quick Start

1. Fetch a problem

cf get 1829A

2. Solve it in your editor

Create a file:

1829A.py

3. Run tests

cf run 1829A.py

📘 Detailed Usage

Fetching Problems

cf get <problem_id>

Examples:

cf get 1829A
cf get 2227D --no-cache

Options:

  • --no-cache → force re-fetch from Codeforces

Running Solutions

cf run <file> [options]

Examples:

cf run solution.py --problem 1829A
cf run 1829A.py
cf run 2227D.cpp

Options:

  • --problem / -p → specify problem ID manually
  • --time-limit → override execution time limit

Example:

cf run solution.py -p 1829A --time-limit 2000

Creating Files and Folders

cf create <target> [lang]

Modes:

cf create 2227        # create contest2227/ folder
cf create A py        # create 2227A.py inside current contest folder
cf create 2227A py    # create folder + file

Behavior:

  • Creates contest<id>/ folder if not present
  • Generates file using language template
  • Automatically infers problem ID
  • Optionally fetches and caches the problem

Cache Management

cf cache <command>

Commands:

cf cache list
cf cache clear 1829A
cf cache clear

🗂 Cache System (Detailed)

Location

Cache is stored in:

.cf_cache/

Each problem is stored as a JSON file:

.cf_cache/
  ├── 1829A.json
  ├── 2227D.json

When using cf create, cache is stored inside the contest folder:

contest2227/
  ├── 2227A.py
  └── .cf_cache/
      └── 2227A.json

Cache Behavior

Scenario Behavior
Not cached Fetch from Codeforces and store
Cached Load instantly
Corrupted cache Re-fetch automatically
--no-cache used Skip cache and overwrite

Benefits

  • Faster repeated runs
  • Reduced network usage
  • Offline access after first fetch

🧪 Exit Codes

Code Meaning
0 All tests passed
1 One or more tests failed

Useful for:

  • scripting
  • CI pipelines
  • automation

⚠️ Disclaimer

This tool is not affiliated with Codeforces.

It fetches publicly available problem statements for personal use only. All problem content belongs to Codeforces: https://codeforces.com

Users are responsible for complying with Codeforces Terms: https://codeforces.com/terms

This tool does not store or redistribute problems beyond local caching.


🔗 Links


📄 License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cfmate-0.2.1.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cfmate-0.2.1-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file cfmate-0.2.1.tar.gz.

File metadata

  • Download URL: cfmate-0.2.1.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for cfmate-0.2.1.tar.gz
Algorithm Hash digest
SHA256 23ca41a9bf2be3194c481388b10429c65d4a31fc72641976d0347f49b169d1e0
MD5 7215f580650ac53895c146e25406e0fe
BLAKE2b-256 ab2a1d790b7f349405d2f0af06995102b1ce51840bedd69f1a58e1b453a85b2a

See more details on using hashes here.

File details

Details for the file cfmate-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: cfmate-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for cfmate-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6fe9501381a3b9c7c97bf014e5c82387272eda91b9459dae8a881cbe1cd98fdc
MD5 0fc33ad3d26e389d1a260f493fa82e0e
BLAKE2b-256 0123751db2b9c955a9947843f74085928c87119f503eaa303c98b3c63f62e27f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page