Hiring process8 levels
  1. 1 IQ Test
  2. 2 Additional Online Test (If Required)
  3. 3 Office Interview with Hiring Manager
  4. 4 Unpaid Test Task (Motivation Check)
  5. 5 Paid Test Task and Follow-Up Interview
  6. 6 Iterative Paid Test Tasks
  7. 7 Office Verification
  8. 8 Final Interview with the Founder

Problems > Emptying Two Piles

Emptying Two Piles

Difficulty: 1300 3000 ms 128 MB

math

Two piles hold A and B coins. A move removes 1 coin from one pile and 2 from the other (your choice which). For each test case, can both piles be emptied exactly?

Input: the first line has T (number of cases); each of the next T lines has A and B.

Output: T lines of YES/NO.

Constraints:

  • 1 ≤ T ≤ 104
  • 0 ≤ A, B ≤ 109

Sample Tests

Input 1
3
2 1
2 2
3 3
Output 1
YES
NO
YES
Input 2
1
0 0
Output 2
YES

Read the Editorial Statistics

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.
Ctrl+Enter submit · Ctrl+Space autocomplete · F11 fullscreen