
from __future__ import annotations


def 					__lowerCAmelCase    (    a__		,					a__						) ->						list:
				__a    							=					[None] * (len(a__						) + len(a__						))

				__a    							=					0  # pointer to current index for left Half
				__a    							=					0  # pointer to current index for the right Half
				__a    							=					0  # pointer to current index for the sorted array Half

				while pointera < len(a__						) and pointera < len(a__						):
								if left_half[pointera] < right_half[pointera]:
												__a    							=					left_half[pointera]
												pointera += 1
												index += 1
								else:
												__a    							=					right_half[pointera]
												pointera += 1
												index += 1
				while pointera < len(a__						):
								__a    							=					left_half[pointera]
								pointera += 1
								index += 1

				while pointera < len(a__						):
								__a    							=					right_half[pointera]
								pointera += 1
								index += 1

				return sorted_array


def 					__lowerCAmelCase    (    a__						) ->						list:
				if len(a__						) <= 1:
								return array
				# the actual formula to calculate the middle element = left + (right - left) // 2
				# this avoids integer overflow in case of large N
				__a    							=					0 + (len(a__						) - 0) // 2

				# Split the array into halves till the array length becomes equal to One
				# merge the arrays of single length returned by mergeSort function and
				# pass them into the merge arrays function which merges the array
				__a    							=					array[:middle]
				__a    							=					array[middle:]

				return merge(merge_sort(a__						)		,					merge_sort(a__						)						)


if __name__ == "__main__":
					import doctest

					doctest.testmod()








from itertools import compress, repeat
from math import ceil, sqrt


def 					__lowerCAmelCase    (    a__						) ->						list[int]:

				if num <= 2:
								return []
				if num == 3:
								return [2]

				# Odd sieve for numbers in range [3, num - 1]
				__a    							=					bytearray(B'''\x01'''						) * ((num >> 1) - 1)

				for i in range(3		,					int(sqrt(a__						)						) + 1		,					2						):
								if sieve[(i >> 1) - 1]:
												__a    							=					i**2
												__a    							=					repeat(
												    0		,					ceil((num - i_squared) / (i << 1)						)						)

				return [2] + list(compress(range(3		,					a__		,					2						)		,					a__						)						)


if __name__ == "__main__":
					import doctest

					doctest.testmod()