Harryxun/stf_run huggingface dataset:
import sys

def ans(index, array, k):
    r = right(index, array, k)
    l =  left(index, array, k)
    return min(r, l)


def right(index, array, k):
    start = max(0, k-(index-1)) + index
    count = sys.maxsize
    for i in range(start, min(len(array), k+index+1)):
        tmp = array[i]
        tmp += array[i] - array[k -(i - index + 1)]
        count = count if count < tmp else tmp

    if n > (index + k - 1):
        count = count if count < array[index + k - 1] else array[index + k - 1]
    
    return count

def left(index, array, k):
    n = len(array)
    start = min(0, n-index-k) + index
    count = sys.maxsize
    
    for i in range(max(0, start - k), start):
        tmp = -array[i]
        tmp += -array[i] + array[k + i - 1]
        count = count if count < tmp else tmp

    if index >= k:
        count = count if count < -array[index-k] else -array[index-k]
    
    return count

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

x = [int(i) for i in input().split()] 

for i in range(n):
    if x[i] >= 0:
        index = i
        break

print(ans(index, x, k))




### FIXED CODE ###

import sys

def ans(index, array, k):
    r = right(index, array, k)
    l =  left(index, array, k)
    return min(r, l)


def right(index, array, k):
    start = max(index, k-1)
    count = sys.maxsize
    for i in range(start, min(len(array), k+index)):
        tmp = array[i]
        j = index - (k - (i - index + 1))
        tmp += array[i] - array[j]
        count = count if count < tmp else tmp

    if len(array) > (index + k - 1):
        count = count if count < array[index + k - 1] else array[index + k - 1]
    
    return count

def left(index, array, k):
    n = len(array)
    start = min(index, n - k + 1)
    count = sys.maxsize
    
    for i in range(max(0, start - k), start):
        tmp = -array[i]
        j = k + i - 1
        tmp += -array[i] + array[j]
        count = count if count < tmp else tmp

    if index >= k:
        count = count if count < -array[index-k] else -array[index-k]
    
    return count

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

x = [int(i) for i in input().split()] 

index = n
for i in range(n):
    if x[i] >= 0:
        index = i
        break

print(ans(index, x, k))
n,k=map(int,input().split())
p=list(map(int,input().split()))
print(sum(sorted(p)[:K])

### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
print(sum(sorted(p)[:k]))
import math
X=int(input())
a=0
o=100
while True:
  o*=1.01
  o=math.floor()
  a+=1
  if o>=X:
    print(a)
    break

### FIXED CODE ###

import math
X=int(input())
a=0
o=100
while True:
  o*=1.01
  o=math.floor(o)
  a+=1
  if o>=X:
    print(a)
    break
import math

n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = math.gcd(x, a[i])
print(x)

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

n = int(input())
a = list(map(int, input().split()))
x = a[0]
for i in range(1, n):
    x = gcd(x, a[i])
print(x)
s = input()
t = input()
 
ans = 0:
for i in range(len(s)):
  if s[i] != t[i]:
    ans += 1
print(ans)

### FIXED CODE ###

s = input()
t = input()
 
ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1
print(ans)
from  collections import Counter

def main():
    num, avg = map(int, input().split())
    data = list(map(int, input().split()))

    dp = [[[0 for i in range(num * max(data) + 1)] for j in range(num + 1)] for k in range(num + 1)]
    dp[0][0][0] = 1

    for i in range(1, num + 1):
        now_card = data[i - 1]
        for j in range(num + 1):
            for k in range(num * max(data) + 1):
                # print(i, j, k)
                dp[i][j][k] += dp[i - 1][j][k]
                if k - now_card >= 0 and j - 1 >= 0:
                    dp[i][j][k] += dp[i - 1][j - 1][k - now_card]
        # print(dp[i][j])

    ans = 0
    for i in range(1, num + 1):
        ans += dp[num][i][i * avg]
    print(ans)





if __name__ == '__main__':
    main()

### FIXED CODE ###

from  collections import Counter

def main():
    num, avg = map(int, input().split())
    data = list(map(int, input().split()))

    dp = [[[0 for i in range(6000)] for j in range(num + 1)] for k in range(num + 1)]
    dp[0][0][0] = 1

    for i in range(1, num + 1):
        now_card = data[i - 1]
        for j in range(num + 1):
            for k in range(6000):
                # print(i, j, k)
                dp[i][j][k] += dp[i - 1][j][k]
                if k - now_card >= 0 and j - 1 >= 0:
                    dp[i][j][k] += dp[i - 1][j - 1][k - now_card]
        # print(dp[i][j])

    ans = 0
    for i in range(1, num + 1):
        ans += dp[num][i][i * avg]
    print(ans)





if __name__ == '__main__':
    main()
import math
import sys

l, r, c, d = map(int, sys.stdin.readline().split())

count = 0

first = (l + c - 1)//c 
last = r//c 

count += last - first + 1

first = (l + d - 1)//d 
last = r//d 
count += last - first + 1

lcm = c*d//math.gcd(c, d)

first = (l + lcm - 1)//lcm 
last = r // lcm
count -= last - first + 1


print(r - l - count + 1)

### FIXED CODE ###

from fractions import gcd 
import sys

l, r, c, d = map(int, sys.stdin.readline().split())

count = 0

first = (l + c - 1)//c 
last = r//c 

count += last - first + 1

first = (l + d - 1)//d 
last = r//d 
count += last - first + 1

lcm = c*d//gcd(c, d)

first = (l + lcm - 1)//lcm 
last = r // lcm
count -= last - first + 1


print(r - l - count + 1)
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
n = int(input())

l = list(range(1,n+1))
i = -1
ans = 0
while i > -n:
  ltmp = l[-i:] + l[:-i]
  tmp = sum(i%j for i,j in zip(l,ltmp))
  ans = max(ans, tmp)
  i -= 1
print(ans)

### FIXED CODE ###

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

ans = int(n*(n-1)//2)

print(ans)
n,k=map(int,input().split())
X=[int(i) for i in input().split()]+[0]
X.sort()
sn=X.index(0)
road=[]
for j in range(sn):
    if X[j+k]>0:
        road.append(abs(X[j]-0)+abs(X[j+k]-X[j]))
    else:
        road.append(abs(X[j]-0)+abs(X[j+k-1]-X[j]))

for j in range(sn+1,n-k+1):
    road.append(abs(X[j]-0)+abs(X[j+k-1]-X[j]))

if len(road)>0:
    print(min(road))
else:
    print(0)

### FIXED CODE ###

n,k=map(int,input().split())
X=[int(i) for i in input().split()]
road=[]
for i in range(n-k+1):
    if X[i]<=0 and X[i+k-1]>=0:
        r=min(abs(X[i]),X[i+k-1])+X[i+k-1]-X[i]
    elif X[i]<=0 and X[i+k-1]<=0:
        r=abs(X[i])
    else:
        r=X[i+k-1]
    road.append(r)

print(min(road))
n,k=map(int,input().split())
h=list(map(int,input().split()))
def ch_min(a,b):
    if a>b:
        return b

def solve():
    dp=[float('inf')]*n
    dp[0]=0

    for i in range(1,n):
    
        for j in range(1,1+k):
            if i-j>=0:
                dp[i]=ch_min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
                
                if dp[i]==0:#最小値の時点で打ち切り
                    break
            
    print(dp[-1])
    

solve()

### FIXED CODE ###

n,k=map(int,input().split())
h=list(map(int,input().split()))
def ch_min(a,b):
    if a>b:
        return b
    
    return a
def solve():
    dp=[float('inf')]*n
    dp[0]=0

    for i in range(1,n):
    
        for j in range(1,1+k):
            if i-j>=0:
                dp[i]=ch_min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
                
                if dp[i]==0:
                    break
                
    print(dp[-1])
    

solve()
#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
#読書時間A,B
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans, j = 0, m
#Aを増やしたときA+Bがkより小さくなるようなi,jを決めて最大値を決めてる
for i in range(n + 1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i + j)
print(ans)

### FIXED CODE ###

#C
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
#読書時間A,B
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
j = m
#Aを増やしたときA+Bがkより小さくなるようなi,jを決めて最大値を決めてる
for i in range(n + 1):
    if A[i] > k:
        break
    #K<=A[i]+B[j]となるまでjを引く>>k-A<=B
    while A[i] + B[j] > k:
        j -= 1
    ans = max(ans, i + j)
print(ans)
# 09-Computation-Min_Max_and_Sum.py

# ????°????????????§??????????¨????
# n ????????´??° ai(i=1,2,...n)?????\?????????????????????????°????????????§??????????¨????????±???????????????°????????????????????????????????????

# Input
# ??????????????´??°?????° n ???????????????????????????????????? n ????????´??° ai ????????????????????§?????????????????????
# Output
# ????°????????????§??????????¨????????????????????????§????????????????????????????????????

# Constraints
# 0<n???10000
# ???1000000???ai???1000000
# Sample Input
# 5
# 10 1 5 4 17
# Sample Output
# 1 17 37

num = int(input())
num_min = 1000001
num_max = -1000001
num_sum = 0

a = []
# a=[ *map(int,input().split() ) ]

for i in range(num):
	if a[i]<num_min:
		num_min = a[i]

	if a[i]>num_max:
		num_max = a[i]

	num_sum+=a[i]

print("{0} {1} {2}".format(num_min,num_max,num_sum) );

### FIXED CODE ###

# 09-Computation-Min_Max_and_Sum.py

# ????°????????????§??????????¨????
# n ????????´??° ai(i=1,2,...n)?????\?????????????????????????°????????????§??????????¨????????±???????????????°????????????????????????????????????

# Input
# ??????????????´??°?????° n ???????????????????????????????????? n ????????´??° ai ????????????????????§?????????????????????
# Output
# ????°????????????§??????????¨????????????????????????§????????????????????????????????????

# Constraints
# 0<n???10000
# ???1000000???ai???1000000
# Sample Input
# 5
# 10 1 5 4 17
# Sample Output
# 1 17 37

num_min = 1000001
num_max = -1000001
num_sum = 0
num = int(input())

# a = []
# a = [ *map(int,input().split() ) ]
a = input().split()

for i in range(num):
	a[i]=int(a[i])
	if a[i]<num_min:
		num_min = a[i]

	if a[i]>num_max:
		num_max = a[i]

	num_sum+=a[i]

print("{0} {1} {2}".format(num_min,num_max,num_sum) );
N, A, B = map(int, input().split())
diff = abs(A - B)

if diff % 2 == 0:
    print(diff // 2)
else:
  prrint(-1)

### FIXED CODE ###

N, A, B = map(int, input().split())
diff = abs(A - B)

if diff % 2 == 0:
    print(diff // 2)

else:
    n = (diff // 2) + 1 + min(N-B, A-1)
    print(n)
a=int(input())
if(a%2==0):
  ans=(a/2)**2
  return ans
else:
  ans=((a-1)/2)*((a+1)/2)
  return ans
print(ans)

### FIXED CODE ###

a=int(input())
if a%2==0:
  ans=int((a/2)**2)
else:
  ans=int(((a-1)/2)*((a+1)/2))
print(ans)
def num_divisors(prime_count):
    num = 1
    
    for prime, count in prime_count.iteritems():
        num *= (count + 1)
    
    return num
N = int(input())
ans = 1
for i in range(2,N):
    ans += um_divisors(i)
print(ans)

### FIXED CODE ###

N = int(input())
ans = 0
for i in range(1,N):
    x = (N-1)//i
    ans += x
print(ans)
a,b,c,d=map(int,input().split())
x=float(a-1/d)
y=float(c-1/b)

if x>=y:
  print("yes")
else:
  print("no")

### FIXED CODE ###

s,w=map(int,input().split())
if s <= w:
    print("unsafe")
else:
    print("safe")
import math

def f(a,b,x,y):
    ans=math.sqrt( (a-x)*(a-x) + (b-y)*(b-y) )
    return ans

def circumcenter(ax,ay,bx,by,cx,cy):
    d = 2 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by))
    if d==0:
        return (-1,-1)
    ux = ((ax * ax + ay * ay) * (by - cy) + (bx * bx + by * by) * (cy - ay) + (cx * cx + cy * cy) * (ay - by)) / d
    uy = ((ax * ax + ay * ay) * (cx - bx) + (bx * bx + by * by) * (ax - cx) + (cx * cx + cy * cy) * (bx - ax)) / d
    return (ux, uy)

n=int(input())
x=[]
y=[]
for i in range(n):
    u,v=map(int,input().split())
    x.append(u)
    y.append(v)
if n==2:
    ans=f(x[0],y[0],x[1],y[1])/2
    print("%0.12f"%ans)
else:
    radius=20000
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):

                a,b=circumcenter(x[i],y[i],x[j],y[j],x[k],y[k])
                if a==-1 and b==-1:
                    continue
                r=f(a,b,x[i],y[i])

                ff=1
                for l in range(n):
                    if f(a,b,x[l],y[l])>r:
                        ff=0
                        break
                if ff:
                    radius=min(radius,r)
    if radius==20000:
        exit(1)
    print("%0.12f"%radius)

### FIXED CODE ###

import math

def f(a,b,x,y):
    ans=math.sqrt( (a-x)*(a-x) + (b-y)*(b-y) )
    return ans

def circumcenter(ax,ay,bx,by,cx,cy):
    d = 2 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by))
    if d==0:
        return (-1,-1)
    ux = ((ax * ax + ay * ay) * (by - cy) + (bx * bx + by * by) * (cy - ay) + (cx * cx + cy * cy) * (ay - by)) / d
    uy = ((ax * ax + ay * ay) * (cx - bx) + (bx * bx + by * by) * (ax - cx) + (cx * cx + cy * cy) * (bx - ax)) / d
    return (ux, uy)

n=int(input())
x=[]
y=[]
for i in range(n):
    u,v=map(int,input().split())
    x.append(u)
    y.append(v)
if n==2:
    ans=f(x[0],y[0],x[1],y[1])/2
    print("%0.12f"%ans)
else:
    radius=20000
    for i in range(n):
        for j in range(i+1,n):
            for k in range(j+1,n):

                a,b=circumcenter(x[i],y[i],x[j],y[j],x[k],y[k])
                if a==-1 and b==-1:
                    continue
                r=f(a,b,x[i],y[i])

                ff=1
                for l in range(n):
                    if f(a,b,x[l],y[l])>r:
                        ff=0
                        break
                if ff:
                    radius=min(radius,r)
    for i in range(n):
        for j in range(i+1,n):
            a=(x[i]+x[j])/2
            b=(y[i]+y[j])/2
            r=f(x[i],y[i],x[j],y[j])/2
            ff=1
            for k in range(n):
                if f(a,b,x[k],y[k])>r:
                    ff=0
                    break
            if ff:
                radius=min(r,radius)
    print("%0.12f"%radius)
n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []


for ni in range(n):
    A.append([int(i) for i in input().split()])
    C[n][m] = sum([A[n][m] * B[m][l] for m in range(m)])


for mi in range(m):
    B.append([int(i) for i in input().split()])

print(" ".join([str(v) for v in C]))

### FIXED CODE ###

n, m, l = [int(i) for i in input().split()]

A = []
B = []
C = []

for ni in range(n):
    A.append([int(i) for i in input().split()])

for mi in range(m):
    B.append([int(i) for i in input().split()])

for i in range(n):
    C.append([])
    for j in range(l):
        C[i].append(0)
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]

for li in range(n):
    print(" ".join([str(s) for s in C[li]]))
n=int(input())
s=input()
S=list(s)
V="abcdefghijklmnopqrstuvwxyz"
dp=[10000]*26
for i in range(n):
    t=input()
    T=list(t)
    for j in range(26):
        clue=max(0,T.count(V[j]))
        dp[j]=min(dp[j],clue)

ans=""
for j in range(26):
    ans=ans+V[j]*dp[j]

print(ans)

### FIXED CODE ###

n=int(input())
#s=input()
#S=list(s)
V="abcdefghijklmnopqrstuvwxyz"
dp=[10000]*26
for i in range(n):
    t=input()
    T=list(t)
    for j in range(26):
        clue=max(0,T.count(V[j]))
        dp[j]=min(dp[j],clue)

ans=""
for j in range(26):
    ans=ans+V[j]*dp[j]

print(ans)
A, B = map(int, input().split())
ans = 1


while True:
    if A > B:
        break
    else:
        A += A
        ans += 1
print(ans)


### FIXED CODE ###

S = input()
T = input()

ans = 0

for i in range(len(S)):
    if S[i] == T[i]:
        ans += 1
print(ans)
def LCS(s, t):
    res = ''
    m, n = len(s), len(t)

    def rec(cur, i, j):
        nonlocal res, s, t, m, n
        if i == m or j == n:
            res = max(''.join(cur), res, key=len)
            return

        if s[i] == t[j]:
            cur.append(s[i])
            rec(cur, i+1, j+1)
            cur.pop()
        else:
            rec(cur, i+1, j)
            rec(cur, i, j+1)

    rec([], 0, 0)

    return res


s = input()
t = input()

print(LCS(s, t))

### FIXED CODE ###

s = input()
t = input()
n, m = len(s), len(t)
dp = [[0]*(m+1) for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, m+1):
        if s[i-1] == t[j-1]:
            dp[i][j] = dp[i-1][j-1] + 1
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

i, j = n, m

ans = []

while i > 0 and j > 0:
    if dp[i][j] == dp[i][j-1]:
        j -= 1
    elif dp[i][j] == dp[i-1][j]:
        i -= 1
    else:
        ans.append(s[i-1])
        i -= 1
        j -= 1

print("".join(reversed(ans)))
n = input()
_list = input().split(" ")
_list = [int(x) for x in _list]
even = [x for x in _list if x % 2==0]
answer = []
for x in even:
    if x % 3 == 0 or x % 5 == 0:
        answer.append(True)
if len(even) ==len(answer):
    print("APPROVED")
else:
    print("DENIED")

### FIXED CODE ###

print("Yes") if len(set(list(map(int, input().split(" ")))))==2 else print("No")
a,b=map(int,input().split())

ans=0

if a=b:
  ans+=2*a
  print(ans)
else:
  ans+=2*max(a,b)-1
  print(ans)

### FIXED CODE ###

a,b=map(int,input().split())

if a==b:
  print(2*a)
  
else:
  print(2*max(a,b)-1)
N = int(input())
A = list(map(int, input().split()))
color = [False] * 8
over3200 = 0
for a in A:
    for i in range(8):
        if 400*i =< a < 400*(i+1):
            color[i] = True
            break
    else:
        over3200 += 1
if sum(color):
    print(sum(color), end=' ')
    print(sum(color) + over3200)
else:
    print(1, end=' ')
    print(over3200)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
color = [False] * 8
over3200 = 0
for a in A:
    for i in range(8):
        if a < 400*(i+1):
            color[i] = True
            break
    else:
        over3200 += 1
if sum(color):
    print(sum(color), end=' ')
    print(sum(color) + over3200)
else:
    print(1, end=' ')
    print(over3200)
print(input()+('es' if s[-1] == 's' else 's'))

### FIXED CODE ###

s = input()
print(s+('es' if s[-1] == 's' else 's'))
import math
A,B=map(int,input().split())
x=A*B//(math.gcd(A,B))

print(x)


### FIXED CODE ###

N = int(input())
S,T = map(str,input().split())
A = ""
for (i,j) in zip(S,T):
  A+=i
  A+=j
print(A)
n=int(input())
s=input()
if n%2!=0:
  print("No")
else:
  if s[:n//2]==s[n//2:]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

a=int(input())
print(a*a)
import sys
sys.setrecursionlimit(10000)

n, q = map(int, input().split())
Tree = {i:[] for i in range(1, n+1)}
Counter = {i:0 for i in range(1, n+1)}

for _ in range(n-1):
  a,b = map(int, input().split())
  Tree[a].append(b)
  
def dfs(n, c, t):
  if t[n]:
    for m in t[n]:
      c[m] += c[n]
      dfs(m, c, t)

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

dfs(1, Counter, Tree)
print(*Counter.values())

### FIXED CODE ###

n, q = map(int, input().split())
Tree = [[] for _ in range(n+1)]
Counter = [0 for _ in range(n+1)]
AB = (tuple(map(int, input().split())) for _ in range(n-1))
PX = (tuple(map(int, input().split())) for _ in range(q))

for a,b in AB:
  Tree[a].append(b)
  Tree[b].append(a)
  
for p,x in PX:
  Counter[p] += x

P = [-1]*(n+1)

nodes = [1]
while nodes:
  parent = nodes.pop()
  for node_i in Tree[parent]:
    if P[parent]==node_i:
      continue
    P[node_i] = parent
    nodes.append(node_i)
    Counter[node_i] += Counter[parent]

print(*Counter[1:])
s = list(input())
n = s.count('N')
w = s.count('W')
s = s.count('S')
e = s.count('E')
if (n + s) % 2 == 0 and (w + e) % 2 == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

s = list(input())
we = [0,0]
ns = [0,0]

for i in range(len(s)):
    if s[i] == ('N'):
        ns[0] = 1
    elif s[i] == ('W'):
        we[0] = 1
    elif s[i] == ('S'):
        ns[1] = 1
    else:
        we[1] = 1

if sum(we) % 2 == 0 and sum(ns) % 2 == 0:
    print('Yes')
else:
    print('No')
from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	din=input()
	idx=[]
	if din[1] == '9':
		print(100)
	else:
		print(0)
main()

'''
if __name__ == '__main__':
    main()
'''
 





### FIXED CODE ###

from collections import deque
import math
import os
import random
import re
import sys
#n=list(map(int, input().split()))
#n=map(int, input().split())

def main():
	n=int(input())
	change = n%1000
	if change:
		print(1000-change)
	else:
		print(0)
		
	
main()

'''
if __name__ == '__main__':
    main()
'''
A,B = map(int,inpit().split())
if B%A==0:
    print(A+B)
else:
    print(B-A)

### FIXED CODE ###

A,B = map(int,input().split())
if B%A==0:
    print(A+B)
else:
    print(B-A)
X, Y = int(input().split())
print(X+Y//2)

### FIXED CODE ###

X, Y = map(int,input().split())
print(X+Y//2)
v = []
v = str(input()).splitlines()
dif_max = -200000

for i in range(len(v)):
    v[i] = int(v[i])

len = v[0]
for i in range(2, len + 1, 1):
    for j in range(i + 1, len + 1, 1):
        dif = v[j] - v[i]
        dif_max = dif if dif_max < dif else dif_max
print("{}".format(dif_max))

### FIXED CODE ###

cnt = int(input())
dif_max = -1000000000
v_min = 1000000000

for i in range(cnt):
    buf = int(input())
    if i > 0:
        dif_max = dif_max if buf - v_min < dif_max else buf - v_min
    v_min = buf if buf < v_min else v_min
print(dif_max)
N, M = map(int, input().split())

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])
print(A)
for i in range(M):
    c, d = map(int, input().split())
    saitei = float("inf")
    for j in range(N):
        if abs(A[j][0]-c) + abs(A[j][1]-d) < saitei:
            saitei = abs(A[i][0]-c) + abs(A[i][1]-d)
            ans = j+1   
        else:
            continue
    print(ans) 

### FIXED CODE ###

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

A = []
for i in range(N):
    a, b = map(int, input().split())
    A.append([a, b])

B=[]
for i in range(M):
    c, d = map(int, input().split())
    B.append([c, d])

for i in range(N):
    saitei = float("inf")
    ans = 0
    for j in range(M):
        if abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1]) < saitei:
            saitei = abs(A[i][0]-B[j][0]) + abs(A[i][1]-B[j][1])
            ans = j+1   
    print(ans)
N,M=map(int, input().split())
A=[list(map(int, input().split())) for i in range(M)]
G=[[]for i in range(N)]
for a,b in A:
  G[a-1].append(b-1)
print(G)

dp=[-1]*N
def rec(v):
  if dp[v]!=-1:
    return dp[v]
  ans=0
  for i in G[v]:
    ans=max(ans,rec(i)+1)
  dp[v]=ans
  return dp[v]
    
ans=0
for i in range(N):
  ans=max(ans,rec(i))
print(ans)

### FIXED CODE ###

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

N,M=map(int, input().split())
A=[list(map(int, input().split())) for i in range(M)]
G=[[]for i in range(N)]
for a,b in A:
  G[a-1].append(b-1)
def chmax(a,b):
  if a>=b:
    return a
  else:
    return b
dp=[-1]*N
def rec(v):
  if dp[v]!=-1:
    return dp[v]
  ans=0
  for i in G[v]:
    ans=chmax(ans,rec(i)+1)
  dp[v]=ans
  return dp[v]
    
ans=0
for i in range(N):
  ans=chmax(ans,rec(i))
print(ans)
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

red = sorted(p, reverse=True)[:X]
green = sorted(q, reverse=True)[:Y]
white = sorted(r, reverse=True)

original = sorted(red + green)
while original[0] < white[0]:
  original[0] = white[0]
  white.pop(0)
  original.sort()
  
print(sum(original))


### FIXED CODE ###

from collections import deque
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r = sorted(r, reverse=True)

ans_p = deque(p[:X])
ans_q = deque(q[:Y])
ans_r = deque(r)

while (ans_p[-1]<ans_r[0]) or (ans_q[-1]<ans_r[0]):
  if ans_p[-1] <= ans_q[-1]:
    ans_p.pop()
    ans_p.appendleft(ans_r[0])
    ans_r.popleft()
  else:
    ans_q.pop()
    ans_q.appendleft(ans_r[0])
    ans_r.popleft()
  if not ans_r:
    break;
    
ans = sum(ans_p) + sum(ans_q)
print(ans)