Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappushpop

N = int(input())
a = list(map(int, input().split()))

max_score = float('-inf')
a_list_1_init = []
a_list_2_init = []
for i in a[0:N]:
    heappush(a_list_1_init, i)
for i in list(reversed(a))[0:N]:
    heappush(a_list_2_init, -i)

sum_1_init = sum(a_list_1_init)
sum_2_init = sum(a_list_2_init)
for i in range(N, 2 * N + 1):
    a_list_1 = list(a_list_1_init)
    a_list_2 = list(a_list_2_init)
    sum_1 = sum_1_init
    sum_2 = sum_2_init
    for k in a[N:i]:
        l = heappushpop(a_list_1, k)
        sum_1 += k - l
    for k in a[i:2*N]:
        l = heappushpop(a_list_2, -k)
        sum_2 += -k - l
    score = sum_1 + sum_2
    if score > max_score:
        max_score = score

print(max_score)

Fixed submission:
from heapq import heappush, heappushpop

N = int(input())
a = list(map(int, input().split()))

a_list_1 = []
a_list_2 = []
for i in a[0:N]:
    heappush(a_list_1, i)
for i in list(reversed(a))[0:N]:
    heappush(a_list_2, -i)

sum_1 = sum(a_list_1)
sum_2 = sum(a_list_2)
sum_arr_1 = [0] * (N + 1)
sum_arr_1[0] = sum_1
sum_arr_2 = [0] * (N + 1)
sum_arr_2[-1] = sum_2
for k in range(N, 2 * N):
    l = heappushpop(a_list_1, a[k])
    sum_1 += a[k] - l
    sum_arr_1[k - N + 1] = sum_1

for k in reversed(range(N, 2 * N)):
    l = heappushpop(a_list_2, -a[k])
    sum_2 += -a[k] - l
    sum_arr_2[k - N] = sum_2

max_score = float('-inf')
for s1, s2 in zip(sum_arr_1, sum_arr_2):
    score = s1 + s2
    if score > max_score:
        max_score = score

print(max_score)

Buggy python submission (verdict: Time Limit Exceeded):
from heapq import heappush, heappushpop

N = int(input())
a = list(map(int, input().split()))

max_score = float('-inf')
for i in range(N, 2 * N + 1):
    rm_count_1 = i - N
    rm_count_2 = N - rm_count_1
    a_list_1 = []
    a_list_2 = []
    for k in a[0:i]:
        if len(a_list_1) >= N:
            heappushpop(a_list_1, k)
        else:
            heappush(a_list_1, k)
    for k in a[i:3*N]:
        if len(a_list_2) >= N:
            heappushpop(a_list_2, -k)
        else:
            heappush(a_list_2, -k)
    sum_1 = sum(a_list_1)
    sum_2 = sum(a_list_2)
    score = sum_1 + sum_2
    if score > max_score:
        max_score = score

print(max_score)

Fixed submission:
from heapq import heappush, heappushpop

N = int(input())
a = list(map(int, input().split()))

a_list_1 = []
a_list_2 = []
for i in a[0:N]:
    heappush(a_list_1, i)
for i in list(reversed(a))[0:N]:
    heappush(a_list_2, -i)

sum_1 = sum(a_list_1)
sum_2 = sum(a_list_2)
sum_arr_1 = [0] * (N + 1)
sum_arr_1[0] = sum_1
sum_arr_2 = [0] * (N + 1)
sum_arr_2[-1] = sum_2
for k in range(N, 2 * N):
    l = heappushpop(a_list_1, a[k])
    sum_1 += a[k] - l
    sum_arr_1[k - N + 1] = sum_1

for k in reversed(range(N, 2 * N)):
    l = heappushpop(a_list_2, -a[k])
    sum_2 += -a[k] - l
    sum_arr_2[k - N] = sum_2

max_score = float('-inf')
for s1, s2 in zip(sum_arr_1, sum_arr_2):
    score = s1 + s2
    if score > max_score:
        max_score = score

print(max_score)

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

N = int(input())
a = list(map(int, input().split()))

max_score = float('-inf')
for i in range(N, 2 * N + 1):
    rm_count_1 = i - N
    rm_count_2 = N - rm_count_1
    a_list_1 = []
    a_list_2 = []
    for k in a[0:i]:
        if len(a_list_1) >= N:
            heappushpop(a_list_1, k)
        else:
            heappush(a_list_1, k)
    for k in a[i:3*N]:
        if len(a_list_2) >= N:
            heappushpop(a_list_2, -k)
        else:
            heappush(a_list_2, -k)
    sum_1 = sum(a_list_1)
    sum_2 = sum(a_list_2)
    score = sum_1 + sum_2
    if score > max_score:
        max_score = score

print(max_score)

Fixed submission:
from heapq import heappush, heappushpop

N = int(input())
a = list(map(int, input().split()))

a_list_1 = []
a_list_2 = []
for i in a[0:N]:
    heappush(a_list_1, i)
for i in list(reversed(a))[0:N]:
    heappush(a_list_2, -i)

sum_1 = sum(a_list_1)
sum_2 = sum(a_list_2)
sum_arr_1 = [0] * (N + 1)
sum_arr_1[0] = sum_1
sum_arr_2 = [0] * (N + 1)
sum_arr_2[-1] = sum_2
for k in range(N, 2 * N):
    l = heappushpop(a_list_1, a[k])
    sum_1 += a[k] - l
    sum_arr_1[k - N + 1] = sum_1

for k in reversed(range(N, 2 * N)):
    l = heappushpop(a_list_2, -a[k])
    sum_2 += -a[k] - l
    sum_arr_2[k - N] = sum_2

max_score = float('-inf')
for s1, s2 in zip(sum_arr_1, sum_arr_2):
    score = s1 + s2
    if score > max_score:
        max_score = score

print(max_score)

Buggy python submission (verdict: Runtime Error):
from collections import heapq

N = int(input())
a = list(map(int, input().split()))

max_score = float('-inf')
for i in range(N, 2 * N + 1):
    rm_count_1 = i - N
    rm_count_2 = N - rm_count_1
    a_list_1 = []
    a_list_2 = []
    for k in a[0:i]:
        if len(a_list_1) >= N:
            heappushpop(a_list_1, k)
        else:
            heappush(a_list_1, k)
    for k in a[i:3*N]:
        if len(a_list_2) >= N:
            heappushpop(a_list_2, -k)
        else:
            heappush(a_list_2, -k)
    sum_1 = sum(a_list_1)
    sum_2 = sum(a_list_2)
    score = sum_1 + sum_2
    if score > max_score:
        max_score = score

print(max_score)

Fixed submission:
from heapq import heappush, heappushpop

N = int(input())
a = list(map(int, input().split()))

a_list_1 = []
a_list_2 = []
for i in a[0:N]:
    heappush(a_list_1, i)
for i in list(reversed(a))[0:N]:
    heappush(a_list_2, -i)

sum_1 = sum(a_list_1)
sum_2 = sum(a_list_2)
sum_arr_1 = [0] * (N + 1)
sum_arr_1[0] = sum_1
sum_arr_2 = [0] * (N + 1)
sum_arr_2[-1] = sum_2
for k in range(N, 2 * N):
    l = heappushpop(a_list_1, a[k])
    sum_1 += a[k] - l
    sum_arr_1[k - N + 1] = sum_1

for k in reversed(range(N, 2 * N)):
    l = heappushpop(a_list_2, -a[k])
    sum_2 += -a[k] - l
    sum_arr_2[k - N] = sum_2

max_score = float('-inf')
for s1, s2 in zip(sum_arr_1, sum_arr_2):
    score = s1 + s2
    if score > max_score:
        max_score = score

print(max_score)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))

max_score = float('-inf')
for i in range(N, 2 * N + 1):
    rm_count_1 = i - N
    rm_count_2 = N - rm_count_1
    a_list_1 = sorted(a[0:i])
    a_list_2 = sorted(a[i:3 * N])
    sum_1 = sum(a_list_1[rm_count_1:i])
    sum_2 = sum(a_list_2[0:N])
    score = sum_1 - sum_2
    if score > max_score:
        max_score = score

print(max_score)

Fixed submission:
from heapq import heappush, heappushpop

N = int(input())
a = list(map(int, input().split()))

a_list_1 = []
a_list_2 = []
for i in a[0:N]:
    heappush(a_list_1, i)
for i in list(reversed(a))[0:N]:
    heappush(a_list_2, -i)

sum_1 = sum(a_list_1)
sum_2 = sum(a_list_2)
sum_arr_1 = [0] * (N + 1)
sum_arr_1[0] = sum_1
sum_arr_2 = [0] * (N + 1)
sum_arr_2[-1] = sum_2
for k in range(N, 2 * N):
    l = heappushpop(a_list_1, a[k])
    sum_1 += a[k] - l
    sum_arr_1[k - N + 1] = sum_1

for k in reversed(range(N, 2 * N)):
    l = heappushpop(a_list_2, -a[k])
    sum_2 += -a[k] - l
    sum_arr_2[k - N] = sum_2

max_score = float('-inf')
for s1, s2 in zip(sum_arr_1, sum_arr_2):
    score = s1 + s2
    if score > max_score:
        max_score = score

print(max_score)