


def __UpperCAmelCase       (		__A			)						->					Any:



       '''simple docstring'''





       UpperCAmelCase__										=     0
       UpperCAmelCase__										=     len(__A			)

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

       return num_inversions





def __UpperCAmelCase       (		__A			)						->					Any:



       '''simple docstring'''





       if len(__A			) <= 1:
              return arr, 0
       UpperCAmelCase__										=     len(__A			) // 2
       UpperCAmelCase__										=     arr[0:mid]
       UpperCAmelCase__										=     arr[mid:]

       UpperCAmelCase__						,			UpperCAmelCase__										=     count_inversions_recursive(__A			)
       UpperCAmelCase__						,			UpperCAmelCase__										=     count_inversions_recursive(__A			)
       UpperCAmelCase__						,			UpperCAmelCase__										=     _count_cross_inversions(__A ,						__A			)

       UpperCAmelCase__										=     inversion_p + inversions_q + cross_inversions
       return c, num_inversions





def __UpperCAmelCase       (		__A ,						__A			)						->					List[str]:



       '''simple docstring'''





       UpperCAmelCase__										=     []
       UpperCAmelCase__										=     UpperCAmelCase__										=     UpperCAmelCase__										=     0
       while i < len(__A			) and j < len(__A			):
              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(__A			) - i
                     r.append(q[j]			)
                     j += 1
              else:
                     r.append(p[i]			)
                     i += 1

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

       return r, num_inversion





def __UpperCAmelCase       (		)						->					Optional[Any]:



       '''simple docstring'''





       UpperCAmelCase__										=     [1_0, 2, 1, 5, 5, 2, 1_1]

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

       UpperCAmelCase__										=     count_inversions_bf(__A			)
       UpperCAmelCase__						,			UpperCAmelCase__										=     count_inversions_recursive(__A			)

       assert num_inversions_bf == num_inversions_recursive == 8

       print("number of inversions = " ,						__A			)

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

       arr_a.sort()
       UpperCAmelCase__										=     count_inversions_bf(__A			)
       UpperCAmelCase__						,			UpperCAmelCase__										=     count_inversions_recursive(__A			)

       assert num_inversions_bf == num_inversions_recursive == 0
       print("number of inversions = " ,						__A			)

       # an empty list should also have zero inversions
       UpperCAmelCase__										=     []
       UpperCAmelCase__										=     count_inversions_bf(__A			)
       UpperCAmelCase__						,			UpperCAmelCase__										=     count_inversions_recursive(__A			)

       assert num_inversions_bf == num_inversions_recursive == 0
       print("number of inversions = " ,						__A			)


if __name__ == "__main__":
    main()









def __UpperCAmelCase       (		__A			)						->					list[int]:



       '''simple docstring'''





       UpperCAmelCase__										=     len(__A			)
       for i in range(__A			):
              for j in range(i + 1 ,						__A			):
                     if numbers[j] < numbers[i]:
                            UpperCAmelCase__						,			UpperCAmelCase__										=     numbers[j], numbers[i]
       return numbers


if __name__ == "__main__":
    A      = input("Enter numbers separated by a comma:\n").strip()
    A      = [int(item) for item in user_input.split(",")]
    print(exchange_sort(unsorted))





