Harryxun/stf_run huggingface dataset:
x1,y1,x2,y2=map(int,input().split())
a=abs(x1-x2)
b=abs(y1-y2)
if(y1<=y2):
  if(x1<=x2):
    print(x2-b,y2+a,x1-b,y1+a)
  else:
    print(x2-b,y2-a,x1-b,y1-a)
else:
  if(x1<=x2):
    print(x2+a,y2-b,x1+a,y1-b)
  else:
    print(x2+b,y2+a,x1+b,y1-a)

### FIXED CODE ###

K=int(input())
print((K//2)*((K + 2 - 1) // 2))
N, T = [int(x) for x in input().strip()]

ok = 2000
for _ in range(N):
  c, t = [int(x) for x in input().strip()]
  if t <= T:
    ok = min(ok, c)

print("TLE" if ok == 2000 else ok)


### FIXED CODE ###

N, T = [int(x) for x in input().split()]

ok = 2000
for _ in range(N):
  c, t = [int(x) for x in input().split()]
  if t <= T:
    ok = min(ok, c)

print("TLE" if ok == 2000 else ok)
while(True):
    a, op, b = input().spilt()
    a = int(a)
    b = int(b)
    if(op == '+'):
        print(a+b)
    elif(op == '-'):
        print(a-b)
    elif(op == '*'):
        print(a*b)
    elif(op == '/'):
        print(a//b)
    elif(op == '?'):
        break


### FIXED CODE ###

while(True):
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if(op == '+'):
        print(a+b)
    elif(op == '-'):
        print(a-b)
    elif(op == '*'):
        print(a*b)
    elif(op == '/'):
        print(a//b)
    elif(op == '?'):
        break
import sys
input=sys.stdin.readline

s=input()
q=int(input())
for i in range(q):
  t=input()
  if t=='1':
    s=s[::-1]
  else:
    t, f, c = map(str, t.split())
    if f =='1':
      s=c+s
    else:
      s=s+c
print(s)

### FIXED CODE ###

s=input()
q=int(input())
head=''
foot=''

a=0
for i in range(q):
  t=input()
  if t=='1':
    a=a^1
  else:
    t, f, c = map(str, t.split())
    f=int(f)
    if (f^a)&1==0:
      foot+=c
    else:
      head=c+head
s=head+s+foot
if a==1:
  s=s[::-1]
print(s)
import sys
sys.setrecursionlimit(1500)
n=int(input())
arr=list(map(int,input().split()))
vis={}
vis[0] = 0
if n < 2:
  print(0)
if n == 2:
  print(min(arr[0]-arr[1]))
vis[1] = min(arr[0]-arr[1])
def count(n):
    if n in vis or n < 0:
        return vis[n]
    else:
      vis[n]=min(abs(arr[n-1]-arr[n-2])+count(n-1),abs(arr[n-1]-arr[n-3])+count(n-2))
    return vis[n]
print(count(n))

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
N = int(input())
lists = list(map(int, input().split()))
count = 1
mins = lists[0]
for i in range(1,N):
	if lists[i] <= mins:
    	count = count + 1
		mins = lists[i]
print(count)

### FIXED CODE ###

N = int(input())
lists = list(map(int, input().split()))
count = 1
mins = lists[0]
for i in range(1,N):
    if lists[i] <= mins:
        count = count + 1
        mins = lists[i]
print(count)
N=int(input())
X=input()
Xnum=int(X,2)
popcount=X.count('1')
for i in range(N):
    if X[i]=='1':
        Xi = Xnum - 2**(N-i-1)
        popcount2=popcount-1
    else:
        Xi = Xnum + 2**(N-i-1)
        popcount2=popcount+1
    if popcount2==0: print(0)
    else:
        ans = 0
        while Xi!=0:
            Xi = Xi % popcount2
            popcount2 = bin(Xi).count('1')
            ans += 1
    print(ans)

### FIXED CODE ###

N=int(input())
X=input()
popcount=X.count('1')
bi1=[]
bi0=[]
Xnum1 = 0
Xnum0 = 0
if popcount != 1:
    for i in range(N):
        if i==0: bi1.append(1)
        else: bi1.append(bi1[i-1]*2%(popcount-1))
        Xnum1 = (Xnum1 + int(X[N-i-1])*bi1[i])%(popcount-1)
for i in range(N):
    if i==0: bi0.append(1)
    else: bi0.append(bi0[i-1]*2%(popcount+1))
    Xnum0 = (Xnum0 + int(X[N-i-1])*bi0[i])%(popcount+1)
for i in range(N):
    if popcount==1 and X[i]=='1':
        print(0)
        continue
    if X[i]=='1':
        Xi = (Xnum1 - bi1[N-i-1])%(popcount-1)
    else:
        Xi = (Xnum0 + bi0[N-i-1])%(popcount+1)
    ans = 1
    while Xi!=0:
        Xi = Xi % bin(Xi).count('1')
        ans += 1
    print(ans)
import numpy as np

N,M = [int(i) for i in input().split(" ")]
H = [int(i) for i in input().split(" ")]
root = np.zeros([N,N])
for i in range(M):
    a,b = [int(i)-1 for i in input().split(" ")]
    root[a,b] = 1
    root[b,a] = 1

ans = 0
for i in range(N):
    count = 0
    for l in range(N):
        if root[i,l] == 1 and H[i] <= H[l]:
            count = 1
    if count == 0:
        ans += 1
    
print(ans)

### FIXED CODE ###

import numpy as np

N,M = [int(i) for i in input().split(" ")]
H = [int(i) for i in input().split(" ")]
mh = np.zeros([N])
for i in range(M):
    a,b = [int(i)-1 for i in input().split(" ")]
    mh[a] = max(mh[a],H[b])
    mh[b] = max(mh[b],H[a])

ans = 0
for i in range(N):
    if mh[i] < H[i]:
        ans += 1

print(ans)
import math
A, B = map(int, input().split())
ans = A * B
print(math.floor(ans))

### FIXED CODE ###

def resolve():
    A, B = input().split()
    ans = int(A)*int(B[0])*100+int(A)*int(B[2:])
    print(str(ans)[:-2] if len(str(ans)) >= 3 else "0")
resolve()
n=int(input())
a=[int(input()) for i in range(n)]
a.append(0)
a.insert(0,0)
print(a)

### FIXED CODE ###

A,B,C,D=[int(input()) for i in range(4)]
print(min(A,B)+min(C,D))
import sys
input=sys.stdin.readline
from string import ascii_lowercase

class BIT(): #1-indexed
    def __init__(self,n): #n: 要素数
        self.size=n
        self.bit=[0]*(n+1)
    def add(self,i,x): #i番目(1-indexed)にxを加算
        while i<=self.size:
            self.bit[i]+=x
            i+=i&-i
    def sum_1_to_i(self,i): #1番目からi番目(含む)までの総和(1-indexed)
        s=0
        while i>0:
            s+=self.bit[i]
            i-=i&-i
        return s
    def sum_i_to_j(self,i,j): #i番目からj番目(含む)までの総和(1-indexed)
        return self.sum_1_to_i(j)-self.sum_1_to_i(i-1)
    def reset(self): #初期化
        self.bit=[0]*(self.size+1)

def main():
    A=ascii_lowercase
    D=dict()
    for i,a in enumerate(A):
        D[a]=i
    n=int(input())
    S=list(input())
    L=[BIT(n) for _ in range(26)]
    for i,s in enumerate(S):
        k=D[s]
        L[k].add(i+1,1)
    q=int(input())
    for _ in range(q):
        k,a,b=input().split()
        if k=='1':
            i=int(a)-1
            s=S[i]
            l1=D[s]
            l2=D[b]
            L[l2].add(i+1,1)
            L[l1].add(i+1,-1)
        else:
            l=int(a); r=int(b)
            ans=0
            for i in range(26):
                ans+=L[i].sum_i_to_j(l,r)>0
            print(ans)
    
if __name__=='__main__':
    main()

### FIXED CODE ###

import sys
input=sys.stdin.readline
from string import ascii_lowercase

class BIT(): #1-indexed
    def __init__(self,n): #n: 要素数
        self.size=n
        self.bit=[0]*(n+1)
    def add(self,i,x): #i番目(1-indexed)にxを加算
        while i<=self.size:
            self.bit[i]+=x
            i+=i&-i
    def sum_1_to_i(self,i): #1番目からi番目(含む)までの総和(1-indexed)
        s=0
        while i>0:
            s+=self.bit[i]
            i-=i&-i
        return s
    def sum_i_to_j(self,i,j): #i番目からj番目(含む)までの総和(1-indexed)
        return self.sum_1_to_i(j)-self.sum_1_to_i(i-1)
    def reset(self): #初期化
        self.bit=[0]*(self.size+1)

def main():
    A=ascii_lowercase
    D=dict()
    for i,a in enumerate(A):
        D[a]=i
    n=int(input())
    S=list(input().strip())
    L=[BIT(n) for _ in range(26)]
    for i,s in enumerate(S):
        L[D[s]].add(i+1,1)
    q=int(input())
    for _ in range(q):
        k,a,b=input().split()
        if k=='1':
            i=int(a)-1
            s=S[i]
            L[D[b]].add(i+1,1)
            L[D[s]].add(i+1,-1)
            S[i]=b
        else:
            l=int(a); r=int(b)
            ans=0
            for i in range(26):
                ans+=L[i].sum_i_to_j(l,r)>0
            print(ans)
    
if __name__=='__main__':
    main()
a,b,k=map(int,input().split())
li =list(range(a,b+1))
li2=[]
for l in li[:k]:
  li2.append(l)
for l in li[-k:]:
  li2.append(l)
li3=sorted(set(li2))
for ll in li3:
  print(ll)

### FIXED CODE ###

A,B,K=map(int,input().split())
li=[]  
for i in range(A,A+K):
  li.append(i)
for j in range(B-K+1,B+1):
  li.append(j)
ans=sorted(set(li))
for l in ans:
  if A<=l<=B:
    print(l)
N = int(input())
xlist = list(map(int, input().split()))
def power(p, xlist):
    s = 0
    for x in xlist:
        s += (x - p)**2
    return s

xmax = max(xlist)
xmin = min(xlist)
powers = []
for p in range(xmin, xmax):
    powers.append(power(p, xlist))
print(min(powers))

### FIXED CODE ###

N = int(input())
xlist = list(map(int, input().split()))
p = round(sum(xlist) / N)
s = 0
for x in xlist:
    s += (x-p)**2
print(s)
s = int(input())
a = s.count(1)
print(a)

### FIXED CODE ###

s = input()
a = s.count("1")
print(a)
H,W,K = list(map(int,input().split()))


amida = [0 for i in range(8)]
amida[0]=1
amida[1]=2
amida[2]=3
amida[3]=5
amida[4]=8
amida[5]=13
amida[6]=21
amida[7]=34

def amida_num(k,l):
    return amida[max(k,0)]*amida[max(l,0)]


dp=[[0 for i in range(W)] for j in range(H+1)]

dp[0][0] = 1

for i in range(1,H+1):
    for j in range(W):
        if j==0:
            dp[i][j]=dp[i-1][j+1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
        elif j==W-1:
            dp[i][j]=dp[i-1][j-1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
        else:
            dp[i][j]=dp[i-1][j-1]*amida_num(j-2,W-j-2) + dp[i-1][j]*amida_num(j-1,W-j-2) + dp[i-1][j+1]*amida_num(j-1,W-j-3)

print(dp[H][K-1]%(10**9+7))

### FIXED CODE ###

H,W,K = list(map(int,input().split()))


amida = [0 for i in range(8)]
amida[0]=1
amida[1]=2
amida[2]=3
amida[3]=5
amida[4]=8
amida[5]=13
amida[6]=21
amida[7]=34

def amida_num(k,l):
    return amida[max(k,0)]*amida[max(l,0)]


dp=[[0 for i in range(W)] for j in range(H+1)]

dp[0][0] = 1

if W!=1:
    for i in range(1,H+1):
        for j in range(W):
            if j==0:
                dp[i][j]=dp[i-1][j+1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
            elif j==W-1:
                dp[i][j]=dp[i-1][j-1]*amida_num(0,W-3) + dp[i-1][j]* amida_num(0,W-2)
            else:
                dp[i][j]=dp[i-1][j-1]*amida_num(j-2,W-j-2) + dp[i-1][j]*amida_num(j-1,W-j-2) + dp[i-1][j+1]*amida_num(j-1,W-j-3)
    print(dp[H][K-1]%(10**9+7))
else:
    print(1)
N,K=[int(i) for i in input().split()]
res=0
for i in range(1,N+1):
  res+=0.5**(math.ceil(math.log2(K/i)))
print(res/N)

### FIXED CODE ###

import math
N,K=[int(i) for i in input().split()]
res=0
for i in range(1,N+1):
	if i<K:
		po=math.ceil(math.log2(K/i))
		j=math.pow(0.5,po)
	else:
		j=1
	res+=j
print(res/N)
from math import *
a,b,c = map(int,input().split())
c = radians(c)
S = a*b*sin(c)/2
print("%f %f %f" %(S,sqrt(a*a+b*b-2*a*b*cos(c)),2*S/a )))


### FIXED CODE ###

from math import *
a,b,c = map(int,input().split())
c = radians(c)
S = a*b*sin(c)/2
print("%.10f %.10f %.10f" %(S,a+b+sqrt(a*a+b*b-2*a*b*cos(c)),2*S/a ))
a = list(map(int,input()))

print(a[0]*a[1])

### FIXED CODE ###

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

print(a[0]*a[1])
N = int(input())
A = int(input())
B = int(input())

print('Hello World' if N == 1 else A+B )

### FIXED CODE ###

N = int(input())

if N==1:
    print('Hello World')
else:
    
    A = int(input())
    B = int(input())

    print(A+B )
a = input()
    b = input()
    c = 0
    for i in range(3):
      if a[i] == b[i]:
        c += 1
    print(c)

### FIXED CODE ###

a = input()
b = input()
c = 0
for i in range(3):
  if a[i] == b[i]:
    c += 1
print(c)
def calc_cost2(h, k):
    n = len(h)
    if (n == 0):
        return 0

    cost = list()
    cost.append(0)
    for i in range(1, len(h)):        
        tmp = cost[i-1] + abs(h[i] - h[i-1])
        for s in range(max(0, i-k), i):
            tmp = min(tmp, cost[s] + abs(h[i] - h[s]))

        cost.append(tmp)

    return cost[n-1]

if __name__ == "__main__":
    n, k = list(map(int, input().split(" ")))
    h = list(map(int, input().split(" ")))
    res = calc_cost2_FAST(h, k)
    print(res)

### FIXED CODE ###

def calc_cost2(h, k):
    n = len(h)
    if (n == 0):
        return 0

    cost = n * [None]
    cost[0] = 0
    for i in range(1, len(h)):
        cost[i] = min([cost[s] + abs(h[i] - h[s]) for s in range(max(0, i-k), i)])
        #cost[i] = min(map(lambda s: cost[s] + abs(h[i] - h[s]), range(max(0, i-k), i)))

    return cost[n-1]


if __name__ == "__main__":
    n, k = list(map(int, input().split(" ")))
    h = list(map(int, input().split(" ")))
    res = calc_cost2(h, k)
    print(res)
n, q = (int(x) for x in input().split())
s = input()
s = [s[i] for i in range(n)]
lr = []
for i in range(q):
    lr.append([int(x) for x in input().split()])
ac = [0 for _ in range(n)]
for i in range(n):
    if s[i] != "A": continue
    elif s[i+1] != "C": continue
    else:
        ac[i] = 1
        ac[i+1] = 1
for p in lr:
    l, r = p[0] - 1, p[1]
    a = sum(ac[l:r])
    if s[l] == "C": a -= 1
    if s[r-1] == "A": a -= 1
    print(int(a/2))

### FIXED CODE ###

n, q = (int(x) for x in input().split())
s = input()
s = [s[i] for i in range(n)]
lr = []
for i in range(q):
    lr.append([int(x) for x in input().split()])
ac = [0 for _ in range(n)]
i, c = 0, 0
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        ac[i+1] = ac[i] + 1
    else:
        ac[i+1] = ac[i]
for p in lr:
    l, r = p[0] - 1, p[1] - 1
    print(int(ac[r] - ac[l]))
from collections import deque
n, k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7

p = []
m = []
for i in a:
    if i >= 0:p.append(i)
    elif i < 0:m.append(i)

p.sort(reverse=True)
m.sort()
res = 1

if len(p) == 0 and k % 2 == 1:
    for i in range(k):
        res = (res * m[-(i + 1)]) %mod
    print(res)

else:
    p_ind = 0
    m_ind = 0
    while k:
        
        if p_ind >= len(p):
            temp = 0
        else:
            temp = p[p_ind] * p[p_ind + 1] if p_ind + 1 < len(p) else p[p_ind]
        temp1 = m[m_ind] * m[m_ind + 1] if m_ind + 1 < len(m) else -1
        if temp > temp1 or k == 1:
            res = (res * p[p_ind]) %mod
            p_ind += 1
            k -= 1
        else:
            res = (res * temp1) %mod
            m_ind += 2
            k -= 2
    print(res)

### FIXED CODE ###

from collections import deque
n, k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10 ** 9 + 7

p = []
m = []
for i in a:
    if i >= 0:p.append(i)
    elif i < 0:m.append(i)

p.sort(reverse=True)
m.sort()
res = 1
if n == k:
    for i in a:
        res = (res * i) %mod
    print(res)
    exit()
    
if len(p) == 0 and k % 2 == 1:
    for i in range(k):
        res = (res * m[-(i + 1)]) %mod
    print(res)

else:
    p_ind = 0
    m_ind = 0
    while k:
        if k == 1:
            res = (res * p[p_ind]) % mod
            break
        
        temp = p[p_ind] * p[p_ind + 1] if p_ind + 1 < len(p) else 0
        temp1 = m[m_ind] * m[m_ind + 1] if m_ind + 1 < len(m) else 0
        if temp > temp1:
            res = (res * p[p_ind]) %mod
            p_ind += 1
            k -= 1
        else:
            res = (res * temp1) %mod
            m_ind += 2
            k -= 2
    print(res)
!pip install numpy

### FIXED CODE ###

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

a_even = a[0::2]
a_odd  = a[1::2] 

# even
if (n - 1) % 2 == 0: # 0-(n-1)の実施なので(n-1)の偶奇を判定
    b = a_even.copy()
    b.reverse()
    b = b + a_odd
# odd
else:
    b = a_odd.copy()
    b.reverse()
    b = b + a_even

b = list(map(str, b))
print(' '.join(b))
a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for i in range(n)]
    ai = [[1]*3 for _ in range(3)]
    for i in range(3):
        for j in range(3):
            if a[i][j] in b:
                ai[i][j] = 0
    ans = "No"
    for k in range(3):
        if sum(ai[k])== 0:
            ans = "Yes"
    for l in range(3):
        if ai[0][k]+ai[1][k]+ai[2][k] == 0:
            ans = "Yes"
    if ai[0][0]+ai[1][1]+ai[2][2] == 0 or ai[0][2]+ai[2][0]+ai[1][1] == 0:
        ans = "Yes"
    print(ans)

### FIXED CODE ###

c = list(map(int,input().split())) + list(map(int,input().split())) + list(map(int,input().split()))
n = int(input())
d = [0]*9
for i in range(n):
    m = int(input())
    for j in range(9):
        if c[j] == m:
            d[j] = 1
if (d[0],d[1],d[2]) == (1,1,1) or (d[3],d[4],d[5]) == (1,1,1) or (d[6],d[7],d[8]) == (1,1,1)\
    or (d[0],d[3],d[6]) == (1,1,1) or (d[1],d[4],d[7]) == (1,1,1) or (d[2],d[5],d[8]) == (1,1,1)\
        or (d[0],d[4],d[8]) == (1,1,1) or (d[2],d[4],d[6]) == (1,1,1):
        print("Yes")
else:
    print("No")
import math

N = int(input())
S = int(input())
L = N-S

def search(b, n=N):
    ans = 0
    while n >= b:
        ans += n%b
        n //= b
    ans += n
    return ans
s
if L < 0:
    print(-1)
elif L == 0:
    print(1)
else:
    P = []
    for l in range(1, int(math.sqrt(L))+1):
        if L%l == 0:
            P.append(l+1)
            P.append(L//l+1)
    P.sort()

    ans = -1
    for p in P:
        S0 = search(p)
        if S == S0:
            ans = p
            break

    print(ans)

### FIXED CODE ###

import math

N = int(input())
S = int(input())
L = N-S

def search(b, n=N):
    ans = 0
    while n >= b:
        ans += n%b
        n //= b
    ans += n
    return ans


def main():

    if L < 0:
        print(-1)
    elif L == 0:
        print(N+1)
    else:
        P = []
        for l in range(1, int(math.sqrt(L))+2):
            if L%l == 0:
                P.append(l+1)
                P.append(L//l+1)
        P.sort()

        ans = -1
        for p in P:
            if p == 1: continue
            S0 = search(p)
            if S == S0:
                ans = p
                break

        print(ans)

if __name__ == "__main__":
    main()
N = int(input())
v = [int(_) for _ in input().split()]

import numpy as np

# v = [2,2,4]
# N = len(v)

A = np.zeros((N, N))
for i in range(N):
    A[(i - 1) % N][i] = 1 / 2
    # A[i][(i - 1) % N] = 1 / 2
    A[i][i] = 1 / 2

# print(A)
# print(np.linalg.inv(A))
ans = np.dot(np.linalg.inv(A), v)
ans = [int(x) for x in ans]
print(ans)

### FIXED CODE ###

import sys
import numpy as np
def input():
    return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    a = [int(e) for e in input().split()]

    x = [0 for _ in range(n)]
    x[0] = sum(a) - (sum(a[1:n:2]) * 2)
    for i in range(2, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    x[1] = sum(a) - (sum(a[2:n:2]) * 2)
    for i in range(3, n, 2):
        x[i] = x[i-2] + ((a[i-1] - a[i-2]) * 2)
    print(*x)
main()
N = int(input())
A = [int(x) for x in input().split()]

M = max(A) + N

counter = [0] * (M + 1)

ans = 0
for i in range(N):
    if i > A[i]:
        ans += counter[i - A[i]]
    counter[i + A[i]] += 1

print(ans)

### FIXED CODE ###

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

counter = {}

for i in range(N):
    counter[i + A[i]] = 0

ans = 0
for i in range(N):
    if i - A[i] in counter:
        ans += counter[i - A[i]]
    counter[i + A[i]] += 1

print(ans)
N = int(input())
A = list(map(int,input().split()))

cnt = 0

for x in range(min(A),max(A)):
    transient = A.count(X-1) + A.count(X) + A.count(X+1)
    if transient > cnt:
        cnt = transient

print(cnt)


### FIXED CODE ###

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

C = [0]*(10**5 + 2)

for i in A:
    C[i-1] += 1
    C[i] += 1
    C[i+1] += 1

print(max(C))
H, W = map(int, input().split())
import numpy as np
x = np.zeros((H,W))
for i in range(H):
  x[i,] = map(int, input().split())

temp_list = []
for i in range(H):
  for j in range(W):
    if x[i,j] == "#":
      continue
    elif i == 0 and j == 0:
      temp_list = [x[i,j+1],x[i+1,j:j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == 0 and j == W:
      temp_list = [x[i,j-1],x[i+1,j:j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == H and j == 0:
      temp_list = [x[i-1,j:j+1],x[i,j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == H and j == W:
      temp_list = [x[i-1,j-1:j],x[i,j-1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == 0:
      temp_list = [x[i,j-1],x[i,j+1],x[i+1,j-1:j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif i == H:
      temp_list = [x[i,j-1],x[i,j+1],x[i-1,j-1:j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif j == 0:
      temp_list = [x[i-1,j:j+1],x[i,j+1],x[i+1,j:j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
    elif j == W:
      temp_list = [x[i-1,j-1:j],x[i,j-1],x[i+1,j-1:j]]
      counts = temp_list.count("#")
      x[i,j] = counts
    else:
      temp_list = [x[i-1,j-1:J+1],x[i,j-1],x[i,j+1],x[i+1,j-1:j+1]]
      counts = temp_list.count("#")
      x[i,j] = counts
      
for i in range(H):
  print(x[i,])
 

### FIXED CODE ###

H, W = map(int, input().split())
S =[input() for i in range(H)]

L = [""]*H
for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
        L[i] += "#"
    else:
      c = sum(t[max(0,j-1):min(W,j+2)].count("#") for t in S[max(0,i-1):min(H,i+2)])
      L[i] += str(c)
for i in range(H):
  print(L[i])
# dp[i][j]: i+1個の品物から価値がj以上になるように選んだときの重量の最小値

dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるときのｊの最大値
ans = []
for j in range(V+1):
    if dp[N][j] <= W:
        ans.append(j)
print(max(ans))

### FIXED CODE ###

# dp[i][j]: i+1個の品物から価値がj以上になるように選んだときの重量の最小値
N, W = map(int, input().split())
w, v = [], []
for _ in range(N):
    tmp = list(map(int, input().split()))
    w.append(tmp[0])
    v.append(tmp[1])
V = sum(v)
dp = [[float("inf") for _ in range(V+1)] for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(V+1):
        if j - v[i] >= 0:
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i])
        else:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# dp[N][j]がW以下であるときのｊの最大値
ans = []
for j in range(V+1):
    if dp[N][j] <= W:
        ans.append(j)
print(max(ans))
import numpy as np

N, K = map(int, input().split())
S = input()

l = [list(np.repeat(0, K)), list(np.repeat(0, K))]
ans = []
k = [int(s) for s in S]
v0 = 1 if k[0] == 0 else 0
v1 = 1 if k[0] == 1 else 0
for i in range(1, N):
    if (k[i]==0) & (k[i-1]==0):
        v0 += 1
    elif (k[i]==1) & (k[i-1]==0):
        l[0].append(v0)
        v0 = 0
        v1 += 1
    elif (k[i]==0) & (k[i-1]==1):
        l[1].append(v1)
        v1 = 0
        v0 += 1
        
        
        a = sum(l[0][-K:]+l[1][-K-1:])
        ans.append(a)
        
    elif (k[i]==1) & (k[i-1]==1):
        v1 += 1
        
for i, v in enumerate([v0, v1]):
    if v > 0:
        l[i].append(v)

if (v0==0) & (v1>0):
    a = sum(l[0][-K:]+l[1][-K-1:])
    ans.append(a)
    
print(max(ans))

### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
S = input()

l = [[], []]
ans = []
k = [int(s) for s in S]
if k[0] == 0:
    l[1].append(0)
v0 = 1 if k[0] == 0 else 0
v1 = 1 if k[0] == 1 else 0
for i in range(1, N):
    if (k[i]==0) & (k[i-1]==0):
        v0 += 1
    elif (k[i]==1) & (k[i-1]==0):
        l[0].append(v0)
        v0 = 0
        v1 += 1
    elif (k[i]==0) & (k[i-1]==1):
        l[1].append(v1)
        v0 += 1
        v1 = 0 
    else:
        v1 += 1
        
for i, v in enumerate([v0, v1]):
    if v > 0:
        l[i].append(v)
        
if k[0] == 0:
    l[1].append(0)

if len(l[0]) <= K:
    print(N)

else:
    l[0].extend(np.repeat(0,K+1))
    l[1].extend(np.repeat(0,K+1))
    a = sum(l[0][:K]) + sum(l[1][:K+1])
    ans.append(a)
    for i in range(1, len(l[0])-K-1):
        a -= l[0][i-1] + l[1][i-1]
        a += l[0][i+K-1] + l[1][i+K]
        ans.append(a)
    print(max(ans))