Given a positive integer N, Your task is to complete the function countValues which returns an integer denoting the count of all positive integers i such that
0 <= i <= n and n+i = n^i where ^ denotes a XOR operation.
Input:
The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer N.
Output:
For each test case in a new line output will be the count of such positive integers.
Constraints:
1<=T<=100
1<=N<=1000
Example(To be used only for expected output):
Input
2
7
12
Output
1
4
Explanation:
For first test case
7^i = 7+i holds only for only for i = 0
7+0 = 7^0 = 7
For second test case
12^i = 12+i hold only for i = 0, 1, 2, 3
for i=0, 12+0 = 12^0 = 12
for i=1, 12+1 = 12^1 = 13
for i=2, 12+2 = 12^2 = 14
for i=3, 12+3 = 12^3 = 15
Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

Difficulty: EASY
Tags: Bit manipulation

Data structures
Skill types: Bit manipulation

Data structures

Starter code:
# You are required to complete this fucntion

# Function should return the an integer

def countValues(n):

    # Code here



Solutions:
def countValues(n):
	unset_bit = 0
	while n != 0:
		if n & 1 == 0:
			unset_bit += 1
		n = n >> 1
	return 1 << unset_bit


def countValues(n):
	res = 0
	for i in range(n + 1):
		if n + i == n ^ i:
			res += 1
	return res


def countValues(n):
	ans = 0
	for i in range(n):
		if i + n == i ^ n:
			ans += 1
	return ans


def countValues(n):
	i = 0
	c = 0
	for i in range(0, n + 1):
		if n + i == n ^ i:
			c += 1
	return c


def countValues(n):
	c = 0
	i = 0
	while i < n:
		if n + i == n ^ i:
			c += 1
		i += 1
	return c


def countValues(n):
	count = 0
	for i in range(n + 1):
		count += n ^ i == n + i
	return count


def countValues(n):
	a = 0
	for i in range(n):
		if n + i == n ^ i:
			a = a + 1
	return a


def countValues(n):
	cnt = 0
	for i in range(0, n + 1):
		if i + n == n ^ i:
			cnt += 1
	return cnt


def countValues(n):
	lst = []
	for i in range(n):
		if n + i == n ^ i:
			lst.append(i)
	return len(lst)


def countValues(n):
	p = 0
	for i in range(n):
		if n & i == 0:
			p += 1
		n >> 1
	return p


def countValues(n):
	unset = 0
	while n:
		if n & 1 == 0:
			unset += 1
		n >>= 1
	return 1 << unset


import math

def countValues(n):
	unset = 0
	while n:
		if n & 1 == 0:
			unset += 1
		n >>= 1
	return int(math.pow(2, unset))


def countValues(n):
	if n == 0:
		return 1
	count = 0
	while n:
		if not n & 1:
			count += 1
		n >>= 1
	return 1 << count


def countValues(n):
	unset_bits = 0
	cnt = 0
	while n > 0:
		if n & 1 == 0:
			unset_bits += 1
		n = n >> 1
	cnt = 1 << unset_bits
	return cnt


def countValues(n):
	count = 0
	while n > 0:
		if n & 1 == 0:
			count += 1
		n = n >> 1
	return 2 ** count


def countValues(n):
	c0 = 0
	while n:
		if n & 1 == 0:
			c0 += 1
		n >>= 1
	return 2 ** c0


def countValues(n):
	return 2 ** bin(n)[2:].count('0')


def countValues(n):
	cnt = 0
	while n:
		if n & 1 == 0:
			cnt += 1
		n = n >> 1
	return 2 ** cnt


def countValues(n):
	s = bin(n)[2:]
	count = 0
	for i in s:
		if i == '0':
			count += 1
	return 2 ** count


def countValues(n):
	sum = 0
	for i in range(0, n + 1):
		if n + i == n ^ i:
			sum += 1
	return sum


def countValues(n):
	if n == 0:
		return 1
	else:
		return 1 << bin(n).count('0') - 1


def countValues(n):
	c = 0
	for x in range(n):
		if x + n == n ^ x:
			c += 1
	return c


def countValues(n):
	count = 0
	for itr in range(n + 1):
		if n + itr == n ^ itr:
			count += 1
	return count
if __name__ == '__main__':
	t = int(input())
	for i in range(t):
		n = int(input().strip())
		print(countValues(n))


import math

def countValues(n):
	count = 0
	while n != 0:
		if n & 1 == 0:
			count += 1
		n = n >> 1
	return pow(2, count)
if __name__ == '__main__':
	t = int(input())
	for i in range(t):
		n = int(input().strip())
		print(countValues(n))


def countValues(n):
	a = 0
	while n:
		if n & 1 == 0:
			a += 1
		n = n >> 1
	return 1 << a
if __name__ == '__main__':
	t = int(input())
	for i in range(t):
		n = int(input().strip())
		print(countValues(n))


def countValues(n):
	a = bin(n)
	a = a[2:]
	c = 0
	for i in a:
		if i == '0':
			c += 1
	return 2 ** c


def countValues(n):
	k = bin(n)
	co = 0
	for i in range(2, len(k)):
		if k[i] == '0':
			co += 1
	co = 2 ** co
	return co


def countValues(n):
	count = 0
	x = 0
	while x < n:
		if n ^ x == n + x:
			count += 1
		x += 1
	return count


def countValues(n):
	countV = 0
	for i in range(n + 1):
		if n + i == n ^ i:
			countV += 1
	return countV


def countValues(n):
	a = 0
	while n > 0:
		if n % 2 == 0:
			a = a + 1
		n = n // 2
	return 2 ** a


def countValues(n):
	s = 1
	l = 0
	for i in range(11, -1, -1):
		if n & 1 << i:
			l = 1
		if l == 1 and (not n & 1 << i):
			s *= 2
	return s


def countValues(n):
	u = 0
	while n:
		if n & 1 == 0:
			u += 1
		n = n >> 1
	return 1 << u


def countValues(n):
	if n == 0:
		return 1
	else:
		k = bin(n)[2:].count('0')
		return 1 << k


def countValues(n):
	return sum((n + i == n ^ i for i in range(n + 1)))


def countValues(n):
	counter = 0
	for i in range(0, n + 1):
		if n + i == n ^ i:
			counter += 1
	return counter