




import operator

def  UpperCAmelCase_							(				__UpperCAmelCase						:     list      ,      __UpperCAmelCase						:     bool = False      ,      __UpperCAmelCase						:     list | None = None							) ->			list:
						SCREAMING_SNAKE_CASE_     						=      operator.lt if reverse else operator.gt
						SCREAMING_SNAKE_CASE_     						=      solution or []

						if not arr:
												return solution

						SCREAMING_SNAKE_CASE_     						=      [arr.pop(0							)]
						for i, item in enumerate(__UpperCAmelCase							):
												if _operator(__UpperCAmelCase      ,      sublist[-1]							):
																		sublist.append(__UpperCAmelCase							)
																		arr.pop(__UpperCAmelCase							)

    #  merging sublist into solution list
						if not solution:
												solution.extend(__UpperCAmelCase							)
						else:
												while sublist:
																		SCREAMING_SNAKE_CASE_     						=      sublist.pop(0							)
																		for i, xx in enumerate(__UpperCAmelCase							):
																								if not _operator(__UpperCAmelCase      ,      __UpperCAmelCase							):
																														solution.insert(__UpperCAmelCase      ,      __UpperCAmelCase							)
																														break
																		else:
																								solution.append(__UpperCAmelCase							)

						strand_sort(__UpperCAmelCase      ,      __UpperCAmelCase      ,      __UpperCAmelCase							)
						return solution


if __name__ == "__main__":
			assert strand_sort([4, 3, 5, 1, 2]) == [1, 2, 3, 4, 5]
			assert strand_sort([4, 3, 5, 1, 2], reverse=True) == [5, 4, 3, 2, 1]





def  UpperCAmelCase_							(				__UpperCAmelCase						:     Optional[Any]      ,      __UpperCAmelCase						:     Union[str, Any]							) ->			List[str]:
      SCREAMING_SNAKE_CASE_     						=      0
      while b > 0:
            if b & 1:
                  res += a

            a += a
            b >>= 1

      return res

def  UpperCAmelCase_							(				__UpperCAmelCase						:     str      ,      __UpperCAmelCase						:     int      ,      __UpperCAmelCase						:     Tuple							) ->			int:
      SCREAMING_SNAKE_CASE_     						=      0
      while b > 0:
            if b & 1:
                  SCREAMING_SNAKE_CASE_     						=      ((res % c) + (a % c)) % c

            a += a
            b >>= 1

      return res