Isnt this problem pretty trivial? U can solve this by basic maths.

Let x be the number of operations of the first type and let y be the operations of the second type then 2x+y=a and 2y+x=b. Solving these equations yields the values of x,y as \{\frac{2a-b}{3}, \frac{2b-a}{3}\}. Just check whether these two values are nonegitive and integers and this will solve the problem

```
#include <bits/stdc++.h>
#define ll long long
#define mod 998244353
#define rep(i,s) for(long long i=0; i<s ; i++)
#define f(i,a,b) for(long long i(a); i<b ; i++)
#define inf -pow(10,9)
#define MAXN 100000
const int INF = 1000000000;
const ll modi = 1000000007;
const ll N=100001;
using namespace std;
int main()
{
int t;
cin >> t;
rep(w2,t){
ll n,m;
cin >> n >> m;
ll r1=(2*n-m);
ll r2=(2*m-n);
if(r1>=0 && r2>=0){
if(r1%3==0 && r2%3==0){
cout << "YES" << endl;
}
else{
cout << "NO" << endl;
}
}
else{
cout << "NO" << endl;
}
}
}
```

My code which got ac