bisect.insort(nums, cnt+1) if loc - 1 >= 0 and seq[loc-1][1] == ch: bg = seq[loc -2][0] + 1 if loc-2 >= 0 else 0 _, _, cnt = seq[loc-1] ed, _, cnt2 =