https://www.codechef.com/problems/PRTAGN

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
int t=Integer.parseInt(br.readLine());
while(t–>0)
{
int q=Integer.parseInt(br.readLine());
ArrayList a=new ArrayList<>();
int n=0,l=0;
int sum=0,e=0,o=0;
while(q–>0)
{
l=n;
int x=Integer.parseInt(br.readLine());
if(!(a.contains(x)))
{
a.add(x);
if(!a.isEmpty())
for(int i=0;i<n;i++)
a.add(a.get(i)^x);
n=a.size();
for(int i=l;i<n;i++)
{
int k=a.get(i);
while(k!=0)
{
int d=k%2;
if(d==1)
sum++;
k=k/2;
}
if(sum%2==0)
e++;
else
o++;
sum=0;
}
}
System.out.println(e+" "+o);

	    }
	        
	}
	
}

}
how is this time limit exceeding?