Buggy python submission (verdict: Time Limit Exceeded):
import bisect

a,b,q=map(int,input().split())
s = []
t = []
for i in range(a):
  s.append(int(input()))
for i in range(b):
  t.append(int(input()))
for _ in range(q):
  x = int(input())
  
  ans = [0,0,0]
  
  if x in s:
    sl = 0
    sr = 0
  else:
    i = bisect.bisect_left(s,x)
    if i == 0:
      sl = 100000000000
    else:
      sl = abs(s[i-1]-x)
    if i == a:
      sr = 100000000000
    else:
      sr = abs(s[i]-x)
  if x in t:
    tl = 0
    tr = 0
  else:
    i = bisect.bisect_left(t,x)
    if i == 0:
      tl = 100000000000
    else:
      tl = abs(t[i-1]-x)
    if i == b:
      tr = 100000000000
    else:
      tr = abs(t[i]-x)
  ans[0] = max(tl,sl)
  ans[1] = max(tr,sr)
  ans[2] = min(2*tl+sr,2*sl+tr,2*sr+tl,2*tr+sl)
  print(min(ans))

Fixed submission:
import bisect

a,b,q=map(int,input().split())
s = []
t = []
for i in range(a):
  s.append(int(input()))
for i in range(b):
  t.append(int(input()))
for _ in range(q):
  x = int(input())
  
  ans = [0,0,0]
  
  i = bisect.bisect_left(s,x)
  if i == 0:
    sl = 100000000000
  else:
    sl = abs(s[i-1]-x)
  if i == a:
    sr = 100000000000
  else:
    sr = abs(s[i]-x)
  i = bisect.bisect_left(t,x)
  if i == 0:
    tl = 100000000000
  else:
    tl = abs(t[i-1]-x)
  if i == b:
    tr = 100000000000
  else:
    tr = abs(t[i]-x)
  ans[0] = max(tl,sl)
  ans[1] = max(tr,sr)
  ans[2] = min(2*tl+sr,2*sl+tr,2*sr+tl,2*tr+sl)
  print(min(ans))

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

a,b,q=map(int,input().split())
s = []
t = []
for i in range(a):
  s.append(int(input()))
for i in range(b):
  t.append(int(input()))
for _ in range(q):
  x = int(input())
  
  ans = [0,0,0,0]
  
  if x in s:
    sl = x
    sr = x
  else:
    i = bisect.bisect_left(s,x)
    sl = s[max(i-1,0)]
    sr = s[min(i,a-1)]
  if sl in t:
    tl = sl
    tr = sl
  else:
    j = bisect.bisect_left(t,sl)
    tl = t[max(j-1,0)]
    tr = t[min(j,b-1)]
  ans[0] = abs(sl-x) + min(abs(tl-sl), abs(tr-sl))
  if sr in t:
    tl = sr
    tr = sr
  else:
    j = bisect.bisect_left(t,sr)
    tl = t[j]
    tr = t[min(j+1,b-1)]
  ans[1] = abs(sr-x) + min(abs(tl-sr), abs(tr-sr))
  
  if x in t:
    tl = x
    tr = x
  else:
    i = bisect.bisect_left(t,x)
    tl = t[max(i-1,0)]
    tr = t[min(i,b-1)]
  if tl in s:
    sl = tl
    sr = tl
  else:
    j = bisect.bisect_left(s,tl)
    sl = s[max(j-1,0)]
    sr = s[min(j,a-1)]
  ans[2] = abs(tl-x) + min(abs(sl-tl), abs(sr-tl))
  if tr in s:
    sl = tr
    sr = tr
  else:
    j = bisect.bisect_left(s,tr)
    sl = s[max(j-1,0)]
    sr = s[min(j,a-1)]
  ans[3] = abs(tr-x) + min(abs(sl-tr), abs(sr-tr))
  print(min(ans))

Fixed submission:
import bisect

a,b,q=map(int,input().split())
s = []
t = []
for i in range(a):
  s.append(int(input()))
for i in range(b):
  t.append(int(input()))
for _ in range(q):
  x = int(input())
  
  ans = [0,0,0]
  
  i = bisect.bisect_left(s,x)
  if i == 0:
    sl = 100000000000
  else:
    sl = abs(s[i-1]-x)
  if i == a:
    sr = 100000000000
  else:
    sr = abs(s[i]-x)
  i = bisect.bisect_left(t,x)
  if i == 0:
    tl = 100000000000
  else:
    tl = abs(t[i-1]-x)
  if i == b:
    tr = 100000000000
  else:
    tr = abs(t[i]-x)
  ans[0] = max(tl,sl)
  ans[1] = max(tr,sr)
  ans[2] = min(2*tl+sr,2*sl+tr,2*sr+tl,2*tr+sl)
  print(min(ans))