You are given a positive integer X. Your task is to tell whether there exist two positive integers a and b (a > 0, b > 0) such that

2\cdot a + 2\cdot b + a\cdot b = X

If there exist positive integers a and b satisfying the above condition print YES, otherwise print NO. 

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of single line containing a positive integer X.

------ Output Format ------ 

For each test case, output on a new line YES or NO.

You may print each character of the string in either uppercase or lowercase (for example, the strings yes, YES, Yes, and yeS will all be treated as identical).

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

$1 ≤ T ≤ 100$
$1 ≤ X ≤ 10^{9}$

----- Sample Input 1 ------ 
4
2
5
6
12

----- Sample Output 1 ------ 
NO
YES
NO
YES

----- explanation 1 ------ 
Test case $1$: There do not exist any positive integers $a$ and $b$ such that $2\cdot a + 2\cdot b + a\cdot b = 2$.

Test case $2$: Let $a=1$ and $b=1$, then $2\cdot a+2\cdot b+a\cdot b=5$.

Test case $3$: There do not exist any positive integers $a$ and $b$ such that $2\cdot a + 2\cdot b + a\cdot b = 6$.

Test case $4$: Let $a=2$ and $b=2$, then $2\cdot a+2\cdot b+a\cdot b=12$.

Difficulty: EASY
Tags: Number theory

Mathematics

Starter code:

Solutions:
import math
for i in range(int(input())):
	n = int(input())
	for a in range(1, int(math.sqrt(n))):
		b = int((n - 2 * a) / (2 + a))
		if n == 2 * a + 2 * b + a * b:
			print('YES')
			break
	else:
		print('NO')


from math import sqrt

def f(x, a):
	b = (x - 2 * a) / (2 + a)
	return b != 0 and b.is_integer()
tc = int(input())
for case in range(tc):
	x = int(input())
	for i in range(1, int(sqrt(x))):
		if f(x, i):
			print('YES')
			break
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input()) + 4
	ans = 'NO'
	for i in range(3, int(n ** (1 / 2)) + 1):
		if n % i == 0:
			ans = 'YES'
			break
	print(ans)


for _ in range(int(input())):
	x = int(input())
	ans = 'NO'
	b = 1
	top = int(x ** 0.5) + 1
	for b in range(1, top):
		a = (x - 2 * b) / (2 + b)
		if a != 0 and a % 1 == 0:
			ans = 'YES'
			break
	print(ans)


import math
for _ in range(int(input())):
	x = int(input())
	f = 0
	for a in range(1, int(math.sqrt(x))):
		b = (x - 2 * a) / (2 + a)
		if b % 1 == 0:
			f = 1
			break
	if f == 0:
		print('NO')
	else:
		print('YES')


import math
for _ in range(int(input())):
	x = int(input())
	for i in range(1, int(math.sqrt(x))):
		t = (x - 2 * i) / (i + 2)
		if t % 1 == 0:
			print('YES')
			break
	else:
		print('NO')


import sys
import math
for i in range(int(sys.stdin.readline())):
	X = int(sys.stdin.readline())
	flag = 0
	for a in range(1, int(math.sqrt(X))):
		b = int((X - 2 * a) / (2 + a))
		if X == 2 * a + 2 * b + a * b:
			flag = 1
			break
	if flag == 1:
		sys.stdout.write('YES\n')
	else:
		sys.stdout.write('NO\n')


import math
t = int(input())
for i in range(t):
	x = int(input())
	c = 0
	r = int(math.sqrt(x))
	for a in range(1, r):
		b = int((x - 2 * a) / (2 + a))
		if x == 2 * a + 2 * b + a * b:
			c = 1
			break
	if c == 1:
		print('YES')
	else:
		print('NO')


import math
for i in range(int(input())):
	n = int(input())
	for i in range(1, int(math.sqrt(n))):
		y = (n - 2 * i) / (2 + i)
		if y % 1 == 0:
			print('YES')
			break
	else:
		print('NO')


t = int(input())
for i in range(t):
	flag = 0
	x = int(input())
	for i in range(1, x):
		f = i * (4 + i)
		if x - f < 0:
			break
		if x - f >= 0 and (x - f) % (2 + i) == 0:
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	x = int(input())
	for j in range(1, int(x ** (1 / 2))):
		if (x - 2 * j) % (2 + j) == 0 and x != 2 * j:
			print('YES')
			break
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = 5
	b = 5
	diff = 3
	while True:
		if n < a:
			print('NO')
			break
		elif (n - a + diff) % diff == 0:
			print('YES')
			break
		else:
			a = a + b + 2
			b += 2
			diff += 1


from math import sqrt
t = int(input())
for i in range(t):
	x = int(input())
	flag = False
	for i in range(1, int(sqrt(x))):
		if (x - 2 * i) % (2 + i) == 0 and x != 2 * i:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


T = int(input())
for Akash in range(T):
	flag = 0
	X = int(input())
	for sky in range(1, X):
		fancy = sky * (4 + sky)
		if X - fancy < 0:
			break
		if X - fancy >= 0 and (X - fancy) % (2 + sky) == 0:
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


import math
for i in range(int(input())):
	x = int(input())
	ans = 0
	res = int(math.sqrt(x))
	for a in range(1, res):
		b = int((x - 2 * a) / (2 + a))
		if x == 2 * a + 2 * b + a * b:
			ans = 1
			break
	if ans == 1:
		print('YES')
	else:
		print('NO')


Z = int(input())
for j in range(Z):
	a = int(input())
	c = 0
	for k in range(1, int(a ** 0.5)):
		if (a - 2 * k) % (k + 2) == 0 and k != 2 * k:
			c += 1
	if c == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	x = int(input())
	import math
	for a in range(1, math.ceil(math.sqrt(x))):
		b = (x - 2 * a) / (2 + a)
		if b - math.floor(b) == 0 and b > 0:
			print('YES')
			break
	else:
		print('NO')


T = int(input())
for i in range(T):
	x = int(input())
	t = 0
	for i in range(1, int(x ** 0.5) + 1):
		if (x - 2 * i) % (2 + i) == 0 and x != 2 * i:
			t += 1
	if t == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	x = int(input())
	if x < 5:
		print('NO')
		t = t - 1
		continue
	flag = 0
	for i in range(1, int(x ** 0.5)):
		if (x - 2 - 3 * i) % (i + 2) == 0:
			flag = 1
			break
	if flag == 1:
		print('YES')
	elif flag == 0:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	X = int(input())
	ans = 'NO'
	(a0, j) = (5, 1)
	while a0 <= X:
		if j * j > X:
			break
		d = j + 2
		a0 = 2 + 3 * j
		n = (X - a0) / d + 1
		if n - int(n) == 0:
			ans = 'YES'
			break
		j += 1
	print(ans)


from bisect import bisect_left
from code import interact
from heapq import heapify, heappush, heappop
from collections import deque
from pydoc import plain
import sys
from math import gcd, sqrt, log10, log2, floor, ceil, sqrt
input = sys.stdin.readline

def il():
	return [int(a) for a in input().strip().split()]

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

def ii():
	return int(input())

def ot(in_p, *args, e=' '):
	if type(in_p) == list:
		print(*in_p, end=e)
	if type(in_p) == str or type(in_p) == int:
		print(in_p, end=e)
		for l in args:
			print(l, end=e)
	print()

def a_pwr_n(a, n, mod):
	if n == 1:
		return a % mod
	if n % 2 == 0:
		val = a_pwr_n(a, n // 2, mod)
		return val % mod * val % mod
	else:
		return a % mod * a_pwr_n(a, n - 1, mod) % mod

def rg(*ag):
	if len(ag) == 3:
		return range(ag[0], ag[1], ag[2])
	elif len(ag) == 2:
		return range(ag[0], ag[1])
	elif len(ag) == 1:
		return range(ag[0])
	else:
		raise 'invalid input'

def ispal(i, j, st):
	while i <= j:
		if st[i] == st[j]:
			i = i + 1
			j = j - 1
		else:
			return False
	return True
mod = 1000000000 + 7
dx = [-1, -2, 1, 2, 2, -2, -1, 1]
dy = [2, 1, 2, 1, -1, -1, -2, -2]
for i in range(ii()):
	t = ii()
	c = 0
	for j in range(1, int(t ** 0.5)):
		if (t - 2 * j) % (j + 2) == 0 and t != 2 * j:
			c += 1
	if c == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	x = int(input())
	exists = 'NO'
	for a in range(1, int(x ** 0.5) + 1):
		b = (x - 2 * a) / (a + 2)
		if b > 0:
			if b.is_integer():
				exists = 'YES'
				break
		else:
			exists = 'NO'
			break
	print(exists)


t = int(input())
for ak in range(t):
	x = int(input())
	h = 0
	for ak in range(1, int(x ** 0.5) + 1):
		if (x - 2 * ak) % (2 + ak) == 0 and x != 2 * ak:
			h += 1
	if h == 0:
		print('NO')
	else:
		print('YES')


tests = int(input())
for i in range(tests):
	num = int(input())
	a = 1
	ans = 'NO'
	while a < num ** 0.5:
		b = (num - 2 * a) / (2 + a)
		if b == int(b) and b > 0:
			ans = 'YES'
		if ans == 'YES':
			break
		a += 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	if n < 5:
		print('NO')
	else:
		flag = 0
		for i in range(1, int(n ** 0.5) + 1):
			if n > 2 * i and (n - 2 * i) % (2 + i) == 0:
				flag = 1
				break
		if flag:
			print('YES')
		else:
			print('NO')


from math import ceil, floor

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

def solve2():
	x = int(input())
	ans = 'NO'
	for a in range(1, x + 10):
		if a * a > x:
			break
		if 2 * a >= x:
			break
		if (x - 2 * a) % (a + 2) != 0:
			continue
		else:
			ans = 'YES'
			break
	print(ans)

def solve1():
	for _ in range(int(input())):
		solve2()
solve1()


for _ in range(int(input())):
	x = int(input())
	ans = 'NO'
	for a in range(1, x + 10):
		if a * a > x:
			break
		if 2 * a >= x:
			break
		if (x - 2 * a) % (a + 2) != 0:
			continue
		ans = 'YES'
		break
	print(ans)


t = int(input())
for _ in range(t):
	x = int(input())
	count = 0
	for a in range(1, int(x ** 0.5)):
		b = (x - 2 * a) % (a + 2)
		if b == 0:
			count = 1
			break
	if count == 1:
		print('YES')
	else:
		print('NO')


import math
for i in range(int(input())):
	z = int(input())
	for y in range(1, (-4 + int(math.sqrt(16 + 4 * z))) // 2 + 1):
		if (z - 2 * y) % (2 + y) == 0:
			if z - 2 * y != 0:
				print('YES')
				break
	else:
		print('NO')