How would you implement a rate-limiter for an API endpoint?
Implement rate_limit(requests, limit, window) for chronologically ordered requests. Each request is [client_id, timestamp]; apply the limit independently per client, and rejected requests must not consume capacity.
Return a boolean for each request. A request at time t can use accepted requests with timestamps in (t - window, t]; requests exactly t - window have expired.
def rate_limit(requests, limit, window):