Harryxun/stf_run huggingface dataset:
N,D = map(int,input().split())

if N & (D*2 + 1 ) = 0:
    print(N/(D*2 + 1))
else :
    print(round(N//(D*2 + 1)+1))
    

### FIXED CODE ###

N,D = map(int,input().split())
 
if N % (D*2 + 1 ) == 0:
    print(round(N/(D*2 + 1)))
else :
    print(round(N//(D*2 + 1)+1))
Sa=list(input())
Sb=list(input())
Sc=list(input())
Sa.pop()
Sb.pop()
#Sc.pop()
S=Sa.pop(0)
Win="A"
while(S!=""):
  if(S=="a"):
    S=""
    if(len(Sa)!=0):
    	S=Sa.pop(0)
    Win="A"
  elif(S=="b"):
    S=""
    if(len(Sb)!=0):
	    S=Sb.pop(0)
    Win="B"
  elif(S=="c"):
    S=""
    if(len(Sc)!=0):
    	S=Sc.pop(0)
    Win="C"
print(Win)


### FIXED CODE ###

Sa=list(input())
Sb=list(input())
Sc=list(input())
S=Sa.pop(0)
Win="A"
while(S!=""):
  if(S=="a"):
    S=""
    if(len(Sa)!=0):
    	S=Sa.pop(0)
    Win="A"
  elif(S=="b"):
    S=""
    if(len(Sb)!=0):
	    S=Sb.pop(0)
    Win="B"
  elif(S=="c"):
    S=""
    if(len(Sc)!=0):
    	S=Sc.pop(0)
    Win="C"
print(Win)
#d-even relation
#ふかさ優先探索の実装
#再起関数の実装を行う
n=int(input())
visitedlist=[-1 for  i in range(n)]
lists=[tuple(map(int,input().split())) for i in range(n-1)]
kilist=[[] for i in range(n)]
for i in lists:
    kilist[i[0]-1].append(i[1:])
    kilist[i[1]-1].append(i[0:3:2])
visitedlist[0]=1
anslist=[0 for i in range(n)]
#開始地点1のところは0を基準としている
#1には初めに訪れる
def search(i):
        flag=False
        for j in kilist[i-1]:
            if visitedlist[j[0]-1]<0:
                visitedlist[j[0]-1]=1
                flag=True
                if j[1]%2==0:
                    anslist[j[0]-1]=anslist[i-1]
                elif j[1]%2!=0:
                    anslist[j[0]-1]=1-anslist[i-1]      
            else:
                pass  
        if flag:    
            for j in kilist[i-1]:
                return search(j[0])
        if not flag:
            pass
            
search(1)
for k in anslist:
    print(k)


### FIXED CODE ###

n,k=map(int,input().split())
s=list(input())
s[k-1]=s[k-1].lower()
print("".join(s))
line = list(map(int,input().split()))
if line[0] >= 10:
  print(line[1])
else:
  print(line[1] + (100 * (10 - line[0]))

### FIXED CODE ###

line = list(map(int,input().split()))
if line[0] >= 10:
  print(line[1])
else:
  print(line[1] + (100 * (10 - line[0])))
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, m, c, ans =0;
	cin >> n >> m >> c;
	vector<int> b(m);
	rep(i,m) cin >> b[i];
	rep(i,n){
		int sum = 0;
		vector<int> a(m);
		rep(j,m){
			cin >> a[j];
			sum += a[j]*b[j];
		}
		sum+=c;
		if(sum > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

### FIXED CODE ###

n, m, c  = map(int, input().split())
b = [int(i) for i in input().split()]
ans = 0
for i in range(n):
        a = [int(i) for i in input().split()]
        sum = 0
        for k in range(m):
            sum +=(a[k]*b[k])
        sum+=c
        if sum > 0: ans+=1
print(ans)
a = input().strip()
if a <= z:
  print('a')
else:
  print('A')

### FIXED CODE ###

a = input().strip()

if a.isupper():
    print('A')
else:
    print('a')
S = map(str,input().split())
s =1
for i in S:
	if i in "+":
		s +=1  
	else:
    	s -=1
print(s)


### FIXED CODE ###

a =input()
s = 0
for i in a:
  if i in "+":
    s +=1
  else:
    s -=1
print(s)
N, K = map(int,input().split())
S = list(input())

Sl = []
c = 0
if S[0] = "0":
  Sl.append(0)
for i in range(N-1):
  c += 1
  if S[i] != S[i+1]:
    Sl.append(c)
    c = 0
if S[N-1] == "0":
  c += 1
  Sl.append(c)
  Sl.append(0)
else:
  c += 1
  Sl.append(c)

Kl = K*2+1

mxl = []
for i in range(len(Sl)+1-Kl):
  mxl.append(sum(Sl[i:Kl+i]))

print(max(mxl))


### FIXED CODE ###

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

mxl = []
Sl = []
c = 0
if S[0] == "0":
  Sl.append(0)
for i in range(N-1):
  c += 1
  if S[i] != S[i+1]:
    Sl.append(c)
    c = 0
if S[N-1] == "0":
  c += 1
  Sl.append(c)
  Sl.append(0)
else:
  c += 1
  Sl.append(c)

Kl = K*2+1

Ru = [0 for i in range(len(Sl)+1)]

if len(Sl) ==1:
  mxl.append(Sl[0])
else:
  for i in range(1,len(Sl)+1):
    Ru[i] = Ru[i-1]+Sl[i-1] 
  mxl.append(Ru[min(Kl,len(Ru)-1)])
  
for i in range(2,min(len(Sl)+1-Kl,len(Ru)-1),2):
  mxl.append(Ru[Kl+i]-Ru[i])

print(max(mxl))
L, R = map(int, input().split())
a = L % 2019
if a == 0:
  print(0)
else:
  if L + (673 - L % 673) <= R or L % 673 == 0:
    if L + (3 - L % 3) <= R or L % 3 == 0:
      print(0)
      sys.exit()
  ans = 2019
  b = R % 2019
  for i in range(a, b):
    for j in range(i+1, b+1):
      ans = min(ans, i * j % 2019)
  print(ans)

### FIXED CODE ###

import sys

L, R = map(int, input().split())
if L + (673 - L % 673) <= R or L % 673 == 0:
  if L + (3 - L % 3) <= R or L % 3 == 0:
    print(0)
    sys.exit()
ans = 2019
a = L % 2019
b = R % 2019
for i in range(a, b):
  for j in range(i+1, b+1):
    ans = min(ans, i * j % 2019)
print(ans)
#75b
H,W = map(int, input().split())

S_list = [[0 for i in range(W+2)] for j in range(H+2)]

for i in range(1,H+1):
    S = list(input())
    S_list[i][1:W+1] = S
    
ans = [["#" for i in range(W+2)] for j in range(H+2)]
    
for i in range(1,H+1):
    for j in range(1,W+1):
        if S_list[i][j] != "#":            
            ans[i][j] = S_list[i-1][j-1:j+2].count("#") + S_list[i][j-1:j+2].count("#") + S_list[i+1][j-1:j+2].count("#")
            
for i in range(1,H+1):
    print(''.join(map(str, ans[i][1:-1])))

### FIXED CODE ###

#75a
A,B,C = map(int, input().split())

if A==B:
    print(C)
elif A==C:
    print(B)
elif B==C:
    print(A)
n,k = map(int, input().split())
for k in range(k):
	d = int(input())
	for d in range(d):
    a.append({int(x) for x in input().split()})
    n = array_diff(n,a)
print(n)

### FIXED CODE ###

n,k = map(int, input().split())
flag = [1 for i in range(n)]
for _ in range(k):
  d = int(input())
  for a in map(int, input().split()):
      flag[a-1] = 0
print(sum(flag))
import sys
ls = []
line = map(lambda x:x.split(), sys.stdin.readlines())
for i in line:
    if i[0] == "insert":
        ls.append(i[1])
    else:
        print("yes" if i[1] in ls else "no")

### FIXED CODE ###

dic = {}
line = []
for i in range(int(input())):
    line.append(input().split())
for i in line:
    if i[0][0] == "i":
        dic[i[1]] = None
    else:
        print("yes" if i[1] in dic else "no")
from sys import stdin
import math

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

def gcd_all(list):
    return gcd_all([math.gcd(*list[:2])] + list[2:]) if len(list) > 1 else list[0]

ma = 0
for i in range(n):
    lin = [li[s] for s in range(n) if s != i]
    ma = max(ma,gcd_all(lin))

print(ma)

### FIXED CODE ###

from fractions import gcd

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

M = [0]*N

#漸化式を作る
L = [0]*N
R = [0]*N

for i in range(1,N):
    L[i] = gcd(L[i-1],A[i-1])
    R[N-1-i] = gcd(R[N-i],A[N-i])

for j in range(N):
    M[j] = gcd(L[j],R[j])

print(max(M))
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

input_n = lambda: int(readline())
input_nn = lambda: map(int, readline().split())
input_s = lambda: readline().rstrip().decode('utf-8')
input_ss = lambda: readline().rstrip().decode('utf-8').split()

mod = 10 ** 9 + 7


@njit('(i4,i4,i4,i4)', cache=True)
def judge(a, b, c, k):

    ret = False
    ret |= (b == 0 and c == 2 and k == 1)
    ret |= (b == 0 and c == 1 and k == 2)
    ret |= (b == 2 and c == 0 and k == 1)
    ret |= (a == 0 and b == 2 and k == 1)
    ret |= (a == 0 and c == 2 and k == 1)

    return not ret


@njit('(i4,i4[:,:,:])', cache=True)
def solve(N, dp):

    for n in range(N - 3):
        next_dp = np.zeros((4, 4, 4), np.int32)
        for a in range(4):
            for b in range(4):
                for c in range(4):
                    for k in range(4):
                        if judge(a, b, c, k):
                            next_dp[b, c, k] += dp[a, b, c]
                            next_dp[b, c, k] %= mod
        dp = next_dp

    return dp


def main():

    N = input_n()
    dp = np.full((4, 4, 4), 1, np.int32)
    dp[0, 2, 1] = 0
    dp[0, 1, 2] = 0
    dp[2, 0, 1] = 0

    ans = solve(N, dp)
    print(ans.sum() % mod)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

input_n = lambda: int(readline())
input_nn = lambda: map(int, readline().split())
input_s = lambda: readline().rstrip().decode('utf-8')
input_ss = lambda: readline().rstrip().decode('utf-8').split()

mod = 10 ** 9 + 7


def judge(a, b, c, k):

    ret = False
    ret |= (b == 0 and c == 2 and k == 1)
    ret |= (b == 0 and c == 1 and k == 2)
    ret |= (b == 2 and c == 0 and k == 1)
    ret |= (a == 0 and b == 2 and k == 1)
    ret |= (a == 0 and c == 2 and k == 1)

    return not ret


def main():

    N = input_n()
    dp = np.full((4, 4, 4), 1, np.int32)
    dp[0, 2, 1] = 0
    dp[0, 1, 2] = 0
    dp[2, 0, 1] = 0

    for n in range(N - 3):
        next_dp = np.zeros((4, 4, 4), np.int32)
        for a in range(4):
            for b in range(4):
                for c in range(4):
                    for k in range(4):
                        if judge(a, b, c, k):
                            next_dp[b, c, k] += dp[a, b, c]
                            next_dp[b, c, k] %= mod
        dp = next_dp

    print(dp.sum() % mod)


if __name__ == '__main__':
    main()
S=input()
T=input()
N=[i in range(len(S))]
visited=[]

for i in N:
    if (S[i] not in visited) and S[i]!=T[i]:
        visited.append(T[i])
        x=S[i]
        S=S.replace(T[i],'_')
        S=S.replace(S[i],T[i])
        S=S.replace('_',x)
    elif S[i] in visited and S[i]!=T[i]:
        break
    else:
        visited.append(T[i])
print('No') if S!=T else print('Yes')

### FIXED CODE ###

S=input()
T=input()
R=[-1]*26
R2=[-1]*26
flag=1

for i in range(len(S)):
    a=ord(S[i])-97
    b=ord(T[i])-97
    if R[a]!=-1 or R2[b]!=-1:
        if R[a]!=b or R2[b]!=a:
            flag=0
            break
    else:
        R[a]=b
        R2[b]=a
if flag==0:
    print('No')
else:
    print('Yes')
N, M = map(int, input().split())
gates = [tuple(map(int, input().split())) for _ in range(M)]

lmax = max(gates, key=lambda x: x[0])[0]
rmin = min(gates, key=lambda x: x[1])[1]

print(max(rmin-lmax+1), 0)

### FIXED CODE ###

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

lmax = max(gates, key=lambda x: x[0])[0]
rmin = min(gates, key=lambda x: x[1])[1]

print(max(rmin-lmax+1, 0))
N = int(input())
while True:
    s = input()
    if len(s) == N:
        break
        
caps = list(s)

if caps.count('R') > N / 2:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

input_length = input().split(' ')

result = ''
x = input_length.count(input_length[0])
if x == len(input_length):
    print('Yes')
else:
    print('No')
#https://atcoder.jp/contests/abc061/tasks/abc061_d



# coding: utf-8
# Your code here!

#input_template
inpPh = 2
debug = True
debug = False
if not debug:
    inpPh = 0

input1 ='''
3 3
1 2 4
2 3 3
1 3 5 
'''[1:]

input2 ='''
2 2
1 2 1
2 1 1
'''[1:]

input3 ='''
6 5
1 2 -1000000000
2 3 -1000000000
3 4 -1000000000
4 5 -1000000000
5 6 -1000000000
'''[1:]



inputXs = [input1, input2, input3, None]


if debug:
    try:
        inputXs.append(inputA0)
    except:
        pass
    else:
        pass



    
inploc = inpPh - 1 #0,1,2

if inpPh > 0:
    print('selected_input:\n'+inputXs[inploc])


inpX_lst = []
if debug and inpPh > 0:
    inpX_lst = inputXs[inploc].splitlines()


if inpPh == 0:
    N,M = tuple(map(lambda x: int(x), input().split() ) )
else:
    N,M =tuple( map(lambda x: int(x),  inpX_lst.pop(0).split() ) )

elist = []    

for i in range(M):
    if inpPh == 0:
        ai,bi,ci = list(map(lambda x: int(x), input().split() ))
    else:
        ai,bi,ci = list(map(lambda x: int(x), inpX_lst.pop(0).split() ))
    
    ai_loc, bi_loc = ai-1, bi - 1
    elist.append(( ai_loc, bi_loc,ci))

vlist =[ [None,[]] for _ in range(N)]    

for e in elist:
    a,b,c = e
    vlist[a][1].append((a,b,-c))
        
s_loc,g_loc = 0, N-1

vlist[s_loc][0] = 0
#print(vlist)

for v1 in vlist:
    v1_d,v1_elist = v1[0],v1[1]
    #print(v1_d,v1_elist)
    for e in v1_elist:
        a,b,c = e
        v2 = vlist[b]
        v2_d, v2_elist = v2
        if v1_d == None:
            continue
        elif v2_d == None or v2_d > v1_d +c:
            vlist[b][0] = v1_d + c

g0 = vlist[g_loc][0]            

for v1 in vlist:
    v1_d,v1_elist = v1[0],v1[1]
    #print(v1_d,v1_elist)
    for e in v1_elist:
        a,b,c = e
        v2 = vlist[b]
        v2_d, v2_elist = v2
        if v1_d == None:
            continue
        elif v3_d == None or v2_d > v1_d +c:
            vlist[b][0] = v1_d + c

g1 = vlist[g_loc][0]  

if g0 != g1:
    print('inf')
else:
    print(-g0)

#print('res',g0,g1)
for v in vlist:
    #print(v)        
    pass

### FIXED CODE ###

import sys

INF = float('inf')

def Bellmanford(n, edges, r): #r: 始点
    d = [INF] * n
    d[r] = 0
    
    for i in range(n):
        for (u, v, c) in edges:
            if d[u] != INF and d[u] + c < d[v]:
                d[v] = d[u] + c
                if i == n-1 and v == n-1:
                    return 'inf'
    
    return -d[n-1]
    

N, M = map(int, sys.stdin.readline().split())
Edges = [None] * M

for i in range(M):
    ai, bi, ci = map(int, sys.stdin.readline().split())
    Edges[i] = (ai-1, bi-1, -ci)
    
ans = Bellmanford(N, Edges, 0)

print(ans)
n,k = map(int,input().split())
sss = input()

now = 1
cnt = 0
x = []

for i in range(n):
    if sss[i] == str(now):
        cnt += 1
    else:
        x.append(cnt)
        now = 1 - now
        cnt = 1
if cnt != 0:
    x.append(cnt)
if len(x) % 2 == 0:
    x.append(0)

Add = 2 * k + 1
ans = 0

for i in range(len(x))[::2]:
    tmp = 0
    left = i
    right = min(i + Add, len(x))
    for j in range(left, right + 1):
        tmp += x[j]
    ans = max(tmp, ans)

print(ans)

### FIXED CODE ###

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

cnt = 0
state = sss[0]
x = []
if sss[0] == "0":
    x.append(0)
for s in sss:
    if s == state:
        cnt += 1
    else:
        state = s
        x.append(cnt)
        cnt = 1
x.append(cnt)
if sss[-1] == "0":
    x.append(0)
#11101010110011
#1:3 1 1 2 2
#0: 1 1 1 2

#1
#1

y = [0]
for i in range(len(x)):
    y.append(y[i] + x[i])
#:0,1,2,3,4,5,6 7, 8 ,9
#:0,3,4,5,6,7,8,10,12,14

#0,1

z = []
for i in range(k*2+1,len(y))[::2]:
    z.append(y[i] - y[i - (k*2+1)])
#print(x)
#print(y)
#print(z)
if len(x) <= k*2-1:
    print(sum(x))
else:
    print(max(z))
N,M = map(int,input().split())
A = []

#フィボナッチ数列
from functools import lru_cache
@lru_cache(maxsize=None)
def Fib(n):
    if n == 0:
        return 0
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        return Fib(n-1) + Fib(n-2)
 
for i in range(M):
  a = int(input())
  A.append(a)
#ans = {0~a1-1 a1+1~a2-1 ... a(M-1)+1~aM-1 の行き方の積}
#各a(i)+1~a(i+1)-1への行き方は1通り
#i ~ i+Nへの行き方 Fib(N+1)通り

#REになっていたのはFib(0)が定義されていなかったから
if(N == 1): 
 ans = 1
elif(M == 0): 
 ans = Fib(N+1)
else: 
 ans = 0
 for i in range(M):  
    if(i == 0): #0~ a1-1 // ai+1 = A[i]
      n = (A[i]-1)-0
      #print(0,A[i]-1)
    else:
      n = (A[i]-1)-(A[i-1]+1) 
      #print(A[i-1]+1,A[i]-1)
      
    if(i != 0): #「渡れない箇所が二連続」が存在するなら0通り
     dif = A[i]-A[i-1]
     if(dif == 1):
       ans = 0
       break
          
    if(ans == 0): ans += (Fib(n+1)%(10**9 + 7))
    else: ans = ans*(Fib(n+1)%(10**9 + 7))

 n = N - (A[M-1]+1)#最後にaM + 1 ~ N のルートも考慮する
 ans = ans*(Fib(n+1)%(10**9 + 7))
 #print(A[M-1]+1,N)
            
ans = ans%(10**9 + 7)
print(ans)  

### FIXED CODE ###

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

#フィボナッチ数列
def Fib(n):
    a, b = 1, 1
    if n == 0:
        return 0
    elif n== 1:
        return 1
    elif n == 2:
        return 1
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
 
for i in range(M):
  a = int(input())
  A.append(a)
#ans = {0~a1-1 a1+1~a2-1 ... a(M-1)+1~aM-1 の行き方の積}
#各a(i)+1~a(i+1)-1への行き方は1通り
#i ~ i+Nへの行き方 Fib(N+1)通り

#REになっていた理由:
#・Fib(0)が定義されていなかったから
#・フィボナッチ数列を再帰的(=Fib(n-1)+Fib(n-2))で定義していると、
#Nが大きい(100000とか）のときに深く潜りすぎるのでRE

if(N == 1): 
 ans = 1
elif(M == 0): 
 ans = Fib(N+1)
else: 
 ans = 0
 for i in range(M):  
    if(i == 0): #0~ a1-1 // ai+1 = A[i]
      n = (A[i]-1)-0
      #print(0,A[i]-1)
    else:
      n = (A[i]-1)-(A[i-1]+1) 
      #print(A[i-1]+1,A[i]-1)
      
    if(i != 0): #「渡れない箇所が二連続」が存在するなら0通り
     dif = A[i]-A[i-1]
     if(dif == 1):
       ans = 0
       break
          
    if(ans == 0): ans += (Fib(n+1)%(10**9 + 7))
    else: ans = ans*(Fib(n+1)%(10**9 + 7))

 n = N - (A[M-1]+1)#最後にaM + 1 ~ N のルートも考慮する
 ans = ans*(Fib(n+1)%(10**9 + 7))
 #print(A[M-1]+1,N)
            
ans = ans%(10**9 + 7)
print(ans)
def main():
    N,K = map(int,input().split())
    As = list(map(int,input().split()))
    route = [0]
    pre = 0
    i = 0
    r_append = route.append
    for _ in range(N):
        i = As[i]-1
        if i in route:
            pre = route.index(i)
            route = route[pre:]
            break
        r_append(i)
        len_route += 1
    # print(route)
    mod = len(route)
    print(route[(K-pre)%mod]+1)

if __name__ == "__main__":
    main()

### FIXED CODE ###

S = input()
T = input()
s_len = len(S)
print("Yes" if S==T[:len(S)] else "No")
s = input()
a, b, c = s.split(',')
print(f'{a} {b} {c}')

### FIXED CODE ###

s = input().replace(',', ' ', 2)
print(s)
X, N = map(int, input().split())
ans = X
if N>0:
  P = list(map(int, input().split()))
  P.sort()
  if X in P:
    ans = 0
    x = P.index(X)
    i = 1
    a = x-1
    b = x+1
    while ans == 0:
      if X-i != P[a]:
        ans = X-i
      elif X+i != P[b]:
        ans = X+i
        a -= 1
      else:
        a -= 1
        b += 1
        i += 1
  else:
    ans = X
print(ans)
      
        
    

### FIXED CODE ###

X, N = map(int, input().split())
ans = X
if N>0:
  P = list(map(int, input().split()))
  P.sort()
  if X in P:
    ans = 0
    x = P.index(X)
    i = 1
    a = x-1
    b = x+1
    m = min(P[N-1]-X, X-P[0])
    for i in range(1,m+2):
      if a < 0:
        a = 0
      if b > N-1:
        b = N-1
      if X-i != P[a]:
        ans = X-i
        break
      elif X+i != P[b]:
        ans = X+i
        break
      else:
        a -= 1
        b += 1
print(ans)
N, heights = input().split('\n')

N = int(N)
heights = map(int, heights.split(' '))

### FIXED CODE ###

N = input() 
heights = input()

N = int(N)
heights = list(map(int, heights.split(' ')))

def solve_problem_dp(N, heights):
    if N == 1:
        return 0
    elif N == 2:
        return abs(heights[0] - heights[1])
    costs = [0] * len(heights)
    costs[1] = abs(heights[0] - heights[1])

    for i in range(2, len(heights)):
        cost_jump1 = abs(heights[i] - heights[i-1]) + costs[i-1]
        cost_jump2 = abs(heights[i] - heights[i-2]) + costs[i-2] 
        best_cost = min(cost_jump1, cost_jump2)
        costs[i] = best_cost
    
    return costs[-1]


print(solve_problem_dp(N, heights))
# -*- coding: utf-8 -*-
h,w = map(int, raw_input().split())

a,b,c = 0,0,0
diff =[0,0,0]   
ans = 999999999999
if(h%3 == 0 or w%3 == 0):
    print('0')
    exit(1)
for i in range(1,h/2+1):
    a = i*w
    b = (w/2)*(h-i)
    c = (w-w/2)*(h-i)
    diff = abs(a-b),abs(a-c),abs(b-c)
    S = max(diff)-min(diff)
    if(S<ans):
        ans = S
    
    
for i in range(1,w/2+1):
    a = i*h
    b = (h/2)*(w-i)
    c = (h-h/2)*(w-i)
    diff = abs(a-b),abs(a-c),abs(b-c)
    S = max(diff)-min(diff)
    if(S<ans):
        ans = S
print(ans)
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
h,w = map(int, raw_input().split())
 
area = [0,0,0]
ans = 10**15
if(h%3 == 0 or w%3 == 0):
    ans = 0
else:
    for i in range(1,h/2+1):
        area[0] = i*w
        tmp = w/2
        area[1] = tmp*(h-i)
        area[2] = (w-tmp)*(h-i)
        S = max(area)-min(area)
        if(S<ans):
            ans = S
        tmp = (h-i)/2
        area[1] = tmp*w
        area[2] = (h-i-tmp)*w
        S = max(area)-min(area)
        if(S<ans):
            ans = S
        
    for i in range(1,w/2+1):
        area[0] = i*h
        tmp = h/2
        area[1] = tmp*(w-i)
        area[2] = (h-tmp)*(w-i)
        S = max(area)-min(area)
        if(S<ans):
            ans = S
        tmp = (w-i)/2
        area[1] = tmp*h
        area[2] = (w-i-tmp)*h
        S = max(area)-min(area)
        if(S<ans):
            ans = S
print(ans)
n = int(input())
x = input()
num = 0
count = 0
for i in range(n):
    if x[-(i+1)] == "1":
        num += 2**i
        count += 1

mod = [0]*n
for i in range(n):
    mod[i] = (2**i%(count-1), 2**i%(count+1))
mod1 = num%(count-1)
mod2 = num%(count+1)

ans = [0]*n
for i in range(n):
    if x[-(i+1)] == "1":
        _num = num-2**i
        if _num == 0:
            continue
        _num = (mod1-mod[i][0])%(count-1)
    else:
        _num = num+2**i
        _num = (mod1-mod[i][1])%(count+1)
    ans[i] += 1
    _count = 0
    for c in bin(_num):
        if c == "1":
            _count += 1
    while True:
        if _num == 0:
            break
        _num %= _count
        _count = 0
        for c in bin(_num):
            if c == "1":
                _count += 1
        ans[i] += 1
for i in range(n):
    print(ans[-(i+1)])

### FIXED CODE ###

n = int(input())
x = input()
num = 0
count = 0
for i in range(n):
    if x[-(i+1)] == "1":
        num += 2**i
        count += 1

mod = [[0, 0] for _ in range(n)]
mod[0][0] = 1%(count-1) if count!=1 else 0
mod[0][1] = 1%(count+1)
for i in range(1, n):
    if mod[i-1][0] != 0:
        mod[i][0] = (mod[i-1][0]*2)%(count-1)
    if mod[i-1][1] != 0:
        mod[i][1] = (mod[i-1][1]*2)%(count+1)
mod1 = num%(count-1) if count!=1 else 0
mod2 = num%(count+1)

table = [0]*(2*10**5+10)
for i in range(2*10**5+10):
    _num = i
    while True:
        _count = 0
        for c in bin(_num):
            if c == "1":
                _count += 1
        if _num == 0:
            break
        _num %= _count
        table[i] += 1

ans = [0]*n
for i in range(n):
    if x[-(i+1)] == "1":
        _num = num-2**i
        if _num == 0:
            continue
        _num = (mod1-mod[i][0])%(count-1)
    else:
        _num = num+2**i
        _num = (mod2+mod[i][1])%(count+1)
    ans[i] = 1+table[_num]
for i in range(n):
    print(ans[-(i+1)])
H, W = map(int, input().split())
S = [list(map(int, input().split())) for i in range(H)]
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(H):
  for j in range(W):
    if s[i][j] == '.':
      cnt = 0
      for n in range(8):
        ni = i + dx[n]
        nj = j + dy[n]
        if ni < 0 or ni >= H:
          continue
        if nj < 0 or nj >= W:
          continue
        if s[ni][nj] == '#':
          cnt += 1
      S[i][j] = cnt

print(S)
    


### FIXED CODE ###

H, W = map(int, input().split())
S = []
for i in range(H):
    S.append(list(input()))
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

for i in range(H):
  for j in range(W):
    if S[i][j] == '#':
      continue
    cnt = 0
    for n in range(8):
      ni = i + dx[n]
      nj = j + dy[n]
      if ni < 0 or H <= ni or nj < 0 or W <= nj:
        continue
      if S[ni][nj] == '#':
        cnt += 1
    S[i][j] = str(cnt)


    
for i in range(H):
    print("".join(S[i]))