



from __future__ import annotations


def 	UpperCAmelCase__      (      UpperCAmelCase__ :list ,					UpperCAmelCase__ :int ,					UpperCAmelCase__ :int ,					UpperCAmelCase__ :int					):






 '''simple docstring'''

 a						=		[]
 a		,  a						=		input_list[low:mid], input_list[mid : high + 1]
 while left and right:
  result.append((left if left[0] <= right[0] else right).pop(0					)					)
 a						=		result + left + right
 return input_list


def 	UpperCAmelCase__      (      UpperCAmelCase__ :list					):






 '''simple docstring'''

 if len(UpperCAmelCase__					) <= 1:
  return input_list
 a						=		list(UpperCAmelCase__					)

 # iteration for two-way merging
 a						=		2
 while p <= len(UpperCAmelCase__					):
  # getting low, high and middle value for merge-sort of single list
  for i in range(0 ,					len(UpperCAmelCase__					) ,					UpperCAmelCase__					):
   a						=		i
   a						=		i + p - 1
   a						=		(low + high + 1) // 2
   a						=		merge(UpperCAmelCase__ ,					UpperCAmelCase__ ,					UpperCAmelCase__ ,					UpperCAmelCase__					)
  # final merge of last two parts
  if p * 2 >= len(UpperCAmelCase__					):
   a						=		i
   a						=		merge(UpperCAmelCase__ ,					0 ,					UpperCAmelCase__ ,					len(UpperCAmelCase__					) - 1					)
   break
  p *= 2

 return input_list


if __name__ == "__main__":
     A_		:     List[str]        =     input('''Enter numbers separated by a comma:\n''').strip()
     if user_input == "":
          A_		:     Dict        =     []
     else:
          A_		:     int        =     [int(item.strip()) for item in user_input.split(''',''')]
     print(iter_merge_sort(unsorted))






import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
     import torch

     from transformers.generation import DisjunctiveConstraint



@require_torch
class 		_lowercase		(       unittest.TestCase	):

   def 		A							(      self			:       Union[str, Any]							)       ->				int:


    """simple docstring"""






    a						=		[[1, 2, 4], [1, 2, 3, 4]]
    a						=		DisjunctiveConstraint(__lowerCAmelCase							)
    self.assertTrue(isinstance(dc.token_ids							,   __lowerCAmelCase							)							)

    with self.assertRaises(__lowerCAmelCase							):
     DisjunctiveConstraint(torch.LongTensor([[1, 2, 4], [1, 2, 3]]							)							)

    with self.assertRaises(__lowerCAmelCase							):
     DisjunctiveConstraint([torch.LongTensor([1, 2, 4]							), torch.LongTensor([1, 2, 3, 4, 5]							)]							)

   def 		A							(      self			:       Tuple							)       ->				Dict:


    """simple docstring"""






    a						=		[[1, 2], [1, 2, 3, 4]]

    with self.assertRaises(__lowerCAmelCase							):
     DisjunctiveConstraint(__lowerCAmelCase							)  # fails here

   def 		A							(      self			:       int							)       ->				Any:


    """simple docstring"""






    a						=		[[1, 2, 3], [1, 2, 4]]

    a						=		DisjunctiveConstraint(__lowerCAmelCase							)

    a		,  a		,  a						=		dc.update(1							)
    a						=		stepped is True and completed is False and reset is False
    self.assertTrue(__lowerCAmelCase							)
    self.assertTrue(not dc.completed							)
    self.assertTrue(dc.current_seq == [1]							)

    a		,  a		,  a						=		dc.update(2							)
    a						=		stepped is True and completed is False and reset is False
    self.assertTrue(__lowerCAmelCase							)
    self.assertTrue(not dc.completed							)
    self.assertTrue(dc.current_seq == [1, 2]							)

    a		,  a		,  a						=		dc.update(3							)
    a						=		stepped is True and completed is True and reset is False
    self.assertTrue(__lowerCAmelCase							)
    self.assertTrue(dc.completed							)  # Completed!
    self.assertTrue(dc.current_seq == [1, 2, 3]							)




   def 		A							(      self			:       List[Any]							)       ->				List[Any]:


    """simple docstring"""






    a						=		[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

    a						=		DisjunctiveConstraint(__lowerCAmelCase							)

    a		,  a		,  a						=		dc.update(1							)
    self.assertTrue(not dc.completed							)
    self.assertTrue(dc.current_seq == [1]							)

    a		,  a		,  a						=		dc.update(2							)
    self.assertTrue(not dc.completed							)
    self.assertTrue(dc.current_seq == [1, 2]							)

    a		,  a		,  a						=		dc.update(4							)
    self.assertTrue(not dc.completed							)
    self.assertTrue(dc.current_seq == [1, 2, 4]							)

    a		,  a		,  a						=		dc.update(5							)
    self.assertTrue(dc.completed							)  # Completed!
    self.assertTrue(dc.current_seq == [1, 2, 4, 5]							)

    dc.reset()

    a		,  a		,  a						=		dc.update(1							)
    self.assertTrue(not dc.completed							)
    self.assertTrue(dc.remaining() == 3							)
    self.assertTrue(dc.current_seq == [1]							)

    a		,  a		,  a						=		dc.update(2							)
    self.assertTrue(not dc.completed							)
    self.assertTrue(dc.remaining() == 2							)
    self.assertTrue(dc.current_seq == [1, 2]							)

    a		,  a		,  a						=		dc.update(5							)
    self.assertTrue(dc.completed							)  # Completed!
    self.assertTrue(dc.remaining() == 0							)
    self.assertTrue(dc.current_seq == [1, 2, 5]							)

