c++ solution
\nclass Solution {\npublic:\n    int find(vector<int>&nums,int window,long long k)\n    {\n        if(window==0) return false;\n        int n=nums.size();\n    
```\nclass Solution {\npublic:\n    int find(vector<int>&nums,int window,long long k)\n    {\n        if(window==0) return false;\n        int n=nums.size();\n        vector<long long>prefix(n,0);\n        prefix[0]=nums[0];\n        for(int i=1;i<nums.size();i++)\n        {\n            prefix[i]=nums[i];\n            prefix[i]+=prefix[i-1];\n        }\n        for(int l=0,r=window-1;r<n;l++,r++)\n        {\n            int mid=(l+r)/2;\n            long long leftOperation = 1ll*nums[mid]*(mid-l+1)-(prefix[mid]-((l>0)?prefix[l-1]:0));\n            long long rightOperation = (prefix[r]-prefix[mid])-1ll*nums[mid]*(r-mid);\n            if(leftOperation+rightOperation<=k)\n            {\n                return true;\n            }\n        }\n        return false;\n    }\n    int maxFrequencyScore(vector<int>& nums, long long k) {\n        int l=1;\n        int r=nums.size();\n        int ans=0;\n        sort(nums.begin(),nums.end());\n        while(l<=r)\n        {\n            int mid=(l+r)/2;\n            if(find(nums,mid,k))\n            {\n                ans=mid;\n                l=mid+1;\n            }\n            else\n            {\n                r=mid-1;\n            }\n        }\n        return ans;\n    }\n};\n```
['C', 'Binary Tree', 'C++']