How would you implement a custom memory allocator for a real-time embedded system with strict deterministic execution requirements?
Implement a fixed-size arena allocator using first-fit allocation. simulate_allocator(capacity, operations) receives an integer capacity and operations ["alloc", size] or ["free", address], returning one result per operation: the allocated address, -1 on failure, or true for a successful free. Allocation must split free regions, and freeing must coalesce adjacent free regions. Assume frees reference currently allocated addresses; do not resize the arena.
Constraints: 1 <= capacity <= 1000, 1 <= len(operations) <= 1000, and allocation sizes are positive integers no greater than capacity.
def simulate_allocator(capacity, operations):