Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
count = 0
Flag = 1
while Flag:
    flag = 0
    for i in range(N):
        for j in range(i, N):
            if(A[j] < A[j-1]):
                temp = A[j-1]
                A[j-1] = A[j]
                A[j] = temp
                flag = 1 
                count += 1
print(*A)
print(count)
            

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
count = 0
Flag = 1
while Flag:
    flag = 0
    for i in range(N-1, 1):
        if(A[i] < A[i-1]):
            temp = A[i-1]
            A[i-1] = A[i]
            A[i] = temp
            flag = 1 
            count += 1
print(*A)
print(count)
            

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0
Flag = True
while Flag:
    Fag = Flase
    for i in range(N-1, 1):
        if(A[i] < A[i-1]):
            temp = A[i-1]
            A[i-1] = A[i]
            A[i] = temp
            Flag = True
            count += 1
print(*A)
print(count)
            

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0
Flag = True
while Flag:
    Flag = Flase
    for i in range(N-1, 1):
        if(A[i] < A[i-1]):
            temp = A[i-1]
            A[i-1] = A[i]
            A[i] = temp
            Flag = True
            count += 1
print(*A)
print(count)
            

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while Flag:
    flag = False
    for i in range(N-1, 1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)
            

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
count = 0
flag = True
while flag:
    flag = False
    for i in range(N-1, 0, -1):
        if(A[i] < A[i-1]):
            A[i], A[i-1] = A[i-1], A[i]
            flag = True
            count += 1
print(*A)
print(count)