Debug a provided distributed-system codebase (concurrency issues such as data races, deadlock, lock contention, rate limiter) in Python.
Asked in the phone screen stage. Implement the corrected rate-limiter core used by the codebase. Requests are processed in arrival order, and each request is [client_id, timestamp]. A request is allowed when that client has made fewer than limit allowed requests in the previous window time units. The implementation must preserve independent state per client and use synchronization correctly when adapted for concurrent callers.
Implement rate_limit(requests, limit, window). Return a Boolean list indicating whether each request is allowed.
def rate_limit(requests, limit, window):