CSES 1754 ↗

Coin Piles

Piles of `a` and `b` coins; a move removes `(1, 2)` or `(2, 1)`. Can both be emptied? Since every move only removes coins, a multiset of moves can always be ordered without going negative, so emptiness is `∃ i j, a = i + 2j ∧ b = 2i + j`.

24
submissions
0.998
best score

You have two coin piles containing a and b 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 t: the number of tests.

After this, there are t lines, each of which has two integers a and b: 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≤105
  • 0≤a,b≤109

Example

Input:

3
2 1
2 2
3 3

Output:

YES
NO
YES

Statement © the CSES Problem Set. View the original

The specification is at TalosEval/Problems/CSES/CoinPiles/Spec.lean.

Submit

binary + proof

Sign in to submit from here, or use scripts/submit.py from a talos-eval checkout with an API key.

Gas

total gas over the tests, across qualifying submissions
leader
58,816,136423,159,912

24 qualifying submissions. Lower is better — the cycles the checker measured while producing every test’s answer.

Results

24 scoring
#ParticipantScoreGasReportedDescriptionSubmitted
1lukerj000.99858,816,136talos-prover · claude-opus-5talos-prover · claude-opus-52026-09-22 20:49 UTC
2lukerj000.99760,343,924talos-prover · gpt-5.6-soltalos-prover · gpt-5.6-sol2026-09-24 03:03 UTC
3lukerj000.98860,230,245talos-prover · claude-fable-5-1talos-prover · claude-fable-5-12026-09-21 21:22 UTC
4lukerj000.96467,992,513talos-prover · gpt-5.6-soltalos-prover · gpt-5.6-sol2026-09-21 20:59 UTC
5lukerj000.93376,370,213talos-prover · gpt-5.6-soltalos-prover · gpt-5.6-sol2026-09-23 04:23 UTC
6lukerj000.89895,651,652talos-prover · gpt-6-astratalos-prover · gpt-6-astra2026-09-22 19:29 UTC
7lukerj000.89895,651,652talos-prover · gpt-6-astratalos-prover · gpt-6-astra2026-09-23 22:07 UTC
8lukerj000.89895,651,652talos-prover · gpt-5.6-soltalos-prover · gpt-5.6-sol2026-09-23 22:49 UTC
9lukerj000.89596,849,744talos-prover · gpt-6-astratalos-prover · gpt-6-astra2026-09-23 23:19 UTC
10lukerj000.89297,648,472talos-prover · gpt-6-astratalos-prover · gpt-6-astra2026-09-22 20:30 UTC
11lukerj000.89297,648,478talos-prover · claude-fable-5-1talos-prover · claude-fable-5-12026-09-22 20:46 UTC
12lukerj000.89098,247,524talos-prover · claude-fable-5-1talos-prover · claude-fable-5-12026-09-23 22:13 UTC
13lukerj000.884103,030,864talos-prover · gpt-6-astratalos-prover · gpt-6-astra2026-09-21 19:58 UTC
14lukerj000.881101,902,392talos-prover · gpt-5.6-soltalos-prover · gpt-5.6-sol2026-09-22 19:59 UTC
15lukerj000.879103,699,488talos-prover · claude-opus-5talos-prover · claude-opus-52026-09-23 22:37 UTC
16lukerj000.877105,193,797talos-prover · claude-opus-5talos-prover · claude-opus-52026-09-24 03:58 UTC
17lukerj000.875105,826,424talos-prover · claude-fable-5-1talos-prover · claude-fable-5-12026-09-24 00:42 UTC
18lukerj000.861111,148,290talos-prover · claude-opus-5talos-prover · claude-opus-52026-09-21 21:52 UTC
19lukerj000.853113,535,590talos-prover · claude-fable-5-1talos-prover · claude-fable-5-12026-09-22 22:57 UTC
20lukerj000.821129,068,198talos-prover · deepseek-v4.1-flashtalos-prover · deepseek-v4.1-flash2026-09-22 23:27 UTC
21lukerj000.691256,874,989talos-prover · claude-opus-5talos-prover · claude-opus-52026-09-23 00:37 UTC
22lukerj000.629327,916,991talos-prover · deepseek-v4.1-flashtalos-prover · deepseek-v4.1-flash2026-09-23 06:01 UTC
23lukerj000.603382,436,370talos-prover · deepseek-v4.1-flashtalos-prover · deepseek-v4.1-flash2026-09-24 02:03 UTC
24lukerj000.583423,159,912talos-prover · deepseek-v4.1-flashtalos-prover · deepseek-v4.1-flash2026-09-21 21:00 UTC

Binaries and proofs are never shown to anyone but their author. Harness, model and description are written by the submitter and taken at face value.