Rectangle Cutting (Codeforces 1928A)
Tags: Math, geometry

Bob has a rectangle of size $$$a \times b$$$. He tries to cut this rectangle into two rectangles with integer sides by making a cut parallel to one of the sides of the original rectangle. Then Bob tries to form some other rectangle from the two resulting rectangles, and he can rotate and move these two rectangles as he wishes.Note that if two rectangles differ only by a $$$90^{\circ}$$$ rotation, they are considered the same. For example, the rectangles $$$6 \times 4$$$ and $$$4 \times 6$$$ are considered the same.Thus, from the $$$2 \times 6$$$ rectangle, another rectangle can be formed, because it can be cut into two $$$2 \times 3$$$ rectangles, and then these two rectangles can be used to form the $$$4 \times 3$$$ rectangle, which is different from the $$$2 \times 6$$$ rectangle.  However, from the $$$2 \times 1$$$ rectangle, another rectangle cannot be formed, because it can only be cut into two rectangles of $$$1 \times 1$$$, and from these, only the $$$1 \times 2$$$ and $$$2 \times 1$$$ rectangles can be formed, which are considered the same.  Help Bob determine if he can obtain some other rectangle, or if he is just wasting his time.

Input: Each test consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. This is followed by the description of the test cases.The single line of each test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$) — the size of Bob's rectangle.

Output: For each test case, output "Yes" if Bob can obtain another rectangle from the $$$a \times b$$$ rectangle. Otherwise, output "No".You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive answers.

Note: In the first test case, the $$$1 \times 1$$$ rectangle cannot be cut into two rectangles, so another rectangle cannot be obtained from it.In the fourth test case, the $$$3 \times 2$$$ rectangle can be cut into two $$$3 \times 1$$$ rectangles, and from these, the $$$1 \times 6$$$ rectangle can be formed.In the fifth test case, the $$$2 \times 2$$$ rectangle can be cut into two $$$1 \times 2$$$ rectangles, and from these, the $$$1 \times 4$$$ rectangle can be formed.

Sample Inputs:
7
1 1
2 1
2 6
3 2
2 2
2 4
6 3

Sample Outputs:
No
No
Yes
Yes
Yes
Yes
No

Solution (Python):
import sys
import math
import bisect
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def read_str():
    return input().strip()

def read_int():
    return int(input())

def read_map():
    return map(int, input().split())

def read_lst():
    return list(map(int, input().split()))

def ok(b):
    print('YES' if b else 'NO')

def debug(*args):
    print('<!>', *args, file=sys.stderr)

def solve():
    (a, b) = read_map()
    works = False
    if a % 2 == 0 and b % 2 == 0:
        works = True
    elif a % 2 == 0 and a // 2 != b:
        works = True
    elif b % 2 == 0 and b // 2 != a:
        works = True
    ok(works)
for _ in range(read_int()):
    solve()

Solution (Python):
""""""

def i():
    (a, b) = map(int, input().split())
    if a < b:
        (a, b) = (b, a)
    if b % 2 == 1:
        if a == b + b or a % 2 == 1:
            return 'NO\n'
    return 'YES\n'
t = int(input())
a = []
for _ in range(t):
    a.append(i())
print(''.join(a), end='')

Solution (Python):
for asd in [*open(0)][1:]:
    (a, b) = sorted(map(int, asd.split()))
    print('YNeos'[a & (b | (b == 2 * a)) & 1::2])