$ show EndlessCheng/codeforces-go
EndlessCheng/codeforces-go is a comprehensive collection of competitive programming solutions and algorithm templates written in Go. The repository provides reusable implementations of data structures (e.g., segment trees, fenwick trees, treaps, suffix automata) and algorithms (e.g., Aho-Corasick, various math functions) in the copypasta directory. It also includes a test harness (main/testutil) for verifying solutions against sample inputs and outputs, along with code generators to automate test file creation. Each solution is typically a standalone Go program that reads from standard input and writes to standard output, following the typical format for online judge submissions. The repository is organized by problem source (LeetCode, Codeforces, AtCoder, etc.) and difficulty, making it a valuable reference for learning and practicing competitive programming.
The LLM identified 5 files worth highlighting for reuse:
Implements a lazy-propagation segment tree supporting range updates and range queries. The code is self-contained, uses only the standard library, and demonstrates a non-obvious implementation of a complex data structure that is reusable in many problems requiring interval operations.
Implements a Fenwick Tree (Binary Indexed Tree) for point updates and prefix sum queries, with support for range updates and point queries via two trees. The code is concise, efficient, and lacks any internal dependencies, making it trivial to extract.
Implements a Suffix Automaton for linear-time construction and various string processing tasks (e.g., substring occurrence, longest common substring). The implementation is self-contained and showcases advanced string algorithm knowledge.
Implements the Aho-Corasick automaton for multi-pattern string matching. Includes failure links and output links, enabling efficient dictionary matching. The code is self-contained and represents a non-trivial algorithm.
Provides a test harness for competitive programming solutions, including functions to assert expected output against given input samples and to run solutions with file-based test cases. This pattern is reusable across any problem that follows the standard I/O format and demonstrates skilled test automation.