def insertion_sort_counting(A):
    """Instrumented Insertion Sort to return #swaps, #compares."""
    N = len(A)
    num_swap = num_compare = 0
    for i in range(N):
        for j in range(i,0,-1):
            num_compare += 1
            if A[j-1] <= A[j]:
                break
            num_swap += 1
            A[j],A[j-1] = A[j-1],A[j]
    return (num_swap, num_compare)