comefrom: <doocs>1838.Frequency of the Most Frequent Element_1.py
code: def maxFrequency( nums: List[int], k: int) -> int:
      nums.sort()
      ans = 1
      window = 0
      l, r, n = 0, 1, len(nums)
      while r < n:
          window += (nums[r] - nums[r - 1]) * (r - l)
          r += 1
          while window > k:
              window -= nums[r - 1] - nums[l]
              l += 1
          ans = max(ans, r - l)
      return ans
masked: def sample_funcname ( var_0 : List [ int ] , var_1 : int ) -> int :
      var_0.sort ( )
      var_2 = 1
      var_3 = 0
      var_4 , var_5 , var_6 = 0 , 1 , len ( var_0 )
      while var_5 < var_6 :
          var_3 += ( var_0 [ var_5 ] - var_0 [ var_5 - 1 ] ) * ( var_5 - var_4 )
          var_5 += 1
          while var_3 > var_1 :
              var_3 -= var_0 [ var_5 - 1 ] - var_0 [ var_4 ]
              var_4 += 1
          var_2 = max ( var_2 , var_5 - var_4 )
      return var_2
  