A number N is given. Divide it in half by using the binary shift operator.
Use the floor value if the result is in decimal. If the number is 1, leave it as it is.
Example 1:
Input: N = 1
Output: 1
Example 2:
Input: N = 37
Output: 18
Explaination: 37/2 = 18.5 which is in 
decimal form and whose floor value is 18.
Your Task:
You do not need to read input or print anything. Your task is to complete the function half(), which takes the number N as input parameter and returns the desired output.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constarints:
1 ≤ N ≤ 10^{9}

Source: geeksforgeeks | Difficulty: EASY
Tags: Bit manipulation

Data structures

Starter code: #User function Template for python3

class Solution:
    def half(self, N):
        # code here

Solutions:
class Solution:

	def half(self, N):
		if N == 1:
			return N
		return N // 2


class Solution:

	def half(self, N):
		if N == 1:
			return 1
		else:
			return N >> 1


import math

class Solution:

	def half(self, N):
		if N == 1:
			return 1
		else:
			return int(math.floor(N / 2))


class Solution:

	def half(self, N):
		if N == 1:
			return 1
		else:
			r = N // 2
			return r


class Solution:

	def half(self, N):
		if N == 1:
			return 1
		elif N > 0:
			return N >> 1


class Solution:

	def half(self, N):
		n = N
		if n == 1:
			return 1
		c = n >> 1
		return c


class Solution:

	def half(self, N):
		if N == 1:
			return 1
		elif N > 1:
			a = N >> 1
			return a


class Solution:

	def half(self, N):
		a = N // 2
		if N == 1:
			return 1
		else:
			return a


class Solution:

	def half(self, n):
		if n == 1:
			return '1'
		else:
			return n >> 1


class Solution:

	def half(self, N):
		if N == 1:
			return 1
		else:
			s = N // 2
			return s


class Solution:

	def half(self, N):
		cnt = 0
		i = 1
		if N >= 2:
			N = N >> 1
			return N
		elif N == 1:
			return 1


class Solution:

	def half(self, N):
		if N == 1:
			return 1
		else:
			return int(N / 2)


class Solution:

	def half(self, N):
		if N > 1:
			binary = '{0:b}'.format(N)
			shiftbinary = binary[:-1]
			ans = int(shiftbinary, 2)
			return ans
		else:
			return 1


class Solution:

	def half(self, N):
		if N == 1:
			return 1
		else:
			m = N // 2
			return m


import math

class Solution:

	def half(self, N):
		if N == 1:
			return N
		ans = N >> 1
		return math.floor(ans)


class Solution:

	def half(self, N):
		if N == 1:
			return 1
		return N >> 1
if __name__ == '__main__':
	t = int(input())
	for _ in range(t):
		N = int(input())
		ob = Solution()
		print(ob.half(N))