Consider a 2d plane and a Robot which is located at (0,0) who can move only one unit step at a time in any direction i.e. if its initial position is (x,y), he can go to positions (x + 1, y), (x - 1, y), (x, y + 1) or (x, y - 1). Now Given three integers a,b (denoting the final position where the robot has to reach), and x. Find out if the Robot can reach the final position in exactly x steps.
 
Example 1:
Input:
a = 5, b = 5, x = 11
Output:
0
Explanation:
No matter how the Robot moves,
the Robot won't be able to reach
point (5,5) in exactly 11 moves.
Example 2:
Input:
a = 10, b = 15, x = 25
Output:
1
Explanation:
The Robot can move 10 times towards
positive x-axis and then 15 times
towards positive y-axis to reach (10,15).
 
Your Task:
You don't need to read input or print anything. Your task is to complete the function canReach() which takes 3 Integers a,b and x as input and returns the answer.
 
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
 
Constraints:
-10^{9} <= a,b <= 10^{9}
1 <= x <= 2*10^{9}

Difficulty: EASY
Tags: Mathematics
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def canReach(self, a, b, x):
        # code here

Solutions:
class Solution:

	def canReach(self, a, b, x):
		a = int(a ** 2) ** 0.5
		b = int(b ** 2) ** 0.5
		if a + b == x:
			return 1
		if a + b < x:
			y = x - (a + b)
			if y % 2 == 0:
				return 1
		return 0


class Solution:

	def canReach(self, a, b, x):
		a = abs(a)
		b = abs(b)
		if a == 0 and b == 0:
			if x % 2 == 0:
				return 1
			return 0
		if a + b <= x:
			z = x
			if (a + b) % 2 == 0:
				if z % 2 == 0:
					return 1
				else:
					return 0
			elif z % 2 == 0:
				return 0
			else:
				return 1
		else:
			return 0


class Solution:

	def canReach(self, a, b, x):
		a = abs(a) + abs(b)
		if x < a:
			return 0
		return int((x - a) % 2 == 0)


from collections import deque

class Solution:

	def canReach(self, a, b, x):
		x = x - (abs(a) + abs(b))
		if x >= 0 and x % 2 == 0:
			return 1
		else:
			return 0


class Solution:

	def canReach(self, a, b, x):
		minSteps = abs(a) + abs(b) - 2
		if x < minSteps or (x - minSteps) % 2 != 0:
			return 0
		return 1


class Solution:

	def canReach(self, a, b, x):
		sum = abs(a) + abs(b)
		if x < sum:
			return 0
		diff = x - sum
		return 1 if diff % 2 == 0 else 0


class Solution:

	def canReach(self, a, b, x):
		short_distance = abs(a) + abs(b)
		if x >= short_distance and abs(x - short_distance) % 2 == 0:
			return 1
		return 0


class Solution:

	def canReach(self, a, b, x):
		total = abs(a) + abs(b)
		if total > x:
			return 0
		di = x - total
		if di % 2 == 0:
			return 1
		return 0


class Solution:

	def canReach(self, a, b, x):
		if x >= abs(a) + abs(b):
			remain = x - (abs(a) + abs(b))
			if remain % 2 == 0:
				return 1
			else:
				return 0
			return 1
		else:
			return 0


class Solution:

	def canReach(self, a, b, x):
		return 0 if x - (abs(a) + abs(b)) & 1 or x - (abs(a) + abs(b)) < 0 else 1


class Solution:

	def canReach(self, a, b, x):
		xsum = abs(a) + abs(b)
		if xsum == x:
			return 1
		elif x - xsum < 0:
			return 0
		elif (x - xsum) % 2 == 0:
			return 1
		return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(a, b, x) = map(int, input().split())
		ob = Solution()
		print(ob.canReach(a, b, x))


from collections import deque

class Solution:

	def canReach(self, a, b, x):
		a = abs(a)
		b = abs(b)
		if a + b > x:
			return 0
		if (x - a - b) % 2 == 0:
			return 1
		return 0
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		(a, b, x) = map(int, input().split())
		ob = Solution()
		print(ob.canReach(a, b, x))


class Solution:

	def canReach(self, a, b, x):
		if x == abs(a) + abs(b):
			return 1
		elif x < abs(a) + abs(b):
			return 0
		else:
			extra = x - (abs(a) + abs(b))
			if extra % 2 == 0:
				return 1
			else:
				return 0


from collections import deque

class Node:

	def __init__(self, x, y, d=0):
		self.x = x
		self.y = y
		self.d = d

class Solution:
	adjRows = [0, 0, 1, -1]
	adjCols = [1, -1, 0, 0]

	def canReach(self, a, b, x):
		s = abs(a) + abs(b)
		if x < s:
			return 0
		if (x - s) % 2 == 0:
			return 1
		else:
			return 0


class Solution:

	def canReach(self, a, b, x):
		min_moves = abs(a) + abs(b)
		if x < min_moves:
			return 0
		extra_steps_we_have = x - min_moves
		if extra_steps_we_have % 2 == 0:
			return 1
		else:
			return 0


class Solution:

	def canReach(self, a, b, x):
		val = abs(a) + abs(b)
		if val <= x:
			if (x - val) % 2 == 0:
				return 1
		return 0


class Solution:

	def canReach(self, a, b, x):
		minSteps = abs(a) + abs(b)
		if minSteps == x:
			return 1
		elif minSteps > x:
			return 0
		else:
			rem = x - minSteps
			if rem % 2 == 0:
				return 1
			else:
				return 0


class Solution:

	def canReach(self, a, b, x):
		if a < 0:
			a = -a
		if b < 0:
			b = -b
		n = x - a - b
		if n > 0 and n % 2 == 0:
			return 1
		return 0


class Solution:

	def canReach(self, a, b, x):
		t = abs(a) + abs(b)
		if t > x:
			return 0
		s = t - x
		if s % 2 == 0:
			return 1
		return 0


class Solution:

	def canReach(self, a, b, x):
		total = abs(a) + abs(b)
		if x >= total and (x - total) % 2 == 0:
			return 1
		else:
			return 0


class Solution:

	def canReach(self, a, b, x):
		if abs(a) + abs(b) > x:
			return 0
		elif abs(a) + abs(b) == x:
			return 1
		k = abs(a) + abs(b)
		if (x - k) % 2 == 0:
			return 1
		return 0


class Solution:

	def canReachBFS(self, a, b, x):
		to_visit = []
		to_visit.append([0, 0])
		step = 0
		while step < x:
			queue_len = len(to_visit)
			id = 0
			while id < queue_len:
				start = to_visit.pop(0)
				next_1 = [start[0], start[1] + 1]
				next_2 = [start[0], start[1] - 1]
				next_3 = [start[0] + 1, start[1]]
				next_4 = [start[0] - 1, start[1]]
				to_visit.append(next_1)
				to_visit.append(next_2)
				to_visit.append(next_3)
				to_visit.append(next_4)
				id += 1
			step += 1
		while to_visit:
			element = to_visit.pop()
			if element[0] == a and element[1] == b:
				return 1
			else:
				continue
		return 0

	def canReach(self, a, b, x):
		sum_ab = abs(a) + abs(b)
		if x < sum_ab:
			return 0
		if sum_ab % 2 == x % 2:
			return 1
		else:
			return 0


import heapq

class Solution:

	def canReach(self, a, b, k):
		dit = abs(a) + abs(b)
		if k < dit:
			return 0
		if (k - dit) % 2 == 0:
			return 1
		return 0