Hello, I have been trying to solve this problem for some time but getting WA.
The Problem This is a simple task for you.You have to write a simple code that can take three input a, b and c which are the length of the three sides of a phythagorian triangle and check the triangle is valid or invalid.

The Input
The input file contains several lines. Each line contains three positive integers a, b, c < 100 which indicates the three sides of a triangle. Input is terminated by EOF.
The Output
For each input lines print a comment. Which contains if the triangle is right then “Valid.”, if the triangle is not right then “Invalid.” (Quote for clarification) in a separate line.
Sample Input
6 9 4 13 5 12
Sample Output
Invalid. Valid.
My code1. Older Code#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define pi 3.141592653589793
#define spc " "
#define el "\n"
#define die return 0
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define bitcount __builtin_popcount
#define gcd __gcd
using namespace std;
int main()
{
int a,b,c;
while(cin>>a>>b>>c)
{
if(a<1||b<1||c<1)
{
cout<<"Invalid.\n";
}
else if((a*a+b*b==c*c)||(a*a+c*c==b*b)||((c*c+b*b)==a*a))
cout<<"Valid.\n";
else
cout<<"Invalid.\n";
}
die;
}
2. Newer Code#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define pi 3.141592653589793
#define spc " "
#define el "\n"
#define die return 0
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define bitcount __builtin_popcount
#define gcd __gcd
using namespace std;
int main()
{
int a[3];
while(cin>>a[0]>>a[1]>>a[2])
{
sort(a, a+3);
if((a[0]*a[0]+a[1]*a[1]==a[2]*a[2])&&!(a[0]<1||a[0]<1||a[0]<1))
cout<<"Valid."<<el;
else
cout<<"Invalid."<<el;
}
die;
}
But this approaches are not working out for me. I keep getting WA. I checked both of this code against this triplets and they checked out correctly.
original problem link : http://school.outsbook.com/problems/problemdetails/363
Please provide me some thoughts or error that is causing WA.
Thank you.