yet another example
Code\n\nclass Solution {\n    fun maxFrequencyScore(nums: IntArray, k: Long): Int {\n        var x = k\n        nums.sort()\n        return nums.size -\n       
# Code\n```\nclass Solution {\n    fun maxFrequencyScore(nums: IntArray, k: Long): Int {\n        var x = k\n        nums.sort()\n        return nums.size -\n               nums.foldIndexed(0) { j, i, v ->\n                                                x -= v - nums[(i+j)/2]\n                                            if (x<0) {\n                                                x += nums[(i+j+1)/2] - nums[i]\n                                                i + 1\n                                            } else\n                                                i\n        }\n    }\n}\n```
['Kotlin']