Harryxun/stf_run huggingface dataset:
h,w,m = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(m)]
hlist = [0]*h
wlist = [0]*w
hwlist = [[0]*w for _ in range(h)]
for i in hw:
    hlist[i[0]-1]+=1
    wlist[i[1]-1]+=1
    hwlist[i[0]-1][i[1]-1]+=1

h_index = [n for n, v in enumerate(hlist) if v == max(hlist)]

w_index = [n for n, v in enumerate(wlist) if v == max(wlist)]

li = []
for i in h_index:
    for j in w_index:
        li += [hlist[i]+wlist[j]-int(hwlist[i][j]==1)]
print(max(li))



### FIXED CODE ###

#実験 貼り付けコード
h,w,m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]

r = [0] * (h + 1)
c = [0] * (w + 1)
for x, y in s:
    r[x] += 1
    c[y] += 1
R = max(r)
nr = {i for i, x in enumerate(r) if x == R}
C = max(c)
nc = {i for i, x in enumerate(c) if x == C}
count = sum(x in nr and y in nc for x, y in s)
print(R + C - (len(nr) * len(nc) == count))
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

li_f = list.sort(F)
li_a = list.sort(A, reverse = True)

from operator import mul
combined1 = map(mul, li_f, li_a)

for i in range(1, K):
  n_max = combined1.index(max(combined1))
  li_a[n_max] = li_a[n_max] - 1
  ans = max(combined1)
 
print(ans)

### FIXED CODE ###

import numpy as np

import sys
input = sys.stdin.buffer.readline

N, K = map(int, input().split())
A = np.array(input().split(), np.int64)
F = np.array(input().split(), np.int64)

A.sort()
F.sort()

F= F[::-1]

left = -1
right = (A * F).sum()
while left + 1 < right:
  middle = (left + right) // 2
  right_arr = np.maximum(0, A - middle // F).sum() <= K
  if right_arr:
    right = middle
  else:
    left = middle
print(right)
import sys
from collections import deque
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, M = map(int, input().split())
m = [list(map(int, input().split())) for _ in range(m)]
 
G = [[] for _ in range(N + 1)]
for a, b in zip(m, m):
    G[a].append(b)
    G[b].append(a)
 
par = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])
while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        par[w] = v
        q.append(w)
 
print('Yes')
print(*par[2:], sep='\n')

### FIXED CODE ###

import sys
from collections import deque
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
N, M = map(int, readline().split())
 
G = [[] for _ in range(N + 1)]
m = map(int, read().split())
for a, b in zip(m, m):
    G[a].append(b)
    G[b].append(a)
 
par = [0] * (N + 1)
visited = [0] * (N + 1)
root = 1
visited[root] = 1
q = deque([root])
while q:
    v = q.popleft()
    for w in G[v]:
        if visited[w]:
            continue
        visited[w] = 1
        par[w] = v
        q.append(w)
 
print('Yes')
print(*par[2:], sep='\n')
A,B = int(input().split())
count = 0
for i in range(A,B+1):
  if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]:
    count += 1
print(count)

### FIXED CODE ###

A,B = map(int,input().split())
count = 0
for i in range(A,B+1):
  if str(i)[0] == str(i)[4] and str(i)[1] == str(i)[3]:
    count += 1
print(count)
N = int(input())
S = list(input())

# print(N, S)
ans = N

for i, h in enumerate(range(N)):
    skipflg = False
    f = S[0: i]
    l = S[i]
    s = S[i+1:]
    print(f, l, s)
    nw = 0
    ne = 0
    nw = f.count('W')
    ne = s.count('E')
    print(nw, ne)
    # for r in f:
    #     if r != 'E':
    #         nw += 1
    #         if nw >= ans:
    #             skipflg = True
    #             break
    #         # print('not e')

    # if skipflg:
    #     break

    # for w in s:
    #     if w != 'W':
    #         ne += 1
    #         if nw+ne >= ans:
    #             skipflg = True
    #             break
    #         # print('not w')

    # if skipflg:
    #     break

    ans = min(ans, nw+ne)

print(ans)


### FIXED CODE ###

N = int(input())
S = list(input())

# print(N, S)
ans = N

f = S[0]
s = S[1:]

nw = 0
ne = 0

for w in s:
    if w != 'W':
        ne += 1

ans = nw+ne
for i in range(1, N):
    # skipflg = False
    # f = S[0: i]
    # l = S[i]
    # s = S[i+1:]
    # # print(i, f, l, s)
    # nw = f.count('W')
    # ne = s.count('E')
    # print(nw, ne)

    if S[i-1] != 'E':
        nw += 1

    if S[i] != 'W':
        ne -= 1
    # print(nw, ne)
    ans = min(ans, nw+ne)

print(ans)
import math
from functools import reduce
from math import gcd
K = int(input())
A=[]
B=[]
sum=0
for a in range(1,K+1):
    for b in range(1,K+1):
        A.append(gcd(a,b))
for c in range(1,K+1):
    for d in range(1,K+1):
        B.append(gcd(A[c],d)
        sum+=B[c]
print(sum)

### FIXED CODE ###

import math
 
 
N = int(input())
 
s = 0
 
for i in range(N):
    for j in range(N):
        ss = math.gcd(i+1,j+1)
        for k in range(N):
            s +=math.gcd(ss,k+1)
 
print(s)
n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

tmp = format(max(k,max(ai)), 'b')

lng = len(tmp)
tmp = format(k, '0'+str(lng)+'b')

li = [0]*(lng)
ai_li = [0]*(n)
#print(len(ai))
#exit()
for i in range(n):
    #print(i)
    #print(ai[i])
    #print(format(ai[i], '0'+str(lng)+'b'))
    ai_li[i] = format(ai[i], '0'+str(lng)+'b')

add_enb_flag = False

for i in range(lng):
    cnt = 0
    for j in range(n):
        if ai_li[j][i] == '1':
            cnt += 1
    #print(cnt,i)
    if cnt >= (n+1) // 2:
        if tmp[i] == "1":
            add_enb_flag = True
        li[i] = 0
    elif tmp[i] == '1' or add_enb_flag == True:
        li[i] = 1
    else:
        li[i] = 0
k_m = 0
bai = 1

for i in range(lng):
    k_m += li[n-i-1] *bai
    bai *= 2

#print(k_m,ai_li,tmp,li)
        
ans = 0
for i in range(n):
    ans += k_m^ai[i]
    
print(ans)


### FIXED CODE ###

n,k = map(int,input().split())
ai = [int(i) for i in input().split()]

tmp = format(max(k,max(ai)), 'b')

lng = len(tmp)
tmp = format(k, '0'+str(lng)+'b')

li = [0]*(lng)
ai_li = [0]*(n)

for i in range(n):
    #print(i)
    #print(ai[i])
    #print(format(ai[i], '0'+str(lng)+'b'))
    ai_li[i] = format(ai[i], '0'+str(lng)+'b')

add_enb_flag = False

for i in range(lng):
    cnt = 0
    for j in range(n):
        if ai_li[j][i] == '1':
            cnt += 1
    #print(cnt,i)
    if cnt >= (n+1) // 2:
        if tmp[i] == "1":
            add_enb_flag = True
        li[i] = 0
    elif tmp[i] == '1' or add_enb_flag == True:
        li[i] = 1
    else:
        li[i] = 0
k_m = 0
bai = 1

for i in range(lng):
    k_m += li[lng-i-1] *bai
    bai *= 2

#print(k_m,ai_li,tmp,li)
        
ans = 0
for i in range(n):
    ans += k_m^ai[i]
    
print(ans)
import sys
input = sys.stdin.readline
N,M=map(int,input().split())
list1=list(map(int,input().split()))
listBC=[]
for _ in range(M):
  B,C=map(int,input().split())
  listBC+=[[C,B]]  
listBC.sort(reverse=True)
i=0
while min(list1)<listBC[i][0]:  
  list1+=[listBC[i][0]]*listBC[i][1]
  for k in range(listBC[i][1]):
    list1.remove(min(list1))
  i+=1  
SUM=sum(list1)
print(SUM)

### FIXED CODE ###

N,M = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort()
 
listBC = [list(map(int, input().split())) for i in range(M)]
listBC = sorted(listBC, key=lambda x: x[1], reverse=True)
countB = 0
 
for i in range(M):
  B, C = listBC[i][0], listBC[i][1]
  listA += [C]*B
  countB += B
  if countB >= N:
    break

listA.sort(reverse=True)
print(sum(listA[:N]))
x=raw_input
x*x*x
print(x)



### FIXED CODE ###

x=int(input())
print(x*x*x)
n = int(input())
a, b, c = map(int, input().split())

i = 0
while True:
    a_ans = divmod(a, 2)
    b_ans = divmod(b, 2)
    c_ans = divmod(c, 2)
    if a_ans[1] == 0 and b_ans[1] == 0 and c_ans[1] == 0:
        i += 1
        a = a_ans[0]
        b = b_ans[0]
        c = c_ans[0]
    else:
        break
print(i)

### FIXED CODE ###

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

i = 0
per = True
while per == True:
    for index in range(n):
        num = a[index]
        ans = divmod(num, 2)
        if num == 0 or ans[1] != 0:
            per = False
            break
        a[index] = ans[0]
    if per == True:
        i += 1
print(i)
N = int(input())
paths = {}
for i in range(N-1):
    u, v, w = map(int,input().split())
    paths.setdefault(u, {})
    paths[u][v] = w
    paths.setdefault(v, {})
    paths[v][u] = w

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in zip(paths[now].keys(), paths[now].values()):
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1])


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N = int(input())
paths = {}
for i in range(N-1):
    u, v, w = map(int,input().split())
    paths.setdefault(u, {})
    paths[u][v] = w
    paths.setdefault(v, {})
    paths[v][u] = w

node_colors = [-1] * (N+1)

def route(last, now, dist):
    for next_node, next_distance in zip(paths[now].keys(), paths[now].values()):
        node_colors[next_node] = (dist + next_distance) % 2
        if next_node != last:
            route(now, next_node, dist + next_distance)

node_colors[1] = 0

route(0, 1, 0)

for i in range(N):
    print(node_colors[i+1])
while True:
    n, x = map(int, input().split())
    if (n == x == 0):
    break

    count = 0
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1)
                Sum = a + b + c
                if (Sum == x):
                    count += 1 
    print(count)

### FIXED CODE ###

while True:
    n, x = map(int, input().split())
    if (n == x == 0):
        break

    count = 0
    for a in range(1, x // 3):
        for b in range(a + 1, x // 2):
            for c in range(b + 1, n + 1):
                Sum = a + b + c
                if (Sum == x):
                    count += 1 
    print(count)
s = input()
t = input()
ratio = []
cnt = 0

for k in range(len(s) - len(t)):
    for i in range(len(t)):
        if s[i + k] == t[i]:
            cnt += 1
    ratio.append(cnt)
    cnt = 0
res = len(t) - max(ratio)
print(res)

### FIXED CODE ###

s = input()
t = input()
ratio = []
cnt = 0
if len(s) == len(t):
    for i in range(len(t)):
        if s[i] == t[i]:
            cnt += 1
    ratio.append(cnt)
else:
    for k in range(len(s) - len(t)):
        for i in range(len(t)):
            if s[i + k] == t[i]:
                cnt += 1
        ratio.append(cnt)
        cnt = 0
res = len(t) - max(ratio)
print(res)
package main

import "fmt"

func main(){
    var a, b int
    fmt.Scan(&a, &b)
    if (a*b%2==0){
        fmt.Println("even")
    }else{
        fmt.Println("odd")
    }
     
}

### FIXED CODE ###

a, b = map(int, input().split())
print(["Even","Odd"][a*b%2])
n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(1, n):
  s.append(abs(a[:i] - a[i:]))
print(min(s))
  

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
s = []
for i in range(1, n):
  s.append(abs(sum(a[:i]) - sum(a[i:])))
print(min(s))
from collections import deque
import sys
sys.setrecursionlimit(20000000)
f = open("C:/Users/naoki/Desktop/Atcoder/input.txt")


N = int(f.readline())
ab = [list(map(int, f.readline().split())) for _ in range(N-1)]
routes = [[] for _ in range(N)]

for i in range(len(ab)):
    routes[ab[i][0]-1].append([ab[i][1]-1, i])
    routes[ab[i][1]-1].append([ab[i][0]-1, i])

route_color = [-10e+10 for _ in range(len(ab))]

route_num = [0]*N
max_route = 0
for i in range(N):
    num = len(routes[i])
    route_num[i] = num
    if max_route < num:
        max_route = num

seen = [False for _ in range(N)]

def function(num):
    seen[num] = True
    colors = set(range(max_route))
    for route in routes[num]:
        if route_color[route[1]] != -10e+10:
            colors.remove(route_color[route[1]])
        else:
            route_color[route[1]] = colors.pop()
        if seen[route[0]] == False:
            function(route[0])

function(0)
print(max_route)
for color in route_color:
    print(color+1)

### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(20000000)

N = int(input())
ab = [list(map(int, input().split())) for _ in range(N-1)]
routes = [[] for _ in range(N)]

for i in range(len(ab)):
    routes[ab[i][0]-1].append([ab[i][1]-1, i])
    routes[ab[i][1]-1].append([ab[i][0]-1, i])

route_color = [-10e+10 for _ in range(len(ab))]

route_num = [0]*N
max_route = 0
for i in range(N):
    num = len(routes[i])
    route_num[i] = num
    if max_route < num:
        max_route = num

seen = [False for _ in range(N)]

def function(num,pre_color):
    color_num = -1
    for route in routes[num]:
        color_num += 1
        if color_num == pre_color:
            color_num+=1
        if route_color[route[1]] != -10e+10:
            color_num-=1
            pass
        else:
            route_color[route[1]] = color_num
            
        if seen[route[0]] == False:
            seen[route[0]] = True
            function(route[0],route_color[route[1]])
    return

function(0,-1)
print(max_route)
for color in route_color:
    print(color+1)
N = int(input())
S = input()
print("Yes" if N%2 == 0 and S[:N/2] == S[N/2:N] else "No")

### FIXED CODE ###

N = int(input())
S = input()
print("Yes" if S[:N//2] == S[N//2:N] else "No")
#2-1-1 #ABC104C
d,g=map(int,input().split())
q=[]
comp=[]
bornus=[]
for i in range(d):
    p,c=map(int,input().split())
    q.append(p)
    bornus.append(100*(i+1)*p+c)
    comp.append((100*(i+1)*p+c)/p)
    
p=[100*i for i in range(1,d+1)]
    
data={0:[0 for i in range(d)]}
def makemax(p,q,bornus,comp,k):
    now=0
    point=0
    pnow=p.copy()
    qnow=q.copy()
    bornusnow=bornus.copy()
    compnow=comp.copy()
    while now<k:
        compnown=compnow.copy()
        kagen=max(pnow)
        kagenidx=pnow.index(kagen)
        kagen_num=qnow[kagenidx]
        for i in range(d):
            maxcomp=max(compnown)
            compnown.pop(compnow.index(maxcomp))
            maxidx=compnow.index(maxcomp)
            if maxcomp<kagen:break
            if qnow[maxidx]>k-now:continue
            point+=bornusnow[maxidx]
            now+=qnow[maxidx]
            compnow[maxidx]=0
            pnow[maxidx]=0
            if maxidx==kagenidx:
                kagen=max(pnow)
                kagenidx=pnow.index(kagen)
                kagen_num=qnow[kagenidx]
        adit=min(k-now,kagen_num)
        if adit==kagen_num:
            point+=bornusnow[kagenidx]
            now+=kagen_num
        elif adit<kagen_num:
            point+=adit*kagen
            now+=adit
        compnow[kagenidx]=0
        pnow[kagenidx]=0
    return point

ans=-1
k=0
while ans==-1:
    if makemax(p,q,bornus,comp,k)>=g:
        ans=k
        
    k+=1
print(ans) 

### FIXED CODE ###

d,g = map(int,input().split())
q={}
comp={}
p={}
minsolve=0
for i in range(d):
    a,b=map(int,input().split())
    q[i]=a
    p[i]=100*(i+1)
    comp[i]=100*(i+1)*a+b
    minsolve+=a
    
solve=[0 for _ in range(d)]
def roop(s,check,point,solved,minsolve):
    solve=s.copy()
    solve2=s.copy()
    if check==d:
        if point>g:
            minsolve=min(minsolve,solved)
            return minsolve
        if 0 in solve:
            solverev=solve.copy()
            solverev.reverse()
            idx=d-solverev.index(0)-1
            shold=1+(g-point-1)//p[idx]
            if q[idx]>shold and shold>=0:
                solved+=shold
                minsolve=min(minsolve,solved)
        return minsolve

    minsolve=roop(solve,check+1,point,solved,minsolve)
    solve2[check]+=1
    minsolve=roop(solve2,check+1,point+comp[check],solved+q[check],minsolve)
    return minsolve

print(roop(solve,0,0,0,minsolve))
n, y = map(int, input().split())

for i in range(n):
    for j in range(n):
        for k in range(n):
            a = i * 10000
            b = j * 5000
            c = k * 1000
            num = i + j + k
            price = a + b + c
            if num == 9 and price == y:
                print(i, j, k)
                exit()
print(-1, -1, -1)

### FIXED CODE ###

print(input().replace("2017", "2018"))
import random

def calc(t, D, s):
  last = [0 for _ in range(26)]
  value = 0
  for i in range(D):
    day = i + 1
    value += s[i][t[i]-1]
    last[t[i]-1] = day
    for j in range(26):
      value -= c[j] * (day - last[j])
  return value

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

t = random.sample(range(1, 27), k=D)

val = calc(t, D, s)
for _ in range(1000):
  d_rand = random.randrange(1, D+1)
  q_rand = random.randrange(1, 27)
  old = t[d_rand-1]
  t[d_rand-1] = q_rand
  if val > calc(t, D, s):
    continue
    #t[d_rand-1] = old
  else:
    val = calc(t, D, s)

for i in range(D):
  print(1)

### FIXED CODE ###

D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(D)]

for i in range(D):
  print(s[i].index(max(s[i]))+1)
N = int(input())
A = [input() for _ in range(N)]

max_A = max(A)
Second = A.copy()
Second.remove(max(max_A))
second_A = max(Second)

max_index = [i for i, v in enumerate(A) if v == max_A]

answer = [max_A] * N
for i in max_index:
    answer[i] = second_A
for i in range(N):
    print(answer[i])

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
max_A = max(A)

# 複数の最大値のインデックスを全て取得
max_index = [i for i, v in enumerate(A) if v == max_A]

# 最大値は1個か?
one_max = (len(max_index) == 1)
answer = [max_A] * N

if one_max:
    Second = A.copy()
    Second.remove(max_A)
    Second_A = max(Second)
    for i in max_index:
        answer[i] = Second_A
for i in range(N):
    print(answer[i])
from decimal import Decimal

def main():
    a, b = input().split()
    v = int((Decimal(a) * Decimal(b))
    print(v)

main()

### FIXED CODE ###

def main():
    astr, bstr = input().split()
    a = int(astr)
    b = int(''.join(c for c in bstr if c != '.'))
    trunc = (a * b) // 100
    print(trunc)


main()
def main():
    N = int(input())
    H = [int(n) for n in input().split()]

    counter = 0
    canView = False
    for i, h in enumerate(H):
        for j in range(i):
            if H[j] > h:
                canView = True
        if canView:
            counter += 1

    print(counter)


if __name__ == '__main__':
    main()



if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    H = [int(n) for n in input().split()]

    counter = 0
    for i, h in enumerate(H):
        canView = True
        for j in range(i):
            if H[j] > h:
                canView = False
        if canView:
            counter += 1

    print(counter)


if __name__ == '__main__':
    main()
a,b,c=map(int,input().split())

if sum(a,b) == c or sum(a,c) == b or sum(c,b) == a:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

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

if a+b==c or a+c==b or c+b==a:
    print("Yes")
else:
    print("No")
a, b, c, d = map(int, input().split())
print("Bad" if a == b or b == c or c == d else "Good")

### FIXED CODE ###

s = input()
print("Bad" if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] else "Good")
n=input()

    if  '7' in n:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

def resolve():
    n=input()

    if  '7' in n:
        print('Yes')
    else:
        print('No')
if __name__ == "__main__":
    resolve()
s = input().split(",")
n = int(s[0])
k=int(s[1])

if k == 1:
    return 0;
else:
    return n-k

### FIXED CODE ###

from sys import stdin
l = stdin.readline().rstrip().split()

n = int(l[0])
k=int(l[1])

if k == 1:
    print(0)
else:
    print(n-k)
import bisect,collections,decimal,itertools,math,numpy,string
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(a,b,c):
    decimal.getcontext().prec = 20
    if decimal.Decimal(math.sqrt(a))+decimal.Decimal(math.sqrt(b)) < decimal.Decimal(math.sqrt(c)):
        return 'Yes'
    else:
        return 'No'
    
a,b,c = LI()
print(main(a,b,c))

### FIXED CODE ###

import bisect,collections,decimal,itertools,math,numpy,string
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
##################################################
def main(a,b,c):
    if c-a-b < 0:
        return 'No'
    if 4*a*b < (c-a-b)**2:
        return 'Yes'
    return'No'
    
a,b,c = LI()
print(main(a,b,c))
s = int(input())

dp = [0]*(s+1)
MOD = 10**9+7

dp[0] = 1
dp[1] = 0
dp[2] = 0

if s >= 3:
    for i in range(3, s+1):
        dp[i] = (dp[i-1] + dp[i-3]) % MOD
    print(dp[s])
else:
    print(0)


### FIXED CODE ###

s = int(input())

dp = [0]*(2001)
MOD = 10**9+7

dp[0] = 1
dp[1] = 0
dp[2] = 0

if s >= 3:
    for i in range(3, s+1):
        dp[i] = (dp[i-1] + dp[i-3]) % MOD
    print(dp[s])
else:
    print("0")
N,K=map(int,input().split())
x=list(map(int,input().split()))
#print(x)

list1=[]
list2=[]
for i in range(len(x)):
    if x[i]<0:
        list2.append(x[i])
    else:
        list1.append(x[i])
list2.sort(reverse=True)
#print(list1)
#print(list2)
if N==1:
    print(abs(x[0]))
else:
    
    list3=[]
    for j in range(1,K):
        if len(list1)-j>=K-1:
            list3.append(list1[K-1])
        elif len(list1)-j>=0:
            list3.append(list1[len(list1)-j]*2+list2[K-2-len(list1)+j]*(-1))
            list3.append(list1[len(list1)-j]+list2[K-2-len(list1)+j]*(-2))
        elif list2[K-len(list1)+J]<=len(list2)-1 :
            list3.append(list2[K-1]*(-1))
            break
        else:
            break
        #print(j)
    #print(list3)
    print(min(list3))
            

### FIXED CODE ###

N,K=map(int,input().split())
x=list(map(int,input().split()))
#print(x)

list1=[]
for i in range(N-K+1):
    if x[i+K-1]<=0:
        list1.append(x[i]*(-1))
    elif x[i]>=0:
        list1.append(x[i+K-1])
    else:
        list1.append(x[i+K-1]*2-x[i])
        list1.append(x[i+K-1]-x[i]*2)
#print(list1)
print(min(list1))
l, r = map(int, input().split())
if r - l > 3000:
  print(0)
else:
  ans = 2000
  for i in range(l, r + 1):
    for j in reversed(range(l, r + 1)):
      #print(str(i) + ' ' + str(j))
      if j <= i: break
      ans = min(ans, (i * j) % 2019)
print(ans)
      

### FIXED CODE ###

l, r = map(int, input().split())
mod = 2019
if r - l > 3000:
  print(0)
else:
  ans = mod
  for i in range(l, r + 1):
    for j in range(r, l, -1):
      #print(str(i) + ' ' + str(j))
      if j <= i: break
      ans = min(ans, (i * j) % mod)
  print(ans)
n, q = map(int, input().split())
s = list(str(input()))


t = [0] * (n+1)
for i in range(n):
    if s[i] == 'A' and s[i+1] == 'C':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]
        

for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

### FIXED CODE ###

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


t = [0] * (n+1)
for i in range(n):
    if s[i:i+2] == 'AC':
        t[i+1] = t[i] + 1
    else:
        t[i+1] = t[i]

        
for i in range(q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
import sys
import math
N = input()
AList = list(map(int, input().split()))
listnum = 1000000000

low = -1000000000
high = 1000000000

mode = 1
a1 = 0
a2 = 0
while(True):
    p1 = math.floor((abs(low) + abs(high))/3) + low
    p2 = high - math.floor((abs(low) + abs(high))/3) 

    for j in range(1,int(N)+1):
        a1 += abs(AList[j-1] -(p1 + j))
    for j in range(1,int(N)+1):
        a2 += abs(AList[j-1] -(p2 + j))

    if a1 == a2 or abs(a1-a2) == 1:
        print(min(a1,a2))
        sys.exit()
    elif a1 < a2:
        high = p2
    else:
        low = p1        
    a1 = 0
    a2 = 0

### FIXED CODE ###

from statistics import median
N = int(input())
AList = list(map(int, input().split()))
 
L = []
m = 0
for j in range(1, N+1):
    L.append(AList[j-1] - j)
m = median(L)
 
p = 0
for j in range(1, N+1):
    p += abs(AList[j-1] - j - m)
 
print(int(p))