competitive programming exercise scaffolder with a c++ template system.
# install
cargo install forge-cp
# install dependencies (g++, make) — auto-detects your os
forge setup
# create an exercise
forge new two-sum
# create a contest with multiple problems
forge new cf1900 a b c deach exercise gets:
./two-sum/
├── solution.cpp # c++ template with common data structures and algorithms
├── Makefile # make / make run / make test / make debug
├── input.txt # paste test input here
├── expected.txt # paste expected output here
└── notes.md # problem notes
everything is automatically committed to git.
cargo install forge-cpbrew tap afonp/tap
brew install forgedownload forge-x86_64-pc-windows-msvc-setup.exe from the latest release and run it.
grab the archive for your platform from releases, extract it, and put forge in your PATH.
forge new <name> # create a single exercise
forge new <contest> a b c d # create multiple problems for a contest
forge list # list exercises in the current directory
forge open <name> # open in $EDITOR or vs code
forge clean <name> # remove compiled binaries (make clean)
forge setup # install dependencies (g++, make)forge new two-sum -c # open in vs code after creation
forge new two-sum -o # open in $EDITOR after creationcd two-sum
make # compile
make run # compile and run
make test # compile and run with input.txt
make debug # compile with sanitizers and run with input.txt
make clean # remove binariesthe debug target enables address sanitizer, ub sanitizer, and the dbg() macro.
the built-in template includes:
- types:
ll,ull,ld,pii,pll,vi,vll,vvi - constants:
inf,linf,eps,mod,mod2,pi - macros:
all(x),rep(i,a,b),per(i,a,b),each(x,v),dbg(x) - data structures: graph (dijkstra, bfs), dsu, segment tree, fenwick tree
- strings: kmp, z-function
- math: gcd, lcm, modular exponentiation, modular inverse
works with both gcc and clang (macos).
customize it by editing ~/.cp/templates/template.cpp.
full documentation at forge.afpereira.me
MIT