LFU Cache Design

Design and reason about a Least Frequently Used (LFU) cache with capacity capacity. An LFU cache supports get(key) and put(key, value): get returns the value for key or -1 if absent; put inserts or updates the key. Every successful get and every update of an existing key increases that key's usage frequency. When inserting a new key into a full cache, evict the key with the smallest frequency; if multiple keys share that frequency, evict the least recently used among them.

Established execution ABI (read-only fixtures and schema): the current platform contract is functional, not class-dispatch. solve(arg1) receives a flat op-encoded number[] and returns a number[] containing the results of get operations in order. Encoding used by fixtures: arg1[0] is capacity; a get(key) is encoded as [1, key]; a put(key, value) is encoded as [2, key, value]. The result list includes -1 for misses and the stored value for hits. Preserve canonical LFU frequency/recency semantics under this encoding.

Examples
Input: [0]
Output: []
Hints

LFU Cache Design

Design and reason about a Least Frequently Used (LFU) cache with capacity `capacity`. An LFU cache supports `get(key)` and `put(key, value)`: `get` returns the value for `key` or `-1` if absent; `put` inserts or updates the key. Every successful `get` and every update of an existing key increases that key's usage frequency. When inserting a new key into a full cache, evict the key with the smallest frequency; if multiple keys share that frequency, evict the least recently used among them.