Python3. Clean code. Sliding window. Nothing fancy
Intuition\n Describe your first thoughts on how to solve this problem. \n\nSuppose stand index is x\nIf we use step 1 -> we need 2 moves to take 1 point\nIf we 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\nSuppose stand index is `x`\nIf we use step 1 -> we need 2 moves to take 1 point\nIf we use step 2 -> we nedd `|y - x|` moves to take 1 point (`y` is one index)\n\nSo step 1 will be optimal if `[y - x] > 2`.\nBut we just can do the step 1 in `max_changes` times\nSo we do step 2 in `k - max_changes`, but if `|y - x| <= 1`, step 2 will be optimal\nSo we consider do the step 2 from `k - max_changes` to `k - max_changes + 2` times because we just have 3 `y` satisfy `|y - x| <= 1`\nSo we can see the problem right now will be count minimum moves to take `z` points if only using step 2\n-> using sliding window\n\nFor example we have array `[1, 5, 6, 9, 10, 15]`\nWe need to chose one index is stand index and total distanse from this index to other index is minimum\n-> Chose the middle index (in this example is 9), so total distance is minimum\nTo caculate the total distanse in `O(1)`, we use prefix sum\nIn this example `total_distance = sum(10, 15) - 9 * 2 + 9 * 3 - sum(1, 5, 6)`\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python []\nclass Solution:\n    def minimumMoves(self, nums: List[int], k: int, max_changes: int) -> int:\n        one_indexes = [index for index in range(len(nums)) if nums[index] == 1]\n        min_moves = float(\'inf\')\n        if max_changes >= k: # with 0 step 2\n            min_moves = 2 * k\n\n        prefix_sums = one_indexes.copy()\n        for i in range(1, len(one_indexes)):\n            prefix_sums[i] += prefix_sums[i - 1]\n\n        def get_sum(left, right):\n            if left > right:\n                return 0\n            if left == 0:\n                return prefix_sums[right]\n            return prefix_sums[right] - prefix_sums[left - 1]\n\n        min_step_twos = max(1, k - max_changes)\n        # step_twos is the number of times using step 2\n        for step_twos in range(min_step_twos, min_step_twos + 3):\n            if step_twos > k:\n                break\n\n            for left in range(len(one_indexes)):\n                right = left + step_twos - 1\n                if right >= len(one_indexes):\n                    break\n\n                stand_index = (right + left) // 2\n                # number moves that using step 1\n                curr_moves = (k - step_twos) * 2\n                # total distance from mid to right\n                curr_moves += get_sum(stand_index + 1, right) - (right - stand_index) * one_indexes[stand_index]\n                # total distance from left to mid\n                curr_moves += (stand_index - left) * one_indexes[stand_index] - get_sum(left, stand_index - 1)\n\n                min_moves = min(min_moves, curr_moves)\n\n        return min_moves\n\n```
['Python3']