Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import bisect
INF = 10**15
def solve(a, b, q, s, t, x):
    for xi in x:
        sl = s[bisect.bisect_left(s, xi+1)-1]
        tl = t[bisect.bisect_left(t, xi+1)-1]
        sr = s[bisect.bisect_right(s, xi-1)]
        tr = t[bisect.bisect_right(t, xi-1)]
        ans = min([
            max(sr-xi, tr-xi),
            max(xi-sl, xi-tl),
            (sr-xi+sr-tl),
            (xi-tl+sr-tl),
            (tr-xi+tr-sl),
            (xi-sl+tr-sl)
        ])
        print(ans)

a, b, q = map(int, input().split())
s = np.asarray([int(input()) for i in range(a)] + [-INF, INF], dtype=int)
t = np.asarray([int(input()) for i in range(b)] + [-INF, INF], dtype=int)
x = np.asarray([int(input()) for i in range(q)], dtype=int)
s.sort()
t.sort()
solve(a,b,q,s,t,x)

Fixed submission:
import numpy as np
import bisect
INF = 10**11
def solve(a, b, q, s, t, x):
    for xi in x:
        si = bisect.bisect_left(s, xi)
        ti = bisect.bisect_left(t, xi)
        sl = s[si-1]
        tl = t[ti-1]
        sr = s[si]
        tr = t[ti]
        ans = min([
            max(sr-xi, tr-xi),
            max(xi-sl, xi-tl),
            (sr-xi+sr-tl),
            (xi-tl+sr-tl),
            (tr-xi+tr-sl),
            (xi-sl+tr-sl)
        ])
        print(ans)

a, b, q = map(int, input().split())
s = np.asarray([int(input()) for i in range(a)] + [-INF, INF], dtype=int)
t = np.asarray([int(input()) for i in range(b)] + [-INF, INF], dtype=int)
x = np.asarray([int(input()) for i in range(q)], dtype=int)
s.sort()
t.sort()
solve(a,b,q,s,t,x)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
INF = 10**15
def f(s, x):
    n = len(s)
    lb = 0
    ub = n - 1
    prev = -1
    while True:
        cur = (lb+ub) // 2
        if s[cur] > x:
            ub = cur
        else:
            lb = cur
        if prev == cur:
            break
        prev = cur
    return cur-1 if (s[cur] > x) else cur

def g(s, x):
    n = len(s)
    lb = 0
    ub = n - 1
    prev = -1
    while True:
        cur = (lb+ub) // 2
        if s[cur] > x:
            ub = cur
        else:
            lb = cur
        if prev == cur:
            break
        prev = cur
    return cur+1 if (s[cur] < x) else cur

def solve(a, b, q, s, t, x):
    for xi in x:
        sl = s[f(s, xi)]
        tl = t[f(t, xi)]
        sr = s[g(s, xi)]
        tr = t[g(t, xi)]
        ans = min([
            max(sr-xi, tr-xi),
            max(xi-sl, xi-tl),
            (sr-xi+sr-tl),
            (xi-tl+sr-tl),
            (tr-xi+tr-sl),
            (xi-sl+tr-sl)
        ])
        print(ans)

a, b, q = map(int, input().split())
s = np.asarray([int(input()) for i in range(a)] + [-INF, INF], dtype=int)
t = np.asarray([int(input()) for i in range(b)] + [-INF, INF], dtype=int)
x = np.asarray([int(input()) for i in range(q)], dtype=int)
s.sort()
t.sort()
solve(a,b,q,s,t,x)

Fixed submission:
import numpy as np
import bisect
INF = 10**11
def solve(a, b, q, s, t, x):
    for xi in x:
        si = bisect.bisect_left(s, xi)
        ti = bisect.bisect_left(t, xi)
        sl = s[si-1]
        tl = t[ti-1]
        sr = s[si]
        tr = t[ti]
        ans = min([
            max(sr-xi, tr-xi),
            max(xi-sl, xi-tl),
            (sr-xi+sr-tl),
            (xi-tl+sr-tl),
            (tr-xi+tr-sl),
            (xi-sl+tr-sl)
        ])
        print(ans)

a, b, q = map(int, input().split())
s = np.asarray([int(input()) for i in range(a)] + [-INF, INF], dtype=int)
t = np.asarray([int(input()) for i in range(b)] + [-INF, INF], dtype=int)
x = np.asarray([int(input()) for i in range(q)], dtype=int)
s.sort()
t.sort()
solve(a,b,q,s,t,x)