How would you implement a debouncing or throttling function from scratch?
Implement the debouncing behavior as a deterministic event simulator. Given timestamped events and a quiet interval, emit the latest event only after no newer event arrives during that interval. Return each emitted event as [timestamp, value], where the timestamp is the scheduled execution time.
Use simulate_debounce(events, wait), with events sorted as [timestamp, value] pairs and wait as a non-negative integer.
def simulate_debounce(events, wait):