t = int(input())
for i in range(t):
a, b, c, n = map(int, input(). split())
if a >= b and a >= c:
n = n-((a-b)+(a-c))
if n >= 0 and n % 3 == 0:
print("YES")
else:
print("NO")
elif b >= a and b >= c:
n = n-((b-a)+(b-c))
if n >= 0 and n % 3 == 0:
print("YES")
else:
print("NO")
elif c >= a and c >= b:
n = n-((c-a)+(c-b))
if n >= 0 and n % 3 == 0:
print("YES")
else:
print("NO")
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
#define ll long long
#define scl(n) cin>>n;
#define scc(c) cin>>c;
#define fr(i,n) for (ll i=0;i<n;i++)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define pfl(x) printf("%lld\n",x)
#define pb push_back
#define l(s) s.size()
#define asort(a) sort(a,a+n)
#define all(x) (x).begin(), (x).end()
#define dsort(a) sort(a,a+n,greater<int>())
#define vasort(v) sort(v.begin(), v.end());
#define vdsort(v) sort(v.begin(), v.end(),greater<int>());
#define uniquee(x) x.erase(unique(x.begin(), x.end()),x.end())
#define pn cout<<endl;
#define md 10000007
#define inf 1e18
#define debug cout<<"Monti valo nei "<<endl;
#define ps cout<<" ";
#define Pi acos(-1.0)
#define mem(a,i) memset(a, i, sizeof(a))
#define tcas(i,t) for(ll i=1;i<=t;i++)
#define pcas(i) cout<<"Case "<<i<<": "<<"\n";
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define conv_string(n) to_string(n)
//ll x[10]= {0,-1,-1,1,1,-2,-2,2,2};
//ll y[10]= {0,-2,2,-2,2,-1,1,-1,1};
//vector<ll>cnt(26, 0); ///create fixed 26 sized vector and initialize initially all 0
// sscanf(c, "%s %s", s,s1); // take string buffer and then distribute all value , here take 2 value and distribute
///cin.ignore(); // Need when we take input as a string line before getline(cin,s)
//ll bigmod(ll b, ll p, ll md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {ll y=bigmod(b,p/2,md);return (y*y)%md;}}
//ll find_all_divisor(ll n){ fr1(i,sqrt(n)){ ll x; if(n % i == 0) { x = n / i; v.pb(i); if(i != x) v.pb(x);}}}
// ll *a=new ll[n+1](); //automatic initialize to zero
///Every even integer greater than 2 can be represented as the sum of two primes numbers.
//count item in array : count(arr,arr+n,'I');
//bool cmp(ll i, ll j){ if( fac[i]==fac[j])return i>j; return fac[i]< fac[j]; }
#define N 100006
int main()
{
fast;
ll t;
cin>>t;
while(t--)
{
ll m,n,a, b,c,d,i,j,k,x,y,z,l,q,r;
string s1, s2, s3, s4;
ll cnt=0,ans=0,sum=0;
cin>>a>>b>>c>>n;
sum=a+b+c+n;
x=max(a, b);
x=max(x, c);
if( sum%3==0 and sum/3>=x ) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
return 0;
}
1351. Count Negative Numbers in a Sorted Matrix | 617. Merge Two Binary Trees |
1450. Number of Students Doing Homework at a Given Time | 700. Search in a Binary Search Tree |
590. N-ary Tree Postorder Traversal | 589. N-ary Tree Preorder Traversal |
1299. Replace Elements with Greatest Element on Right Side | 1768. Merge Strings Alternately |
561. Array Partition I | 1374. Generate a String With Characters That Have Odd Counts |
1822. Sign of the Product of an Array | 1464. Maximum Product of Two Elements in an Array |
1323. Maximum 69 Number | 832. Flipping an Image |
1295. Find Numbers with Even Number of Digits | 1704. Determine if String Halves Are Alike |
1732. Find the Highest Altitude | 709. To Lower Case |
1688. Count of Matches in Tournament | 1684. Count the Number of Consistent Strings |
1588. Sum of All Odd Length Subarrays | 1662. Check If Two String Arrays are Equivalent |
1832. Check if the Sentence Is Pangram | 1678. Goal Parser Interpretation |
1389. Create Target Array in the Given Order | 1313. Decompress Run-Length Encoded List |
1281. Subtract the Product and Sum of Digits of an Integer | 1342. Number of Steps to Reduce a Number to Zero |
1528. Shuffle String | 1365. How Many Numbers Are Smaller Than the Current Number |