#add-multiply-set 6.851 Pset 2 code-up, https://courses.csail.mit.edu/6.851/fall17/psets/ps2.pdf. Segment B-tree works in O(log n) per operation. I used the same implementation of a segment B-tree for the retroactive deque. -Kliment