Prefix sums + point updates, both O(log n). A segment tree's job for sums — in one array, two loops.
i & -i positions ending at i (lowest set bit)i -= i & -ii += i & -iprefix_sum(6): 6 → 4 → 0 (subtract lowbit). update(3): 3 → 4 → 8 (add lowbit). No tree drawn — there is no tree.
46× faster than raw array, 403× than prefix sums — and 4× faster than a segment tree (6ms vs 25ms).
Same Big-O, tiny constant → match the tool to the exact problem. Next: B-trees — the balanced tree, reimagined for disk.