can anyone tell me why this is wrong? if wrong then for which test case?
please help me.
/* package codechef; // don't place package name! */
//@Author=Mr.Kashyap
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
public static void main(String[] args) throws IOException
{
Scan sc = new Scan();
Print print=new Print();
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(System.out));
int t=sc.scanInt();
while(t-->0){
int N=sc.scanInt();
long X=(long)sc.scanDouble();
long[] arr=new long[N];
HashMap<Long, Long> map=new HashMap<>();
for(int i=0;i<N;i++){arr[i]=(long)sc.scanDouble();
if(map.containsKey(arr[i])){
map.put(arr[i], map.get(arr[i])+ 1l);
}
else map.put(arr[i],1l);
}
long op=0;
long max=0;
if(X==0){
for(int i=0;i<N;i++){
max=max<map.get(arr[i])?map.get(arr[i]):max;
}
bw.append(max+" "+op+"\n");
continue;
}
for(int i=0;i<N;i++){
long xorr=arr[i]^X;
if(map.containsKey(xorr)){
if(map.get(arr[i])+map.get(xorr)>max){
max=map.get(arr[i])+map.get(xorr);
op=map.get(arr[i])<map.get(xorr)?map.get(arr[i]):map.get(xorr);
}
else if(map.get(arr[i])+map.get(xorr)==max){
long check=map.get(arr[i])<map.get(xorr)?map.get(arr[i]):map.get(xorr);
op=op<check?op:check;
}
}
else{
max=max<map.get(arr[i])?map.get(arr[i]):max;
}
}
bw.append(max+" "+op+"\n");
}
bw.close();
}
/*BufferedWriter with scanInt, (long)scanDouble, scanString , bw.append("Result\n")*/
static class Print
{
private final OutputStream out;
/*public Print(OutputStream outputStream)
{
writer=new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}*/
public Print()
{
this.out=System.out;
}
public void print(String str)throws IOException
{
//buf=str.getBytes();
for (int i = 0; i < str.length(); i++)
{
/*if (i != 0)
out.write(' ');*/
out.write(str.charAt(i));
}
}
public void printLine(String str)throws IOException
{
print(str);
out.write('\n');
}
public void close()throws IOException
{
out.close();
}
}
static class Scan
{
private byte[] buf=new byte[1024];
private int index;
private InputStream in;
private int total;
public Scan()
{
in=System.in;
}
public int scan()throws IOException
{
if(total<0)
throw new InputMismatchException();
if(index>=total)
{
index=0;
total=in.read(buf);
if(total<=0)
return -1;
}
return buf[index++];
}
public int scanInt()throws IOException
{
int integer=0;
int n=scan();
while(isWhiteSpace(n))
n=scan();
int neg=1;
if(n=='-')
{
neg=-1;
n=scan();
}
while(!isWhiteSpace(n))
{
if(n>='0'&&n<='9')
{
integer*=10;
integer+=n-'0';
n=scan();
}
else throw new InputMismatchException();
}
return neg*integer;
}
public double scanDouble()throws IOException
{
double doub=0;
int n=scan();
while(isWhiteSpace(n))
n=scan();
int neg=1;
if(n=='-')
{
neg=-1;
n=scan();
}
while(!isWhiteSpace(n)&&n!='.')
{
if(n>='0'&&n<='9')
{
doub*=10;
doub+=n-'0';
n=scan();
}
else throw new InputMismatchException();
}
if(n=='.')
{
n=scan();
double temp=1;
while(!isWhiteSpace(n))
{
if(n>='0'&&n<='9')
{
temp/=10;
doub+=(n-'0')*temp;
n=scan();
}
else throw new InputMismatchException();
}
}
return doub*neg;
}
public String scanString()throws IOException
{
StringBuilder sb=new StringBuilder();
int n=scan();
while(isWhiteSpace(n))
n=scan();
while(!isWhiteSpace(n))
{
sb.append((char)n);
n=scan();
}
return sb.toString();
}
private boolean isWhiteSpace(int n)
{
if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
return true;
return false;
}
}
}