Hi. Can anyone explain why it's TLE? It's O(n), since it just iterates through pairs and gets/sets values by key from dicts (which is O(1)), and checking for dict membership is also O(1). Or isn't it? Or even O(n) isn't enough here, using Python? Oh, I see that only one person managed to do it in Python, but I don't understand what can be slow in my code. 
no need for code :-)