C++ Solution
\n/*****************************************************************************/\n/* Include libraries.                                                        
```\n/*****************************************************************************/\n/* Include libraries.                                                        */\n/*****************************************************************************/\n#include <bits/stdc++.h>\n#include <fstream>\nusing namespace std;\n\n#define ll long long\n#define bits_in_a_byte 8\n\nbool LOG = true;\n\ninline void env_opti()\n{\n    ios::sync_with_stdio(false);\n    cin.tie(nullptr);\n    cout.tie(nullptr);\n}\n\nstruct element_info\n{\n    /*************************************************************************/\n    /* Shows the number of elements which can reach here.                    */\n    /*************************************************************************/\n    ll count;\n\n    /*************************************************************************/\n    /* Shows the number of elements which need modification to reach here.   */\n    /*************************************************************************/\n    ll modifie_count;\n};\n\nclass Solution {\npublic:\n    int maxFrequency(vector<int>& nums, int k, int numOperations)\n    {\n        env_opti();\n\n        /*********************************************************************/\n        /* Local variable.                                                   */\n        /*********************************************************************/\n        ll n = nums.size();\n        element_info obj1;\n        element_info obj2;\n        map<ll, element_info> my_map;\n        ll ans = 0;\n\n        obj1.count = 0;\n        obj1.modifie_count = 0;\n\n        for (ll i=0; i<n; i++)\n        {\n            // Start at the left most value it can reach\n            my_map[nums[i]-k].count += 1;\n            my_map[nums[i]-k].modifie_count += 1;\n\n            // Reduce the modifie_count at that number\n            my_map[nums[i]].modifie_count -= 1;\n\n            // Increase it at the next value\n            my_map[nums[i]+1].modifie_count += 1;\n\n            // reduce at the right most value it cannot go anymore\n            my_map[nums[i]+k+1].count -= 1;\n            my_map[nums[i]+k+1].modifie_count -= 1;\n        }\n\n        if (LOG)\n        {\n            for(auto i: my_map)\n            {\n                cout << "Key: " << i.first << " Value: {" << i.second.count\n                     << ", " << i.second.modifie_count << "}\\n";\n            }\n        }\n\n        for (auto i: my_map)\n        {\n            obj2 = i.second;\n\n            // Add it in the calculation then decide if to take this in \n            // consideration\n            obj1.count += obj2.count;\n            obj1.modifie_count += obj2.modifie_count;\n\n            // At this point we have this:\n            // obj1.count         -> shows the number of elements can reach here\n            // obj1.modifie_count -> shows the number of elements needs modification\n\n            ans = max(ans,\n                      (obj1.count - obj1.modifie_count +\n                       min(obj1.modifie_count, (ll)numOperations)));\n            if (LOG) cout << "ans: " << ans << \'\\n\';\n        }\n        return((int)ans);\n    }\n};\n```
['C']