This might help you. The code is bit clumsy, please bear with it
@hyphencore700
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define MAX_LIMIT 10000000
#define remove_zero(str) str.erase(0, str.find_first_not_of('0'));
#define all(x) x.begin(),x.end()
#define br break
#define pb push_back
using ld = long double;
#define endl "\n"
using namespace std;
string multiply(string num1, string num2)
{
ll n1 = num1.size();
ll n2 = num2.size();
if (n1 == 0 || n2 == 0)
return "0";
vector<ll> result(n1 + n2, 0);
ll i_n1 = 0;
ll i_n2 = 0;
for (ll i = n1 - 1; i >= 0; i--) {
ll carry = 0;
ll n1 = num1[i] - '0';
i_n2 = 0;
for (ll j = n2 - 1; j >= 0; j--) {
ll n2 = num2[j] - '0';
ll sum = n1 * n2 + result[i_n1 + i_n2] + carry;
carry = sum / 10;
result[i_n1 + i_n2] = sum % 10;
i_n2++;
}
if (carry > 0)
result[i_n1 + i_n2] += carry;
i_n1++;
}
ll i = result.size() - 1;
while (i >= 0 && result[i] == 0)
i--;
if (i == -1)
return "0";
string s = "";
while (i >= 0)
s += std::to_string(result[i--]);
return s;
}
string findSum(string str1, string str2)
{
if (str1.length() > str2.length())
swap(str1, str2);
string str = "";
ll n1 = str1.length(), n2 = str2.length();
ll diff = n2 - n1;
ll carry = 0;
for (ll i=n1-1; i>=0; i--)
{
ll sum = ((str1[i]-'0') +
(str2[i+diff]-'0') +
carry);
str.push_back(sum%10 + '0');
carry = sum/10;
}
for (ll i=n2-n1-1; i>=0; i--)
{
ll sum = ((str2[i]-'0')+carry);
str.push_back(sum%10 + '0');
carry = sum/10;
}
if (carry)
str.push_back(carry+'0');
reverse(str.begin(), str.end());
return str;
}
bool isSmaller(string str1, string str2)
{
int n1 = str1.length(), n2 = str2.length();
if (n1 < n2)
return true;
if (n2 < n1)
return false;
for (int i=0; i<n1; i++)
if (str1[i] < str2[i])
return true;
else if (str1[i] > str2[i])
return false;
return false;
}
string findDiff(string str1, string str2)
{
if (isSmaller(str1, str2))
swap(str1, str2);
string str = "";
ll n1 = str1.length(), n2 = str2.length();
reverse(str1.begin(), str1.end());
reverse(str2.begin(), str2.end());
ll carry = 0;
for (ll i=0; i<n2; i++)
{
ll sub = ((str1[i]-'0')-(str2[i]-'0')-carry);
if (sub < 0)
{
sub = sub + 10;
carry = 1;
}
else
carry = 0;
str.push_back(sub + '0');
}
for (ll i=n2; i<n1; i++)
{
ll sub = ((str1[i]-'0') - carry);
if (sub < 0)
{
sub = sub + 10;
carry = 1;
}
else
carry = 0;
str.push_back(sub + '0');
}
reverse(str.begin(), str.end());
return remove_zero(str);
}
void solve(){
//input
string a,b,c,x;
cin>>a>>b>>c>>x;
string s1=findSum(a,x),s2=findSum(b,x),s3=findSum(c,x);
string str1=multiply(s1,s1),str2=multiply(s2,s2),str3=multiply(s3,s3);
string f=findSum(str1,str2),f1=findSum(str2,str3),f3=findSum(str1,str3);
string ans=multiply(a,a),ans1=multiply(b,b),ans2=multiply(c,c);
if(f==ans2 or str1==findDiff(ans2,str2) or str2==findDiff(ans2,str1)) {
cout<<"Yes"<<endl;
}
else if(f1==ans or str2==findDiff(ans,str3) or str3==findDiff(ans,str2)){
cout<<"Yes"<<endl;
}
else if(f3==ans1 or str1==findDiff(ans1,str3) or str3==findDiff(ans1,str1)){
cout<<"Yes"<<endl;
}
else{
cout<<"No"<<endl;
}
}
int32_t main()
{
fio;
ll t=1;
cin>>t;
while(t--){
solve();
}
}