Harryxun/stf_run huggingface dataset:
import numpy as np

in_string = input()
in_arr = in_string.split()
N = np.int64(in_arr[0])
A = np.int64(in_arr[1])
B = np.int64(in_arr[2])

if ((A-B) % np.int64(2)) == np.int64(0):
    print(np.int64((B-A)/np.int64(2)))
else:
    if (N-B) > A-np.int64(1):
        print(int(A+((B-A)-1)/2)
    else:
        print(int(N-B+1+(N-(A+N-B+1))/2))


### FIXED CODE ###

in_string = raw_input()
in_arr = in_string.split()
N = int(in_arr[0])
A = int(in_arr[1])
B = int(in_arr[2])

if ((B-A) % 2) == 0:
    print(int((B-A)/2))
else:
    if (N-B) > A-1:
        print(int(A+(B-A-1)/2))
    else:
        print(int(N-B+1+((N-(A+N-B+1))/2)))
import numpy as np
import math
N, D, A = map(int, input().split())
xh = np.array(sorted([list(map(int, input().split())) for _ in range(N)]), dtype=np.int32)
b = 0
c = 0
while 1:
  if all(xh[:, 1]<=0):
    break
  x, h = xh[c]
  c += 1
  if h<=0:
    continue
  r = min(x+2*D, xh[-1, 0])
  times = math.ceil(h/A)
  xh[xh[:, 0]<=r] -= times*A
  b += times
print(b)

### FIXED CODE ###

from bisect import bisect_right

N, D, A = map(int, input().split())
xh = sorted([list(map(int, input().split())) for _ in range(N)])
ds = [0]*(N+2)
b = 0
for i, (x, h) in enumerate(xh, 1):
  ds[i] += ds[i-1]
  d = ds[i]
  if d>=h:
    continue
  h -= d
  times = h//A if h%A==0 else h//A+1
  ds[i] += times*A
  ds[bisect_right(xh, [x+2*D, float('inf')])+1] -= times*A
  b += times
print(b)
a,b = ((x) for x in input().split(" "))
c = (a - b)
if c > 0:
    print (c)
else:
    print('0')

### FIXED CODE ###

X, t = map(int, input().split())
x = X - t
 
if x > 0:
    print(x)
else:
    print(0)
A=input("")
B=input("")

A=int(A)
B=int(B)

K=0
Ans=0
for K in range(-100000,100000,1):
    if abs(A-K)==abs(B-K):
        print(K)
        Ans=K
        break
if Ans==0:
    print("impossible")

### FIXED CODE ###

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

K=(A+B)/2
print(int(K) if int(K)==K else "IMPOSSIBLE")
# 初期入力
N,K = (int(x) for x in input().split(" "))
R,S,P = (int(x) for x in input().split(" "))
ten_janken_dic ={"R":R,"S":S,"P":P} #じゃんけんの役ごとの点を辞書
ten_janken_sort =sorted(ten_janken_dic.items(),key=lambda x: x[1])
T =input()

#合計点と高橋君が出す手を同時進行
sum_janken = 0 # 合計点
takahasi = [] # 高橋君が出す手,K回前の手も出せる＝すべて勝つとした場合
for i in T:
    if i =="r":
        sum_janken += P #6
        takahasi.append("P")
    elif i == "s":
        sum_janken += R #8
        takahasi.append("R")

    elif i == "p":
        sum_janken += S #7
        takahasi.append("S")
takahasi_mae =[]
from copy import deepcopy
takahasi_mae = deepcopy(takahasi)

# K回前の手は出せない        
for i,v in enumerate(takahasi[K:]):
    if v ==takahasi[(i+K)-K]:
        sum_janken -= ten_janken_dic[v]
        x = ["R","S","P"]
        if takahasi[(i+K)-K] in x:
            x.remove( takahasi[(i+K)-K] ) #K回前の手を消す
        if i+K+K <=len(takahasi):    
            if takahasi[i+K+K] in x:
                x.remove( takahasi[i+K+K] ) #K回後の手を消す
        if len(x) ==1:
            takahasi[i+K] =x[0]
        elif x[0]==ten_janken_sort[2][0] or x[1] ==ten_janken_sort[2][0] : #高い点を選ぶ
            takahasi[i+K] =ten_janken_sort[2][0]
        else:
            takahasi[i+K] =ten_janken_sort[1][0] #2番目に高い点のキー（点順でソートしてある）
print(sum_janken)

### FIXED CODE ###

# 初期入力
N,K = (int(x) for x in input().split(" "))
R,S,P = (int(x) for x in input().split(" "))
ten_janken_dic ={"R":R,"S":S,"P":P} #じゃんけんの役ごとの点を辞書
ten_janken_sort =sorted(ten_janken_dic.items(),key=lambda x: x[1])
T =input()

#合計点と高橋君が出す手を同時進行
sum_janken = 0 # 合計点
takahasi = [] # 高橋君が出す手,K回前の手も出せる＝すべて勝つとした場合
for i in T:
    if i =="r":
        sum_janken += P #6
        takahasi.append("P")
    elif i == "s":
        sum_janken += R #8
        takahasi.append("R")

    elif i == "p":
        sum_janken += S #7
        takahasi.append("S")
takahasi_mae =[]
from copy import deepcopy
takahasi_mae = deepcopy(takahasi)

# K回前の手は出せない        
for i,v in enumerate(takahasi[K:]):
    if v ==takahasi[(i+K)-K]:
        sum_janken -= ten_janken_dic[v]
        x = ["R","S","P"]
        if takahasi[(i+K)-K] in x:
            x.remove( takahasi[(i+K)-K] ) #K回前の手を消す
        if i+K+K < len(takahasi):    
            if takahasi[i+K+K] in x:
                x.remove( takahasi[i+K+K] ) #K回後の手を消す
        if len(x) ==1:
            takahasi[i+K] =x[0]
        elif x[0]==ten_janken_sort[2][0] or x[1] ==ten_janken_sort[2][0] : #高い点を選ぶ
            takahasi[i+K] =ten_janken_sort[2][0]
        else:
            takahasi[i+K] =ten_janken_sort[1][0] #2番目に高い点のキー（点順でソートしてある）
print(sum_janken)
import sys
sys.setrecursionlimit(10**15)

N = int(input())

def DoubleFactorial(n):
    if n == 0 or n == 1:
        return 1
    else:
        return n*DoubleFactorial(n-2)

num = float(DoubleFactorial(N))

count = -1
while num.is_integer():
    num /= 10
    count += 1

print(count)

### FIXED CODE ###

from math import factorial

N = int(input())

if N%2 == 0:
    ans = 0
    devisor = 10
    while devisor <= N:
        ans += N//devisor
        devisor *= 5
    print(ans)   
else:
    print(0)
# abc044_a
# https://atcoder.jp/contests/abc044/tasks/abc044_a

# 最初のK泊までは、X円
# K＋1泊目以降は、Y円

# N泊連続で宿泊した際の宿泊費

# 入力
n, k, x, y = map(int, input().split())

# 処理

# x円とy円
if n > k:
    answer = k * x + (n - k) * y
# x円のみ
else:
    answer = n * x

print(answer)


### FIXED CODE ###

# abc044_a
# https://atcoder.jp/contests/abc044/tasks/abc044_a

# 最初のK泊までは、X円
# K＋1泊目以降は、Y円

# N泊連続で宿泊した際の宿泊費

# 入力
n = int(input())
k = int(input())
x = int(input())
y = int(input())

# 処理

# x円とy円
if n > k:
    answer = k * x + (n - k) * y
# x円のみ
else:
    answer = n * x

print(answer)
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]

count = 0
for n in range(N):
  sum = C
  for m in range(M):
    sum += b[m]*a[n][m]
  if sum > 0:
    count += 1
print(count)

### FIXED CODE ###

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
count=0
for n in range(N):
    sum = C
    for m in range(M):
        sum += B[m]*A[n][m]
    if sum > 0:
        count+= 1
print(count)
N = int(input())
ab = [list(map(int, input().split())) for _ in range(N - 1)]

T = [[0] * N for _ in range(N)]
R = {}
for a, b in ab:
  T[a - 1][b - 1] = 1
  T[b - 1][a - 1] = 1
  if a - 1 in R:
    R[a - 1].append(b - 1)
  else:
    R[a - 1] = [b - 1]
  if b - 1 in R:
    R[b - 1].append(a - 1)
  else:
    R[b - 1] = [a - 1]

L = [0] * N
L[0] = 1
F = []
RL = {}
RL[1] = [0]
RL[2] = []
for i in R[0]:
  F.append(i)
  L[i] = 2
  RL[2].append(i)

k = 2
while F != []:
  k += 1
  Ft = []
  RL[k] = []
  for i in F:
    for j in R[i]:
      if L[j] == 0:
        L[j] = k
        Ft.append(j)
        RL[k].append(j)
  F = Ft

d = 0
D = [0] * N
for i in range(k - 1, 0, -1):
  for j in RL[i]:
    for k in R[j]:
      if L[k] == i - 1:
        if D[k] == 0:
          D[k] = D[j] + 1
          d = max(d, D[j] + 1)
        else:
          d = max(d, D[j] + D[k] + 1)
          D[k] = max(D[k], D[j] + 1)

if d % 3 == 1:
  print("Second")
else:
  print("First")


### FIXED CODE ###

N = int(input())
if N == 1:
  print("First")
  exit()
ab = [list(map(int, input().split())) for _ in range(N - 1)]

R = {}
for a, b in ab:
  if a - 1 in R:
    R[a - 1].append(b - 1)
  else:
    R[a - 1] = [b - 1]
  if b - 1 in R:
    R[b - 1].append(a - 1)
  else:
    R[b - 1] = [a - 1]

L = [0] * N
L[0] = 1
F = []
RL = {}
RL[1] = [0]
RL[2] = []
for i in R[0]:
  F.append(i)
  L[i] = 2
  RL[2].append(i)

k = 2
while F != []:
  k += 1
  Ft = []
  RL[k] = []
  for i in F:
    for j in R[i]:
      if L[j] == 0:
        L[j] = k
        Ft.append(j)
        RL[k].append(j)
  F = Ft

d = 0
D = [0] * N
for i in range(k - 1, 0, -1):
  for j in RL[i]:
    for k in R[j]:
      if L[k] == i - 1:
        if D[k] == 0:
          D[k] = D[j] + 1
          d = max(d, D[j] + 1)
        else:
          d = max(d, D[j] + D[k] + 1)
          D[k] = max(D[k], D[j] + 1)

if d % 3 == 1:
  print("Second")
else:
  print("First")
N = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    B[i] = B[i-1]+A[0][i-1]
C = [0 for _ in range(N+1)]
for i in range(1,N):
    C[i] = C[i-1]+A[1][i-1]
cmax = 0
for i in range(N):
    a = A[i+1]+B[N]-B[i]
    cmax = max(cmax,)
print(cmax)

### FIXED CODE ###

N = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
B = [0 for _ in range(N+1)]
for i in range(1,N+1):
    B[i] = B[i-1]+A[0][i-1]
C = [0 for _ in range(N+1)]
for i in range(1,N+1):
    C[i] = C[i-1]+A[1][i-1]
cmax = 0
for i in range(N):
    a = B[i+1]+C[N]-C[i]
    cmax = max(cmax,a)
print(cmax)
n = int(input())
print(if(n%2==0) 1/2 else (n+1)/2/n)

### FIXED CODE ###

N = int(input())
print(1/2 if (N % 2 == 0) else (N + 1) / 2 / N)
#!/usr/bin/env python3

class City:
    def __init__(self, i1, p, y, o=None):
        self.i1 = i1
        self.p = p
        self.y = y
        self.o = o

    def __repr__(self):
        return f"City({self.i1}, {self.p}, {self.y}, {self.o})"

    def get_id(self):
        return "%06d%06d" % (self.p, self.o)

def put_ids(n, cities):
    years = {i: [] for i in range(1, n + 1)}
    for c in cities:
        years[c.p].append(c.y)

    year_to_order = {i: {} for i in range(1, n + 1)}
    for i in range(1, n + 1):
        ys = sorted(years[i])
        for j0, y in enumerate(ys):
            year_to_order[i][y] = j0 + 1

    for c in cities:
        c.o = year_to_order[c.p][c.y]

def main():
    n, m = map(int, input().split())
    cities = []
    for i0 in range(m):
        p, y = map(int, input().split())
        city = City(i0, p, y)
        cities.append(city)
    put_ids(n, cities)
    for c in cities:
        print(c.get_id())

main()


### FIXED CODE ###

#!/usr/bin/env python3

class City:
    def __init__(self, i1, p, y, o=None):
        self.i1 = i1
        self.p = p
        self.y = y
        self.o = o

    # def __repr__(self):
    #     return f"City({self.i1}, {self.p}, {self.y}, {self.o})"

    def get_id(self):
        return "%06d%06d" % (self.p, self.o)

def put_ids(n, cities):
    years = {i: [] for i in range(1, n + 1)}
    for c in cities:
        years[c.p].append(c.y)

    year_to_order = {i: {} for i in range(1, n + 1)}
    for i in range(1, n + 1):
        ys = sorted(years[i])
        for j0, y in enumerate(ys):
            year_to_order[i][y] = j0 + 1

    for c in cities:
        c.o = year_to_order[c.p][c.y]

def main():
    n, m = map(int, input().split())
    cities = []
    for i0 in range(m):
        p, y = map(int, input().split())
        city = City(i0, p, y)
        cities.append(city)
    put_ids(n, cities)
    for c in cities:
        print(c.get_id())

main()
n, l = map(int, input().split())
a = sorted([input() for i in range(n)])
print("".join(s))

### FIXED CODE ###

n, l = map(int, input().split())
s = [input().rstrip() for i in range(n)]
print(''.join(sorted(s)))
import numpy as np
N = int(input())
B = list(map(int, input().split()))
A = [0]*N
A[0]=min(B[0],B[1])
for i in range(1,N-1):
    A[i]=min(B[i],B[i-1])
A[N-1]=B[N-2]
print(np.sum(A))

### FIXED CODE ###

#c
import numpy as np
N = int(input())
B = list(map(int, input().split()))
A = [0]*N
if N>2:
    A[0]=B[0]
    for i in range(1,N-1):
        A[i]=min(B[i],B[i-1])
    A[N-1]=B[N-2]
    print(np.sum(A))
else:
    print(B[0]*2)
print(int(input())+int(input())//2)

### FIXED CODE ###

x,y=map(int,input().split())
print(x+y//2)
a,n=0,int(input())
for i in range(2,int(n**0.5+1)):x=0
  while(n%i==0):n//=i;x+=1
  j=1
  while(x>=j):a+=1;x-=j;j+=1
print(1 if n-1 else a)

### FIXED CODE ###

a,n=0,int(input())
for i in range(2,int(n**0.5+1)):
  x=0
  while(n%i==0):n//=i;x+=1
  j=1
  while(x>=j):a+=1;x-=j;j+=1
print(a+(n>1))
N = int(input())

sn = math.sqrt(N)

while True:
  if N % sn == 0:
    break
  sn += 1

print(sn + (N / sn) - 2)

### FIXED CODE ###

import math

N = int(input())

sn = int(math.sqrt(N) // 1)
ans = N

for i in range(1, sn + 1):
  if N % i == 0:
    ans = min(ans, int(i + (N / i) - 2))

print(ans)
import sys

n, m = map(int, input().split())
x = list(map(int, input().split()))
if m == 1:
    print(0)
    sys.exit()
if n == 1:
    print(max(x) - min(x))
    sys.exit()
x.sort()
a = []
for i in range(m - 1):
    a.append(abs(x[i] - x[i + 1]))
ans = sum(a)
a.sort(reverse=True)
for i in range(n - 1):
    ans -= a[i]
print(max(0, ans))


### FIXED CODE ###

import sys

n, m = map(int, input().split())
x = list(map(int, input().split()))
if m == 1:
    print(0)
    sys.exit()
if n == 1:
    print(max(x) - min(x))
    sys.exit()
if n >= m:
    print(0)
    sys.exit()
x.sort()
a = []
for i in range(m - 1):
    a.append(abs(x[i] - x[i + 1]))
ans = sum(a)
a.sort(reverse=True)
for i in range(n - 1):
    ans -= a[i]
print(max(0, ans))
s = input()

dDic = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1 }

print(int(dDic[s]))


### FIXED CODE ###

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

if a+b+c > 21:
  print('bust')
else:
  print('win')
a = input()
if a%10==7:
  print("Yes")
elif( a%100 )//10==7:
  print("Yes")
elif( a//100 )==7:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = input()
a = int(a)
if a%10==7:
  print("Yes")
elif( a%100 )//10==7:
  print("Yes")
elif( a//100 )==7:
  print("Yes")
else:
  print("No")
import math

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

print( (a * b) // math.gcd(a, b))

### FIXED CODE ###

import fractions

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

print( (a * b) // fractions.gcd(a, b))
def main():
    MOD = 7 + 10**9
    S = list(input())
    N = len(S)
    dp = [[0]*13 for _ in range(N)]
    if S[N-1] == '?':
        for m in range(10):
            dp[0][m] = 1
    else:
        tm = int(S[N-1])%13
        dp[0][tm] = 1
    for i in range(1,N):
        if S[N-1-i] == '?':
            for k in range(10):
                dp[i][j] += sum([dp[i-1][(j-(k*10**i)%13)%13]%MOD for j in range(13)])
        else:
            m = (int(S[N-1-i])*10**i) % 13
            for l in range(13):
                dp[i][l] += dp[i-1][(l-m)%13]
    print(dp[N-1][5]%MOD)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    MOD = 7 + 10**9
    S = tuple(input())
    N = len(S)
    dp = [[0]*13 for _ in range(N+1)]
    dp[0][0] += 1
    s=[1]
    for n in range(1,N):
        s.append((s[n-1]*10)%13)
    for i in range(N):
        for k in range(13):
            if S[-(i+1)] != '?':
                dp[i+1][(k+int(S[-(i+1)])*s[i])%13] += dp[i][k] 
                dp[i+1][(k+int(S[-(i+1)])*s[i])%13] %= MOD
            else:
                for l in range(10):
                    dp[i+1][(k+l*s[i])%13] += dp[i][k]
                    dp[i+1][(k+l*s[i])%13] %= MOD
    print(dp[-1][5])

if __name__ == '__main__':
    main()
N = int(input())
print(N^^3)

### FIXED CODE ###

N = int(input())
print(N**3)
# 190928 D
from math import gcd as bltin_gcd

if __name__ == "__main__":
    def coprime2(a, b):
        return bltin_gcd(a, b) == 1

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

    def divisor(n): #nの約数を全て求める
        i = 1
        table = []
        while i * i <= n:
            if n%i == 0:
                table.append(i)
                table.append(n//i)
            i += 1
        table = list(set(table))
        return table
    A,B = list(map(int,input().split()))
    kotable = sorted(divisor(gcd(A,B)))
    N = len(kotable)
    while True:
        flg = True
        for i in range(0,N-1):
            for j in range(i+1,N,1):
                if coprime2(kotable[i],kotable[j]) == False:
                    kotable.remove(kotable[j])
                    N -= 1
                    flg = False
                    break
            if flg == False:
                break
        if flg == True:
            break
                    
    print(len(kotable))
    

### FIXED CODE ###

# 190928 D

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

A,B = list(map(int,input().split()))
soA = prime_factorize(A)
soB = prime_factorize(B)
output = []
for i in range(len(soA)):
    if soA[i] in soB:
        output.append(soA[i])

print(len(list(set(output))) + 1)
N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for y in range(N-M+1):
    for x in range(N-M+1):
        for k in range(M):
            if A[y+k][x:x+M] != B[y+k]:
                break
        else:
            print("Yes")
            exit()
print("No")

### FIXED CODE ###

import sys

N, M = map(int, input().split())
A = [input() for _ in range(N)]
B = [input() for _ in range(M)]

for y in range(N-M+1):
    for x in range(N-M+1):
        for k in range(M):
            if A[y+k][x:x+M] != B[k]:
                break
        else:
            print("Yes")
            sys.exit()
print("No")
# -*- coding: utf-8 -*-
X = int(input())
t = int(input())
if X > t:
  print(X - t)
else:
  print(0)

### FIXED CODE ###

# -*- coding: utf-8 -*-
X , t= map(int, input().split())
if X > t:
  print(X - t)
else:
  print(0)
import collections
N=int(input())
x=list(map(int,input().split()))
c=collections.Counter(x)
t=[2**i for i in range(len(str(bin(max(x)*2))[2:])+1)[::-1]]
count=0
#print(c)
#print("x=",x)
#print("t=",t)
for i in range(len(x))[::-1]:
    if x[i] != 0:
        for j in range(0,len(t)):
            if t[j] <= x[i]:
                break
            if t[j]-x[i] in c:
                if t[j]-x[i] == x[i]:
                    if c.get(x[i],-1) >= 2:
                        c[x[i]] -= 2
                        count +=1
                        break
                else:
                    if c.get(t[j]-x[i],-1)>0 and c.get(x[i],-1)>0:
                        c[t[j]-x[i]] -= 1
                        c[x[i]] -= 1
                        count+=1
                        break
#print(c)    
print(count)

### FIXED CODE ###

S=input()
count=0
def sigma(i):
    a=[b for b in range(0,i+1)]
    return sum(a)
place=0
flag=0
start=0
for i in range(len(S)):
    if S[i]=="B":
        flag=1
    elif S[i]=="W":
        if flag == 1:
            count += 1
            place += i - start
        else:
            start+=1
ans=place-sigma(count-1)
print(ans)
S=input()
T=input()
from collections import Counter
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(len(s)):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2:
        e=[]
        for j in range(len(s)):
            if t[j]==d[i][0]:
                e.append(s[j])
        for j in range(len(e)-1):
            if e[j]!=e[j+1]:
                flag=False
    if c[i][1]>=2:
        f=[]
        for j in range(len(s)):
            if s[j]==c[i][0]:
                f.append(t[j])
        for j in range(len(f)-1):
            if f[j]!=f[j+1]:
                flag=False
if flag:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

from collections import Counter
S=input()
T=input()
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(min(len(d),len(c))):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2 and flag:
        e=[]
        for j in range(len(s)):
            if t[j]==d[i][0]:
                e.append(s[j])
        for j in range(len(e)-1):
            if e[j]!=e[j+1]:
                flag=False
                break
    if c[i][1]>=2 and flag:
        f=[]
        for j in range(len(s)):
            if s[j]==c[i][0]:
                f.append(t[j])
        for j in range(len(f)-1):
            if f[j]!=f[j+1]:
                flag=False
                break
if flag:
    print('Yes')
else:
    print('No')
N = int(input())
L = list(map(int,input().split()))
S = sum(L)
A = []
for i in range(1,N):
  p = abs(2*sum(L[0:i])-S)
    A.append(p)
print(min(A))

### FIXED CODE ###

N = int(input())
L = list(map(int,input().split()))
S = sum(L)
k = 0
ans = abs(2*sum(L[0:1])-S)
for i in range(0,N-1):
  k += L[i]
  ans = min(ans,abs(2*k-S))
print(ans)
from collections import deque

H, W = map(int, input().split())
items = []
black = []
for i in range(H):
    tmp = input()
    for j in range(W):
        if tmp[j] == "#":
            black.append((i, j))
    items.append(list(tmp))

que = deque()

for b in black:
    que.append(b)

ans = 0
d4 = [(1, 0), (0, -1), (-1, 0), (0, 1)]
next_que = que.copy()
while len(que) != H * W:
    tmp = next_que.copy()
    next_que = []
    for b in list(tmp):
        x, y = b[0], b[1]
        for d in d4:
            dx = d[0]
            dy = d[1]
            if 0 <= x + dx <= H - 1 and 0 <= y + dy <= W - 1:
                tar = items[x + dx][y + dy]
                if tar == ".":
                    next_que.append((x + dx, y + dy))
                    que.append((x + dx, y + dy))
                    items[x + dx][y + dy] = "#"
    ans += 1
print(ans)


### FIXED CODE ###

H, W = map(int, input().split())
items = []
black = []
for i in range(H):
    tmp = list(input())
    for j in range(W):
        if tmp[j] == "#":
            black.append((i, j))
    items.append(tmp)

que = []
for b in black:
    que.append(b)

ans = 0
d4 = [(1, 0), (0, -1), (-1, 0), (0, 1)]
next_que = que
while len(que) != H * W:
    tmp = next_que
    next_que = []
    for b in list(tmp):
        x, y = b[0], b[1]
        for d in d4:
            dx = d[0]
            dy = d[1]
            if 0 <= x + dx <= H - 1 and 0 <= y + dy <= W - 1:
                tar = items[x + dx][y + dy]
                if tar == ".":
                    next_que.append((x + dx, y + dy))
                    que.append((x + dx, y + dy))
                    items[x + dx][y + dy] = "#"
    ans += 1
print(ans)
a = input
count = a.count()
print(a[0]+str(count)+a[count-1])

### FIXED CODE ###

a = input()
count = len(a)
print(a[0]+str(count-2)+a[count-1])
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b_list=[]
for i in range(N):
  b_list.append(int(input))

for i in b_list:
  A1 = [x in A1 if x != i else -1]
  A2 = [y in A2 if y != i else -1]
  A3 = [z in A3 if z != i else -1]

if sum(A1)==-3 or sum(A2)==-3 or sum(A3)==-3:
  print('Yes')
  exit()
for t in range(3)
  if A1[t]+A2[t]+A3[t] == -3:
    print('Yes')
    exit()
if A1[0]+A2[1]+A3[2] == -3 or A1[2]+A2[1]+A3[0] == -3:
  print('Yes')
  exit()
print('No')

### FIXED CODE ###

import sys
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))
N = int(input())
b_list=[]
for i in range(N):
  b_list.append(int(input()))
 
for i in b_list:
  A1 = [x if x != i else -1 for x in A1]
  A2 = [y if y != i else -1 for y in A2]
  A3 = [z if z != i else -1 for z in A3]
 
if sum(A1)==-3 or sum(A2)==-3 or sum(A3)==-3:
  print('Yes')
  sys.exit()
for t in range(3):
  if A1[t]+A2[t]+A3[t] == -3:
    print('Yes')
    sys.exit()
if A1[0]+A2[1]+A3[2] == -3 or A1[2]+A2[1]+A3[0] == -3:
  print('Yes')
  sys.exit()
print('No')
n,k= map(int, input().split())
x= list(map(int, input().split()))
s=0
cnt=0
while x[s]<0:
    s+=1
a=[]
for i in range(s,min(s+k,n)):
    cnt+=1
    if i-k-1>=0:
        a.append(2*x[i]-x[i-k+1])
    if cnt==k:
        a.append(x[i])
s-=1
cnt=0
for i in range(s,max(s-k,-1),-1):
    cnt+=1
    if i+k-1<n:
        a.append(-2*x[i]+x[i+k-1])
    if cnt==k:
        a.append(-x[i])
print(min(a))

### FIXED CODE ###

n,k= map(int, input().split())
x= list(map(int, input().split()))
s=0
cnt=0
while x[s]<0:
    s+=1
    if n==s+1:
        break
a=[]
if x[s]>=0:
    for i in range(s,min(s+k,n)):
        cnt+=1
        if i-k-1>=0:
            a.append(2*x[i]-x[i-k+1])
        if cnt==k:
            a.append(x[i])
    s-=1
cnt=0
for i in range(s,max(s-k,-1),-1):
    cnt+=1
    if i+k-1<n:
        a.append(-2*x[i]+x[i+k-1])
    if cnt==k:
        a.append(-x[i])
print(min(a))