Sir help me where the problem arises?

public class Patterntry {
public static void main(String[] args) {

	//Pythagoras Triplet a^2-b^2 , 2*a*b ,  a^2+b^2
	
	Scanner scn = new Scanner(System.in);
	int N = scn.nextInt();
	if (N % 2 == 0) {
		int a = N / 2;
		int b = 1;
		int P=2 * a * b;
		int B=a * a - b * b;
		int H=a * a + b * b;
		if(N<B && N<H)
			System.out.println(B + " " + H);
		else
			System.out.println("-1");
	}
	else  {
		int a = (N+1) / 2;
		int b = (N-1)/2;
		int P=2 * a * b;
		int B=a * a - b * b;
		int H=a * a + b * b;
		if(N<P && N<H)
			System.out.println(P + " " + H);
		else
			System.out.println("-1");
	}

		
}

}

@Harsh_Sonwani,
Use long instead of int everywhere.

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.