Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

def comp(i,j):
    # i < j <-> 1
    # i > j <-> -1
    # i == j <-> 0
    if len(i) < len(j):
        return 1
    elif len(i) > len(j):
        return -1
    for x in range(len(i)):
        if i[x] == j[x]:
            continue
        elif i[x] > j[x]:
            return -1
        else:
            return 1
    return 0



def bisect_left(array, i):
    __bisect_array = array
    def _bisect_left(i, left, right):
        n = right - left + 1
        mid = (left+right) // 2
        if n == 1:
            if comp(__bisect_array[mid],i) == 1:
                return 1
            else:
                return 0
        if comp(i, __bisect_array[mid]) >= 0:
            return _bisect_left(i,left,mid)
        else:
            return (mid-left+1) + _bisect_left(i,mid+1,right)
    return _bisect_left(i, 0, len(array)-1)

def bisect_right(array, i):
    __bisect_array = array
    def _bisect_right(i, left, right):
        n = right - left + 1
        mid = (right+left) // 2
        if n == 1:
            if comp(i, __bisect_array[mid]) == 1:
                return 0
            else:
                return 1
        if comp(__bisect_array[mid] ,i) >= 0:
            return  (mid-left+1) + _bisect_right(i,mid+1,right)
        else:
           return _bisect_right(i,left,mid)
    return _bisect_right(i, 0, len(array)-1)

N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    l = list(map(str,sorted(l)))
    L.append(l)
ans = 0
for x in L[1]:
    n = bisect_left(L[0],x)
    m = bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

### FIXED CODE ###

N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
import bisect
ans = 0
for x in L[1]:
    n = bisect.bisect_left(L[0],x)
    m = bisect.bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 998244353

N = int(input())
XY = [tuple(int(x) for x in input().split()) for _ in range(N)]
XY.sort() # X ascending
X,Y = zip(*XY)
Y_rank = {x:i for i,x in enumerate(sorted(Y),1)}

def BIT_update(tree,x):
    while x <= N:
        tree[x] += 1
        x += x & (-x)

def BIT_sum(tree,x):
    ret = 0
    while x:
        ret += tree[x]
        x -= x & (-x)
    return ret

pow2 = [1]
for _ in range(N):
    pow2.append(pow2[-1] * 2 % MOD)

answer = 0
tree = [0] * (N+1)
for L,y in enumerate(Y):
    y = Y_rank[y]
    R = N - 1 - L
    D = y - 1
    U = N - 1 - D
    LD = BIT_sum(tree,y)
    BIT_update(tree,y)
    LU = L - LD
    RD = D - LD
    RU = R - RD
    # bounding box が自分自身を含むような集合を数える
    # 全体から引く
    cnt = pow2[N]
    cnt -= pow2[L]
    cnt -= pow2[R]
    cnt -= pow2[D]
    cnt -= pow2[U]
    cnt += pow2[LD]
    cnt += pow2[LU]
    cnt += pow2[RD]
    cnt += pow2[RU]
    cnt -= 1
    answer += cnt

answer %= MOD

print(answer)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 998244353

N = int(input())
XY = [[int(x) for x in input().split()] for _ in range(N)]
XY.sort() # X ascending
X,Y = zip(*XY)
Y_rank = {x:i for i,x in enumerate(sorted(Y),1)}

def BIT_update(tree,x):
    while x <= N:
        tree[x] += 1
        x += x & (-x)

def BIT_sum(tree,x):
    ret = 0
    while x:
        ret += tree[x]
        x -= x & (-x)
    return ret

pow2 = [1]
for _ in range(N):
    pow2.append(pow2[-1] * 2 % MOD)

answer = 0
tree = [0] * (N+1)
for L,(x,y) in enumerate(XY):
    y = Y_rank[y]
    R = N - 1 - L
    D = y - 1
    U = N - 1 - D
    LD = BIT_sum(tree,y)
    BIT_update(tree,y)
    LU = L - LD
    RD = D - LD
    RU = R - RD
    # bounding box が自分自身を含むような集合を数える
    # 全体から引く
    cnt = pow2[N]
    cnt -= pow2[L]
    cnt -= pow2[R]
    cnt -= pow2[D]
    cnt -= pow2[U]
    cnt += pow2[LD]
    cnt += pow2[LU]
    cnt += pow2[RD]
    cnt += pow2[RU]
    cnt -= 1
    answer += cnt

answer %= MOD

print(answer)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)


from functools import lru_cache

n = list(map(int, list(input())))
m = len(n)

@lru_cache(10**10)
def rec(keta, tight):
    if keta == m:
        if tight:
            return 1
        else:
            return 0
    tmp = float("inf")
    for i in range(10):
        if tight:
            if i == 0:
                tmp = min(tmp, rec(keta+1, True)+9-n[keta])

            elif i <= n[keta]:
                tmp = min(tmp, rec(keta+1, True)+i+10+i-1-n[keta])
            else:
                tmp = min(tmp, rec(keta+1, False)+i+i-1-n[keta])
        else:
            if i < n[keta]:
                tmp = min(tmp, rec(keta+1, True)+i+(10+i)-n[keta])
            else:
               tmp = min(tmp, rec(keta+1, False)+i+i-n[keta])
    return tmp

ans = rec(0, False)
print(ans)

### FIXED CODE ###

n = list(map(int, list(input())))
m = len(n)

DP = [[float("inf")]*2 for i in range(m+1)]
DP[0] = [0,1]

for i in range(m):
    # tight
    tmp = float("inf")
    for j in range(10):
        if j == 0:
            tmp = min(tmp, DP[i][1]+9-n[i])
        elif j <= n[i]:
            tmp = min(tmp, DP[i][1]+j+10+j-1-n[i])
        else:
            tmp = min(tmp, DP[i][0]+j+j-1-n[i])
    DP[i+1][1] = tmp

    # not tight
    tmp = float("inf")
    for j in range(10):
        if j < n[i]:
            tmp = min(tmp, DP[i][1]+j+(10+j)-n[i])
        else:
            tmp = min(tmp, DP[i][0]+j+j-n[i])
    DP[i+1][0] = tmp

print(DP[-1][0])
### BUGGY CODE ###

import numpy as np
import sys
sys.setrecursionlimit(200000)

X = input()
Y = input()
lenX = len(X)
lenY = len(Y)
dp = np.full((lenX+1,lenY+1),"-1",dtype=object)
dp[0,:]=""
dp[:,0]=""
def f(i,j):
  if dp[i][j]=="-1":
    x = X[i-1]
    y = Y[j-1]
    lo = f(i-1,j-1)
    l = f(i,j-1)
    o = f(i-1,j)
    if x==y:
      dp[i][j]="".join([lo,x])
    else:
      if len(l)>=len(o):
        dp[i][j]=l
      else:
        dp[i][j]=o
  return dp[i][j]

print(f(lenX,lenY))

### FIXED CODE ###

# LongestCommonSubsequences
import numpy as np
S = np.array([ord(i)-97 for i in input()], dtype=int)
T = np.array([ord(i)-97 for i in input()], dtype=int)
Ns = len(S)
Nt = len(T)
equal = np.equal.outer(S, T).astype(int)

dp = [np.zeros(Nt + 1, dtype=int)]
for i in range(Ns):
    x = dp[-1].copy()
    newDP = x.copy()
    newDP[1:] = np.maximum(x[:-1] + equal[i], newDP[1:])
    np.maximum.accumulate(newDP, out=newDP)
    dp.append(newDP)


ans = ""
i, j = Ns, Nt
while i > 0 and j > 0:
    if S[i-1] == T[j-1]:
        ans += chr(S[i-1]+97)
        i -= 1
        j -= 1
        continue
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    else:
        j -= 1

print(ans[::-1])
### BUGGY CODE ###

S = input()
T = input()
LS = len(S); LT = len(T)

dp = [[-1]*(LT+1) for i in range(LS+1)]
nxt = [[(0, None, None)]*(LT+1) for i in range(LS+1)]
for i in range(LS-1, -1, -1):
    for j in range(LT-1, -1, -1):
        r0 = dp[i+1][j]; r1 = dp[i][j+1]
        r = max(r0, r1)
        x = (0, i, j+1) if r0 < r1 else (0, i+1, j)
        if S[i] == T[j]:
            r2 = dp[i+1][j+1] + 1
            if r < r2:
                r = r2
                x = (1, i+1, j+1)
        dp[i][j] = r
        nxt[i][j] = x

i = j = 0
ans = []
while i is not None:
    m, i0, j = nxt[i][j]
    if m:
        ans.append(S[i])
    i = i0
print(*ans, sep='')

### FIXED CODE ###

*S, = map(ord, input())
*T, = map(ord, input())
LS = len(S); LT = len(T)

dp = [[-1]*(LT+1) for i in range(LS+1)]
for i in range(LS-1, -1, -1):
    for j in range(LT-1, -1, -1):
        if S[i] == T[j]:
            dp[i][j] = max(dp[i+1][j+1] + 1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i][j] = max(dp[i+1][j], dp[i][j+1])
i = j = 0
ans = []
while i < LS and j < LT:
    if S[i] == T[j]:
        if dp[i][j] == dp[i+1][j+1] + 1:
            ans.append(S[i])
            i += 1; j += 1
        elif dp[i][j] == dp[i+1][j]:
            i += 1
        else:
            j += 1
    else:
        if dp[i][j] == dp[i+1][j]:
            i += 1
        else:
            j += 1
print(*map(chr, ans), sep='')
### BUGGY CODE ###

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

water_sum = sum(a)
kotae = [water_sum for _ in range(n)]

for i in range(n):
    for j in range(n // 2):
        kotae[i] -= 2*a[(i+1+2*j) % n]

print(" ".join(map(str, kotae)))

### FIXED CODE ###

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

water_sum = sum(a)
kotae = [-1 for _ in range(n)]

# 和を足しておく
kotae[0] = water_sum

# 全体の和からほかの山の水量を引いて行って山0の水量を求める
for i in range(n // 2):
    kotae[0] -= 2*a[(1+2*i) % n]

# 漸化式でほかのすべてを求める
for i in range(1, n):
    kotae[i] = 2*a[i-1] - kotae[i-1]

print(" ".join(map(str, kotae)))
### BUGGY CODE ###

n = int(input())
a_list = [int(i) for i in input().split()]
divide = 10 ** 9 + 7

inf=float("inf")
dp=[[inf for i in range(n+1)] for j in range(n+1)]

sum = 0
for i in range(n):
    for j in range(i+1, n):
        if dp[i][j] != inf or dp[j][i] != inf:
            sum += dp[i][j]
            print('yes')
        else:
            val =  a_list[i] ^ a_list[j]
            dp[i][j] = val
            dp[j][i] = val
            sum += val

print(sum % divide)

### FIXED CODE ###

n = int(input())
divide = 10 ** 9 + 7

a = [format(i, '060b') for i in map(int, input().split())]
ans = []

for i in range(60):
    bit_list = [b[59-i] for b in a]
    val = bit_list.count('0') * bit_list.count('1')
    ans.append((val * 2 ** i))

print(sum(ans)%divide)
### BUGGY CODE ###

from copy import copy
def solve():
    ans = 0
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for j in range(K):
        check = [0]*(N+1)
        for i in range(N):
            check[max(0,i-A[i])] += 1
            check[min(N,i+A[i]+1)] -= 1
        B = [check[0]]*N
        for i in range(1,N):
            B[i] = B[i-1]+check[i]
        A = copy(B)
        if A==[N]*N:
            break
    return A
print(*solve())

### FIXED CODE ###

from copy import copy
def solve():
    ans = 0
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for j in range(K):
        check = [0]*(N+1)
        for i in range(N):
            check[max(0,i-A[i])] += 1
            check[min(N,i+A[i]+1)] -= 1
        B = [check[0]]*N
        for i in range(1,N):
            B[i] = B[i-1]+check[i]
        A = copy(B)
        if A==[N]*N:
            break
    return A
print(*solve())
### BUGGY CODE ###

class LinkedList(object):
    def __init__(self):
        self.nodes = []
        self.first = None
        self.last = None

    def insert(self, key):
        node = {'key':key, 'next':None, 'prev':None}
        if not self.nodes:
            self.first = self.last = node
            self.nodes.append(node)
        else:
            node['next'] = self.first
            self.first['prev'] = node
            self.first = node
            self.nodes.append(node)

    def delete(self, key):
        node = self.first
        if len(self.nodes) == 1 and node['key'] == key:
            self.first = self.last = None
            self.nodes = []
            return
        if self.first['key'] == key:
            self.deleteFirst()
            return
        while node['next']:
            if node['key'] == key:
                node['prev']['next'] = node['next']
                node['next']['prev'] = node['prev']
                self.nodes.remove(node)
                return
            node = node['next']
        if self.last['key'] == key:
            self.deleteLast()

    def deleteFirst(self):
        if len(self.nodes) == 1:
            self.first = self.last = None
            self.nodes = []
        else:
            self.first['next']['prev'] = None
            self.nodes.remove(self.first)
            self.first = self.first['next']

    def deleteLast(self):
        if len(self.nodes) == 1:
            self.first = self.last = None
            self.nodes = []
        else:
            self.last['prev']['next'] = None
            self.nodes.remove(self.last)
            self.last = self.last['prev']

    def show(self):
        if not self.nodes:
            print('')
            return
        node = self.first
        res = [node['key']]
        while node['next']:
            node = node['next']
            res.append(node['key'])
        print(' '.join(res))

def run():
    n = int(input())
    linked_list = LinkedList()
    for _ in range(n):
        order = [o.strip() for o in input().split()]
        if order[0] == 'insert':
            linked_list.insert(order[1])
        elif order[0] == 'delete':
            linked_list.delete(order[1])
        elif order[0] == 'deleteFirst':
            linked_list.deleteFirst()
        elif order[0] == 'deleteLast':
            linked_list.deleteLast()
    linked_list.show()

if __name__ == '__main__':
    run()


### FIXED CODE ###

from collections import deque

def run():
    n = int(input())
    dq = deque()
    for _ in range(n):
        order = input()
        if order[0] == 'i':
            dq.appendleft(order[7:])
        elif order[6] == ' ':
            key = order.split()[1]
            if not key in dq:
                continue
            for i in range(len(dq)):
                if dq[i] == key:
                    dq.remove(key)
                    break
        elif order[6] == 'F':
            dq.popleft()
        elif order[6] == 'L':
            dq.pop()

    print(' '.join(dq))

if __name__ == '__main__':
    run()
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""

def simulation(N, K, A_list):
    for k in range(min(K, 42)):
        #next_A_list = [0 for i in range(N)]
        imos_list = [0 for i in range(N)]
        for i in range(N):
            d = A_list[i]
            imos_list[max(i-d, 0)] += 1
            if i+d+1 <= N-1:
                imos_list[i+d+1] -= 1
            #for j in range(i-d, i+d+1):
            #    if j >= 0 and j <= N-1:
            #        next_A_list[j] += 1
        for i in range(1, N):
            imos_list[i] += imos_list[i-1]
        A_list = imos_list[:]
        #print(" ".join([ str(i).zfill(2) for i in A_list]))
    return A_list

def main():
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    print(" ".join([ str(i) for i in simulation(N, K, A_list)]))

if __name__ == "__main__":
    main()



### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
@author: H_Hoshigi
"""

def simulation(N, K, A_list):
    for k in range(min(K, 42)):
        #next_A_list = [0 for i in range(N)]
        imos_list = [0 for i in range(N)]
        for i in range(N):
            d = A_list[i]
            imos_list[max(i-d, 0)] += 1
            if i+d+1 <= N-1:
                imos_list[i+d+1] -= 1
            #for j in range(i-d, i+d+1):
            #    if j >= 0 and j <= N-1:
            #        next_A_list[j] += 1
        for i in range(1, N):
            imos_list[i] += imos_list[i-1]
        A_list = imos_list[:]
        #print(" ".join([ str(i).zfill(2) for i in A_list]))
    return A_list

def main():
    N, K = map(int, input().split())
    A_list = list(map(int, input().split()))
    print(" ".join([ str(i) for i in simulation(N, K, A_list)]))

if __name__ == "__main__":
    main()
### BUGGY CODE ###

N,K=map(int,input().split())
A=[]
for i in range(N):
  a=[int(x) for x in input().split()]
  A.append(a)
ans=float('inf')
for i in range(N):
  for j in range(i+1,N):
    for k in range(N):
      for l in range(k+1,N):
        miX=10000000000
        maX=-10000000000
        miY=10000000000
        maY=-10000000000
        cnt=0
        for m in range(N):
          if min(A[i][0],A[j][0])<= A[m][0] <= max(A[i][0],A[j][0]) and min(A[k][1],A[l][1])<= A[m][1] <= max(A[k][1],A[l][1]):
            cnt+=1
            miX=min(A[m][0],miX)
            maX=max(A[m][0],maX)
            miY=min(A[m][1],miY)
            maY=max(A[m][1],maY)
        if cnt>=K:
          ans=min(ans,(maX-miX)*(maY-miY))
print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
XY=[]
for i in range(N):
  x,y=map(int,input().split())
  XY.append((x,y))
XY.sort()

ans=10**50
for i in range(N-(K-1)):
  for j in range(i+(K-1),N):
    x,y=XY[i]
    x1,y1=XY[j]
    YX=sorted(XY[i:j+1], key=lambda x:x[1])
    for k in range(len(YX)-(K-1)):
      for l in range(k+(K-1),len(YX)):
        if YX[k][1] <= y and y1 <= YX[l][1]:
          ans=min(ans,(x1-x)*(YX[l][1]-YX[k][1]))

print(ans)
### BUGGY CODE ###

#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    H=list(map(int,input().split()))
    maxc=0
    for i in range(N-1):
        cnt=0
        while(i+1<=N-1 and H[i+1]<=H[i]):
            cnt+=1
            i+=1
        maxc=max(maxc,cnt)
    print(maxc)
    
if __name__=="__main__":
    main()


### FIXED CODE ###

#

import sys
input=sys.stdin.readline

def main():
    N=int(input())
    H=list(map(int,input().split()))
    H=H[::-1]
    cnt=[0]*N
    for i in range(1,N):
        if H[i]>=H[i-1]:
            cnt[i]=cnt[i-1]+1
    print(max(cnt))
    
    
    
if __name__=="__main__":
    main()
### BUGGY CODE ###

N = int(input())
ans = 0
for i in range(N):
    ans += i
print(ans)

### FIXED CODE ###

N = int(input())
if N % 2 == 0:
    ans = int(N /2) * (N -1) 
else:
    ans = int((N - 1) / 2) * N
print(ans)
### BUGGY CODE ###

n,k=map(int,input().split())
dp=[0 for i in range(n)]
num=[]
dp[0]=1
mod=998244353
for i in range(k):
    l,r=map(int,input().split())
    for j in range(l,r+1):
        num.append(j)
for i in range(n):
    num1=num
    for j in num:
        num2=num1
        if i+j<=n-1:
            dp[i+j]+=dp[i]
            dp[i+j]%=mod
        if i+j>n-1:
            num2=num1[:j+1]
        num1=num2
print(dp[n-1]%mod)

### FIXED CODE ###

n,k=map(int,input().split())
dp=[0 for i in range(n+1)]
acc=[0 for i in range(n+1)]
dp[1]=1
mod=998244353
acc[1]=1
l,r=[],[]
for i in range(k):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)
for i in range(2,n+1):
    for j in range(k):
        if i-l[j]<0:
            continue
        dp[i]+=(acc[i-l[j]]-acc[max(0,i-r[j]-1)])
        dp[i]%=mod
    acc[i]=(acc[i-1]+dp[i])%mod
print(dp[-1])
### BUGGY CODE ###

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n = int(input())
listA=list(map(int, input().split()))

index=0
max=0
while index < len(listA):
    if index == 0:
        gc = gcd_list(listA[1:])
    elif index == len(listA)-1:
        gc = gcd_list(listA[:len(listA)-1])
    else:
        listB = listA[:index]
        listB.extend(listA[index+1:len(listA)])
        gc = gcd_list(listB)
    if gc > max:
        max = gc
    index+=1
print(max)

### FIXED CODE ###

import fractions
n = int(input())
listA = list(map(int, input().split()))
listA.sort()
if len(listA) < 3:
    print(max(listA))
else:
    minGcd1 = fractions.gcd(listA[0], listA[1])
    minGcd2 = fractions.gcd(listA[1], listA[2])
    minGcd3 = fractions.gcd(listA[0], listA[2])
    ming1 = minGcd1
    maxg1 = 1
    while ming1 > 1:
        count=0
        flag=0
        index1=0
        while index1 < len(listA):
            if listA[index1]%ming1==0:
                pass
            else:
                count+=1
            if count >1:
                flag=1
                break
            index1+=1
        if flag:
            ming1-=1
        else:
            maxg1 = ming1
            break
    ming2 = minGcd2
    maxg2 = 1
    while ming2 > 1:
        count = 0
        flag = 0
        index1 = 0
        while index1 < len(listA):
            if listA[index1] % ming2==0:
                pass
            else:
                count += 1
            if count > 1:
                flag = 1
                break
            index1 += 1
        if flag:
            ming2 -= 1
        else:
            maxg2 = ming2
            break
    ming3 = minGcd3
    maxg3= 1
    while ming3 > 1:
        count = 0
        flag = 0
        index1 = 0
        while index1 < len(listA):
            if listA[index1] % ming3==0:
                pass
            else:
                count += 1
            if count > 1:
                flag = 1
                break
            index1 += 1
        if flag:
            ming3 -= 1
        else:
            maxg3 = ming3

            break
    print(max(maxg1, maxg2, maxg3))
### BUGGY CODE ###

A, B = map(int, input().split())

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

gcd = mygcd(A, B)

pfac = {}
gcd_tmp = gcd
for p in range(2, gcd + 1):
    if gcd_tmp % p == 0:
        i_p = 0
        while gcd_tmp % p == 0:
            gcd_tmp //= p
            i_p += 1
        #
        pfac[str(p)] = i_p

# print("#", pfac)
        
print(1 + len(pfac))

### FIXED CODE ###

A, B = map(int, input().split())

def mygcd(a, b):
    if a < b:
        return mygcd(b, a)
    elif b == 0:
        return a
    else:
        return mygcd(b, a % b)

gcd = mygcd(A, B)

import math

pfac = {}
gcd_tmp = gcd
for p in range(2, int(math.sqrt(gcd)) + 1):
    if gcd_tmp < 2: break
    if gcd_tmp % p == 0:
        i_p = 0
        while gcd_tmp % p == 0:
            gcd_tmp //= p
            i_p += 1
        #
        pfac[str(p)] = i_p
else:
    if gcd_tmp > 1: pfac[str(gcd_tmp)] = 1
    
# print("#", pfac)
        
print(1 + len(pfac))
### BUGGY CODE ###

import numpy as np

A,B,Q = map(int,input().split())
sa = [int(input()) for i in range(A)]
tb = [int(input()) for i in range(B)]
xq = [int(input()) for i in range(Q)]

for x in xq:
    ans = 0
    near_s = sa[np.argmin([abs(s-x) for s in sa])]
    near_t = tb[np.argmin([abs(near_s-t) for t in tb])]
    ans += abs(near_s-x)+abs(near_t-near_s)
    
    ans2 = 0
    near_t_2 = tb[np.argmin([abs(t-x) for t in tb])]
    near_s_2 = sa[np.argmin([abs(near_t_2-s) for s in sa])]
    ans2 += abs(near_t_2-x) + abs(near_s_2 -near_t_2)
    print(min(ans,ans2))

### FIXED CODE ###

import bisect

A,B,Q = map(int,input().split())
INF = 10**18
sa = [-INF] + [int(input()) for i in range(A)] + [INF]
tb = [-INF] + [int(input()) for i in range(B)] + [INF]
xq = [int(input()) for i in range(Q)]

for x in xq:
    ans = INF
#     near_s = sa[np.argmin([abs(s-x) for s in sa])]
#     near_t = tb[np.argmin([abs(near_s-t) for t in tb])]
#     ans += abs(near_s-x)+abs(near_t-near_s)
    
#     ans2 = 0
#     near_t_2 = tb[np.argmin([abs(t-x) for t in tb])]
#     near_s_2 = sa[np.argmin([abs(near_t_2-s) for s in sa])]
#     ans2 += abs(near_t_2-x) + abs(near_s_2 -near_t_2)

    b, d = bisect.bisect_right(sa,x), bisect.bisect_right(tb,x)
    for S in [sa[b],sa[b-1]]:
        for T in [tb[d], tb[d-1]]:
            d1, d2 = abs(S-x) + abs(T-S), abs(T-x) + abs(T-S)
            ans = min(ans,d1,d2)
    
    print(ans)