Design decisions

68. LazyTreap in std.lazy and flat SparseTable storage (2026-11-21)

  1. Add LazyTreap<T, F> to std.lazy (no new module, no compiler privilege). Arena-backed randomized treap over a contiguous node arena with subtree-size-aware lazy tag pushdown (apply(v, left_sz, f), compose(new_f, old_f), optional split(f, left_sz), optional before(x, y)), supporting both value-ordered insertion (insert, for slope-trick / priority-with-lazy-updates) and 0-based implicit sequence operations (push, insert_at, apply_range, get), plus apply_all, take(k), and to_list. Stores pending tags as ?F so F needs neither id nor Eq, and lowers all operation closures statically (0 std::function). Adopted by proto/ports/ecnerwala/cf2084g2.cp (895 -> 359 tokens, 1.05x of dream; 0.90x time vs C++ original on n = 500_000). Reverse: remove LazyTreap from stdlib/lazy.cp and restore the hand-rolled treap in cf2084g2.cp.
  2. Flatten SparseTable storage in stdlib/sparse.cp. Store all bit_width(n) levels in a single flat List<T> with unchecked: indexing in build and fold, matching DisjointSparseTable and eliminating nested std::vector heap allocations. Reverse: restore rows: List<List<T>> in stdlib/sparse.cp.