Complexity runs a Python example for sizes n from 10 to 500, counts the lines run and draws them beside n, n log n and n². The growth that fits best is named.

n = int(input())
a = list(map(int, input().split()))
pairs = 0
for i in range(n):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            pairs += 1
print(pairs)

6
5 2 8 1 9 3
Student
  1. Click Complexity: the example counts the inverted pairs with two loops, so the lines grow like n².
  2. Keep for comparison, change the program, measure again and compare both curves.
Teacher
  1. The input for the size n is made from the default input: the first number is n, the numbers after it are random.