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: import java.util.*;

import java.io.*;


 

class Main {

static class Reader {

final private int BUFFER_SIZE = 1 << 16;

private DataInputStream din;

private byte[] buffer;

private int bufferPointer, bytesRead;


 

public Reader()

{

din = new DataInputStream(System.in);

buffer = new byte[BUFFER_SIZE];

bufferPointer = bytesRead = 0;

}


 

public Reader(String file_name) throws IOException

{

din = new DataInputStream(

new FileInputStream(file_name));

buffer = new byte[BUFFER_SIZE];

bufferPointer = bytesRead = 0;

}


 

public String readLine() throws IOException

{

byte[] buf = new byte[64]; // line length

int cnt = 0, c;

while ((c = read()) != -1) {

if (c == '\n') {

if (cnt != 0) {

break;

}

else {

continue;

}

}

buf[cnt++] = (byte)c;

}

return new String(buf, 0, cnt);

}


 

public int nextInt() throws IOException

{

int ret = 0;

byte c = read();

while (c <= ' ') {

c = read();

}

boolean neg = (c == '-');

if (neg)

c = read();

do {

ret = ret * 10 + c - '0';

} while ((c = read()) >= '0' && c <= '9');


 

if (neg)

return -ret;

return ret;

}


 

public long nextLong() throws IOException

{

long ret = 0;

byte c = read();

while (c <= ' ')

c = read();

boolean neg = (c == '-');

if (neg)

c = read();

do {

ret = ret * 10 + c - '0';

} while ((c = read()) >= '0' && c <= '9');

if (neg)

return -ret;

return ret;

}


 

public double nextDouble() throws IOException

{

double ret = 0, div = 1;

byte c = read();

while (c <= ' ')

c = read();

boolean neg = (c == '-');

if (neg)

c = read();


 

do {

ret = ret * 10 + c - '0';

} while ((c = read()) >= '0' && c <= '9');


 

if (c == '.') {

while ((c = read()) >= '0' && c <= '9') {

ret += (c - '0') / (div *= 10);

}

}


 

if (neg)

return -ret;

return ret;

}


 

private void fillBuffer() throws IOException

{

bytesRead = din.read(buffer, bufferPointer = 0,

BUFFER_SIZE);

if (bytesRead == -1)

buffer[0] = -1;

}


 

private byte read() throws IOException

{

if (bufferPointer == bytesRead)

fillBuffer();

return buffer[bufferPointer++];

}


 

public void close() throws IOException

{

if (din == null)

return;

din.close();

}

}

public static void main(String[] args) throws IOException {

Reader br = new Reader();

long t = br.nextLong();

for (long i =0;i<t;i++){

long a=br.nextLong(),b=br.nextLong(),c=0;

long[] s = new long[(int) a];

for(long j=0;j<a;j++)

{

s[(int) j]=br.nextLong();

}

HashMap<Long,Integer> hash = new HashMap<Long,Integer>();

for(int k=0;k<s.length;k++){

if (hash.containsKey(s[k])) {

hash.put(s[k], hash.get(s[k]) + 1);

} else {

hash.put(s[k],1);

}

}

ArrayList<Long> arr = new ArrayList<Long>();

for (Map.Entry<Long, Integer> e : hash.entrySet()) {

arr.add(e.getKey()*e.getValue());

}

Collections.sort(arr);

Collections.reverse(arr);

for(long m:arr){

if(b>0 && m>=0){

c+=m;

b-=1;

}

}

System.out.println(c);

hash.clear();

arr.clear();

c=0;

}

}

}

, In this Programming Language: Java, Now tell me if this Code is compilable or not?