Token bucket limiter
Your task
Simulate a token-bucket rate limiter using integer arithmetic only. The bucket holds up to capacity tokens and starts full. It refills at rate tokens per second, accrued continuously: between two times, floor((t - last_refill) * rate) tokens are added (capped at capacity), and last_refill advances by the whole seconds actually consumed for those tokens to avoid losing fractional credit. Each request (given as non-decreasing integer timestamps) costs 1 token: if a token is available it is ALLOWED and a token is spent, else REJECTED. Return the list of booleans. Assume rate >= 1 and capacity >= 1.
Examples
token_bucket(requests: list[int], capacity: int, rate: int) -> list[bool]Example 1
Input
token_bucket([0, 0, 0], 2, 1)Output
[True, True, False]