if (position + adjustedSpeed in memo and adjustedSpeed in memo[position + adjustedSpeed] and adjustedSpeed in memo[position + adjustedSpeed]):