Tifa's CP Library

CP-lib

My code library for competitive programming.
powered by competitive-verifier/competitive-verifier & Tiphereth-A/TINplate.

Documentation Site · Report Bug & Request Feature · Latest Release · Citation File

GitHub license Standard Requirements Code Size

GitHub deployments GitHub Workflow Status (with event) - verify GitHub Workflow Status (with event) - release GitHub Workflow Status (with event) - codeql GitHub Workflow Status (with event) - flawfinder

CP-lib is a header-only C++ code library designed for competitive programming with 450+ implementations of algorithms and data structures commonly used in competitive programming contests.

The repository solves several key problems for competitive programmers:

Key Characteristics

Usage

Requirements:

The project uses Python for management scripts. Install dependencies using uv.

Optional dependency groups:

For LaTeX compiling:

# Clone the repository
git clone -c core.symlinks=true [email protected]:Tiphereth-A/CP-lib.git
cd CP-lib

# Install Python dev dependencies
uv sync --frozen --group dev
uv run pre-commit install

# Install Python dependencies
uv sync --frozen

# Install verify group for using `oj-verify` if needed
uv sync --frozen --group verify

# Install bundle group for using `oj-bundle` if needed
# Warning: NEVER use `oj-verify` from `online-judge-verify-helper`
uv sync --frozen --group bundle

# Verify installation
python3 manager.py --help

# Run all C++ benchmarks locally (writes .cp-lib/benchmark_result.json)
python3 manager.py benchmark

The manager.py script provides several commands for managing the repository, see python manager.py --help for details.

FAQs

Q: How can I submit the code using headers of this repo to any OJ
A: Use oj-bundle to auto-expansion your code, it has been included in verify group of Python dependencies already.

You can also find a bundled button at any code pages of documentation site, click the button then you will get the expanded code.

Q: PDF generation is slow
A: This is normal for large LaTeX documents, the expected time used in PDF generation is about 6 minutes in GitHub Action.

Acknowledgments

Core Tools and Libraries

Online Judges

This library is verified against problems from:

Contributors

Thank you to all contributors who have helped improve this library! See the Contributors page.

Inspiration

This library is inspired by and builds upon the work of the competitive programming community, including:

See notebook.bib for details.

Citation

If you use this library in academic work, please cite it using the provided CITATION.bib file.

Library Files

src/bit/

src/comb/

src/conv/

src/ds/

src/edh/

src/fast/

src/fps/

src/fpssp/

src/game/

src/gen/

src/geo2d/

src/geo3d/

src/graph/

src/io/

src/lalg/

src/math/

src/nt/

src/opt/

src/sheet/

src/sps/

src/str/

src/tree/

src/util/

test/cpv_local/

Verification Files

src/ds/

test/cpv/aizu-alds1/

test/cpv/aizu-cgl/

test/cpv/aizu-dpl/

test/cpv/aizu-dsl/

test/cpv/aizu-grl/

test/cpv/aizu-info1/

test/cpv/aizu-itp1/

test/cpv/aizu-itp2/

test/cpv/aizu-ntl/

test/cpv/aizu/

test/cpv/library-checker-big_integer/

test/cpv/library-checker-convolution/

test/cpv/library-checker-datastructure/

test/cpv/library-checker-enumerative_combinatorics/

test/cpv/library-checker-geo/

test/cpv/library-checker-graph/

test/cpv/library-checker-linear_algebra/

test/cpv/library-checker-number_theory/

test/cpv/library-checker-other/

test/cpv/library-checker-polynomial/

test/cpv/library-checker-sample/

test/cpv/library-checker-set_power_series/

test/cpv/library-checker-string/

test/cpv/library-checker-tree/

test/cpv/yukicoder/

test/cpv_local/comb/

test/cpv_local/ds/

test/cpv_local/edh/

test/cpv_local/enum/

test/cpv_local/fps/

test/cpv_local/game/

test/cpv_local/geo2d/

test/cpv_local/geo3d/

test/cpv_local/graph/

test/cpv_local/io/

test/cpv_local/lalg/

test/cpv_local/math/

test/cpv_local/nt/

test/cpv_local/opt/

test/cpv_local/tree/

test/cpv_local/util/

Others