Buggy python submission (verdict: Time Limit Exceeded):
import sys
from collections import deque

def merge(deq, left, mid, right, compare_counter):
    n_fore = mid - left
    n_rear = right - mid
    l_fore = [deq[left + i] for i in range(n_fore)]
    l_fore.append(sys.maxsize)
    #print(left, mid, right)
    l_rear = [deq[mid + i] for i in range(n_rear)]
    l_rear.append(sys.maxsize)
    i = j = 0
    for k in range(left, right):
        compare_counter[0] += 1
        if l_fore[i] < l_rear[j]:
            deq[k] = l_fore[i]
            i += 1
        else:
            deq[k] = l_rear[j]
            j += 1

def merge_sort(deq, left, right, compare_counter):
    compare_times = 0
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(deq, left, mid, compare_counter)
        merge_sort(deq, mid, right, compare_counter)
        merge(deq, left, mid, right, compare_counter)
    return compare_times

def main():
    n = int(input())
    deq = deque()
    [deq.append(int(x)) for x in input().split()]
    compare_counter = [0]
    compare_times = merge_sort(deq, 0, n, compare_counter)
    print(" ".join(map(str, deq)))
    print(compare_counter[0])
    return


main()


Fixed submission:
import sys
#import time

compare_counter = 0
array = [0 for x in range(500000)]

def merge(left, mid, right):
    n_fore = mid - left
    n_rear = right - mid
    l_fore = array[left:left + n_fore]
    l_fore.append(sys.maxsize)
    l_rear = array[mid:mid + n_rear]
    l_rear.append(sys.maxsize)

    #print(left, mid, right)
    i = j = 0
    global compare_counter
    compare_counter += (right - left)
    for k in range(left, right):
        if l_fore[i] < l_rear[j]:
            array[k] = l_fore[i]
            i += 1
        else:
            array[k] = l_rear[j]
            j += 1


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


def main():
    #start = time.time()
    n = int(input())
    for idx, tmp in enumerate(input().split()):
        array[idx] = int(tmp)
    #print("time", time.time()-start)
    merge_sort(0, n)
    #print("time", time.time()-start)
    print(" ".join(map(str, array[:n])))
    print(compare_counter)
    #print("time",time.time()-start)
    return


main()

Buggy python submission (verdict: Runtime Error):
import sys

compare_counter = 0
array = [0 for x in range(500000)]

def merge(left, mid, right):
    n_fore = mid - left
    n_rear = right - mid
    l_fore = array[left:left + n_fore]
    l_fore.append(sys.maxsize)
    l_rear = array[mid:mid + n_rear]
    l_rear.append(sys.maxsize)

    i = j = 0
    global compare_counter
    compare_counter += (right - left)
    for k in range(left, right):
        if l_fore[i] < l_rear[j]:
            array[k] = l_fore[i]
            i += 1
        else:
            array[k] = l_rear[j]
            j += 1


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


def main():
    start = time.time()
    n = int(input())
    for idx, tmp in enumerate(input().split()):
        array[idx] = int(tmp)

    merge_sort(0, n)

    print(" ".join(map(str, array[:n])))
    print(compare_counter)

    return


main()


Fixed submission:
import sys
#import time

compare_counter = 0
array = [0 for x in range(500000)]

def merge(left, mid, right):
    n_fore = mid - left
    n_rear = right - mid
    l_fore = array[left:left + n_fore]
    l_fore.append(sys.maxsize)
    l_rear = array[mid:mid + n_rear]
    l_rear.append(sys.maxsize)

    #print(left, mid, right)
    i = j = 0
    global compare_counter
    compare_counter += (right - left)
    for k in range(left, right):
        if l_fore[i] < l_rear[j]:
            array[k] = l_fore[i]
            i += 1
        else:
            array[k] = l_rear[j]
            j += 1


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


def main():
    #start = time.time()
    n = int(input())
    for idx, tmp in enumerate(input().split()):
        array[idx] = int(tmp)
    #print("time", time.time()-start)
    merge_sort(0, n)
    #print("time", time.time()-start)
    print(" ".join(map(str, array[:n])))
    print(compare_counter)
    #print("time",time.time()-start)
    return


main()