Find the last element < target in a sorted array using binary search.
Prefix tree for string storage with insert, search, prefix check, and erase in O(|s|).
Find the max or min of a unimodal function on a continuous interval in O(log(range/eps)).
SCC decomposition, bridges, and articulation points in a single O(V+E) DFS pass.
Square root decomposition with sorted blocks for range counting queries and point updates in O(sqrt n).
Self-adjusting BST with O(log n) amortized operations via splay rotations.
Static range query structure — O(1) for idempotent operations (min/max/gcd), O(log n) for non-idempotent.
Linear sieve computing primes, smallest prime factor (SPF), Euler's totient, and Mobius function in O(n).
Nested segment tree for 2D point update and rectangle queries in O(log n * log m).
Classic segment tree with point update and range query for any associative operation.
Polynomial rolling hash with double hashing for collision-resistant O(1) substring comparison.
Minimum spanning tree using priority queue — greedy cut-based approach in O(E log V).
Find the smallest primitive root (generator) modulo a prime p.
2D prefix sum for O(1) rectangle sum queries on a static grid.
Factorize 64-bit integers into primes using Pollard's Rho with Miller-Rabin primality testing.
Segment tree preserving all versions via path copying — O(log n) per update, O(n + q log n) total memory.
2D difference array for O(1) range updates and O(n*m) final propagation.
Policy-based order-statistics tree — find k-th element and count elements less than x in O(log n).
Primality test, factorization, Euler's totient, divisors, integer sqrt, and perfect power check.
Mo's algorithm adapted for tree path queries using Euler tour flattening and LCA via binary lifting.
Offline range query processing with Hilbert curve ordering for optimal cache performance.
Next/previous greater/smaller element queries in O(n) using a monotonic stack.
Sliding window min/max in O(1) amortized using the two-stack queue pattern.
Modular multiplicative inverse via Fermat's little theorem, extended Euclidean, and linear precomputation.
Safe modular add, multiply, binary exponentiation, Russian peasant multiplication, and big mod.
Type-safe modular arithmetic with operator overloading for clean competitive programming code.
Deterministic Miller-Rabin primality test for 64-bit integers using verified witness sets.
Binary exponentiation on square matrices for solving linear recurrences in O(n^3 log k).
Base conversion, range summation, counting/summing multiples, and log base.
Find all palindromic substrings in O(n) time using linear expansion with symmetry reuse.
Find the first element >= target in a sorted array using binary search.
Dynamic forest structure supporting link, cut, and path queries in O(log n) amortized.
LCA with path aggregate queries (sum/max/min) on weighted trees using binary lifting in O(log n).
Binary lifting for LCA, distance, and k-th ancestor queries on unweighted trees in O(log n).
Segment tree with lazy propagation — supports range updates and range queries in O(log n).
Maximum bipartite matching via augmenting paths in O(V*E).
Knuth-Morris-Pratt pattern matching and prefix function in O(n + m).
Maximum contiguous subarray sum in O(n) time using linear DP.
Read and print __int128 values — a GCC extension for 128-bit signed integers not supported by standard cin/cout.
Count elements satisfying none/any of n properties using bitmask inclusion-exclusion.
Index-keyed splay tree for sequence operations — insert, erase, range query with lazy propagation.
Decomposes a tree into chains for O(log^2 n) path queries using a segment tree.
Min/max binary heap with push, pop, and top in O(log n).
Segment tree storing double hash values for range substring hashing with point updates in O(log n).
Deque with O(1) rolling polynomial double hash for constant-time equality comparison.
DFS and BFS with bipartite check, cycle detection, topological sort, and path reconstruction.
Linked-list (head array) adjacency — cache-friendly graph representation for contests.
Generic 2D point with full operator support: dot, cross, distance, rotation, unit, normal.
GCD, LCM, Extended Euclidean algorithm, and linear Diophantine equation solver.
All-pairs shortest paths via O(V^3) dynamic programming on the adjacency matrix.
Fenwick tree supporting both range add and range sum queries using two BITs.
2D Binary Indexed Tree for point updates and rectangle sum queries in O(log n * log m).
Binary Indexed Tree for prefix sum queries and point updates in O(log n).
Disjoint Set Union with path compression and union by size in near-constant amortized time.
Shortest path in non-negative weighted graphs using priority queue relaxation in O((V+E) log V).
Count numbers in [L, R] satisfying digit-level constraints using memoized recursion.
Modern competitive programming starter template with fast I/O, common aliases, and contest-ready boilerplate.
Maps sparse values to dense 0-indexed ranks for use with BIT/segment tree.
Dynamic line container with O(log C) insert and min query using Li Chao segment tree.
Andrew's monotone chain algorithm for convex hull in O(n log n).
Non-modular nCr, nPr, and Legendre's formula for prime power in factorials.
Divide-and-conquer on trees via centroid selection for O(n log n) path processing.
Catalan number computation via closed-form formula and DP recurrence.
Count distinct objects under symmetry (rotations) using Burnside's lemma.
Common bit manipulation operations — check, set, clear, toggle, popcount, subset enumeration.
Precomputed factorial and inverse factorial for O(1) nCr and nPr queries modulo a prime.
Trie on bit representation of integers — supports insert, erase, and XOR maximum query.
Basic BST with insert, delete, search, min/max, and all four traversal orders.
Classic binary search for finding a target value in a sorted array in O(log n).
Search for the optimal value satisfying a monotonic predicate in O(log n).
Fast exponentiation using binary representation of the exponent in O(log n) multiplications.
Non-negative arbitrary-precision integer with addition, subtraction, multiplication, division, and modulo.
Shortest path with negative edge weights and negative cycle detection in O(V*E).
Triangle validity, Euclidean distance, and collinearity check using cross product.
Complete 2D computational geometry toolkit: points, lines, segments, polygons with intersection, area, and point-in-polygon.