Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
l=list(map(int,input().split()))
if(sum(l)>n):
	print(-1)
else:
	print(n-sum(l))

### FIXED CODE ###

import math
print(2*math.pi*(int(input())))
n,m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = []
for i in range(m):
    b.append(int(input()))

import numpy as np
c = np.array(A).dot(b)

for ci in c:
    print(ci)

### FIXED CODE ###

n,m = map(int, input().split())

A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = [0] * m
for i in range(m):
    b[i] = int(input())

from operator import mul
for i in range(n):
    print(sum(map(mul, A[i], b)))
import sys
input= sys.stdin.readline
N, M = map(int,input().split())
 
A= list(map(int,input().split()))
 
A.sort(reverse=True)
cnt = 1
A[0]=A[0]//2
 
if N==1:
    while A[0]>0 and cnt<M:
        cnt+=1
        A[0]=A[0]//2
else:
    while cnt<M:
        c=min(M-cnt,int(math.log2(A[0]/A[1])+1))
        cnt+=c
        A[0]=A[0]//(2**c)
          
        b=A[0]
        A.sort(reverse=True)
    
print(sum(A))

### FIXED CODE ###

import heapq

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

a = [-int(x) for x in input().split()]

heapq.heapify(a)

num = 0
hq = 1

while num < M and hq != 0:
    hq = -heapq.heappop(a)
    hq2 = hq // 2
    heapq.heappush(a, -hq2)
    num += 1

print(-sum(a))
N = input()
print("bon" if N[-1] == 3 else "pon" if N[-1] in == 0 or N[-1] == 1 or N[-1] == 6 or N[-1] == 8 else "hon")

### FIXED CODE ###

N = input()
print("hon" if N[-1] in "24579" else "pon" if N[-1] in "0168" else "bon")
n = list(map(int, input().split()))
nmax = max(n)
print(nmax * 10 + sum(n.remove(nmax)))

### FIXED CODE ###

import itertools, copy

n = input().split()

ans = 0
for p0, p1 in itertools.permutations(n, 2):
    n_ = copy.copy(n)
    n_.remove(p0)
    n_.remove(p1)
    
    total = int(''.join([p0, p1])) + int(n_[0])
    ans = max(ans, total)

print(ans)
from math import factorial

N = int(input())
nums = list(map(int, input().split()))
d = dict()

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += factorial(n) / factorial(2) / factorial(n - 2)

for num in nums:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))


### FIXED CODE ###

import math

N = int(input())
nums = list(map(int, input().split()))
numsB = nums[:]
d = dict()

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for num in nums:
    if num not in d:
        d[num] = 1
    else:
        d[num] += 1

total = 0
for i in d:
    n = d[i]
    if n == 2:
        total += 1
    elif n > 2:
        total += combinations_count(n, 2)

for num in numsB:
    tmp = d[num] - 1
#    if tmp >= 2:
#        hoge = factorial(tmp) / factorial(2) / factorial(tmp - 2)
    print(int(total - tmp))
N, M = map(int, input().split())
a_data = input()
a = a_data.split(' ')

sum = 0
# sum = sum(a)
for item as a:
  sum += int(item)

if sum > N:
  print(-1)
else:
  print(N-sum)


### FIXED CODE ###

N, M = map(int, input().split())
a_data = input()
a = a_data.split(' ')

sum = 0
# sum = sum(a)
for item in a:
  sum += int(item)

if sum > N:
  print(-1)
else:
  print(N-sum)
n = int(input())

a = sorted(list(map(int, input())))

ans = 0
d_min = a[-1]
for i in range(n-1):
  d = abs(a[-1]/2 - a[i])
  if d < d_min:
    d_min = d
    ans = a[i]
    
print('{} {}'.format(a[-1], ans))

### FIXED CODE ###

n = int(input())

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

ans = 0
d_min = a[-1]
for i in range(n-1):
  d = abs(a[-1]/2 - a[i])
  if d < d_min:
    d_min = d
    ans = a[i]
    
print('{} {}'.format(a[-1], ans))
a=input()
b=input()
sum=a*500
if b>sum:
  print("Yes")
else:
  print("NO")

### FIXED CODE ###

a,b=map(int,input().split( ))
sum=a*500
if sum>=b:
  print("Yes")
else:
  print("No")
exit()
S,T = map(str,import().split())
print(S + T)

### FIXED CODE ###

S,T = map(str,input().split())
print(T + S)
A_B = input().split()
print(int(A_B[1])//(int(A_B[0])-1))

### FIXED CODE ###

# Sを入力する
S = list(input())
# Lを入力する
L = list(input())
 
# 3つの要素に定義しなおす
S1 = S[0]
S2 = S[1]
S3 = S[2]
L1 = L[0]
L2 = L[1]
L3 = L[2]
 
# 全部同じ
if S1 == L1 and S2 == L2 and S3 == L3:
  print(3)
# 全部違う
elif S1 != L1 and S2 != L2 and S3 != L3:
  print(0)
# 一つだけ
elif (S1 == L1 and S2 != L2 and S3 != L3) or (S1 != L1 and S2 == L2 and S3 != L3) or (S1 != L1 and S2 != L2 and S3 == L3):
  print(1)
# その他
else:
  print(2)
# coding: utf-8
# Your code here!
#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################
import numpy as np
l ={}
N,K = map(int,input().split())
#P = list(map(int,input().split()))
P = np.asarray(list(map(int,input().split())))
#print(P)
P_ = []
#print(P_)

def kitai(num):
    x = 0
    for j in range(num):
        x += num-j
    return x/num
for i in P:
    P_ = np.append(P_,kitai(i))
#print(type(P_))


#print(P)
for i in range(0,N-K+1):
    #print(P[i:i+K])
    l[sum(P_[i:i+K])]=i
#print(l)
max = max(l.keys())
print(max)
import sys
def input():
    return sys.stdin.readline()[:-1]







### FIXED CODE ###

#########行列読み込み ##############################################
"""
from sys import stdin
n = int(stdin.readline().rstrip())
data = [stdin.readline().rstrip().split() for _ in range(n)]
print(data)
print(*data, sep='\n')
"""
##################################################################
#########入力系####################################################
"""
s =input()
s=list(input())
a=int(input())
x,y = map(int,input().split())	
li = input().split()	
li = list(map(int,input().split()))	
li = input().split('T')	
"""
##################################################################

N,K = map(int,input().split())
def kitai(num):
    return (1+int(num))/2
P = list(map(kitai,input().split()))	  

S = [0]*(N+1)
ans = 0
for i in range(N):
    S[i+1]=S[i]+P[i]
for i in range(N-K+1):
    ans = max(ans,S[i+K]-S[i])
print(ans)
print(int(input()).replace(1,9).replace(9,1))


### FIXED CODE ###

a=int(input())
b=str(a).replace('1','a').replace('9','b')
c=b.replace('a','9').replace('b','1')
print(int(c))
N = int(input())
C0 = 0
C1 = 0
C2 = 0
C3 = 0
for i in range(N):
    if input() == "AC":
        C0 += 1
    elif input() == "WA":
        C1 += 1
    elif input() == "TLE":
        C2 += 1
    elif input() == "RE":
        C3 += 1
print("AC × %d",C0)
print("WA × %d",C1)
print("TLE × %d",C2)
print("RE × %d",C3)

### FIXED CODE ###

N = int(input())
C0 = C1 = C2 = C3 = 0
for _ in range(N):
    S = input()
    if S == "AC":
        C0 += 1
    elif S == "WA":
        C1 += 1
    elif S == "TLE":
        C2 += 1
    elif S == "RE":
        C3 += 1

print("AC x %d"%C0)
print("WA x %d"%C1)
print("TLE x %d"%C2)
print("RE x %d"%C3)
N = int(input())
D = list(map(int, input().split()))

M = int(input())
T = list(map(int, input().split()))

d = [0 for _ in range(200005)]
t = [0 for _ in range(200005)]

ans = "YES"

for i in range(N):
    d[D[i]] += 1

for i in range(M):
    t[T[i]] += 1

for i in range(len(d)):
    if t[i] > d[i]:
        ans = "NO"

print(ans)


### FIXED CODE ###

from collections import defaultdict
n = int(input())
d = tuple(map(int, input().split()))
m = int(input())
t = tuple(map(int, input().split()))
l = defaultdict(int)
for x in d:
    l[x] += 1
for y in t:
    if l[y] == 0:
        print('NO')
        exit()
    l[y] -= 1
print('YES')
import math

A, B, C, D = map(int, input().split(' '))

num_C_baisu = (B//C - math.ceil(A/C)) + 1

num_D_baisu = (B//D - math.ceil(A/D)) + 1

CD = int(C*D/math.gcd(C,D))

num_CD_baisu = (B//CD - math.ceil(A/CD)) + 1

baisu_num = num_C_baisu + num_D_baisu - num_CD_baisu

print(B-A+1-baisu_num)

### FIXED CODE ###

a,b,c,d= list(input())

if a==b:
    print('Bad')
elif b==c:
    print('Bad')
elif c==d:
    print('Bad')
else:
    print('Good')
n = int(input())
s = int(input())

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n%b


for b in range(int(math.sqrt(n))):
    if f(b, n) == s:
        print(b)
        exit()

for p in range(int(math.sqrt(n))):
    q = s - p
    b = (n - q) // p
    if f(b, n) == s:
        print(b)
        exit()
        
print(-1)

### FIXED CODE ###


import math

n = int(input())
s = int(input())

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n%b

if n == s:
    print(n+1)
    exit()

for b in range(2, int(math.sqrt(n))+1):
    if f(b, n) == s:
        print(b)
        exit()

for p in list(range(1, min(int(math.sqrt(n))+1, s+1)))[::-1]:
    q = s - p
    b = (n - q) // p
    if b >= 2 and f(b, n) == s:
        print(b)
        exit()

print(-1)
# -*- coding: utf-8 -*-
N = int(raw_input())
li = map(int, raw_input().split())

ans = 0
tmp = 0

for i in xrange(N-1):
    if li[i] < li[i+1]
        tmp +=1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)

### FIXED CODE ###

n = int(raw_input())
a = map(int, raw_input().split())
 
ans = 0
temp = 0
for i in xrange(n-1):
    if a[i] >= a[i+1]:
        temp = temp + 1
    else:
        ans = max(ans, temp) 
        temp = 0
 
print max(ans, temp)
a,b,c=map(input().split())

if a[-1]==b[0] and b[-1]==c[0]:
    print('YES')
else:
    print('NO')


### FIXED CODE ###

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

if a[-1]==b[0] and b[-1]==c[0]:
    print('YES')
else:
    print('NO')
N = input()
L = input().split()
b=0
L.sort()

a = L.pop(-1)

for i in range(N-1):
  b+= L[i]

if (a < b):
  print("Yes")
else:
  print("No")



### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
b=0
L.sort()
 
a = L.pop(-1)
 
for i in range(N-1):
  b+= L[i]
 
if (a < b):
  print("Yes")
else:
  print("No")
def rec(x,y,c):
    if   A[y][x] == ".": A[y][x] = c
    elif A[y][x] != c  : A[y][x] = "x"
    for dx,dy in zip([1,0,-1,0],[0,1,0,-1]):
        nx,ny = x+dx,y+dy
        if 0 <= nx < w and 0 <= ny < h and A[ny][nx] in [".","b" if c == "w" else "w"]:
            rec(nx,ny,c)

while 1:
    w,h = map(int,raw_input().split())
    if w == 0: break
    A = [list(raw_input()) for _ in range(h)]
    for y in range(h):
        for x in range(w):
            if A[y][x] == "W": rec(x,y,"w")
            if A[y][x] == "B": rec(x,y,"b")
    print sum(Ai.count("b") for Ai in A),sum(Ai.count("w") for Ai in A)

### FIXED CODE ###

import sys
sys.setrecursionlimit(3000)
def rec(x,y,c):
    if   A[y][x] == ".": A[y][x] = c
    elif A[y][x] != c  : A[y][x] = "x"
    for dx,dy in zip([1,0,-1,0],[0,1,0,-1]):
        nx,ny = x+dx,y+dy
        if 0 <= nx < w and 0 <= ny < h and A[ny][nx] in [".","b" if c == "w" else "w"]:
            rec(nx,ny,c)

while 1:
    w,h = map(int,raw_input().split())
    if w == 0: break
    A = [list(raw_input()) for _ in range(h)]
    for y in range(h):
        for x in range(w):
            if A[y][x] == "W": rec(x,y,"w")
            if A[y][x] == "B": rec(x,y,"b")
    print sum(Ai.count("b") for Ai in A),sum(Ai.count("w") for Ai in A)
r,d,x=map(int,input().split())
for i in range(10):
  x=r*x-D
  print(x)

### FIXED CODE ###

r,d,x=map(int,input().split())
for i in range(10):
  x=r*x-d
  print(x)
N = int(input())

s = input()

if N < 1000:
    print('ABC')

elif N > 999:
    print('ABD')

### FIXED CODE ###

N = int(input())

if N < 1000:
    print('ABC')

elif 1000 <= N <= 1998:
    print('ABD')
lists = []
lists2 = []
a = int(input())
if a %10 == 0:
    lists2.append(a)
else:
    lists.append(a)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if lists != None:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if lists != None:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if lists != None:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if lists != None:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
time = 0
for t in lists2:
    time += t
for t in lists[0:len(lists)-1]:
    time += (10 - t%10) + t
time +=lists[-1]
print(time)

### FIXED CODE ###

lists = []
lists2 = []
a = int(input())
if a %10 == 0:
    lists2.append(a)
else:
    lists.append(a)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
time = 0
for t in lists2:
    time += t
for t in lists[0:len(lists)-1]:
    time += (10 - t%10) + t
if len(lists) >= 1:
    time +=lists[-1]
print(time)
import sys
import math

for line in sys.stdin.readlines():
     x, y = line.split(" ")

x = int(x)
y = int(y)

divide = 1

if x > y:
    x, y = y, x

for i in range(2, sqrt(x) + 1):
    if x % i == 0 and y % i == 0:
        divide *= i
        x /= i
        y /= i
        i -= 1

print divide

### FIXED CODE ###

import sys

def div(x, y):
    if x % y == 0:
        print y
    else:
        div(y, x%y)


line = sys.stdin.readline()
x, y = line.split(" ")

x = int(x)
y = int(y)

if x < y:
    x, y = y, x

if x == y:
    print x

else:
    div(x, y)
X, A = map(int, input.split())
print(0 if X < A else 10)

### FIXED CODE ###

X, A = map(int, input().split())
print(0 if X < A else 10)
K = int(input())
ans = [K//50 + i for i in range(50)]
if K%50:
  for i in range(K%50):
    ans[i] += 50
print(50)
print(" ".join(ans))

### FIXED CODE ###

K = int(input())
ans = [K//50 + i for i in range(50)]
if K%50:
  for i in range(K%50):
    ans[i] += 51
    ans = [a-1 for a in ans]
print(50)
ans = [str(a) for a in ans]
print(" ".join(ans))
x,y=map(input())
if x<y:
  print('<')
elif x>y:
  print('>')
else:
  print('=')

### FIXED CODE ###

x,y=map(str,input().split())
if x<y:
  print('<')
elif x>y:
  print('>')
else:
  print('=')
def count(data):
    dic = {}
    for d in data:
        if d in dic:
            dic[d] += 1
        else:
            dic[d] = 1
    return dic

n = int(input())
data = []
for _ in range(n):
    s = input()
    data.append(count(s))
ans = 0
for i in range(n):
    for ii in range(i+1, n):
        if data[i] == data[ii]|:
            ans += 1
print(ans)



### FIXED CODE ###

def count(data):
    dic = {}
    for d in data:
        if d in dic:
            dic[d] += 1
        else:
            dic[d] = 1
    return dic

n = int(input())
counts = {}
for _ in range(n):
    s = ''.join(sorted(input()))
    if s in counts:
        counts[s] += 1
    else:
        counts[s] = 1

ans = 0
for v in counts.values():
    ans += (v*(v-1))//2
print(ans)
N = int(input())

print(int((1 + N) * N / 2)

### FIXED CODE ###

N = int(input())

print(int((1 + N) * N / 2))
while True:
  H,M=map(int,input().split())
  if H == 0 and M == 0:
    break
  else:
    for i in range(H):
  ???    print('#'*M)
  ???print('')

### FIXED CODE ###

while True:
 H,M=map(int,input().split())
 if H == 0 and M == 0:
     break
 else:
     for i in range(H):
         print('#'*M)
     print('')
N = int(input())
A = [int(a) for a in input().split()]

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

mat = [1]
divs_set = set()
divs_powers = {}
for a in A:
    tmp = factorization(a)
    for div in tmp:
        if div[0] not in divs_set:
            divs_set.add(div[0])
            divs_powers[div[0]] = div[1]
        else:
            if divs_powers[div[0]] < div[1]:
                divs_powers[div[0]] = div[1]

Z = 1
for n in divs_set:
    Z = Z*(n**divs_powers[n])

B = [0]*N
for i, a in enumerate(A):
    B[i] = int(Z/a)

print(B)
print(int(sum(B) % (10**9+7)))

### FIXED CODE ###

import math
from collections import defaultdict

n = int(input())
A = list(map(int,input().split()))
mod = 10**9+7

divisor_primes = defaultdict(int)

def prime_factrizer(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

for a in A:
    factrized_a = prime_factrizer(a)
    for prime in factrized_a:
        divisor_primes[prime[0]] = max(divisor_primes[prime[0]],prime[1])

invs = [1] * (max(A) + 1)
for i in range(2, max(A) + 1):
    invs[i] = mod - invs[mod % i] * (mod//i) % mod

lcm = 1
for key in divisor_primes.keys():
    power = divisor_primes[key]
    div = 1
    for i in range(power):
        div *= key
        div %= mod
    lcm *= div

ans = 0

for a in A:
    ans += invs[a]
    ans %= mod
ans *= lcm
ans %= mod
print(ans)
n1 = int(input())
n2 = int(input())
 
print(n1)
print(n2)
 
if n1 == 1:
  if n2 == 2:
    print("3")
  else:
    print("2")
else n1 == 2:
  if n2 == 1:
    print("3")
  else:
    print("1")
else n1 ==3:
  if n2 == 1:
    print("2"):
  else:
    print("1"):

### FIXED CODE ###

n1 = int(input())
n2 = int(input())
 
#print(n1)
#print(n2)
 
if n1 == 1:
  if n2 == 2:
    print("3")
  else:
    print("2")
elif n1 == 2:
  if n2 == 1:
    print("3")
  else:
    print("1")
elif n1 ==3:
  if n2 == 1:
    print("2")
  else:
    print("1")
n, x = map(int, input().split())
a = list(map(int, input().split()))
d = a.copy()
ans = float('inf')
for i in range(n):
    ans = min(ans, sum(d) + x * i)
    for j in range(n):
        d[j] = min(d[j], a[(j - (i + 1) + n) % n])
print(ans)

### FIXED CODE ###

n, x = map(int, input().split())
a = list(map(int, input().split()))
d = a[:]
ans = float('inf')
for i in range(n):
    ans = min(ans, sum(d) + x * i)
    for j in range(n):
        d[j] = min(d[j], a[(j - (i + 1) + n) % n])
print(ans)
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
mi = None

for i in range(2 ** (H - 1)):
    # div[j] is true if row j and row j + 1 is divided
    div = [(i & (1 << j)) > 0 for j in range(H - 1)]
    group = [0] * H
    for j in range(H - 1):
        group[j + 1] = group[j] + 1 if div[j] else group[j]
    count = Counter()
    ans = div.count(True)
    ok = True
    for j in range(W):
        tmp = Counter()
        for k in range(H):
            if S[k][j] == '1':
                tmp[group[k]] += 1
        if max(tmp.values(), default=0) > K:
            ok = False
        elif max((tmp + count).values(), default=0) <= K:
            count += tmp
        else:
            count = tmp
            ans += 1
    if ok and (mi is None or ans < mi):
        mi = ans

print(mi)


### FIXED CODE ###

import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

H, W, K = map(int, input().split())
S = [input() for _ in range(H)]
mi = None

def _max(iterable):
    ma = 0
    for i in iterable:
        ma = max(ma, i)
    return ma

for i in range(2 ** (H - 1)):
    # div[j] is true if row j and row j + 1 is divided
    div = [(i & (1 << j)) > 0 for j in range(H - 1)]
    group = [0] * H
    for j in range(H - 1):
        group[j + 1] = group[j] + 1 if div[j] else group[j]
    count = Counter()
    ans = div.count(True)
    ok = True
    for j in range(W):
        tmp = Counter()
        for k in range(H):
            if S[k][j] == '1':
                tmp[group[k]] += 1
        if _max(tmp.values()) > K:
            ok = False
        elif _max((tmp + count).values()) <= K:
            count += tmp
        else:
            count = tmp
            ans += 1
    if ok and (mi is None or ans < mi):
        mi = ans

print(mi)
from math import gcd


def lcm(x, y):
    return (x*y) // gcd(x, y)


N = int(input())
ans = 0
for i in range(N):
    T = int(input())

    if i == 0:
        ans = T

    else:
        ans = lcm(ans, T)

print(ans)


### FIXED CODE ###

N = input()

print("Yes" if N[0] == N[2] else "No")
O=str(input())
E=str(input())
m=max(len(O),len(E))
for i in range(m):
 if (i<len(O)):
  print (O[i], end=" ")
 if (i<len(E)):
  print(E[i], end=" ")


### FIXED CODE ###

a,b,c=map(int,input().split())
if b-a==c-b:
 print ('YES')
else:
 print ('NO')
n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 9 + 1
count = 0

def merge(S, left, mid, right):
    L = S[left:mid] + [SENTINEL]
    R = S[mid:right] + [SENTINEL]
    i = j = 0
    global count
    for k in range(left, right):
        if (L[i] <= R[j]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1
    count += right - left

mergeSort(S, left, right):
    if(left + 1 < right):
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)

mergeSort(S, 0, n)
print(*S)
print(count)

### FIXED CODE ###

n = int(input())
S = list(map(int, input().split()))
SENTINEL = 10 ** 9 + 1
count = 0
 
def merge(S, left, mid, right):
    L = S[left:mid] + [SENTINEL]
    R = S[mid:right] + [SENTINEL]
    i = j = 0
    global count
    for k in range(left, right):
        count += 1
        if (L[i] <= R[j]):
            S[k] = L[i]
            i += 1
        else:
            S[k] = R[j]
            j += 1
 
def mergeSort(S, left, right):
    if(left + 1 < right):
        mid = (left + right) // 2
        mergeSort(S, left, mid)
        mergeSort(S, mid, right)
        merge(S, left, mid, right)
 
mergeSort(S, 0, n)
print(*S)
print(count)