A personal library of C++ algorithms, data structures, and mathematical routines for competitive programming, organized so it can be converted into ready-to-use code snippets for VSCode and Sublime Text.
The Code/ directory contains 106 C++ source files (plus a small debugger header and a text reference note) grouped into topic folders:
DATA STRUCTURE: Bitset, Cartesian Tree, Convex Hull Trick, Cumulative Table, Disjoint Set Union, Dynamic Set, Explicit Treap, Hash Table, Heavy Light Decomposition, Li Chao Tree, Link Cut Tree, Lowest Common Ancestor, Monotonic Queue/Stack, Order Statistic Set, Rollback Trick, Segment Tree, Slope Trick, Sparse Table, Sqrt Decomposition (including Mo's Algorithm), Venice TechniqueDYNAMIC PROGRAMMING: Divide and Conquer OptimizationGAME THEORY: Grundy numbers and related game analysis snippetsGRAPH THEORY: Centroid Decomposition, Euler Tour, Flow Theory, Graph Structure, Inverse Graph ComponentsMATHEMATICS: Algebra, Combinatorial Theory, Number Theory, Numerical MathMISCELLANY: Big Number, Calendar, Coordinate Compression, Debugger, IOS_BASE, Longest Increasing Subsequence, Modular Number, Pragma, Random, Stress testing, and a base TemplateSTRING: Aho-Corasick, Hashing, Manacher, Suffix Array
Each .cpp file in Code/ begins with a // TAB_TRIGGER "NAME" comment, which names the snippet trigger keyword used when it's converted into an editor snippet.
- C++ (the snippet bodies themselves, targeting competitive programming judges)
- Python 3 (
generateSnippets.py), used only to build the editor snippet files from the C++ sources
generateSnippets.py performs a two-stage build:
generate_sublime_snippets(): copiesCode/into a newSublime-snippets/directory, reads theTAB_TRIGGERcomment out of each.cppfile, wraps the remaining code in a<snippet>XML block, and writes it out as a.sublime-snippetfile (replacing the original.cpp).generate_vscode_snippets(): copiesSublime-snippets/intoVSCode-snippets/, parses each.sublime-snippetfile's code and trigger, and rewrites it as a VSCode.code-snippetsJSON file (withscope: "cpp", aprefix,body, anddescription).
Both generated folders (Sublime-snippets/, VSCode-snippets/) are rebuilt from scratch (deleted and recreated) each time the script runs.
Generate the VSCode and Sublime Text snippet files from the source in Code/:
python3 generateSnippets.pyThis produces:
Sublime-snippets/: one.sublime-snippetfile per source file, mirroring theCode/folder structureVSCode-snippets/: one.code-snippetsfile per source file, generated from the Sublime snippets
Import either folder into the corresponding editor to get the algorithms available as typed snippets (using each file's TAB_TRIGGER as the trigger prefix).
This is a personal reference collection built up over time rather than a general-purpose package; there is no build system, test suite, or dependency manifest beyond the Python standard library used by generateSnippets.py.