Keyset pagination
Your task
Implement keyset (cursor) pagination over a table ordered by (created_ts ASC, id ASC). Rows are given as [id, created_ts] (both integers, the pair is unique). Given a cursor (cursor_ts, cursor_id) and a page size limit, return up to limit rows that come strictly AFTER the cursor in the ordering, i.e. created_ts > cursor_ts, or (created_ts == cursor_ts and id > cursor_id). Return them in sorted order. A cursor of (-1, -1) means start from the beginning. Up to 50000 rows.
Examples
keyset_page(rows: list[list], cursor_ts: int, cursor_id: int, limit: int) -> list[list]Example 1
Input
keyset_page([[1, 100], [2, 100], [3, 200]], 100, 1, 2)Output
[[2, 100], [3, 200]]