



"""simple docstring"""






def 					snake_case__       (		__lowerCamelCase    :   Any     ):
			"""simple docstring"""
			lowerCamelCase__		:		Optional[int]		     =0
			lowerCamelCase__		:		Optional[int]		     =len(__lowerCamelCase     )

			for i in range(n - 1     ):
						for j in range(i + 1							,		__lowerCamelCase     ):
									if arr[i] > arr[j]:
												num_inversions += 1

			return num_inversions






def 					snake_case__       (		__lowerCamelCase    :   Tuple     ):
			"""simple docstring"""
			if len(__lowerCamelCase     ) <= 1:
						return arr, 0
			lowerCamelCase__		:		Optional[Any]		     =len(__lowerCamelCase     ) // 2
			lowerCamelCase__		:		Dict		     =arr[0:mid]
			lowerCamelCase__		:		List[Any]		     =arr[mid:]

			lowerCamelCase__     ,       lowerCamelCase__		:		Optional[Any]		     =count_inversions_recursive(__lowerCamelCase     )
			lowerCamelCase__     ,       lowerCamelCase__		:		Union[str, Any]		     =count_inversions_recursive(__lowerCamelCase     )
			lowerCamelCase__     ,       lowerCamelCase__		:		Tuple		     =_count_cross_inversions(__lowerCamelCase							,		__lowerCamelCase     )

			lowerCamelCase__		:		Dict		     =inversion_p + inversions_q + cross_inversions
			return c, num_inversions






def 					snake_case__       (		__lowerCamelCase    :   Optional[Any]							,		__lowerCamelCase    :   int     ):
			"""simple docstring"""
			lowerCamelCase__		:		Optional[int]		     =[]
			lowerCamelCase__		:		Tuple		     =0
			while i < len(__lowerCamelCase     ) and j < len(__lowerCamelCase     ):
						if p[i] > q[j]:
									# if P[1] > Q[j], then P[k] > Q[k] for all  i < k <= len(P)
									# These are all inversions. The claim emerges from the
									# property that P is sorted.
									num_inversion += len(__lowerCamelCase     ) - i
									r.append(q[j]     )
									j += 1
						else:
									r.append(p[i]     )
									i += 1

			if i < len(__lowerCamelCase     ):
						r.extend(p[i:]     )
			else:
						r.extend(q[j:]     )

			return r, num_inversion






def 					snake_case__       (		):
			"""simple docstring"""
			lowerCamelCase__		:		Optional[Any]		     =[10, 2, 1, 5, 5, 2, 11]

			# this arr has 8 inversions:
			# (10, 2), (10, 1), (10, 5), (10, 5), (10, 2), (2, 1), (5, 2), (5, 2)

			lowerCamelCase__		:		Dict		     =count_inversions_bf(__lowerCamelCase     )
			lowerCamelCase__     ,       lowerCamelCase__		:		str		     =count_inversions_recursive(__lowerCamelCase     )

			assert num_inversions_bf == num_inversions_recursive == 8

			print('''number of inversions = '''							,		__lowerCamelCase     )

			# testing an array with zero inversion (a sorted arr_1)

			arr_a.sort()
			lowerCamelCase__		:		List[str]		     =count_inversions_bf(__lowerCamelCase     )
			lowerCamelCase__     ,       lowerCamelCase__		:		Union[str, Any]		     =count_inversions_recursive(__lowerCamelCase     )

			assert num_inversions_bf == num_inversions_recursive == 0
			print('''number of inversions = '''							,		__lowerCamelCase     )

			# an empty list should also have zero inversions
			lowerCamelCase__		:		str		     =[]
			lowerCamelCase__		:		Tuple		     =count_inversions_bf(__lowerCamelCase     )
			lowerCamelCase__     ,       lowerCamelCase__		:		Union[str, Any]		     =count_inversions_recursive(__lowerCamelCase     )

			assert num_inversions_bf == num_inversions_recursive == 0
			print('''number of inversions = '''							,		__lowerCamelCase     )


if __name__ == "__main__":
		main()









"""simple docstring"""






def 					snake_case__       (		__lowerCamelCase    :   int							,		__lowerCamelCase    :   int     ):
			"""simple docstring"""
			return int((input_a, input_a).count(0     ) != 0     )






def 					snake_case__       (		):
			"""simple docstring"""
			assert nand_gate(0							,		0     ) == 1
			assert nand_gate(0							,		1     ) == 1
			assert nand_gate(1							,		0     ) == 1
			assert nand_gate(1							,		1     ) == 0


if __name__ == "__main__":
		print(nand_gate(0, 0))
		print(nand_gate(0, 1))
		print(nand_gate(1, 0))
		print(nand_gate(1, 1))




