Python using dict, 212ms 14.6MB
\nclass OrderedStream:\n\n    def __init__(self, n: int):\n        self.seen = {}\n        self.ptr = 1\n\n    def insert(self, id: int, value: str) -> List[str
```\nclass OrderedStream:\n\n    def __init__(self, n: int):\n        self.seen = {}\n        self.ptr = 1\n\n    def insert(self, id: int, value: str) -> List[str]:\n        seen, ptr = self.seen, self.ptr\n        \n        seen[id] = value\n        result = []\n        while ptr in seen:\n            result.append(seen[ptr])\n            del seen[ptr]\n            ptr += 1\n        \n        self.ptr = ptr\n        return result\n\n\n# Your OrderedStream object will be instantiated and called as such:\n# obj = OrderedStream(n)\n# param_1 = obj.insert(id,value)\n```
['Python', 'Python3']