Comments

A solution that I found was that instead of having the keys in your dictionary as integers make them as strings, that reduced the density of integers at a particular place, which was originally leading to TLE