Buggy python submission (verdict: Time Limit Exceeded):
A, B, Q = list(map(int, raw_input().split()))

jinja = list()
for a in xrange(A): jinja.append(long(raw_input()))
tera = list()
for b in xrange(B): tera.append(long(raw_input()))

max_val = 10000000000000000.0

for q in xrange(Q):
    question = long(raw_input())
    if jinja[0] >= question:
        min_jinja = max_val
        max_jinja = jinja[0] - question
    elif jinja[-1] <= question:
        min_jinja = question - jinja[-1]
        max_jinja = max_val
    else:
        for a in xrange(A-1):
            if jinja[a] <= question and jinja[a+1] >= question:
                min_jinja = question - jinja[a]
                max_jinja = jinja[a+1] - question
    if tera[0] >= question:
        min_tera = max_val
        max_tera = tera[0] - question
    elif tera[-1] <= question:
        min_tera = question - tera[-1]
        max_tera = max_val
    else:
        for b in xrange(B-1):
            if tera[b] <= question and tera[b+1] >= question:
                min_tera = question - tera[b]
                max_tera =  tera[b+1] - question

    if max_tera == max_val and max_jinja == max_val:
        if min_jinja >= min_tera: print min_jinja
        else: print min_tera
    elif min_tera == max_val and min_jinja == max_val:
        if max_jinja >= max_tera: print max_jinja
        else: print max_tera
    elif min_jinja > min_tera and max_tera < max_jinja:
        if min_jinja >= max_jinja: print max_jinja
        else: print min_jinja
    elif min_tera < min_jinja and min_jinja < max_tera:
        if min_tera >= max_tera: print max_tera
        else: print min_tera
    elif min_tera <= min_jinja:
        print min(min_jinja, min_tera*2 + max_jinja, min_tera + max_jinja*2, max_tera)
    elif min_jinja <= min_tera:
        print min(min_tera, min_jinja*2 + max_tera, min_jinja + max_tera*2, max_jinja)

Fixed submission:
import bisect

A, B, Q = list(map(int, raw_input().split()))

max_val = 10.0 ** 15

jinja = list()
jinja.append(-max_val)
for a in xrange(A): jinja.append(long(raw_input()))
jinja.append(max_val)
tera = list()
tera.append(-max_val)
for b in xrange(B): tera.append(long(raw_input()))
tera.append(max_val)

for q in xrange(Q):
    question = long(raw_input())
    idx_tera, idx_jinja = bisect.bisect_right(tera, question), bisect.bisect_right(jinja, question)

    cost = max_val
    for T in [tera[idx_tera-1], tera[idx_tera]]:
        for S in [jinja[idx_jinja-1], jinja[idx_jinja]]:
            d_T = abs(T - question) + abs(S - T) # pattern1: question -> T -> S
            d_S = abs(S - question) + abs(T - S) # pattern2: question -> S -> T
            cost = min(cost, d_T, d_S)
    print cost

Buggy python submission (verdict: Time Limit Exceeded):
A, B, Q = list(map(int, raw_input().split()))

jinja = list()
for a in xrange(A): jinja.append(long(raw_input()))
tera = list()
for b in xrange(B): tera.append(long(raw_input()))

max_val = 10000000000000000.0

for q in xrange(Q):
    question = long(raw_input())
    if jinja[0] >= question:
        min_jinja = max_val
        max_jinja = jinja[0] - question
    elif jinja[-1] <= question:
        min_jinja = question - jinja[-1]
        max_jinja = max_val
    else:
        for a in xrange(A-1):
            if jinja[a] <= question and jinja[a+1] >= question:
                min_jinja = question - jinja[a]
                max_jinja = jinja[a+1] - question
    if tera[0] >= question:
        min_tera = max_val
        max_tera = tera[0] - question
    elif tera[-1] <= question:
        min_tera = question - tera[-1]
        max_tera = max_val
    else:
        for b in xrange(B-1):
            if tera[b] <= question and tera[b+1] >= question:
                min_tera = question - tera[b]
                max_tera =  tera[b+1] - question

    if max_tera == max_val and max_jinja == max_val:
        if min_jinja >= min_tera: print min_jinja
        else: print min_tera
    elif min_tera == max_val and min_jinja == max_val:
        if max_jinja >= max_tera: print max_jinja
        else: print max_tera
    elif min_jinja > min_tera and max_tera < max_jinja:
        if min_jinja >= max_jinja: print max_jinja
        else: print min_jinja
    elif min_tera < min_jinja and min_jinja < max_tera:
        if min_tera >= max_tera: print max_tera
        else: print min_tera
    elif min_tera <= min_jinja:
        dist = [min_jinja, min_tera*2 + max_jinja, min_tera + max_jinja*2, max_tera]
        dist.sort()
        print dist[0]
    elif min_jinja <= min_tera:
        dist = [min_tera, min_jinja*2 + max_tera, min_jinja + max_tera*2, max_jinja]
        dist.sort()
        print dist[0]

Fixed submission:
import bisect

A, B, Q = list(map(int, raw_input().split()))

max_val = 10.0 ** 15

jinja = list()
jinja.append(-max_val)
for a in xrange(A): jinja.append(long(raw_input()))
jinja.append(max_val)
tera = list()
tera.append(-max_val)
for b in xrange(B): tera.append(long(raw_input()))
tera.append(max_val)

for q in xrange(Q):
    question = long(raw_input())
    idx_tera, idx_jinja = bisect.bisect_right(tera, question), bisect.bisect_right(jinja, question)

    cost = max_val
    for T in [tera[idx_tera-1], tera[idx_tera]]:
        for S in [jinja[idx_jinja-1], jinja[idx_jinja]]:
            d_T = abs(T - question) + abs(S - T) # pattern1: question -> T -> S
            d_S = abs(S - question) + abs(T - S) # pattern2: question -> S -> T
            cost = min(cost, d_T, d_S)
    print cost