For this Question: Given an array arr[] of N integers in which elements may be repeating several times. Also, a positive number K is given and the task is to find sum of total frequencies of K most occurring elements

Note: The value of K is guaranteed to be less than or equal to the number of distinct elements in arr.First line of input contains number of testcases T. For each testcase, first line of input contains the size of array N, and next line contains N positive integers. The last line contains K.

Constraints:
1 <= T <= 100
1 <= K <= N
1 <= N <= 10^4
1 <= arr[i] <= 10^6For each testcase, print the sum of total frequencies of K most occurring elements in the given array.Sample Input:
2
8
3 1 4 4 5 2 6 1
2
8
3 3 3 4 1 1 6 1
2

Sample Output:
4
6

Explanation:
Testcase 1: Since, 4 and 1 are 2 most occurring elements in the array with their frequencies as 2, 2. So total frequency is 2 + 2 = 4.

Testcase 2: Since, 3 and 1 are most occurring elements in the array with frequencies 3, 3 respectively. So, total frequency is 6., I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;


int main(){

int t;
cin>>t;
while(t--){
      int n;
cin>>n;
vector<int> v;
unordered_map<long,int> m;
long x;
for(int i=0;i<n;i++){
    cin>>x;
    m[x]++;

}
    int k;
cin>>k;
for(auto it=m.begin();it!=m.end();it++){
    v.emplace_back(it->second);
}
sort(v.begin(),v.end());
int ans=0;
for(int i=v.size()-1;i>=(v.size()-k);i--){
    ans+=v[i];
}
cout<<ans<<endl;}
}
, In this Programming Language: C++, Now tell me if this Code is compilable or not?