Buggy python submission (verdict: Runtime Error):
counter = 0

def merge(L, R, left, right):
    A=[]
    L.append(float('inf'))
    R.append(float('inf'))

    i,j=(0,0)
    global counter
    for n in range(0,right-left):
        counter = counter+1
        if L[i]<=R[j]:
            A[n]=L[i]
            i=i+1
        else:
            A[n]=R[j]
            j=j+1
    return A

def mergeSort(A, left, right):
    if left+1 < right:
        mid = int((left+right)/2)
        L = mergeSort(A[left:mid],0,mid-left)
        R = mergeSort(A[mid:right],0,right-mid)
        A = merge(L, R, left, right)
    return A

n = int(input())
l = list(map(int,input().split()))
ll = mergeSort(l,0,n)
print(*ll)
print(counter)

Fixed submission:
counter = 0

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    #print(L)
    #print(R)
    L.append(float('inf'))
    R.append(float('inf'))
    i=j=0
    global counter
    for k in range(left,right):
        counter = counter+1
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1

def mergeSort(A, left, right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n = int(input())
l = list(map(int,input().split()))
mergeSort(l,0,n)
print(*l)
print(counter)

Buggy python submission (verdict: Time Limit Exceeded):
counter = 0

def merge(L, R, left, right):
    A = [i for i in range(0,right-left)]
    L.append(float('inf'))
    R.append(float('inf'))

    i,j=(0,0)
    global counter
    for n in range(0,right-left):
        counter = counter+1
        if L[i]<=R[j]:
            A[n]=L[i]
            i=i+1
        else:
            A[n]=R[j]
            j=j+1
    return A

def mergeSort(A, left, right):
    if left+1 < right:
        mid = int((left+right)/2)
        L = mergeSort(A[left:mid],0,mid-left)
        R = mergeSort(A[mid:right],0,right-mid)
        A = merge(L, R, left, right)
    return A

n = int(input())
l = list(map(int,input().split()))
ll = mergeSort(l,0,n)
print(*ll)
print(counter)

Fixed submission:
counter = 0

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    #print(L)
    #print(R)
    L.append(float('inf'))
    R.append(float('inf'))
    i=j=0
    global counter
    for k in range(left,right):
        counter = counter+1
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1

def mergeSort(A, left, right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n = int(input())
l = list(map(int,input().split()))
mergeSort(l,0,n)
print(*l)
print(counter)

Buggy python submission (verdict: Runtime Error):
counter = 0

def merge(L, R, left, right):
    A = range(0,right-left)
    L.append(float('inf'))
    R.append(float('inf'))

    i,j=(0,0)
    global counter
    for n in range(0,right-left):
        counter = counter+1
        if L[i]<=R[j]:
            A[n]=L[i]
            i=i+1
        else:
            A[n]=R[j]
            j=j+1
    return A

def mergeSort(A, left, right):
    if left+1 < right:
        mid = int((left+right)/2)
        L = mergeSort(A[left:mid],0,mid-left)
        R = mergeSort(A[mid:right],0,right-mid)
        A = merge(L, R, left, right)
    return A

n = int(input())
l = list(map(int,input().split()))
ll = mergeSort(l,0,n)
print(*ll)
print(counter)

Fixed submission:
counter = 0

def merge(A, left, mid, right):
    L = A[left:mid]
    R = A[mid:right]
    #print(L)
    #print(R)
    L.append(float('inf'))
    R.append(float('inf'))
    i=j=0
    global counter
    for k in range(left,right):
        counter = counter+1
        if L[i]<=R[j]:
            A[k]=L[i]
            i=i+1
        else:
            A[k]=R[j]
            j=j+1

def mergeSort(A, left, right):
    if left+1<right:
        mid=(left+right)//2
        mergeSort(A,left,mid)
        mergeSort(A,mid,right)
        merge(A,left,mid,right)

n = int(input())
l = list(map(int,input().split()))
mergeSort(l,0,n)
print(*l)
print(counter)