Help me in solving MXEVNSUB problem

My issue

What is wrong with this code, it’s failing hidden test cases

My code

/* 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
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-- > 0){
		    int n = sc.nextInt();
		    int s;
		    while(true){
		        s = (n * n + 1) / 2;
		        if(s % 2 == 0)
		            break;
		        n--;
		    }
		    System.out.println(n);
		}
	}
}

Problem Link: CodeChef: Practical coding for everyone

@chandra_lokesh
this question is applied math and u get the logic only after u dry run test cases on your own

i have pasted the correct code below

hope this helps!!

include
using namespace std;

int main() {
// your code goes here
int t,n;
cin>>t;
while(t–)
{
cin>>n;
if(n%4==0 || n%4==3)
{
cout<<n;
}
else
{
cout<<n-1;
}
cout<<endl;
}
return 0;
}

@anish1301
for n=2
answer should be 1
your code will give 0
1+2=3 in this if i remove 1 then it will become 2 which is even

@dpcoder_007
according to my code n%4 will be computed and 2%4=2 , so it will go to the else part and return n-1
which is 1 .
and i guess that should be the answer.

@anish1301 yeah yours is fine actually i was going to ping @chandra_lokesh but accidently i pinged u .