Account
GitHubFeedback
Drafts and results saved on this device
Submit on CSES.fi
CSES Problemset/Introductory Problems

Coin Piles

#1754
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

Time limit:1.00 s
Memory limit:512 MB
Unsolved
Download Tests (.zip)

You have two coin piles containing aa and bb coins. On each move, you can either remove one coin from the left pile and two coins from the right pile, or two coins from the left pile and one coin from the right pile.

Your task is to efficiently find out if you can empty both the piles.

Input

The first input line has an integer tt: the number of tests.

After this, there are tt lines, each of which has two integers aa and bb: the numbers of coins in the piles.

Output

For each test, print "YES" if you can empty the piles and "NO" otherwise.

Constraints
  • 1≤t≤1051 \le t \le 10^5
  • 0≤a,b≤1090 \le a, b \le 10^9
Sample Test Cases (1)
Example 1ID: sample-1
Input
3
2 1
2 2
3 3
Expected Output
YES
NO
YES
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 chars
Test Bench
Download .zip
Input (stdin)
3
2 1
2 2
3 3
Expected Output
YES
NO
YES