These are the CP templates I've written during my competitive programming journey in high school. All implementations have been tested and used at various points along the way. Some include comments and explanations within the source code.
- Binary Search (4) - Standard Binary Search, STL Functions, Count/Left/Right Variations
- Dynamic Programming (13) - Classic DP: Coins, Knapsack, LIS, LCS, Kadane, and more
- Graphs (10) - Dijkstra, Bellman-Ford, Floyd-Warshall, Kruskal, Kosaraju, 2-SAT, Topological Sort
- Mathematics (11) - Number theory, Modular Arithmetic, Combinatorics, Prime sieves
- Range Queries (5) - Segment Trees, Lazy Propagation, Prefix Sums, Ordered Set
- Strings (7) - Z-algorithm, Aho-Corasick, Rabin-Karp, Suffix Arrays, Manacher's
- Trees (4) - LCA, Diameter, Center, Re-rooting
- Other (7) - Bitwise operations, Ternary Search, Two-Pointers, Game Theory
- standardTemplate.cpp - Base template with common includes and macros
- geometryTemplate.cpp - Point and vector operations for computational geometry
- moduloTemplate.cpp - Modular arithmetic operations
- bigIntegerTemplate.cpp - Arbitrary precision integer arithmetic
- randomGeneratorTemplate.cpp - For generating random test cases (numbers, arrays, permutations, trees)
- speedTestTemplate.cpp - Benchmarking and performance testing
Feel free to use these templates for your own competitive programming practice and contests. If you find any mistakes or have suggestions for improvements, I'd appreciate hearing about them!
This repository is provided as-is for educational and competitive programming purposes. You are free to use, modify, and distribute these templates for personal practice, contests, and learning. No warranty is provided.
Contact me at [email protected] or open an issue on this repository for questions, suggestions, or bug reports.