acr
AtCoder competitive programming CLI tool for Rust. One command sets up the Cargo workspace, fetches sample inputs, drops you in your editor with the problem page already open, and ships your solution.
Why acr?
- One-shot setup:
acr new abc400creates a Cargo workspace, fetches every sample input, and drops you in your editor focused on problem A. - Prebuilt binaries for macOS / Linux / Windows: install in seconds via
shell script, PowerShell, Homebrew tap, or
cargo binstall— no Rust toolchain required. - Start-time wait:
acr new abc400 --at 21:00blocks until the contest opens, then creates the workspace the moment the tasks appear.acr virtual abc300uses the same mechanic for virtual contests — pick any past contest and start a timed run of your own. - Native editor + browser integration:
acr open,acr view, andacr newlaunch your configured editor and browser together, shell flags and all ("code --new-window","firefox --new-window", ...). - Judge-parity dependencies: generated
Cargo.tomlpins the exact crates and versions that AtCoder's judge uses, so "compiles locally" means "compiles on the judge". - Portable, shareable templates:
~/.config/acr/template.rsis your snippet library.acr template add <url>pulls in anyone's Gist or repo file, with an automatic backup for safe experimentation.
Note: AtCoder recently introduced Cloudflare Turnstile, which makes CLI-only login and submission infeasible for any tool right now.
acruses a pastedREVEL_SESSIONcookie for reads and hands the final submit off to your browser.
Install
Prebuilt binaries (fastest, no Rust toolchain required):
# Linux / macOS
|
# Windows (PowerShell)
|
# Homebrew (macOS / Linux)
Via Cargo:
# If you already have cargo-binstall (fetches the prebuilt binary)
# From source (compiles locally)
Setup
-
Install — see above. Verify with
acr --version. -
Initialize the config —
acr initwalks you through:- Editor command (e.g.
vim,nvim,code --new-window) - Browser command (defaults to
openon macOS,exploreron Windows,xdg-openelsewhere; override if you want flags like--new-window)
It also seeds a default source template at
~/.config/acr/template.rs. Re-runacr initanytime — current values are offered as prompt defaults, so pressing Enter keeps them. - Editor command (e.g.
-
Log in to AtCoder —
acr loginopens the AtCoder login page in your browser and waits for you to paste theREVEL_SESSIONcookie value. Grab it from DevTools → Application → Cookies → atcoder.jp, then copy theREVEL_SESSIONrow's value. Cookies typically last around a month; re-run when they expire.
Why paste a cookie manually? AtCoder's Cloudflare Turnstile blocks automated form-login for CLI tools. Copying the
REVEL_SESSIONcookie once via DevTools → Application → Cookies → atcoder.jp is a one-minute step.
Usage
# From a problem directory
# From a contest directory
# From outside the contest directory
# Session management
# Configuration
Libraries
Every problem Cargo.toml that acr new generates pins the same crate set
and versions that AtCoder's judge provides. Commonly reached-for crates
work out of the box:
use input;
use ModInt998244353 as Mint;
The full list is defined in src/workspace/generator.rs and includes
ac-library-rs, proconio, itertools, num, nalgebra, ndarray,
petgraph, rustc-hash, and others.
When the judge updates its crate set, acr update -d refreshes the pinned
dependencies for an existing workspace.
Adding a crate that is not in the judge's list is possible locally (edit
Cargo.tomldirectly), but the judge will fail to compile the submission andacr update -dwill overwrite your local edits.
Workspace Structure
acr new abc001 generates:
abc001/
├── Cargo.toml # [workspace]
├── a/
│ ├── Cargo.toml
│ ├── src/main.rs # Generated from template
│ └── tests/
│ ├── 1.in
│ └── 1.out
├── b/
│ └── ...
Configuration
Config files are stored in ~/.config/acr/:
config.toml- Editor and browser settingstemplate.rs- Source code templatesession.json- Login session
Template
acr init creates a default template at ~/.config/acr/template.rs:
use input;
Edit this file to customize the boilerplate generated for each problem.
Sharing templates
Install someone else's template (or your own) without editing the file by hand:
add and reset move the existing file aside to ~/.config/acr/template.rs.bak
before writing, so you can always roll back with
mv ~/.config/acr/template.rs.bak ~/.config/acr/template.rs.
GitHub "blob" URLs and Gist pretty URLs are rewritten to their raw-content
equivalents automatically; other http(s):// URLs are fetched as-is.
Releasing (maintainers)
Releases are automated with release-please and crates.io Trusted Publishing:
- Merge PRs to
mainusing Conventional Commits (feat:,fix:,chore:,feat!:for breaking). - A Release PR is automatically opened by release-please with the version bump and CHANGELOG updates.
- Merging the Release PR tags
vX.Y.Zand publishes a GitHub Release. - The tag push triggers
.github/workflows/publish.yml, which uses OIDC to obtain a short-lived crates.io token and runscargo publish.
One-time setup on crates.io is required before the first automated publish: visit the acr-cli crate settings on crates.io and register the GitHub repo t-seki/acr with workflow filename publish.yml as a trusted publisher.
License
MIT