input: from typing import List
  
  def min_operations_to_make_median_k(nums: List[int], k: int) -> int:
      """
      You are given an integer array nums and a non-negative integer k. In one operation, you can increase or decrease any element by 1.
  
      Return the minimum number of operations needed to make the median of nums equal to k.
  
      The median of an array is defined as the middle element of the array when it is sorted in non-decreasing order. If there are two choices for a median, the larger of the two values is taken.
  
      Examples:
      >>> nums = [2,5,6,8,5], k = 4
      2
      >>> nums = [2,5,6,8,5], k = 7
      3
      >>> nums = [1,2,3,4,5,6], k = 4
      0
  
      Constraints:
      1 <= nums.length <= 2 * 10^5
      1 <= nums[i] <= 10^9
      1 <= k <= 10^9
      """
  
output: 
      nums.sort()
      n = len(nums)
      median_index = n // 2
      
      if nums[median_index] == k:
          return 0
      
      operations = 0
      if nums[median_index] < k:
          for i in range(median_index, n):
              operations += abs(nums[i] - k)
      else:
          for i in range(median_index + 1):
              operations += abs(nums[i] - k)
      
      return operations
  