Buggy python submission (verdict: Runtime Error):
def bubble(A):
    flag = True
    n = len(A)
    i = 0
    while flag:
        flag = False
        for j in range(n-1,i,-1):
           if A[j][1] < A[j-1][1]:
               A[j],A[j-1] = A[j-1],A[j]
               flag = True
        i += 1
 
 
def selection(A):
    n = len(A)
    for i in range(n):
        minj = i
        for j in range(i,n):
            if A[j][1] < A[minj][1]:
                minj = j
        if i != minj:
            A[i],A[minj] = A[minj],A[i]
             
   
           
n = int(input())
ss = [x for x in input().split()]     
ss2 = ss.copy()
 
 
bubble(ss)
for i in range(len(ss)-1):
    print(ss[i], end=' ')
print(ss[-1])
print('Stable')
    
 
selection(ss2)
for i in range(len(ss2)-1):
    print(ss2[i], end=' ')
print(ss2[-1])
if ss == ss2:
    print('Stable')
else:
    print('Not stable')


Fixed submission:
n = int(input())
*A, = input().split()
B = A[:]
for i in range(n):
    for j in range(n-1, i, -1):
        if A[j][1] < A[j-1][1]:
            A[j], A[j-1] = A[j-1], A[j]
print(*A)
print("Stable")
 
for i in range(n):
    minj = i
    for j in range(i, n):
        if B[j][1] < B[minj][1]:
            minj = j
    B[i], B[minj] = B[minj], B[i]
print(*B)
if A == B:
    print("Stable")
else:
    print("Not stable")

Buggy python submission (verdict: Runtime Error):
def bubble(A):
    flag = True
    n = len(A)
    i = 0
    while flag:
        flag = False
        for j in range(n-1,i,-1):
           if A[j][1] < A[j-1][1]:
               A[j],A[j-1] = A[j-1],A[j]
               flag = True
        i += 1
 
 
def selection(A):
    n = len(A)
    for i in range(n):
        minj = i
        for j in range(i,n):
            if A[j][1] < A[minj][1]:
                minj = j
        if i != minj:
            A[i],A[minj] = A[minj],A[i]
             
   
           
n = int(input())
ss = list(map(int,input().split()))
ss2 = ss.copy()
 
 
bubble(ss)
for i in range(len(ss)-1):
    print(ss[i], end=' ')
print(ss[-1])
print('Stable')
    
 
selection(ss2)
for i in range(len(ss2)-1):
    print(ss2[i], end=' ')
print(ss2[-1])
if ss == ss2:
    print('Stable')
else:
    print('Not stable')


Fixed submission:
n = int(input())
*A, = input().split()
B = A[:]
for i in range(n):
    for j in range(n-1, i, -1):
        if A[j][1] < A[j-1][1]:
            A[j], A[j-1] = A[j-1], A[j]
print(*A)
print("Stable")
 
for i in range(n):
    minj = i
    for j in range(i, n):
        if B[j][1] < B[minj][1]:
            minj = j
    B[i], B[minj] = B[minj], B[i]
print(*B)
if A == B:
    print("Stable")
else:
    print("Not stable")

Buggy python submission (verdict: Runtime Error):
def bubble(A):
    flag = True
    n = len(A)
    i = 0
    while flag:
        flag = False
        for j in range(n-1,i,-1):
           if A[j][1] < A[j-1][1]:
               A[j],A[j-1] = A[j-1],A[j]
               flag = True
        i += 1
 
 
def selection(A):
    n = len(A)
    for i in range(n):
        minj = i
        for j in range(i,n):
            if A[j][1] < A[minj][1]:
                minj = j
        if i != minj:
            A[i],A[minj] = A[minj],A[i]
             
   
           
n = int(input())
ss = list(map(int,input().split()))
ss2 = ss.copy()
 
 
bubble(ss)
for i in range(len(ss)-1):
    print(ss[i], end=' ')
print(ss[-1])
print('Stable')
    
 
selection(ss2)
for i in range(len(ss2)-1):
    print(ss2[i], end=' ')
print(ss2[-1])
if ss == ss2:
    print('Stable')
else:
    print('Not stable')


Fixed submission:
n = int(input())
*A, = input().split()
B = A[:]
for i in range(n):
    for j in range(n-1, i, -1):
        if A[j][1] < A[j-1][1]:
            A[j], A[j-1] = A[j-1], A[j]
print(*A)
print("Stable")
 
for i in range(n):
    minj = i
    for j in range(i, n):
        if B[j][1] < B[minj][1]:
            minj = j
    B[i], B[minj] = B[minj], B[i]
print(*B)
if A == B:
    print("Stable")
else:
    print("Not stable")