Buggy python submission (verdict: Runtime Error):
import math
import bisect
import itertools
import sys


def most_simRL(ds, x):
    index = bisect.bisect_left(ds, x)
    if index == 0:
        return [ds[0]]
    elif index == len(ds):
        return [ds[-1]]
    return ds[index-1:index+1]

if __name__ == '__main__':
    A, B, Q = map(int, input().split())


    s_list = [-math.inf] + [int(input()) for i in range(A)] + [math.inf]
    t_list = [-math.inf] + [int(input()) for i in range(B)] + [math.inf]
    x_list = [int(input()) for i in range(Q)]


    for xi in x_list:
        s_RL = most_simRL(s_list, xi)
        t_RL = most_simRL(t_list, xi)

        answer = sys.maxsize

        for a, b in itertools.product(s_RL, t_RL):
            answer = min(answer, min(abs(xi-a), abs(xi-b)) + abs(a-b))

        print(answer)


Fixed submission:
import bisect
import itertools
import sys


def most_simRL(ds, x):
    index = bisect.bisect_left(ds, x)
    if index == 0:
        return [ds[0]]
    elif index == len(ds):
        return [ds[-1]]
    return ds[index-1:index+1]

if __name__ == '__main__':
    A, B, Q = map(int, input().split())


    s_list = [-sys.maxsize] + [int(input()) for i in range(A)] + [sys.maxsize]
    t_list = [-sys.maxsize] + [int(input()) for i in range(B)] + [sys.maxsize]
    x_list = [int(input()) for i in range(Q)]


    for xi in x_list:
        s_RL = most_simRL(s_list, xi)
        t_RL = most_simRL(t_list, xi)

        answer = sys.maxsize

        for a, b in itertools.product(s_RL, t_RL):
            answer = min(answer, min(abs(xi-a), abs(xi-b)) + abs(a-b))

        print(answer)

Buggy python submission (verdict: Runtime Error):
if __name__ == '__main__':
    A, B, Q = map(int, input().split())

    s_list = [int(input()) for i in range(A)]
    t_list = [int(input()) for i in range(B)]
    x_list = [int(input()) for i in range(Q)]

    for xi in x_list:
        distance_ti_right_xi = [ti-xi for ti in t_list if ti >= xi]
        distance_ti_left_xi = [xi-ti for ti in t_list if ti <= xi]
        distance_si_right_xi = [si-xi for si in s_list if si >= xi]
        distance_si_left_xi = [xi-si for si in s_list if si <= xi]
        
        first_move = min(distance_si_left_xi, distance_si_right_xi, distance_ti_left_xi, distance_ti_right_xi)
        if first_move == distance_ti_left_xi or first_move == distance_si_left_xi:
            first_move = -1 * first_move
        xi += first_move

        if abs(first_move) == distance_si_left_xi or abs(first_move) == distance_si_right_xi:
            distance_ti_right_xi = [ti-xi for ti in t_list if ti >= xi]
            distance_ti_left_xi = [xi-ti for ti in t_list if ti <= xi]
            second_move = min(distance_ti_left_xi, distance_ti_right_xi)

        if abs(first_move) == distance_ti_left_xi or abs(first_move) == distance_ti_right_xi:
            distance_si_right_xi = [si-xi for si in s_list if si >= xi]
            distance_si_left_xi = [xi-si for si in s_list if si <= xi]
            second_move = min(distance_si_left_xi, distance_si_right_xi)
        answer = abs(first_move) + abs(second_move)
        print(answer)

Fixed submission:
import bisect
import itertools
import sys


def most_simRL(ds, x):
    index = bisect.bisect_left(ds, x)
    if index == 0:
        return [ds[0]]
    elif index == len(ds):
        return [ds[-1]]
    return ds[index-1:index+1]

if __name__ == '__main__':
    A, B, Q = map(int, input().split())


    s_list = [-sys.maxsize] + [int(input()) for i in range(A)] + [sys.maxsize]
    t_list = [-sys.maxsize] + [int(input()) for i in range(B)] + [sys.maxsize]
    x_list = [int(input()) for i in range(Q)]


    for xi in x_list:
        s_RL = most_simRL(s_list, xi)
        t_RL = most_simRL(t_list, xi)

        answer = sys.maxsize

        for a, b in itertools.product(s_RL, t_RL):
            answer = min(answer, min(abs(xi-a), abs(xi-b)) + abs(a-b))

        print(answer)