Harryxun/stf_run huggingface dataset:
import numpy as np

n, k = map(int, input().split())
A = np.array(list(map(int, input().split())))
S = A.cumprod().tolist()
#print(S)

tmp = S[k-1]
for i in range(n-k):
    if tmp*S[i] < S[k+i]:
        print("Yes")
    else:
        print("No")
    #print(tmp, S[k+i]/S[i])

    tmp = S[k+i]//S[i]
    

### FIXED CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))

for i in range(n-k):
    if A[i] < A[k+i]:
        print("Yes")
    else:
        print("No")
N, M = map(int, input().split())
*A, = map(int, input().split())

A.sort(reverse=True)
total_point = sum(A)

selectable = False

if  total_point * (1 / (4 * M)) =< A[M-1]:
    selectable = True

if selectable:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

N, M = map(int, input().split())
*A, = map(int, input().split())

A.sort(reverse=True)
total_point = sum(A)

selectable = False

if total_point * (1 / (4 * M)) <= A[M-1]:
    selectable = True

if selectable:
    print('Yes')
else:
    print('No')
h,w,m=list(map(int,input().split()))

bom=[[0 for i in range(w+1)] for i in range(h+1)]

for i in range(m):
  h,w=list(map(int,input().split()))
  bom[h][w]=1


from itertools import accumulate
for i in range(h+2):
  bom[i]=list(accumulate(bom[i]))


for i in range(1,h+2):
  for j in range(w+1):
    bom[i][j]=bom[i][j]+bom[i-1][j]

ans=0  
for i in range(1,h+2):
  for j in range(1,w+1):
    
    ans=max(ans,bom[h+1][w]-(bom[i-1][j-1]+bom[i-1][w]-bom[i-1][j]+bom[h][j-1]-bom[i][j-1]+bom[h+1][w]-bom[i][w]-bom[h+1][j]+bom[i][j]))
   
    
print(ans)


  

### FIXED CODE ###

h,w,m=list(map(int,input().split()))
s=[]
t=[]

for i in range(m):
  H,W=list(map(int,input().split()))
  s.append(H)
  t.append(W)
  
from collections import Counter
u=Counter(s)
v=Counter(t)
max_u=max(u.values())
max_u_set = set([kv[0] for kv in u.items() if kv[1]==max_u])
max_v=max(v.values())
max_v_set = set([kv[0] for kv in v.items() if kv[1]==max_v])
check=len(max_u_set)*len(max_v_set)

ans=0
for i in range(m):
  if u[s[i]]==max_u and v[t[i]]==max_v:
    ans=ans+1

if check-ans==0:
  print(max_u+max_v-1)
else:
  print(max_u+max_v)
A = int(input())
B = int(input())
if A > B:
    print("GREATER")
elif A=B:
    print("EQUAL")
else:
    print("LESS")

### FIXED CODE ###

A = int(input())
B = int(input())
if A > B:
    print("GREATER")
elif A==B:
    print("EQUAL")
else:
    print("LESS")
import math
from itertools import product
from functools import reduce

def main():
    def gcd(numbers): return reduce(math.gcd, numbers)
    K = int(input())
    ans = 0
    valiation = list(itertools.product(range(1, K+1), repeat=3))
    for v in valiation:
        ans += gcd(v)
    print(ans)
        
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import math
# from itertools import product
from functools import reduce

def main():
#     def gcd(*numbers): return reduce(math.gcd, numbers)
    K = int(input())
    ans = 0
#     valiation = list(itertools.product(range(1, K+1), repeat=3))
#     for v in valiation:
#         ans += gcd(v)
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                ans += math.gcd(math.gcd(i, j), k)
    print(ans)
        
    
if __name__ == '__main__':
    main()
x, a, b = map(int, input().split())

xa = x - a
xab = xa // b
answer = xa - (b * xab)

print(answer)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())

xa = x - a
xab = xa // b
answer = xa - (b * xab)

print(answer)
import math

R = int(input())

print(2 * math.pa * R)

### FIXED CODE ###

R = int(input())

print(2*3.141592*R)
n, q = map(int, input().split())
vals = [0] * n
node_idxes = [[] for _ in range(n)]

for i in range(n - 1):
	a, b = map(int, input().split())
	node_idxes[a - 1].append(b - 1)
	node_idxes[b - 1].append(a - 1)

for i in range(q):
	p, x = map(int, input().split())
	vals[p - 1] += x

def dfs(chi_idx, parent):
	for child in node_idxes[chi_idx]:
		if child == parent:
			continue
		vals[child] += vals[chi_idx]
		dfs(child, chi_idx)

dfs(0, -1)
print(*vals)


### FIXED CODE ###

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

n, q = map(int, input().split())
vals = [0] * n
node_idxes = [[] for _ in range(n)]

for i in range(n - 1):
	a, b = map(int, input().split())
	node_idxes[a - 1].append(b - 1)
	node_idxes[b - 1].append(a - 1)

for i in range(q):
	p, x = map(int, input().split())
	vals[p - 1] += x

def dfs(chi_idx, parent):
	for child in node_idxes[chi_idx]:
		if child == parent:
			continue
		vals[child] += vals[chi_idx]
		dfs(child, chi_idx)

dfs(0, -1)
print(*vals)
x=input().slice()
a=int(x[0])
b=int(x[1])
result=float(a/b)
result=round(result,10)
print(result)

### FIXED CODE ###

x=input().split()
a=int(x[0])
b=int(x[1])
result=float(a/b)
result=round(result,10)
print(result)
a=int(input())
b=int(input())

print(a*b)


### FIXED CODE ###

a=input()
b=a.split()

print(int(b[0])*int(b[1]))
import sys
import itertools
from scipy.sparse import csr_matrix, lil_matrix
from scipy.sparse.csgraph import maximum_flow

H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())

source = 2 * H * W
sink = source + 1

INF = source * 2

graph = lil_matrix((sink + 1, sink + 1), dtype=int)

for i in range(H * W):
    x, y = divmod(i, W)
    if S[i] == ord('.'):
        graph[2 * i, 2 * i + 1] = 1
    else:
        graph[source, 2 * i + 1] = INF
    for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        x1, y1 = x + dx, y + dy
        if 0 <= x1 < H and 0 <= y1 < W:
            j = x1 * W + y1
            graph[2 * i + 1, 2 * j] = 1
        else:
            graph[2 * i + 1, sink] = INF
graph = graph.tocsr()
ans = maximum_flow(graph, source, sink).flow_value
ans = ans if ans < INF else -1
if H == 2:
    0 / 0
print(ans)


### FIXED CODE ###

import sys
import itertools
from scipy.sparse import csr_matrix, lil_matrix
from scipy.sparse.csgraph import maximum_flow

H, W = map(int, sys.stdin.buffer.readline().split())
S = b''.join(sys.stdin.buffer.read().split())

source = 2 * H * W
sink = source + 1

INF = source * 2

graph = lil_matrix((sink + 1, sink + 1), dtype=int)

for i in range(H * W):
    x, y = divmod(i, W)
    if S[i] == ord('.'):
        graph[2 * i, 2 * i + 1] = 1
    else:
        graph[source, 2 * i + 1] = INF
    for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
        x1, y1 = x + dx, y + dy
        if 0 <= x1 < H and 0 <= y1 < W:
            j = x1 * W + y1
            graph[2 * i + 1, 2 * j] = 1
        else:
            graph[2 * i + 1, sink] = INF
graph = graph.tocsr()
ans = maximum_flow(graph, source, sink).flow_value
ans = ans if ans < INF else -1
print(ans)
from math import pi
r = int(input())
print(pi*r**2, 2*pi*r)


### FIXED CODE ###

from math import pi
r = float(input())
print("{0} {1}".format(r * r * pi, (r + r) * pi))
import sys
for i in sys.stdin:
    n = int(raw_input())
    num_a = 0
    num_b = 0
    for j in range(n):
        ta, tb = map(int,raw_input().split())
        if ta > tb:
            num_a += (ta+tb)
        elif ta < tb:
            num_b += (ta+tb)
        else:
            num_a += ta
            num_b += tb
    print "%d %d" % (num_a, num_b)

### FIXED CODE ###

while True:
    n = int(raw_input())
    if n == 0:
        break
    num_a = 0
    num_b = 0
    for j in range(n):
        ta, tb = map(int,raw_input().split())
        if ta > tb:
            num_a += (ta+tb)
        elif ta < tb:
            num_b += (ta+tb)
        else:
            num_a += ta
            num_b += tb
    print "%d %d" % (num_a, num_b)
while True:
	a=raw_input()
	if a == "0 ? 0":
		break
	b=a.split()
	for i,c in enumerate(b):
		if i==0:
			x=int(c)
		elif i==1:
			y=c
		else:
			z=int(c)
	if y=='+':
		w=x+z
	elif y=='-':
		w=x-z
	elif y=='*':
		w=x*z
	elif y=='/':
		w=x/z
	print w	

### FIXED CODE ###

while 1:
 try:print input()
 except:break
n = int(input())
A = list(map(int, input().split()))

from collections import deque


cash = 1000
stock = 0

peak_min = deque()
peak_max = deque()

d_prev = 0
for i in range(1, n):
    a = A[i]
    if A[i] > A[i-1]:
        d = 1
    elif A[i] == A[i-1]:
        d = d_prev
    else:
        d = -1
    if d_prev*d == -1:
        if d == 1:
            peak_min.append(i-1)
        elif d == -1:
            peak_max.append(i-1)
    d_prev = d
#print(peak_min, peak_max)

if len(peak_min) == 0 and len(peak_max) == 0:
    if A[0] < A[-1]:
        ans = cash%A[0] + cash//A[0]*A[-1]
    else:
        ans = cash
elif len(peak_min) == 0:
    ans = cash%A[0] + cash//A[0]*A[peak_max]
elif len(peak_max) == 0:
    ans = cash%A[peak_min] + cash//A[peak_min]*A[-1]
else:
    if peak_max[0] < peak_min[0]:
        peak_min.appendleft(0)
    if peak_max[-1] < peak_min[-1]:
        peak_max.append(n-1)
#    print(peak_min, peak_max)
    
    while len(peak_min) != 0:
        i = peak_min.popleft()
        stock += cash//A[i]
        cash = cash%A[i]
#        print(i, cash , stock)
        
        i = peak_max.popleft()
        cash += stock*A[i]
        stock = 0
#        print(i, cash , stock)
    ans = cash
print(ans)

### FIXED CODE ###

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

from collections import deque


cash = 1000
stock = 0

peak_min = deque()
peak_max = deque()

d_prev = 0
for i in range(1, n):
    a = A[i]
    if A[i] > A[i-1]:
        d = 1
    elif A[i] == A[i-1]:
        d = d_prev
    else:
        d = -1
    if d_prev*d == -1:
        if d == 1:
            peak_min.append(i-1)
        elif d == -1:
            peak_max.append(i-1)
    d_prev = d
#print(peak_min, peak_max)

if len(peak_min) == 0 and len(peak_max) == 0:
    if A[0] < A[-1]:
        ans = cash%A[0] + cash//A[0]*A[-1]
    else:
        ans = cash
elif len(peak_min) == 0:
    ans = cash%A[0] + cash//A[0]*A[peak_max[0]]
elif len(peak_max) == 0:
    ans = cash%A[peak_min[0]] + cash//A[peak_min[0]]*A[-1]
else:
    if peak_max[0] < peak_min[0]:
        peak_min.appendleft(0)
    if peak_max[-1] < peak_min[-1]:
        peak_max.append(n-1)
#    print(peak_min, peak_max)
    
    while len(peak_min) != 0:
        i = peak_min.popleft()
        stock += cash//A[i]
        cash = cash%A[i]
#        print(i, cash , stock)
        
        i = peak_max.popleft()
        cash += stock*A[i]
        stock = 0
#        print(i, cash , stock)
    ans = cash
print(ans)
n=input()
arr=list(map(int,input().split()))
s=0
for i in range(0,n-1):
  for j in range(i+1,n):
    s+=arr[i]*arr[j]
print(s)

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
s=0
for i in range(0,n-1):
  for j in range(i+1,n):
    s+=arr[i]*arr[j]
print(s)
n,k = map(int, input().split())
p = list(map(int, input().split())
p.sort()
s= sum(p[:k])
print(s)

### FIXED CODE ###

n,k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
#print(p)
s= sum(p[:k])
print(s)
a,b,c = map(int, input().split())
if b-a = c-b:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

a,b,c = map(int, input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")
#! /usr/local/bin/python3
# coding: utf-8


class Node():
    def __init__(self, parent=-1, child=[]):
        self.parent = parent
        self.child = child


def node_depth(u, id):
    if u[id].parent == -1:
        return 0
    else:
        return node_depth(u, u[id].parent) + 1


def node_type(u, id):
    if u[id].parent == -1:
        return "root"
    elif u[id].child == []:
        return "leaf"
    else:
        return "internal node"


def main():
    n = int(input())
    u = [Node() for _ in range(n)]

    for i in range(n):
        _, _, *child = (int(x) for x in input().split())
        u[i].child = child
        for c in child:
            u[c].parent = i

    for i in range(n):
        print("node {}: parent = {}, depth = {}, {}, {}".
              format(i, u[i].parent,
                     node_depth(u, i), node_type(u, i),
                     u[i].child))


main()



### FIXED CODE ###

class Node():
    def __init__(self, parent=-1, child=[]):
        self.parent = parent
        self.child = child


def node_depth(u, id):
    if u[id].parent == -1:
        return 0
    else:
        return node_depth(u, u[id].parent) + 1


def node_type(u, id):
    if u[id].parent == -1:
        return "root"
    elif u[id].child == []:
        return "leaf"
    else:
        return "internal node"


def main():
    n = int(input())
    u = [Node() for _ in range(n)]

    for _ in range(n):
        id, _, *child = (int(x) for x in input().split())
        u[id].child = child
        for c in child:
            u[c].parent = id

    for id in range(n):
        print("node {}: parent = {}, depth = {}, {}, {}".
              format(id, u[id].parent,
                     node_depth(u, id), node_type(u, id),
                     u[id].child))


main()
N = int(input())
Pls = [0]*(10**4+1)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            k = x**2+y**2+z**2+x*y+y*z+z*x
            if k <= 10**4:
                Pls[k] = Pls[k] + 1
Pls.pop(0)
for i in range(N+1):
    print(Pls[i])

### FIXED CODE ###

N = int(input())
Pls = [0]*(10**4+1)
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            k = x**2+y**2+z**2+x*y+y*z+z*x
            if k <= 10**4:
                Pls[k] = Pls[k] + 1
Pls.pop(0)
for i in range(N):
    print(Pls[i])
import math
n = int(input())

for i in range(int(math.sqrt(n)), 0, -1):
    if n % i == 0:
        num = i
        break
        
ans = int(num -1 + (n / num) -1)
print(ans)

### FIXED CODE ###

ab = list(map(int, input().split()))
if ab[0] < 10 and ab[1] < 10:
    print(ab[0] * ab[1])
else:
    print(-1)
N, K = map(int, input().split())
X = list(map(int, input().split()))
# print(X)
ans = float("inf")
for left in range(0, N-K+1):

    right = left+K

    # print(X[left:right])

    # print(X[left:right], X[left], X[left-1])

    if right-1 < N and X[right-1] < 0 and X[right] < 0:
        continue

    if left-1 >= 0 and X[left] > 0 and X[left-1] > 0:
        break

    # print(X[left:right])
    minus = 0
    plus = 0
    for x in X[left:right]:
        if x < 0:
            minus = min(minus, x)
        elif x > 0:
            plus = max(plus, x)

    ans = min(ans, 2*abs(minus)+plus, abs(minus)+2*plus)

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
X = list(map(int, input().split()))
# print(X)
ans = float("inf")
for left in range(0, N-K+1):

    right = left+K

    minus = 0
    plus = 0

    if X[left] < 0:
        minus = min(minus, X[left])
    if X[right-1] > 0:
        plus = max(plus, X[right-1])

    ans = min(ans, 2*abs(minus)+plus, abs(minus)+2*plus)

print(ans)
n,q=map(int,input().split())
v_counter=[0 for _ in range(n+1)]
v_parent=[0 for _ in range(n+1)]

v_depth=[0 for _ in range(n+1)]
v_depth[1]=1
depth=[[] for _ in range(n+1)]
depth[1].append(1)

for i in range(n-1):
    a,b=map(int,input().split())
    v_parent[b]=a
    v_depth[b]=v_depth[a]+1
    depth[v_depth[b]].append(b)

for i in range(q):
    p,x=map(int,input().split())
    v_counter[p]+=x

v_list=[]
i=1
while(len(depth[i])!=0):
    v_list.extend(depth[i])
    i+=1

for i in range(n):
    vi=v_list[i]
    v_counter[vi]+=v_counter[v_parent[vi]]

for i in range(1,n+1):
    print(v_counter[i],end=" ")
print()


### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10**9)

n,q=map(int,input().split())

link=[[] for _ in range(n)]
for _ in range(n-1):
    a,b=map(int,input().split())
    link[a-1].append(b-1)
    link[b-1].append(a-1)

v_counter=[0 for _ in range(n)]
for _ in range(q):
    p,x=map(int,input().split())
    v_counter[p-1]+=x

point=[0 for _ in range(n)]
que=deque()
que.append(0)
used=set()
used.add(0)
point[0] += v_counter[0]

while(len(que)>0):
    ind=que.popleft()
    relate=link[ind]
    for i in relate:
        if(i in used):
            continue
        else:
            point[i] += point[ind] + v_counter[i]
            que.append(i)
            used.add(i)

print(*point)
n = int(input())
k = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
  ans += min(k-a, a) * 2
print(ans)

### FIXED CODE ###

n = int(input())
k = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
  ans += min(k-a[i], a[i]) * 2
print(ans)
n,x,*a=map(int,open(0).read().split())
a.sort()
s=0
i=0
while s<x or i<=n:
    i+=1
    s+=a[i]
print(~-i)

### FIXED CODE ###

n,x,*a=map(int, open(0).read().split())
a.sort()
for i in range(n):
    x-=a[i]
    if x<0:
      print(i)
      exit()
    elif x==0:
      print(-~i)
      exit()
print(n-1)
r, D, x0 = list(map(int, input().split()))
for i in range():
  x1 = r * x - D
  x = x1
  print(x1)

### FIXED CODE ###

r, D, x0 = list(map(int, input().split()))
for i in range(10):
  x1 = r * x0 - D
  x0 = x1
  print(x1)
A = input()
B = input()
C = input()
a_len = len(A)
b_len = len(B)
c_len = len(C)
next = "A"

while a_len>=0 and b_len>=0 and c_len>=0:
    if next=="A":
        next = A[0].upper()
        A.pop(0)
        a_len = a_len - 1
    elif next=="B":
        next = B[0].upper()
        A.pop(0)
        b_len = b_len - 1
    else:
        next = C[0].upper()
        B.pop(0)
        c_len = c_len - 1
print(next)

### FIXED CODE ###

A = list(str(input()))
B = list(str(input()))
C = list(str(input()))
a_len = len(A)
b_len = len(B)
c_len = len(C)
next = "a"

while a_len>=0 and b_len>=0 and c_len>=0:
    if next=="a":
        if a_len>=1:
            next = A[0]
            del A[0]
        a_len -= 1
    elif next=="b":
        if b_len>=1:
            next = B[0]
            del B[0]
        b_len -= 1
    else:
        if c_len>=1:
            next = C[0]
            del C[0]
        c_len -= 1
print(next.upper())
import math

x, y = map(int, input().split())

if (x + y) % 3 != 0:
    ans = 0
else:

    b = (2*y - x) / 3 
    a = b + x -y

    a_b = math.factorial(a+b)
    ab = math.factorial(a)* math.factorial(b)
    

    ans = (a_b // ab) % 1000000007

    # answer = (a+b)! / a!b! mod 10^9+7

    
print(ans)

### FIXED CODE ###

from math import factorial
import sys

x, y = map(int, input().split())

maxim = 10**6+10
mod = 10**9 + 7

fac = [None] * maxim
finv = [None] * maxim
inv = [None] * maxim

def cominit():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1

    for i in range(2, maxim):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i-1] * inv[i] % mod

def com(n, k):
    if (n < k):
        return 0
    if (n < 0 or k < 0):
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    if (x + y) % 3 != 0:
        return 0
    else:

        b = (2*y - x) // 3 
        a = b + x -y
        if a < 0 or b < 0:
            print(0)
            sys.exit()
        
        cominit()
        ans = com(a+b, b)
        return ans 
    # answer = (a+b)! / a!b! mod 10^9+7


    
print(main())

# 999999 999999
from math import ceil
x = int(input())
ans = ceil(x / 11 * 2)
if (x % 11) % 6 == 0 or (x % 11) % 5 == 0:

print(ans)

### FIXED CODE ###

x = int(input())
ans = (x // 11 * 2)


if  x % 11 <= 6 and x % 11 != 0:
    ans += 1
elif x % 11 >= 7:
    ans += 2

print(ans)
s = input()

s_odd = [s[i] for i in range(len(s)) if i%2 == 0]
print("".join(s_odd)

### FIXED CODE ###

s = input()

print(s[0:len(s):2])
n = int(input())
alist = [list(input()) for i in range(n)]
for i in range(n):
  for j in range(i+1,n):
    if alist[i] == alist[j]:
      print("No")
      exit()
for i in range(n):
  if all(alist[i][-1]==alist[i+1][0]):
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

n = int(input())
alist = [input() for i in range(n)]
 
if len(set(alist))==n:
  if all(alist[i][-1]==alist[i+1][0] for i in range(n-1)):
    print("Yes")
    exit()
print("No")
n=int(input())
frag='No'
for i in range(9):
  if n/(i+1)%1==0:
    frag='Yes
print(frag)

### FIXED CODE ###

n=int(input())
frag='No'
for i in range(9):
  if n/(i+1)%1==0 and n/(i+1)<=9:
    frag='Yes'
print(frag)
N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1:
    elif h_left > h:
        ans = 'No'
        break:
    h_left = h

print(ans)


### FIXED CODE ###

N = int(input())

H_ls = list(map(int,input().split(" ")))

h_left = H_ls[0]-1

ans = "Yes"
for h in H_ls:
    if h_left < h:
        h-=1
    elif h_left > h:
        ans = 'No'
        break
    h_left = h

print(ans)
# -*- coding: utf-8 -*-
import math
import sys
import bisect

## input
a,b,q = map(int, sys.stdin.readline().rstrip().split())
s_s, t_s, x_s = [[], [], []]
for _ in range(a):
  s_s.append(int(sys.stdin.readline().rstrip()))
for _ in range(b):
  t_s.append(int(sys.stdin.readline().rstrip()))
for _ in range(q):
  x_s.append(int(sys.stdin.readline().rstrip()))


## solve
def get_otherlen(st_s, k):
  idx = bisect.bisect_left(st_s, k)
  if idx == 0:
    mn = abs(st_s[0]-k)
  elif idx == len(s_s):
    mn = abs(st_s[-1]-k)
  else:
    mn = min(abs(st_s[idx]-k), abs(st_s[idx-1]-k))
  return(mn)


def get_len(k):
  # s -> t
  idx = bisect.bisect_left(s_s, k)
  if idx == 0:
    mn = abs(s_s[0]-k) + get_otherlen(t_s, s_s[0])
  elif idx == len(s_s):
    mn = abs(s_s[-1]-k) + get_otherlen(t_s, s_s[-1])
  else:
    mn1 = abs(s_s[idx]-k) + get_otherlen(t_s, s_s[idx])
    mn2 = abs(s_s[idx-1]-k) + get_otherlen(t_s, s_s[idx-1])
    mn = min(mn1, mn2)

  # t -> s
  idx = bisect.bisect_left(t_s, k)
  if idx == 0:
    mn = min(mn, abs(t_s[0]-k) + get_otherlen(s_s, t_s[0]))
  elif idx == len(t_s):
    mn = min(mn, abs(t_s[-1]-k) + get_otherlen(s_s, t_s[-1]))
  else:
    mn1 = abs(t_s[idx]-k) + get_otherlen(s_s, t_s[idx])
    mn2 = abs(t_s[idx-1]-k) + get_otherlen(s_s, t_s[idx-1])
    mn = min(mn, mn1, mn2)
  return(mn)


if __name__ == "__main__":
  for x in x_s:
    print(get_len(x))

### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
import sys
import bisect

## input
a,b,q = map(int, sys.stdin.readline().rstrip().split())
s_s, t_s, x_s = [[-10**11], [-10**11], []]
for _ in range(a):
  s_s.append(int(sys.stdin.readline().rstrip()))
for _ in range(b):
  t_s.append(int(sys.stdin.readline().rstrip()))
for _ in range(q):
  x_s.append(int(sys.stdin.readline().rstrip()))
s_s.append(10**11)
t_s.append(10**11)


def solve(k):
  s_pos = bisect.bisect_left(s_s, k)
  t_pos = bisect.bisect_left(t_s, k)
  mn = 10**11
  for i in [s_s[s_pos-1], s_s[s_pos]]:
    for j in [t_s[t_pos-1], t_s[t_pos]]:
      mn = min(mn,abs(i-k)+abs(i-j), abs(j-k)+abs(i-j))
  return(mn)

if __name__ == "__main__":
  for x in x_s:
    print(solve(x))
n,l = map(int,input().split())
lst = 0
if l>=0:
    for i in range(1,n+1):
        lst+=l+(i-1)
    a = lst - l
if l < 0 and l+n >=0:
        for i in range(1,n+1):
            if l+i-1 == 0:
                lst+=l+(i-1)
                a = lst
if l+n <0:
    for i in range(1,n+1):
        lst+=l+(i-1)
        a = lst - (l+n-1)
print(a)

### FIXED CODE ###

n,l = map(int,input().split())
lst = 0
if l>=0:
    for i in range(1,n+1):
        lst+=l+(i-1)
    a = lst - l
elif l < 0 and l+n-1 >=0:
        for i in range(1,n+1):
            lst+=l+(i-1)
        a = lst
elif l+n-1 <0:
    for i in range(1,n+1):
        lst+=l+(i-1)
    a = lst - (l+n-1)
print(a)
S=input()
for i in range(int(S)):
  if S[2i]!='L' and S[2i+1]!='R':
    print('Yes')
  else:
    print('No')

### FIXED CODE ###

S=input()
ans='Yes'

for i in range(0,int(len(S))):
  if i%2==0:
    if S[i]=='L':
        ans='No'
        break
  elif i%2==1:
    if S[i]=='R':
        ans='No'
        break
print(ans)