WorldQuant interview question

Heap log aggregation question in Python.