For this Question: Ram is given an array A of N integers. He was asked to perform the following operation, The operation goes like this, Ram can choose at most X numbers of distinct elements from the array. Print the maximum sum he could achieve.The first line of the input contains an integer T denoting number of test cases.
For each test cases there will be two lines.
The first line will contain two space separated integers N and X.
The second line will contain the N space separated integers denoting array A.

<b>Constraints</b>
1 &le; T &le; 1000
1 &le; X, N &le; 10<sup>5</sup>
-10<sup>9</sup> &le; A[i] &le; 10<sup>9</sup>
Sum of N over all test cases will not exceed 2 x 10<sup>6</sup>For each test case print the maximum sum Ram can achieve.Sample Input 
2
4 1
1 2 3 4
5 1
1 3 3 2 5

Sample Output 
4
6

<b>Explanation:</b>
For the first test case, we can choose 4 and maximize the sum.
For the second test case, we can choose two 3 as we have chosen only 1 distinct integer and maximize the result., I have written this Solution Code: /**
 *    author:  tourist1256
 *    created: 2022-07-12 13:59:06
 **/

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class key, class value, class cmp = std::less<key>>
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 2351
#endif

#define int long long

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

inline int64_t random_long(long long l = LLONG_MIN, long long r = LLONG_MAX) {
    uniform_int_distribution<int64_t> generator(l, r);
    return generator(rng);
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    unordered_map<int, int> mp;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]] += a[i];
    }
    vector<int> v;
    for (auto &it : mp) {
        if (it.second > 0) {
            v.push_back(it.second);
        }
    }
    sort(v.begin(), v.end(), greater<int>());
    debug(v);
    int ans = 0;
    for (int i = 0; i < min(k, (int)v.size()); i++) {
        ans += v[i];
    }
    cout << ans << "\n";
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    auto start = std::chrono::high_resolution_clock::now();

    int tt;
    cin >> tt;
    while (tt--) {
        solve();
    }

    return 0;
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?