A small, local-first Java workspace for competitive programming. It removes the repetitive setup around contests—folders, boilerplate, local samples, compiling, and saving reference solutions—while keeping every command visible and simple.
- Java 17 contest boilerplate with fast input and buffered output.
- Interactive contest scaffolding for Codeforces, AtCoder, or any named platform.
make runfor root or contest-problem execution using local sample input.- Terminal-scoped contest mode, so repeated runs ask only for
A,B, and so on. - Reusable algorithms for graphs, strings, range queries, math, and data structures.
make storefor collecting polished solutions under Java-style filenames.- VS Code tasks, Java extension recommendations, and debug configuration.
- Java 17 or newer (
javacandjava) - GNU Make or a compatible
makeimplementation - Bash (included by default on macOS and most Linux distributions)
Check the essentials:
javac -version
make --versiongit clone https://github.com/soumajitgh/cp-local-setup.git
cd cp-local-setup
make help
make contest new
make runmake run asks whether to execute the root Main.java or a contest problem. It reads that directory's input.txt and writes output.txt; both local files are ignored by Git.
Create a contest interactively:
make contest newIt asks for the contest slug and comma-separated problem labels. For another platform, include PLATFORM:
make contest new PLATFORM=atcoderEach problem gets a copy of templates/java/boilerplate/Main.java plus an empty input.txt:
contests/codeforces/2112/
├── A/
│ ├── Main.java
│ └── input.txt
├── B/
└── C/
For a guided run:
make runTo run a known problem directly, provide its directory:
make run PROBLEM=contests/codeforces/2112/AThe compiled classes go to a local .build/ directory. make clean removes all generated builds and resets the root Main.java from the boilerplate, ready for a new scratch problem.
Enter contest mode after creating the contest:
make contest 2112This opens an interactive child shell scoped to contests/codeforces/2112. In that shell, every make run asks only for the problem label. You can also add or remove problems without leaving the contest terminal:
make add # prompt for a label; creates Main.java and input.txt
make add PROBLEM=F # add F directly
make problems # list this contest's problem folders
make remove # prompt for a label and confirm before deletion
make remove PROBLEM=F FORCE=1 # scripted removal without a promptType exit when the contest is over.
make contest PLATFORM=atcoder CONTEST=abc400
make run # then enter A, B, or C
exitWhen the root Main.java is worth keeping, save it as a reference:
make storeEnter a descriptive name when prompted. The command converts it to PascalCase and stores a copy under store/: for example, binary search lower bound becomes store/BinarySearchLowerBound.java. It never overwrites an existing stored file.
| Command | Purpose |
|---|---|
make help |
Show the built-in command reference. |
make contest new |
Interactively create problem workspaces. |
make contest 2112 |
Open a terminal-scoped contest mode. |
make add |
Add a boilerplate problem in contest mode. |
make remove |
Remove a problem in contest mode after confirmation. |
make problems |
List active-contest problem folders. |
make compile PROBLEM=contests/codeforces/2112/A |
Compile one problem. |
make run |
Interactively select and run code. |
make store |
Save root Main.java into store/. |
make list |
List all created problem folders. |
make clean |
Remove builds and reset root Main.java. |
The templates directory contains small, copy-ready Java snippets. Their comments state indexing conventions and constraints.
| Area | Included template |
|---|---|
| Boilerplate | Fast scanner, buffered output, and solve() structure |
| Data structures | Fenwick tree |
| Range queries | Iterative segment tree for sums |
| Graphs | Dijkstra for non-negative weights |
| Math | Modular exponentiation and modular inverse |
| Strings | Prefix function and KMP matching |
Copy only the pieces a problem needs. Fewer lines mean fewer contest-time mistakes.
Open this folder in VS Code and accept the recommended Java extensions. The included configuration supports:
- Compile current Java file with
Cmd+Shift+B - Debug current Java file with breakpoints
- Code Runner execution with a sibling
input.txtandoutput.txt
.
├── contests/ # created contest workspaces
├── scripts/ # Makefile helper scripts
├── store/ # saved reference solutions
├── templates/ # reusable Java boilerplate and algorithms
├── Main.java # root scratch solution
└── Makefile # task runner entry point
This is intentionally lightweight. Improvements that make contest setup faster or templates safer are welcome. Keep templates dependency-free, document assumptions (especially indexing and complexity), and verify new commands with make help and a representative local run.
Distributed under the MIT License.