Implement an LFU (Least Frequently Used) cache template class.
Asked in the Technical Phone Screens (3 rounds) stage. This is a practical C++ coding task focused on data structures and template classes.
For grading, implement lfu_cache(operations, capacity). Each operation is ['put', key, value] or ['get', key]; return the values from get operations, using -1 for missing keys. When frequencies tie, evict the least recently used key.
def lfu_cache(operations, capacity):