Implement a custom polyfill for the debounce function.
Implement debounce_calls(wait, calls, cancel_at) using a debounced closure. Each call is represented as [time, args], where args is a list of positional arguments. Return the argument lists from callbacks that actually execute. If cancel_at is not null, cancel the pending invocation at that time. Calls are sorted by time, and the deterministic input format replaces real timers for grading.
Function signature: debounce_calls(wait, calls, cancel_at)
A call executes only after no newer call arrives during wait seconds. A call exactly at the pending deadline allows the previous invocation to execute first.
def debounce_calls(wait, calls, cancel_at):