Skip to content
hina-kura49Public

About

Fetch AtCoder samples, test your solution locally, and get ready to submit (with Neovim integration)

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

acrun icon

acrun

Test your AtCoder solution before you press Submit.

CI Release License: MIT OR Apache-2.0

Product page · Download · Usage · English · 日本語

acrun is a small command-line tool for AtCoder. It downloads every sample of a contest, runs your solution against all of them in one command, and shows exactly which sample fails and why. When everything is AC, it copies your code and opens the submit page. A Neovim plugin is included.

acrun new abc387 downloads the samples; acrun test shows two AC and two WA with input, expected and actual output; after the fix all four are AC; acrun submit copies the code and opens the submit page

  1. acrun new abc387 — makes a folder per task with your solution file and every sample.
  2. acrun test — runs all samples and prints AC / WA / RE / TLE, with the input, the expected output and yours for each failure.
  3. acrun submit — copies your code to the clipboard and opens the submit page. You paste and press Submit.

acrun never asks for your password and never submits for you.

New in 1.1: acrun problems — browse every AtCoder problem by difficulty in your terminal, hide the ones you solved, and set up the next one with Enter.

Download

Homebrew (macOS, Linux):

brew install hina-kura49/tap/acrun

Install script (macOS, Linux):

curl --proto '=https' --tlsv1.2 -LsSf https://github.com/hina-kura49/acrun/releases/latest/download/acrun-installer.sh | sh

PowerShell (Windows):

powershell -ExecutionPolicy Bypass -c "irm https://github.com/hina-kura49/acrun/releases/latest/download/acrun-installer.ps1 | iex"

Or download the file for your computer. These links always point to the newest release.

OS File
macOS (Apple silicon) acrun-aarch64-apple-darwin.tar.xz
macOS (Intel) acrun-x86_64-apple-darwin.tar.xz
Linux (x86_64) acrun-x86_64-unknown-linux-gnu.tar.xz
Linux (arm64) acrun-aarch64-unknown-linux-gnu.tar.xz
Windows (x86_64) acrun-x86_64-pc-windows-msvc.zip
Checksums SHA256SUMS

The macOS binary is not signed by Apple. If you download it by hand, macOS may say it "cannot be verified". Remove the download mark once:

tar -xf acrun-aarch64-apple-darwin.tar.xz
xattr -d com.apple.quarantine acrun-aarch64-apple-darwin/acrun
sudo mv acrun-aarch64-apple-darwin/acrun /usr/local/bin/

Homebrew and the install script do not need this.

Usage

acrun new abc387        # a/, b/, ... each with main.py and tests/
cd abc387/a
# write main.py
acrun test              # run every sample
acrun submit            # copy the code and open the submit page
Command What it does
acrun new <contest> Create <contest>/<task>/ with a solution file, tests/, the statement as problem.md and .acrun.toml. Accepts an id (abc387) or any contest URL. -o a,b fetches only some tasks, -l cpp picks a language.
acrun fetch <task URL> Fetch the samples and the statement of one task into the current directory (-d DIR to change it).
acrun test [FILE] (t) Run the solution against tests/*.in and compare with *.out. -e 1e-6 accepts numeric answers within an error, -t 3000 sets the time limit in ms.
acrun submit [FILE] (s) Copy the solution to the clipboard and open the submit page (--no-copy only opens it).
acrun login / logout Save / remove the REVEL_SESSION cookie (needed only for running contests).
acrun init Write the default config file and a templates directory.
acrun shell-init <zsh|bash|fish> Print a shell function that moves you into the task directory after acrun problems (see below).
acrun problems (p) Browse problems by difficulty and set one up. See below.

Answers are compared like AtCoder's judge: tokens must match, while trailing spaces and the final newline are ignored. The time limit is read from the task page. TLE is reported at twice that limit, because local interpreters are often slower, and an AC that is slower than the limit is marked.

You can add your own cases too: put my-1.in and my-1.out in tests/ and acrun test runs them with the samples.

Pick your next problem

acrun problems opens a full-screen list of every AtCoder problem with its difficulty, colored like AtCoder Problems, and a ✓ on the ones you solved. Narrow it down, let acrun pick one at random, and press Enter: you get the same folder as acrun new, ready for acrun test.

acrun problems shows a list of AtCoder problems with colored difficulties; the user searches, filters to ABC, green difficulty and unsolved, picks one at random, and Enter creates abc301/d with main.py and three samples

Tell acrun who you are once, so it can mark what you solved. Add this line to ~/.config/acrun/config.toml (or pass --user <id>):

atcoder_user = "your_atcoder_id"
Key What it does
↑ ↓ / j k Move (PgUp PgDn, g G for the top and bottom)
/ Search the title or id (abc300 c works too)
t Contest type: all → ABC → ARC → AGC → others
d / D Difficulty color: any → gray → brown → … → red (D goes back)
u Only problems you have not solved
s Sort: newest → oldest → easiest → hardest. The picker starts with the order you used last time.
r Jump to a random problem from the current list
Enter Set the problem up like acrun new (abc300/c/ with the samples) and quit
o Open the problem page in your browser
? / q Help / quit

✓ is AC, ✗ is submitted but not AC yet. A difficulty with ? is an estimate from few contestants.

Move into the picked problem. A program cannot change the directory of the shell that started it, so acrun comes with a small shell function that does it after Enter:

# ~/.zshrc or ~/.bashrc
eval "$(acrun shell-init zsh)"   # or bash
# ~/.config/fish/config.fish
acrun shell-init fish | source

With it, acrun problems → Enter leaves you in abc300/c/, ready for nvim main.py.

For scripts, the same filters work without the full screen:

acrun problems --list --type abc --diff 800-1199 --unsolved   # a table
acrun problems --list --type arc --sort easiest -n 20 --json  # JSON
acrun problems --random --diff 1200-1599 --unsolved           # one pick, with its URL

--diff takes MIN-MAX, MIN- or -MAX; --type is abc, arc, agc or other; --sort is newest, oldest, easiest or hardest (default: the order you used last time in the picker); -s WORDS searches. Problems with Korean titles (contests by Korean universities held on AtCoder) are hidden unless you pass --korean.

Polite to AtCoder Problems. The list, the difficulties and your submissions come from the AtCoder Problems API, a free community service. acrun keeps them in a cache (~/.cache/acrun, ~/Library/Caches/acrun on macOS, %LOCALAPPDATA%\acrun on Windows), downloads at most once a day (--refresh to force it), waits more than a second between requests, and asks only for your submissions since the last time. Offline, it shows the cached list and says so.

Problem statements are not downloaded in bulk: only the problem you press Enter on is fetched from AtCoder, one page, like acrun new.

When you'll use it

  • The ABC just started. Run acrun new abc432 as the contest opens. You get a/ to g/, each with a solution file from your template and all the samples, and start reading problem A instead of creating files.
  • Sample 1 passes, but sample 3 would have cost you a penalty. acrun test runs every sample and shows the input, the expected output and yours for each failure, so you see the bug before AtCoder does.
  • Practising old contests on a train. Past contests need no login. acrun fetch <task URL> once, then test as often as you like. Testing runs on your machine and works offline.
  • "What should I solve today?" acrun problems, press t for ABC, d until green, u for unsolved, r for a random pick, Enter. The folder is ready before you have finished deciding.
  • Living in Neovim. <leader>at saves and shows the results in a split; <leader>as copies the code and opens the submit page.

Running contests

Tasks of a running contest are only visible to logged-in users. AtCoder's login page has a CAPTCHA, so acrun cannot log in with a password. Instead:

  1. Log in to AtCoder in your browser.
  2. Open the developer tools → Application (Storage) → Cookies → https://atcoder.jp and copy the value of REVEL_SESSION.
  3. Run acrun login and paste it (it is not shown).

The cookie is stored in ~/.config/acrun/session with permission 600. Treat it like a password. Past contests do not need it.

Languages and templates

acrun init writes ~/.config/acrun/config.toml ($XDG_CONFIG_HOME/acrun if set):

default_language = "python"
timeout_ms = 2000            # used when the task page has no time limit

atcoder_user = "your_id"     # optional, for the ✓ marks in `acrun problems`

[languages.python]
file = "main.py"
run = "python3 {file}"

[languages.cpp]
file = "main.cpp"
build = "g++ -std=c++20 -O2 -o {dir}/a.out {file}"
run = "{dir}/a.out"

{file} is the solution file and {dir} its directory. Built-in languages: python, pypy, cpp, rust. Add any language with a file, an optional build and a run command.

A template for new solution files goes to ~/.config/acrun/templates/<file>, e.g. templates/main.py.

Neovim

Requires Neovim 0.10 or later. With lazy.nvim:

{
  "hina-kura49/acrun",
  config = function()
    require("acrun").setup()
  end,
}
Key / command What it does
<leader>at / :AcrunTest [args] Save and run the samples in a split. Press q to close it.
<leader>as / :AcrunSubmit Save, copy the code and open the submit page.
<leader>ap / :AcrunProblem Show or hide the statement (problem.md) on the right. It opens by itself the first time you open a solution in a tab; q closes it.
:AcrunNew <contest> Run acrun new in the current directory.

Options (defaults shown):

require("acrun").setup({
  cmd = "acrun",
  keymaps = { test = "<leader>at", submit = "<leader>as", problem = "<leader>ap" }, -- or false
  split = "botright 15split",
  problem = { auto_open = true, width = 0.45 }, -- width: fraction of the screen or columns
})

FAQ

Is it allowed in rated contests? Fetching samples and testing locally is what many contestants do by hand, and acrun never submits for you. Still, check AtCoder's current rules (especially on automation and generative AI) before a rated contest.

Why doesn't it submit automatically? That needs your password, the login page has a CAPTCHA, and it breaks whenever AtCoder changes its form. Pasting and pressing the button takes two seconds and never breaks.

How is it different from online-judge-tools or atcoder-cli? Those tools have not been updated for years and break on recent AtCoder changes (the login CAPTCHA, MiB memory limits, new language names). acrun does less on purpose: read the pages, test locally, open the submit page.

Does it put load on AtCoder? No more than opening the pages yourself. It only fetches when you run new or fetch (or press Enter in acrun problems), and waits between requests. test never contacts AtCoder. The problem list comes from AtCoder Problems, not AtCoder, and is cached for a day.

Fetching stopped working. AtCoder has no public API, so acrun reads its HTML. If the sample headings change, acrun falls back to other ways of finding the sample blocks and warns you to check them. If it finds no samples at all, it says AtCoder's layout may have changed and prints a link that opens a prefilled issue. A daily check against AtCoder also opens an atcoder-change issue when the pages change, so a fix is usually already on its way; brew upgrade acrun (or re-running the installer) picks it up.

Building from source

With a recent stable Rust:

cargo install --locked --git https://github.com/hina-kura49/acrun

See DEVELOPMENT.md for how the code is organised, testing and releases.

License

Made by kura. Licensed under either of Apache License, Version 2.0 or MIT license at your option.

The problem list and difficulties in acrun problems come from AtCoder Problems by kenkoooo (MIT); acrun is not affiliated with it.

AtCoder is a trademark of AtCoder Inc. acrun is an independent project and is not affiliated with AtCoder Inc.

About

Fetch AtCoder samples, test your solution locally, and get ready to submit (with Neovim integration)

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages