✅ 정답 공개
from collections import OrderedDict
class LRUCache:
def __init__(self, capacity):
self.cap=capacity; self.cache=OrderedDict()
def get(self, key):
if key not in self.cache: return -1
self.cache.move_to_end(key); return self.cache[key]
def put(self, key, value):
if key in self.cache: self.cache.move_to_end(key)
self.cache[key]=value
if len(self.cache)>self.cap: self.cache.popitem(last=False)
c=int(input()); lru=LRUCache(c)
while True:
line=input().strip()
if line=='END': break
parts=line.split()
if parts[0]=='get': print(lru.get(int(parts[1])))
else: lru.put(int(parts[1]),int(parts[2]))