Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

h,w,k=map(int,input().split())
Cho=[list(map(int,list(input()))) for _ in range(h)]
ans=10000000
for i in range(2**(h-1)):
	need=0
	seq=[]
	t=[]
	for j in range(h-1):
		t.append(j)
		if i&(1<<j):
			need+=1
			seq.append(t)
			t=[]
	seq.append(t+[h-1])
	f=1
	q=need+1
	cnt=[0]*q
	for x in range(w):
		cntp=[0]*q
		for i,g in enumerate(seq):
			cntg=0
			for y in g:
				cntg+=Cho[y][x]
				if cntg>k:
					f=0
					break
				cntp[i]+=Cho[y][x]
			if not f:
				break
		if not f:
			break
		for xx in range(q):
			cnt[xx]+=cntp[xx]
		if any(xxx>k for xxx in cnt):
			need+=1
			cnt=cntp
	if f:
		ans=min(ans,need)
print(ans)


### FIXED CODE ###

h,w,k=map(int,input().split())
Cho=[list(map(int,list(input()))) for _ in range(h)]
ans=10000000
for i in range(2**(h-1)):
	need=0
	seq=[]
	t=[]
	for j in range(h-1):
		t.append(j)
		if i&(1<<j):
			need+=1
			seq.append(t)
			t=[]
	seq.append(t+[h-1])
	f=1
	q=need+1
	cnt=[0]*q
	for x in range(w):
		cntp=[0]*q
		for i,g in enumerate(seq):
			cntg=0
			for y in g:
				cntg+=Cho[y][x]
				if cntg>k:
					f=0
					break
				cntp[i]+=Cho[y][x]
			if not f:
				break
		if not f:
			break
		for xx in range(q):
			cnt[xx]+=cntp[xx]
		if any(xxx>k for xxx in cnt):
			need+=1
			if need>ans:
				f=0
				break
			cnt=cntp
	if f:
		ans=min(ans,need)
print(ans)
### BUGGY CODE ###

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

ans = 0
for i in range(N):
    current = 0
    while(True):
        if(i==N-1):
            break
        elif(H[i] >= H[i+1]):
                current += 1
                i += 1
        else:
            break

    if(current > ans):
        ans = current

print(ans)



### FIXED CODE ###

N = int(input())
H = [int(x) for x in input().split()]
 
ans = 0
current = 0
for i in range(N):
    if(i == N-1):
        if(current > ans):
            ans = current
        break
    if(H[i] >= H[i+1]):
        current += 1
    else:
        if(ans < current):
            ans = current
        current = 0
 
print(ans)
### BUGGY CODE ###

S = input()
mod = 10 ** 9 + 7

dp = [[0] * 13 for _ in range(2)]
dp[0][0] = 1
cnt = 1

for i, s in enumerate(S[::-1]):
    dp[cnt] = [0]*13
    if s == "?":
        for j in range(10):
            d = j * (10 ** i) % 13
            for k in range(13):
                x = k + d
                if x >= 13:
                    x -= 13
                dp[cnt][x] += dp[1 - cnt][k]
                dp[cnt][k] %= mod
    else:
        d = int(s) * (10 ** i) % 13
        for j in range(13):
            x = j + d
            if x >= 13:
                x -= 13
            dp[cnt][x] += dp[1 - cnt][j]
            dp[cnt][j] %= mod
    cnt = 1-cnt

ans = dp[1-cnt][5] % mod
print(ans)


### FIXED CODE ###

S = input()
mod = 10 ** 9 + 7

dp = [0]*13
dp[0] = 1

mul = 1
for i, s in enumerate(S[::-1]):
    new = [0]*13
    if s == "?":
        for x in range(13):
            for y in range(10):
                next_x = y * mul + x
                new[next_x % 13] += dp[x]
                new[next_x % 13] %= mod
    else:
        for x in range(13):
            next_x = int(s) * mul + x
            new[next_x % 13] = dp[x]

    dp = new
    mul *= 10
    mul %= 13

ans = dp[5] % mod
print(ans)
### BUGGY CODE ###

s = input()

def get_integers(whitespaced_string):
    cleaned_string = whitespaced_string.split(" ")

    formatted_numbers = []
    for number in cleaned_string:
        formatted_numbers.append(int(number))
    
    return tuple(formatted_numbers)

input_arg = get_integers(s)

def get_answers(index = 2):

    answers = []
    for i in range(input_arg[index]):
        answers.append(int(input()))

    return answers

def compute_score(index = 0):
    answers = get_answers()

    for i in range(1, input_arg[index] + 1):
        initial_score = input_arg[index + 1]
        for j in answers:
            if j != i:
                initial_score -= 1
        if initial_score <= 0:
            print("No")
        else:
            print("Yes")

compute_score()

### FIXED CODE ###

import sys

N,K,Q = map(int,input().split())
A = (int(x) for x in sys.stdin.read().split())
 
score = [K-Q] * (N+1) 
for x in A:
    score[x] += 1
 
answer = '\n'.join('No' if x <= 0 else 'Yes' for x in score[1:])
print(answer)
### BUGGY CODE ###

H,W = map(int,input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]

#差分だけで良い，これを*1 or -1していく
diff = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        diff[i][j] = abs(A[i][j] - B[i][j])

#i,jマスにおいて，偏りがkになれるかどうかでDP
K = 4001 #適当
kk = int((K-1)/2)
dp = [[[False]*K for _ in range(W)] for _ in range(H)]

dp[0][0][kk+diff[0][0]] = True
dp[0][0][kk-diff[0][0]] = True

                 

for i in range(H):
    for j in range(W):
        for k in range(K):
            if i-1>=0:
                if k+diff[i][j]<K:
                    if dp[i-1][j][k+diff[i][j]]:
                        dp[i][j][k] =True
                if k-diff[i][j]>=0:
                    if dp[i-1][j][k-diff[i][j]]:
                        dp[i][j][k] =True
            if j-1>=0:
                if k+diff[i][j]<K:
                    if dp[i][j-1][k+diff[i][j]]:
                        dp[i][j][k] =True
                if k-diff[i][j]>=0:
                    if dp[i][j-1][k-diff[i][j]]:
                        dp[i][j][k] =True

ans = K
for k in range(K):
    if dp[H-1][W-1][k]:
        ans = min(ans,abs(k-kk))

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline

H,W = map(int,input().split())
#差分だけで良い，これを*1 or -1していく
diff = [list(map(int, input().split())) for _ in range(H)]

for i in range(H):
    B = list(map(int,input().split()))
    for j in range(W):
        diff[i][j] = abs(diff[i][j] - B[j])
        
 # i,jマスにおいて，偏りがkになれるかどうかでDP
#dp[i][j]にはkという数字にたどり着けるかどうかを示す2進数を入れる

dp = [[False]*W for _ in range(H)]
ofs = 80*(H+W)


dp[0][0]=(1<<(ofs+diff[0][0]) | 1>>(ofs-diff[0][0]))
 
for i in range(H):
    for j in range(W):
        if i>0:
            dp[i][j]|=(dp[i-1][j]<<diff[i][j] | dp[i-1][j]>>diff[i][j])
        if j>0:
            dp[i][j]|=(dp[i][j-1]<<diff[i][j] | dp[i][j-1]>>diff[i][j])


#0のところから見て，最初に1が出てきたところが答え
for k in range(ofs):
    if (dp[-1][-1]>>(k+ofs)&1):
        print(k)
        break
### BUGGY CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]
 
up =    [[0]*(W+2) for _ in range(H+2)]
down =  [[0]*(W+2) for _ in range(H+2)]
left =  [[0]*(W+2) for _ in range(H+2)]
right = [[0]*(W+2) for _ in range(H+2)]

for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i-1][j-1] == '.':
            up[i][j] = up[i-1][j] + 1
            left[i][j] = left[i][j-1] + 1
        
        if S[-i][-j] == '.':
            down[-1-i][-1-j] = down[-i][-1-j] + 1
            right[-1-i][-1-j] = right[-1-i][-j] + 1

ans = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        ans = max(ans, up[i][j]+down[i][j]+left[i][j]+right[i][j]-3)
print(ans)

### FIXED CODE ###

import numpy as np

H, W = map(int, input().split())
S = np.array([list(input()) for _ in range(H)]) == '.'
up = np.zeros((H, W), dtype=int)
down = np.zeros((H, W), dtype=int)
left = np.zeros((H, W), dtype=int)
right = np.zeros((H, W), dtype=int)
 
for i in range(H):
    up[i] = (up[i-1] + 1) * S[i]
    down[-i-1] = (down[-i] + 1) * S[-i-1]

for i in range(W):
    left[:, i] = (left[:, i-1] + 1) * S[:, i]
    right[:, -i-1] = (right[:, -i] + 1) * S[:, -i-1]

print(np.max(up+down+left+right)-3)
### BUGGY CODE ###

Q = int(input())

P = [list(map(int,input().split())) for i in range(Q)]

List = [3, 5, 13, 37, 61, 73, 157, 193, 277, 313, 397, 421, 457, 541, 613, 661, 673, 733, 757, 877, 997, 1093, 1153, 1201, 1213, 1237, 1321, 1381, 1453, 1621, 1657, 1753, 1873, 1933, 1993, 2017, 2137, 2341, 2473, 2557, 2593, 2797, 2857, 2917, 3061, 3217, 3253, 3313, 3517, 3733, 4021, 4057, 4177, 4261, 4273, 4357, 4441, 4561, 4621, 4933, 5077, 5101, 5113, 5233, 5413, 5437, 5581, 5701, 6037, 6073, 6121, 6133, 6217, 6337, 6361, 6373, 6637, 6661, 6781, 6997, 7057, 7213, 7393, 7417, 7477, 7537, 7753, 7933, 8053, 8101, 8221, 8317, 8353, 8461, 8521, 8677, 8713, 8893, 9013, 9133, 9181, 9241, 9277, 9601, 9661, 9721, 9817, 9901, 9973]

for i in range (0, Q):
	count = 0
	for j in range (P[i][0],P[i][1]+1):
		if j%2 == 0:
			continue
		elif List.count(j) >0:
			count+=1
		else:
			continue
	print(count)

### FIXED CODE ###

import math

Q = int(input())

def prime(n):
	if n > 1:
		for i in range(2,math.floor(math.sqrt(n))+1):
			if (n % i) == 0:
				return(False)
				break
		else:
			return(True)
	else:
		return(False)

Numero = [0]*100001
for i in range (1, 50001):
	if prime(2*i+1) == 1 and prime(i+1) == 1:
		for j in range (2*i+1, 100001):
			Numero[j]+=1
	else:
		continue

for i in range (0, Q):
	A, B = map(int, input().split())
	print(Numero[B]-Numero[A-1])
### BUGGY CODE ###

import sys

N=int(input())
amat=[[-1]]
for i in range(N):
  alist=list(map(int,input().split()))
  amat.append(list(reversed(alist)))
  
#print(amat)
answer=0
matched_flag=[False]*(N+1)
new_search_index=list(range(1,N+1))
for answer in range(1,N**3):
  matched_flag=[False]*(N+1)
  unchanged=True

  search_index=new_search_index;
  new_search_index=[]
  for i in search_index:
    if matched_flag[i] or len(amat[i]) == 0:
      continue
      
    ai_next = amat[i][-1]
    if amat[ai_next][-1]==i and not matched_flag[ai_next]:
      #print(i,ai_next,answer)
      matched_flag[amat[i].pop()]=True
      matched_flag[amat[ai_next].pop()]=True
      unchanged=False
      new_search_index.append(i)
      new_search_index.append(ai_next)
  
  if unchanged:
    print(-1)
    sys.exit()
  else:
    for i in range(1,N+1):
      if len(amat[i])>0:
        break
    else:
      print(answer)
      sys.exit()


### FIXED CODE ###

import sys

N=int(input())
amat=[[-1]]
for i in range(N):
  alist=list(map(int,input().split()))
  amat.append(list(reversed(alist)))
  
#print(amat)
answer=0
matched_flag=[False]*(N+1)
for answer in range(1,N**3):
  if N>900 and answer>3000:
    print(N*(N-1)//2)
    sys.exit()
  
  matched_flag=[False]*(N+1)
  unchanged=True
  
  for i in range(1,N+1):
    if matched_flag[i] or len(amat[i]) == 0:
      continue
      
    ai_next = amat[i][-1]
    if amat[ai_next][-1]==i and not matched_flag[ai_next]:
      #print(i,ai_next,answer)
      matched_flag[amat[i].pop()]=True
      matched_flag[amat[ai_next].pop()]=True
      unchanged=False
  
  if unchanged:
    print(-1)
    sys.exit()
  else:
    for i in range(1,N+1):
      if len(amat[i])>0:
        break
    else:
      print(answer)
      sys.exit()
### BUGGY CODE ###

#ABC122_C
N,Q=map(int,input().split())
S=input()

ls=[0]

Spre=S[0]
for i in range(1,N):
    
    Si=S[i]
    if Spre=='A' and Si=='C':
        ls.append(1)
    else:
        ls.append(0)
    Spre=Si

for i in range(Q):
    l,r=map(int,input().split())
    print(sum(ls[l:r]))





### FIXED CODE ###

#ABC122_C
N,Q=map(int,input().split())
S=input()

ls=[0]

Spre=S[0]
for i in range(1,N):
    Si=S[i]
    if Spre=='A' and Si=='C':
        ls.append(ls[-1]+1)
    else:
        ls.append(ls[-1])
    Spre=Si
 
for i in range(Q):
    l,r=map(int,input().split())
    print(ls[r-1]-ls[l-1])
### BUGGY CODE ###

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

travellist = []
for _ in range(M):
    a, b = map(int, input().split())
    travellist.append([a,b])

travellist = sorted(travellist)


To_list = []
for i in range(M):

    oneroot = travellist[i]
    From = oneroot[0]
    To   = oneroot[1]

    if From == 1:
        To_list.append(To)

    if To == N and From in To_list:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE") 
        

      

### FIXED CODE ###

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

travellist = []
for _ in range(M):
    a, b = map(int, input().split())
    travellist.append([a,b])

travellist = sorted(travellist)


To_list = [0]*N
From_list = []
for i in range(M):

    oneroot = travellist[i]
    From = oneroot[0]
    To   = oneroot[1]

    if From == 1:
        To_list[To] = 1

    if To == N:
        From_list.append(From)


for i in From_list:
    if To_list[i] == 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
from itertools import chain
import numpy as np


def solve(N: int):
    fx = np.zeros(N + 1, dtype=np.uint64)
    for i in range(1, N + 1):
        fx[i::i] += 1
    return np.sum(np.arange(0, N + 1, dtype=np.uint64) * fx)


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    # N = map(int, line.split())
    N = int(next(tokens))  # type: int
    answer = solve(N)
    print(answer)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3

#                 N    N'
#   | 1  2  3  4  5
# 1 | 1  2  3  4  5 :  N // 1   1 * N' (N'+1) // 2
# 2 |    2     4    :  N // 2   2 * N' (N'+1) // 2
# 3 |       3       :  N // 3   3 * N' (N'+1) // 2
# 4 |          4    :  N // 4   4 * N' (N'+1) // 2
# 5 |             5 :  N // 5   5 * N' (N'+1) // 2


def solve(N):
    answer = 0
    for i in range(1, N + 1):
        mprime = N // i
        answer += i * (mprime * (mprime + 1)) // 2
    return answer


def main():
    N = int(input())  # type: int
    answer = solve(N)
    print(answer)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

# coding: utf-8
# Your code here!
import fractions

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

koyaku=fractions.gcd(A,B)

num=min(A,B)
count=0

for i in range(2,num+1):
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)


### FIXED CODE ###

# coding: utf-8
# Your code here!
import fractions

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

def yaku(num):
    temp=[]
    for i in range(2,-int(-num**0.5//1)+1):
        if num%i==0:
            temp.append(i)
            temp.append(num//i)
    temp=list(set(temp))
    if num!=2:
        temp.append(num)
    temp.sort()
    return temp

koyaku=fractions.gcd(A,B)

cand=yaku(min(A,B))
#print(cand)

if cand[0]==1:
    print(1)
    exit()

count=0

for i in cand:
    judge=True
    while koyaku%i==0:
        koyaku//=i
        if judge==True:
            count+=1
            judge=False
    if koyaku==1:
        break
print(count+1)
### BUGGY CODE ###

n, m, q = map(int, input().split())
tr = []
for i in range(m):
    l, r = map(int, input().split())
    tr.append((l, r))

qu = []
for i in range(q):
    p, q = map(int, input().split())
    qu.append((p, q))
    print(len(list(filter(lambda s: p <= s[0] and s[1] <= q, tr))))

### FIXED CODE ###

n, m, q = map(int, input().split())
T = [[0] * n for i in range(n)]
for i in range(m):
    l, r = map(int, input().split())
    T[l - 1][r - 1] += 1

for i in range(n):
    for j in range(1, n):
        T[i][j] += T[i][j - 1]

for j in range(n):
    for i in range(n - 2, -1, -1):
        T[i][j] += T[i + 1][j]

for i in range(q):
    p, q = map(int, input().split())
    print(T[p - 1][q - 1])
### BUGGY CODE ###

import sys

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

cl=[]
city=1
count=0
while city not in cl:
    count+=1
    cl.append(city)
    city=a[city-1]
#arrive at city in count, len(cl)=count
if k<count:
    print(cl[k])
    sys.exit()
    
loop=0
for i in range(len(cl)):
    if cl[i]==city:
        loop=len(cl)-i
        break

d=(k-count)%loop

for i in range(d):
    city=a[city-1]

print(city)

### FIXED CODE ###

import sys
import numpy

n,k=map(int,input().split())
a=list(map(int,input().split()))
b=numpy.zeros(n,dtype=int)

city=1
count=0
while b[city-1]==0:
    count+=1
    b[city-1]=1
    
    city=a[city-1]

#arrive at city in count, len(cl)=count
if k<count:
    cc=1
    for i in range(k):
        cc=a[cc-1]
    print(cc)
    sys.exit()

c=1
cnt=0
while c!=city:
    cnt+=1
    c=a[c-1]

loop=count-cnt

d=(k-count)%loop

for i in range(d):
    city=a[city-1]

print(city)
### BUGGY CODE ###

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

ans = [0] * n

for i in range(n):
    ans[i] = A.index(min(A)) + 1
    A[A.index(min(A))] = n + 1
    
print(' '.join(map(str, ans)))

### FIXED CODE ###

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

ans = [0] * n

for idx, i in enumerate(A):
    ans[i-1] = idx + 1
    
print(' '.join(map(str, ans)))
### BUGGY CODE ###

N = list(map(int, input().split()))[-1]
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

first = [i+j for i in A for j in B]
first = sorted(first)[::-1]
second = [i+j for i in first for j in C]

print("\n".join([str(value) for value in sorted(second)[::-1][:N]]))

### FIXED CODE ###

N = list(map(int, input().split()))[-1]
A = sorted(list(map(int, input().split())), reverse=True)[:N]
B = sorted(list(map(int, input().split())), reverse=True)[:N]
C = sorted(list(map(int, input().split())), reverse=True)[:N]

first = [i+j for i in A for j in B]
first = sorted(first, reverse=True)[:N]
second = [i+j for i in first for j in C]
result = sorted(second, reverse=True)[:N]

[print(i) for i in result]
### BUGGY CODE ###

#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    a = s.count("-")
    b = s.count("+")
    print(b-a)
    return

#B
def B():
    n = S()
    num = sum(map(int, n))
    n = int("".join(n))
    print(["Yes", "No"][n % num > 0])
    return

#C
def C():
    n, k = LI()
    LI()
    print((n - k) // (k - 1) + 1 + bool((n - k) % (k - 1)))
    return

#D
def D():
    K = II()
    ans = 1
    i = 0
    k = 0
    def Sunuke(a):
        return a / sum(map(int, str(a)))
    def Check(a, i):
        return Sunuke(a + 10 ** i) > Sunuke(ans + 10 ** (i + 1))
    while K:
        print(ans)
        k -= 1
        i += Check(ans, i)
        ans += 10 ** i

    return


#Solve
if __name__ == '__main__':
    D()

### FIXED CODE ###

def main():
    s=set()
    for digit in range(16):
        for i in range(1,1000):
            c=i*10**digit+int('9'*digit or 0)
            if c<10**15:
                s.add(c)
    c=sorted(s)
    for i,n in enumerate(c):
        sn=n/sum(map(int,str(n)))
        for m in c[i+1:i+50]:
            sm=m/sum(map(int,str(m)))
            if sm<sn:
                s.remove(n)
                break
    print(*sorted(s)[:int(input())],sep='\n')
main()
### BUGGY CODE ###

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

count = 1

for i in range(1, N):
    if p[i] < min(p[:i]):
        count +=1

print(count)

### FIXED CODE ###

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

count = 1
min = p[0]

for i in range(1, N):
    if p[i] < min:
        count +=1
        min = p[i]
    

print(count)
### BUGGY CODE ###

import bisect

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

for _ in range(M):
    b, c = map(int, input().split())
    index = bisect.bisect_left(A, c)
    index = min(index, b)
    for i in range(index):
        A[i] = c
    if index > 0:
        A = sorted(A)

print(sum(A))



### FIXED CODE ###

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

bc = [list(map(int, input().split())) for _ in range(M)]

ans = sum(A)

bc = sorted(bc, key=lambda i: i[1], reverse=True)

i = 0
for b, c in bc:
    for _ in range(b):
        if A[i] > c:
            break
        ans += c - A[i]
        i += 1
        if i >= N:
            break
    else:
        continue
    break

print(ans)
### BUGGY CODE ###

h,w,m=list(map(int,input().split()))

bom=[[0 for i in range(w+1)] for i in range(h+1)]
 
for i in range(m):
  a,b=list(map(int,input().split()))
  bom[a][b]=1
 
 
from itertools import accumulate
for i in range(h+1):
  bom[i]=list(accumulate(bom[i]))
 
 
for i in range(1,h+1):
  for j in range(1,w+1):
    bom[i][j]=bom[i][j]+bom[i-1][j]

ans=0  
for i in range(1,h+1):
  for j in range(1,w+1):

    ans=max(ans,bom[h][w]-(bom[i-1][j-1]+bom[i-1][w]-bom[i-1][j]+bom[h][j-1]-bom[i][j-1]+bom[h][w]-bom[i][w]-bom[h][j]+bom[i][j]))
    
    
print(ans)
 
 


### FIXED CODE ###

h,w,m=list(map(int,input().split()))
s=[]
t=[]

for i in range(m):
  H,W=list(map(int,input().split()))
  s.append(H)
  t.append(W)
  
from collections import Counter
u=Counter(s)
v=Counter(t)
max_u=max(u.values())
max_u_set = set([kv[0] for kv in u.items() if kv[1]==max_u])
max_v=max(v.values())
max_v_set = set([kv[0] for kv in v.items() if kv[1]==max_v])
check=len(max_u_set)*len(max_v_set)

ans=0
for i in range(m):
  if u[s[i]]==max_u and v[t[i]]==max_v:
    ans=ans+1

if check-ans==0:
  print(max_u+max_v-1)
else:
  print(max_u+max_v)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
r=0
from collections import defaultdict
d=defaultdict(int)
d[A[0]]=1
for i in range(1,N):
    d2=defaultdict(int)
    for a in d.keys():
        if a&A[i]==0:
            r+=d[a]
            d2[a+A[i]]+=d[a]
    d2[A[i]]+=1
    d=d2
print(r+N)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
r=0
from collections import defaultdict
d=defaultdict(int)
d[A[0]]=1
for i in range(1,N):
    d2=defaultdict(int)
    for a in d.keys():
        if a&A[i]==0:
            r+=d[a]
            d2[a+A[i]]+=d[a]
    d2[A[i]]+=1
    d=d2
print(r+N)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
c = 0
while True:
    c = a[c] - 1
    ans += 1
    if c == 0:
        ans = -1
        break
    if c == 1:
        break
print(ans)

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
b = [0] * n
ans = 0
c = 0
b[c] = 1
while True:
    c = a[c] - 1
    ans += 1
    if b[c] == 1:
        ans = -1
        break
    if c == 1:
        break
    b[c] = 1
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)
def f(a,*b):
    if len(b)>1:
        return f(a,f(*b))
    b=b[0]
    if b:
        return f(b,a%b)
    return a
n=int(input())
a=list(map(int,input().split()))
print(f(*a))

### FIXED CODE ###

def f(a,b):
    if b:
        return f(b,a%b)
    return a
n=int(input())
a=list(map(int,input().split()))
p=f(a[0],a[1])
for i in a:
    p=f(p,i)
print(p)
### BUGGY CODE ###

t = input()
s = [c for c in t]
Removable = True
count = 0
while True and len(s)>1:
    tmp = len(s)
    for i in range(len(s)-1):
        if int(s[i])+int(s[i+1]) == 1:
            count += 2
            s.pop(i)
            s.pop(i)
            break
    if tmp == len(s):
        break
print(count)
            

### FIXED CODE ###

t = input()
s = [int(c) for c in t]
print(2 * min(len(s)-sum(s), sum(s)))