Read problems statements in [Mandarin Chinese], [Russian] and [Vietnamese] as well.

Chef is a farmer and a pet lover. He has a lot of his favorite pets cats and dogs in the barn. He knows that there are $C$ cats and $D$ dogs in the barn. Also, one day went to field and found that there were $L$ legs of the animals touching the ground. Chef knows that cats love to ride on the dogs. So, they might ride on the dogs, and their legs won't touch the ground and Chef would miss counting their legs. Chef's dogs are strong enough to ride at max two cats on their back.

It was a cold foggy morning, when Chef did this counting. So he is now wondering whether he counted the legs properly or not. Specifically, he is wondering whether it is possible that he counted correctly. Please help Chef in finding it.

------  Input ------

First line of the input contains an integer $T$, denoting number of test cases. $T$ test cases follow.

The only line of each test case contains three space separated integers $C, D, L$, denoting number of the cats, number of the dogs and number of legs of animals counted by Chef, respectively.

------  Output ------

For each test case, output a single line containing a string yes or no, according to the situation.

------  Constraints ------

$1 ≤ T ≤ 10^{5}$
$0 ≤ C, D, L ≤ 10^{9}$

------  Subtasks ------

Subtask #1 (20 points):

$1 ≤ T ≤ 10^{4}$
$0 ≤ C, D ≤ 100$

Subtask #2 (30 points):

$1 ≤ T ≤ 10^{5}$
$0 ≤ C, D ≤ 1000$

Subtask #3 (50 points):

Original constraints

----- Sample Input 1 ------ 
3

1 1 8

1 1 4

1 1 2
----- Sample Output 1 ------ 
yes

yes

no
----- explanation 1 ------ 
Example 1: There is one cat and one dog. The number of legs of these animals on the ground are $8$, it can be possible when both cat and dog are standing on the ground.

Example 2: There is one cat and one dog. The number of legs of these animals on the ground are $4$, it can be possible if the cat will ride on the dog, so its legs won't be counted by Chef, only the dog's legs will be counted.

Example 3: There is one cat and one dog. The number of legs of these animals are $2$, it can not be true at all, Chef might have made some mistake. Hence, the answer is no.

Difficulty: EASY
Tags: Constructive algorithms

Ad-hoc

Starter code:

Solutions:
t = int(input(''))
while t > 0:
	s = input('').split(' ')
	c = int(s[0])
	d = int(s[1])
	l = int(s[2])
	maxLegs = (c + d) * 4
	if c <= 2 * d:
		minLegs = 4 * d
	else:
		minLegs = 4 * (c - d)
	if l > maxLegs or l % 4 != 0 or l < minLegs:
		print('no')
	else:
		print('yes')
	t -= 1


def sol(c, d, l):
	cat_ground = 0
	if c >= 2 * d:
		cat_ground = c - 2 * d
	if 4 * d + cat_ground * 4 <= l <= 4 * d + 4 * c and l % 4 == 0:
		print('yes')
	else:
		print('no')
for i in range(int(input())):
	(c, d, l) = map(int, input().split())
	sol(c, d, l)


for _ in range(int(input())):
	(c, d, l) = map(int, input().split())
	if l % 4 == 0:
		ma = c * 4 + d * 4
		if d * 2 >= c:
			mi = d * 4
		else:
			mi = (c - d * 2) * 4 + d * 4
		if l in range(mi, ma + 1):
			print('yes')
			continue
	print('no')


for _ in range(int(input())):
	(c, d, l) = map(int, input().split())
	if l % 4:
		print('no')
	else:
		l //= 4
		t = d + max(0, c - 2 * d)
		if l < t or l > c + d:
			print('no')
		else:
			print('yes')


for i in range(int(input())):
	(c, d, l) = map(int, input().split(' '))
	if c == 0 and d == 0 and (l == 0):
		print('yes')
	elif l % 4 != 0 or l < d * 4:
		print('no')
	else:
		l = l - d * 4
		x = l / 4
		if x > c:
			print('no')
		else:
			dc = c - x
			if dc > d * 2:
				print('no')
			else:
				print('yes')


t = int(input())
while t > 0:
	(c, d, l) = map(int, input().split())
	if c == 0 and d == 0 and (l == 0):
		print('yes')
	elif l % 4 != 0:
		print('no')
	elif d * 4 > l:
		print('no')
	else:
		l = l - d * 4
		if l == 0:
			if d * 2 >= c:
				print('yes')
			else:
				print('no')
		else:
			gc = l // 4
			if gc > c:
				print('no')
			else:
				dc = c - gc
				if d * 2 < dc:
					print('no')
				else:
					print('yes')
	t -= 1


t = int(input())
for i in range(t):
	(c, d, l) = map(int, input().split())
	if c > 2 * d:
		if l <= (c + d) * 4 and l % 4 == 0 and (l >= 4 * (c - d)):
			print('yes')
		else:
			print('no')
	elif l <= (c + d) * 4 and l % 4 == 0 and (l >= 4 * d):
		print('yes')
	else:
		print('no')


a = int(input(''))
for i in range(a):
	(C, D, L) = [int(x) for x in input().split()]
	if L % 4 == 0:
		num = L / 4
		if 0 <= D <= num:
			if num - D <= C <= num + D:
				print('yes')
			else:
				print('no')
		else:
			print('no')
	else:
		print('no')


T = int(input())
for i in range(T):
	(c, d, l) = list(map(int, input().split()))
	if l % 4 == 0:
		num = l / 4
		if 0 <= d <= num:
			if num - d <= c <= num + d:
				print('yes')
			else:
				print('no')
		else:
			print('no')
	else:
		print('no')


t = int(input())
while t:
	(C, D, L) = map(int, input().split())
	M = C * 4 + D * 4
	m = D * 4
	if C > 2 * D:
		m += (C - 2 * D) * 4
	if m <= L <= M and L % 4 == 0:
		print('yes')
	else:
		print('no')
	t = t - 1


t = int(input())
for i in range(t):
	(C, D, L) = map(int, input().split())
	max_legs = (C + D) * 4
	min_legs = D * 4 + max(C - 2 * D, 0) * 4
	if L % 4 != 0:
		print('no')
	elif L > max_legs:
		print('no')
	elif L < min_legs:
		print('no')
	else:
		print('yes')


import math
g = int(input())
for i in range(g):
	a = input().split()
	c = int(a[0])
	d = int(a[1])
	l = int(a[2])
	fullpackage = int(c / 2)
	halfpackage = int(math.modf(c / 2)[0] * 2)
	if d >= fullpackage + halfpackage:
		minp = (c + d) * 4 - 4 * c
	elif fullpackage < d < fullpackage + halfpackage:
		minp = (c + d) * 4 - (d - 1) * 8 - 4
	elif d <= fullpackage:
		minp = (c + d) * 4 - d * 8
	if l % 4 == 0 and l >= minp and (l <= (c + d) * 4):
		print('yes')
	else:
		print('no')


n = int(input())
for i in range(0, n):
	(c, d, l) = list(map(int, input().split()))
	if l % 4 != 0:
		print('no')
	elif (c + d) * 4 >= l >= (c + d) * 4 - 4 * min(2 * d, c) and l % 4 == 0:
		print('yes')
	else:
		print('no')


for t in range(int(input())):
	(c, d, l) = list(map(int, input().split()))
	if l % 4 != 0:
		print('no')
	else:
		y = c + d
		y = y - l // 4
		if y >= 0 and y <= min(c, 2 * d):
			print('yes')
		else:
			print('no')


T = int(input())
for _ in range(0, T):
	(c, d, l) = map(int, input().split())
	t1 = 4 * (d + c)
	t2 = t1 - 4 * min(2 * d, c)
	if l <= t1 and l >= t2 and (l % 4 == 0):
		print('yes')
	else:
		print('no')


n = int(input())
for x in range(n):
	l = list(map(int, input().split()))
	p = 0
	if l[0] < l[1] * 2:
		p = 0
	elif l[0] > l[1] * 2:
		p = (l[0] - l[1] * 2) * 4
	min = l[1] * 4 + p
	if l[2] % 4 == 0 and l[2] <= (l[0] + l[1]) * 4 and (l[2] >= min):
		print('yes')
	else:
		print('no')


test_cases = input()
for _ in range(int(test_cases)):
	(c, d, l) = list(map(int, input().strip().split()))
	max_val = (c + d) * 4
	bc = 0 if c <= 2 * d else (c - d * 2) * 4
	min_val = d * 4 + bc
	if min_val <= l <= max_val and l % 4 == 0:
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	l = list(map(int, input().split()))
	if (l[0] == 0 or l[1] == 0) and l[2] == 4 * (l[0] + l[1]):
		print('yes')
	elif l[2] <= 4 * (l[0] + l[1]) and l[2] >= 4 * l[1] and (l[2] >= abs(4 * l[0] - 4 * l[1])) and (l[2] % 4 == 0):
		print('yes')
	else:
		print('no')


t = int(input())
while t > 0:
	(c, d, l) = input().split()
	c = int(c)
	d = int(d)
	l = int(l)
	if l % 4 != 0:
		print('no')
	else:
		y = c + d
		y = y - l // 4
		if y >= 0 and y <= min(c, 2 * d):
			print('yes')
		else:
			print('no')
	t -= 1


t = int(input())
for i in range(t):
	(c, d, l) = map(int, input().split())
	min_l = 4 * (d + max(0, c - 2 * d))
	max_l = 4 * (c + d)
	if l >= min_l and l <= max_l and (l % 4 == 0):
		print('yes')
	else:
		print('no')


import math
for i in range(int(input())):
	(c, d, l) = list(map(int, input().split()))
	r = 0
	if c > 2 * d:
		r = abs(d * 2 - c)
	res1 = d * 4 + r * 4
	res2 = d * 4 + c * 4
	c = 0
	if l % 4 == 0 and res1 <= l and (l <= res2):
		c = 1
	if c == 1:
		print('yes')
	else:
		print('no')


for i in range(int(input())):
	s = input()
	(C, D, L) = map(int, s.split())
	M = 4 * (C + D)
	Pak = 4 * D
	if L < Pak or L > M:
		print('no')
	elif C == 0 or D == 0:
		if M == L:
			print('yes')
		else:
			print('no')
	elif D >= C / 2:
		1
		if L % Pak % 4 == 0:
			print('yes')
		else:
			print('no')
	elif L % Pak % 4 == 0 and L >= M - 4 * (2 * D):
		print('yes')
	else:
		print('no')


test_case = int(input())
for i in range(test_case):
	(cat, dog, leg) = map(int, input().split(' '))
	max_leg = (cat + dog) * 4
	if cat > 2 * dog:
		min_leg = 4 * dog + (cat - 2 * dog) * 4
	else:
		min_leg = 4 * dog
	if leg % 4 != 0:
		print('no')
	elif min_leg <= leg <= max_leg:
		print('yes')
	else:
		print('no')


for t in range(int(input())):
	(c, d, l) = map(int, input().split())
	a = l // 4
	if c <= d * 2:
		m = d
	else:
		m = c - 2 * d + d
	x = c + d
	if m <= a <= x and l % 4 == 0:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	(C, D, L) = map(int, input().split())
	if C <= 2 * D:
		min = D * 4
	else:
		min = (C - 2 * D) * 4 + D * 4
	max = C * 4 + D * 4
	if min <= L <= max and L % 4 == 0:
		print('yes')
	else:
		print('no')


try:
	for _ in range(int(input())):
		(C, D, L) = map(int, input().split())
		maxL = C * 4 + D * 4
		minL = D * 4 + (0 if D * 2 >= C else (C - D * 2) * 4)
		if minL <= L <= maxL and L % 4 == 0:
			print('yes')
		else:
			print('no')
except:
	pass


Munda = int(input())
for p in range(Munda):
	(ramd, jaya, d) = input().split()
	ramd = int(ramd)
	jaya = int(jaya)
	d = int(d)
	if ramd > 2 * jaya:
		extra = ramd - 2 * jaya
	else:
		extra = 0
	if d <= 4 * jaya + 4 * ramd and d >= 4 * jaya + 4 * extra and (d % 4 == 0):
		print('yes')
	else:
		print('no')


t = int(input())
for _ in range(t):
	(c, d, l) = map(int, input().split())
	a = c + d
	if c > 2 * d:
		b = c - 2 * d
	else:
		b = 0
	if l <= 4 * a and l >= (b + d) * 4 and (l % 4 == 0):
		print('yes')
	else:
		print('no')


t = input()
for x in range(0, int(t)):
	(c, d, l) = input().split()
	c = int(c)
	d = int(d)
	l = int(l)
	if c > 2 * d:
		extra = c - 2 * d
	else:
		extra = 0
	if l <= 4 * c + 4 * d and l >= 4 * d + 4 * extra and (l % 4 == 0):
		print('yes')
	else:
		print('no')


g = int(input())
for i in range(g):
	(x, y, l) = input().split()
	x = int(x)
	y = int(y)
	l = int(l)
	if x > 2 * y:
		extra = x - 2 * y
	else:
		extra = 0
	if l <= 4 * y + 4 * x and l >= 4 * y + 4 * extra and (l % 4 == 0):
		print('yes')
	else:
		print('no')


n = int(input())
for i in range(n):
	(c, d, l) = input().split()
	c = int(c)
	d = int(d)
	l = int(l)
	if c > 2 * d:
		extra = c - 2 * d
	else:
		extra = 0
	if l <= 4 * d + 4 * c and l >= 4 * d + 4 * extra and (l % 4 == 0):
		print('yes')
	else:
		print('no')


T = int(input())
for i in range(T):
	(c, d, l) = map(int, input().split(' '))
	cl = c - 2 * d
	if cl > 0:
		nl = cl * 4 + d * 4
	else:
		nl = d * 4
	if l >= nl and l % 4 == 0 and (l <= (c + d) * 4):
		print('yes')
	else:
		print('no')


for a in range(int(input())):
	(C, D, L) = map(int, input().split())
	minlegs = D * 4
	maxlegs = (D + C) * 4
	if L < minlegs or L % 4 != 0 or L > maxlegs:
		print('no')
	elif L < maxlegs and (maxlegs - L) / 4 > D * 2:
		print('no')
	else:
		print('yes')


T = int(input())
for tc in range(T):
	nums = list(map(int, input().split()))
	dl = nums[1] * 4
	h = nums[0] - nums[1] * 2
	c = max(h, 0)
	tl = dl + c * 4
	ml = 4 * (nums[0] + nums[1])
	stn = 'no'
	if nums[2] % 4 == 0 and nums[2] >= tl and (nums[2] <= ml):
		print('yes')
	else:
		print('no')


no = int(input())
for i in range(no):
	flag = False
	l = list(map(int, input().split()))
	C = int(l[0])
	D = int(l[1])
	L = int(l[2])
	UB = 4 * (C + D)
	LB = 4 * (max(C - 2 * D, 0) + D)
	if L % 4 == 0 and L >= LB and (L <= UB):
		print('yes')
	else:
		print('no')


T = int(input())
for i in range(T):
	(C, D, L) = map(int, input().split())
	if L % 4 == 0 and 4 * (D + max(C - 2 * D, 0)) <= L and (L <= 4 * (C + D)):
		print('yes')
	else:
		print('no')


T = int(input())
for _ in range(T):
	inp = input()
	(c, d, l) = list(map(int, inp.split()))
	LB = 4 * (d + max(c - 2 * d, 0))
	UB = 4 * (c + d)
	if l % 4 == 0 and l <= UB and (l >= LB):
		out = 'yes'
	else:
		out = 'no'
	print(out)


t = int(input())
for T in range(t):
	(c, d, l) = [int(x) for x in input().split()]
	if l % 4 == 0 and l <= 4 * (c + d) and (l >= 4 * (max(0, c - 2 * d) + d)):
		print('yes')
		continue
	print('no')


T = int(input())
for t in range(T):
	(c, d, l) = map(int, input().split(' '))
	if int(l % 4) != 0:
		ans = 'no'
	else:
		if c <= 2 * d:
			mini_l = 4 * d
		else:
			mini_l = 4 * d + (c - 2 * d) * 4
		if l >= mini_l and l <= 4 * (c + d):
			ans = 'yes'
		else:
			ans = 'no'
	print(ans)


T = int(input())
import sys
lines = sys.stdin.readlines()
for t in range(T):
	(C, D, L) = map(int, lines[t].split())
	if L % 4 != 0:
		print('no')
		continue
	elif L > (C + D) * 4:
		print('no')
		continue
	elif L < D * 4:
		print('no')
		continue
	elif C <= 2 * D:
		print('yes')
		continue
	elif L >= 4 * (C - D):
		print('yes')
		continue
	else:
		print('no')
		continue


for _ in range(int(input())):
	(c, d, l) = map(int, input().split())
	fcatleg = 0
	if c > d * 2:
		fcatleg = (c - d * 2) * 4
	dogleg = d * 4
	lmin = dogleg + fcatleg
	lmax = dogleg + c * 4
	if l % 4 == 0 and l >= lmin and (l <= lmax):
		print('yes')
	else:
		print('no')


t = int(input())
for i in range(t):
	(c, d, l) = map(int, input().split())
	max_legs = 4 * (c + d)
	c1 = c - 2 * d
	min_legs = 4 * (d + max(0, c1))
	if l % 4 == 0 and l <= max_legs and (l >= min_legs):
		print('yes')
	else:
		print('no')


t = int(input())
for k in range(t):
	l = input().split()
	cats = int(l[0])
	dogs = int(l[1])
	legs = int(l[2])
	max_legs = (cats + dogs) * 4
	min_legs = dogs * 4
	remaining_cats = cats - 2 * dogs
	if remaining_cats > 0:
		min_legs += remaining_cats * 4
	if legs < min_legs or legs > max_legs or legs % 4 != 0:
		print('no')
	else:
		print('yes')


tests = int(input())
for i in range(tests):
	(c, d, l) = map(int, input().split())
	dogs_legs = d * 4
	cats_legs = c * 4
	minimum_legs = dogs_legs
	minimum_cats = c - 2 * d
	if minimum_cats > 0:
		minimum_legs += minimum_cats * 4
	if l < minimum_legs or l > dogs_legs + cats_legs or l % 4 != 0:
		print('no')
	else:
		print('yes')


t = int(input())
for i in range(t):
	str = input().split()
	k = list(map(lambda x: int(x), str))
	min = 0
	c = k[0]
	d = k[1]
	l = k[2]
	if l % 4 != 0:
		print('no')
	else:
		if c / 2 > d:
			min = d * 4 + (c - 2 * d) * 4
		else:
			min = d * 4
		max = c * 4 + d * 4
		if l >= min and l <= max:
			print('yes')
		else:
			print('no')


n = int(input())
for k in range(n):
	n = list(input().split())
	a = int(n[0])
	b = int(n[1])
	c = int(n[2])
	if a / 2 > b:
		min_cats = a - 2 * b
		min_legs = 4 * (min_cats + b)
	else:
		min_legs = 4 * b
	if (c >= min_legs and c <= 4 * (a + b)) and c % 4 == 0:
		print('yes')
	else:
		print('no')


def Verifier(cats, dogs, legs):
	if legs % 4 != 0:
		return 'no'
	if dogs >= cats:
		if 4 * cats + 4 * dogs >= legs and legs >= 4 * dogs:
			return 'yes'
		else:
			return 'no'
	elif cats > dogs and cats <= 2 * dogs:
		if 4 * cats + 4 * dogs >= legs and legs >= 4 * dogs:
			return 'yes'
		else:
			return 'no'
	elif cats > 2 * dogs:
		if 4 * cats + 4 * dogs >= legs and dogs * 4 + 4 * (cats - 2 * dogs) <= legs:
			return 'yes'
		else:
			return 'no'
test = int(input())
for i in range(test):
	(C, D, L) = input().split()
	print(Verifier(int(C), int(D), int(L)))


T = int(input())
for i in range(0, T):
	(c, d, l) = input().split()
	c = int(c)
	d = int(d)
	l = int(l)
	if l % 4 != 0:
		print('no')
	elif l <= (d + c) * 4 and l >= d * 4 + max(0, c - 2 * d) * 4:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	(c, d, l) = map(int, input().split())
	(high, low) = ((c + d) * 4, max(d, d + c - 2 * d) * 4)
	if l % 4 == 0 and low <= l and (l <= high):
		print('yes')
		continue
	print('no')


t = int(input())
while t > 0:
	(C, D, L) = map(int, input().split())
	L_max = 4 * (C + D)
	L_min = 4 * (D + max(0, C - 2 * D))
	if L % 4 == 0 and L <= L_max and (L >= L_min):
		print('yes')
	else:
		print('no')
	t -= 1


for _ in range(int(input())):
	(c, d, l) = map(int, input().split())
	a = l // 4
	if l % 4 != 0:
		print('no')
	elif a - d < 0:
		print('no')
	elif c + d - a < 0 or c + d - a > 2 * d:
		print('no')
	else:
		print('yes')


for _ in range(int(input())):
	(c, d, l) = map(int, input().split())
	mr_hlpr = d
	if d < c / 2:
		mr_hlpr += c - 2 * d
	if l % 4 == 0 and (l >= mr_hlpr * 4 and l <= (c + d) * 4):
		print('yes')
	else:
		print('no')


t = int(input())
while t:
	(c, d, n) = list(map(int, input().split()))
	if n % 4 != 0:
		print('no')
		t -= 1
		continue
	a = n // 4
	cg = a - d
	if cg < 0:
		print('no')
		t -= 1
		continue
	cd = c - cg
	if cd < 0 or cd > 2 * d:
		print('no')
		t -= 1
		continue
	print('yes')
	t -= 1