Write a function to optimize the memory allocation for a streaming data pipeline. Given memory requests as [start, end, blocks], where end is exclusive, assign reusable integer block IDs to every request. Requests whose lifetimes overlap must not share blocks. Return allocations in input order and the minimum peak number of blocks required. Use def optimize_memory_allocation(requests):, with output {"allocations": List[List[int]], "peak_blocks": int}. Requests may be unsorted, and a request ending at time t may share blocks with one starting at t].
def optimize_memory_allocation(requests):