Hostel Visit in java

I am writing this code in java. I don’t know why this code is giving me error in this portal while I am running the same code in my system it is executed properly.

import java.util.;
public class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int q = scan.nextInt();
int k = scan.nextInt();
ArrayList a = new ArrayList();
int b = 0;
while(q>0){
int c = scan.nextInt();
if(c == 1){
int x = scan.nextInt();
int y = scan.nextInt();
int value = (x
x)+(y*y);
a.add(value);
}else if(c == 2){
Collections.sort(a);
System.out.println(a.get(k-1));
}
q–;
}
}
}

its might be due to excessive elements in the array, try and remove elemets from a when the size is greater then k

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.