My code in java for this is :
import java.io.;
import java.util.;
public class Solution {
public static long tri(int n ){
return n*(n+1)/2;
}
public static long factors(long a){
if (a == 1)return 1;
int i = 2;
long res =0 ;
while(i*i<a){
if(a%i==0){
res+=2;
}
i++;
}
if(i*i == a){
res+=1;
}
return res;
}
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named
Solution. */
Scanner sc = new Scanner(System.in);
long[] a = new long[1001];
a[1] = 1;
for(int i =2;i<1001;i++){
a[i] = tri(i);
}
long[] b = new long[1001];
b[1] = 1;
for(int i =2;i<1001;i++){
b[i] = 2;
}
for(int i =2;i<1001;i++){
b[i]+=factors(a[i]);
}
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
for(int i = 0;i<1001;i++){
if(n<b[i]){
System.out.println(a[i]);
break;
}
}
}
}
}
Showing wrong answer for all test cases except the first three.