Target is always K distant from some element
\nimport bisect\n\nclass Solution:\n    def maxFrequency(self, nums: List[int], k: int, numOperations: int) -> int:\n        nums.sort()\n        ctr = Counter(
```\nimport bisect\n\nclass Solution:\n    def maxFrequency(self, nums: List[int], k: int, numOperations: int) -> int:\n        nums.sort()\n        ctr = Counter(nums)\n        s = set()\n        for el in nums:\n            s.add(el)\n            s.add(el - k)\n            s.add(el + k)\n        res = 0\n        for el in s:\n            res = max(res, ctr[el] + min(bisect.bisect_right(nums, el + k) - bisect.bisect_left(nums, el - k) - ctr[el], numOperations))\n        return res\n```
['Python']