Harryxun/stf_run huggingface dataset:
import math                                                                                            

n,k = raw_input().split()
s = list(raw_input())


cnt = 0

prev = ''
tmp = ''
ar = []
for i in s:
    if i == '0' and prev !=  1:
        tmp += '0'
        prev = 0
    elif i == '0' and prev == 1:
        prev = 0
        ar.append(tmp)
        tmp = '0'
    elif i == '1' and prev != 0:
        tmp += '1'
        prev = 1
    elif i == '1' and prev == 0:
        prev = 1
        ar.append(tmp)
        tmp = '1'

ar.append(tmp)
k = int(k)


j = 0
cnt = 0
total = 0
m = 0

for i in ar:
    total += len(i)
    if '0' in i:
        cnt += 1
    if '0' in i and cnt == k + 1:
        total = total - (len(ar[j-2*k]) + len(ar[j-2*k-1]))                                            
        cnt = k                                    
    m = max(m, total)
    j += 1

print m

### FIXED CODE ###

ar = []                                            
raw = raw_input().split()                          
#ar.append(int(raw))                               
#raw = raw_input()                                 
#raw = raw_input()                                 
#ar.append(int(raw))                               
#raw = raw_input()                                 
#ar.append(int(raw))                               
#raw = raw_input()                                 
#ar.append(int(raw))                               
#raw = raw_input()                                 
#ar.append(int(raw))                               




#n = ar[0]                                         
a = int(raw[0])                                    
b = int(raw[1])
#c = ar[3]
#d = ar[4]
#e = ar[5]                                         

first = max(a,b)                                   

if ( a > b):                                       
    a -= 1                                         
else:
    b -= 1                                         


second = max(a,b)                                  

print first + second
K=int(input())
X=int(input())

if 500*K < X:
	print("No")
else:
  print("Yes")

### FIXED CODE ###

K,X = map(int,input().split())
if 500*K<X:
  print("No")
else:
  print("Yes")
import numpy as np

N = int(input())
s = []
for i in range(N):
  s.append(input())
    
M = int(input())
t = []
for i in range(M):
  t.append(input())
    
s = np.unique(s, return_counts=True)
t = np.unique(t, return_counts=True)

ans = 0
for i,ch_s in enumerate(s[0]):
  ans_tmp = s[1][i]
  for j,ch_t in enumerate(t[0]):
    if ch_s == ch_t:
      ans_tmp -= t[1][j]
  if ans_tmp > ans:
    ans = ans_tmp
print(int(ans))

### FIXED CODE ###

import numpy as np

N = int(input())
s = []
for i in range(N):
  s.append(input())
    
M = int(input())
t = []
for i in range(M):
  t.append(input())

s = np.array(s)
t = np.array(t)
s_uni = np.unique(s)

ans = 0
for i,ch_s in enumerate(s_uni):
  ans_tmp = (s==ch_s).sum()
  ans_tmp -= (t==ch_s).sum()
  if ans_tmp > ans:
    ans = ans_tmp
print(int(ans))
import copy

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

q = copy.copy(p)

r = q.sort()

kaisu = 0

for i in range(n):
  if p[i] != r[i]:
    kaisu += 1

if kaisu == 0 or kaisu == 2:
  print("YES")
else:
  print("NO")


### FIXED CODE ###

import copy

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

q = copy.copy(p)

q.sort()

kaisu = 0

for i in range(n):
  if p[i] != q[i]:
    kaisu += 1

if kaisu == 0 or kaisu == 2:
  print("YES")
else:
  print("NO")
import math


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

if n[0] % 2 == 0:
  print(math.ceil(n[0] / 2 * n[1]))
  
elif n[1] % 2 ==0:
  print(math.ceil(n[1]/ 2 * n[0]))
  
  elif n[0] == 1 or n[1] == 1
else:
  result = math.ceil(n[0] / 2) * math.ceil(n[1] / 2) + math.floor(n[0] / 2) *math.floor(n[1] / 2)
  print(result)

### FIXED CODE ###

import math


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

if n[0] == 1 or n[1] == 1:
  print('1')
  
else:
  print(math.floor((n[0] * n[1] + 1)/ 2))
def modpow(x,p,mod):
    ret=1
    for i in range(70):
        if (1<<i)&p:
            ret=ret*x%mod
        x=x*x%mod
    return ret

def inverse_table(n,mod):
    table=[]
    for i in range(0,n+1):
        table.append(modpow(i,mod-2,mod))
    return table

def factorial_table(n,mod):
    table=[1]
    for i in range(1,n+1):
        table.append(table[-1]*i%mod)
    return table


it=inverse_table(10**5,1000000007)
ft=factorial_table(10**5,1000000007)

def c(n,k,it,ft,mod):
    return ft[n]*it[ft[k]]*it[ft[(n-k)]]%mod

n,k=map(int,input().split())
a=sorted(map(int,input().split()))
hoge=[]
while True:
    hoge.append(c(n-1,k-1,it,ft,1000000007))
    if n-1==k-1:
        break
    n-=1
ans=0
for i in range(len(hoge)):
    ans-=hoge[i]*a[i]%1000000007
    ans+=hoge[i]*a[-i-1]%1000000007
    ans%=1000000007
print(ans)



### FIXED CODE ###

def modpow(x,p,mod):
    ret=1
    for i in range(64):
        if (1<<i)&p:
            ret=ret*x%mod
        x=x*x%mod
    return ret

def inverse_table(n,mod):
    table=[]
    for i in range(0,n+1):
        table.append(modpow(i,mod-2,mod))
    return table

def factorial_table(n,mod):
    table=[1]
    for i in range(1,n+1):
        table.append(table[-1]*i%mod)
    return table

def inverse_factorial_table(n,it,mod):
    table=[1]
    for i in range(1,n+1):
        table.append(table[-1]*it[i]%mod)
    return table

it=inverse_table(10**5,1000000007)
ft=factorial_table(10**5,1000000007)
ift=inverse_factorial_table(10**5,it,1000000007)
def c(n,k,it,ft,mod):
    return ft[n]*ift[k]*ift[(n-k)]%mod
n,k=map(int,input().split())
a=sorted(map(int,input().split()))
hoge=[]
while True:
    hoge.append(c(n-1,k-1,it,ft,1000000007))
    if n-1==k-1:
        break
    n-=1
ans=0
for i in range(len(hoge)):
    ans-=hoge[i]*a[i]%1000000007
    ans+=hoge[i]*a[-i-1]%1000000007
    ans%=1000000007
print(ans)
n,k = map(int,input().split())
print(abs(n//k - (n-(n//k)*k))

### FIXED CODE ###

n,k = map(int,input().split())
if n < k:
    print(1)
else:
    if n%k == 0:
        print(0)
    else:
        if k >= n%k:
            print(1)
        else : 
            print(k - n%k)
s = input()
w = int(input())
ans = ''
count = 0
while count <= len(s):
  ans += s[count]
  count += w
print(ans)

### FIXED CODE ###

s = input()
w = int(input())
ans = ''
count = 0
while count <= len(s)-1:
  ans += s[count]
  count += w
print(ans)
n = int(input())
x = input()
ones = 0
for i in x:
    if i=='1':
        ones += 1
mods = [0, 0]
for i in range(n):
    if x[n-i-1]=='1':
        if ones>1:
            mods[0] += pow(2, i, ones-1)
        mods[1] += pow(2, i, ones+1)
if ones>1:
    mods[0] %= ones-1
mods[1] %= ones+1
def f(x):
    if x==0:
        return 1
    cnt = 1
    while x>0:
        p = bin(x).count('1')
        x %= p
        cnt += 1
    return cnt
for i in range(n-1, -1, -1):
    if x[n-i-1]=='1' and ones==1:
        print(0)
        continue
    if x[n-i-1]=='1':
        init = (mods[0] - pow(2, i, ones-1))%(ones-1)
    else:
        init = (mods[1] + pow(2, i, ones+1))%(ones+1)
    print(f(init))

### FIXED CODE ###

from heapq import heappop, heappush
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
    n = int(input())
    ans = 0
    camels0 = [[] for _ in range(n)]
    camels1 = [[] for _ in range(n)]
    for _ in range(n):
        k, l, r = map(int, input().split())
        if l>r:
            camels0[k-1].append(l-r)
        elif l<r and k<n:
            camels1[n-k-1].append(r-l)
        ans += min(l, r)
    h = []
    for i in range(n):
        for j in camels0[i]:
            heappush(h, j)
        while len(h)>i+1:
            heappop(h)
    ans += sum(h)
    h = []
    for i in range(n):
        for j in camels1[i]:
            heappush(h, j)
        while len(h)>i+1:
            heappop(h)
    ans += sum(h)
    print(ans)
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
else:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

### FIXED CODE ###

X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)
import sys

input = sys.stdin.readline

A=[int(input()) for _ in range(5)]

for i,a in enumerate(A):
  if a == 0:
    print(i)
    break

### FIXED CODE ###

import sys
 
input = sys.stdin.readline
 
s = input().rstrip()
 
s_1 = s.split(" ")
 
s_i = list(map(int,s_1))

for i,a in enumerate(s_i):
  if a == 0:
    print(i+1)
    break
O,E=[input().rstrip() for _ in range(2)]
for i in range(len(O)):
    print(O[i]+E[i],end="")

### FIXED CODE ###

o, e = [input().rstrip() for i in range(2)] 
ans = ""
for i in range(len(o)):
  ans += o[i]
  if len(e) > i: ans += e[i]
print(ans)
x = int(input())
y = int(input())
print(x*y)

### FIXED CODE ###

a,b = map(int,input().split())
print(a*b)
while True:
  a,op,b = raw_input().split
  a,b = map(int,[a,b])

  if op == "?":
     break

  if op == "+":
     print a+b
  elif op == "-":
     print a-b
  elif op == "*":
     print a*b
  elif op == "/":
     print a/b

### FIXED CODE ###

while True:
  a,op,b = raw_input().split()
  a,b = map(int,[a,b])

  if op == "?":
     break

  if op == "+":
     print (a+b)
  elif op == "-":
     print (a-b)
  elif op == "*":
     print (a*b)
  elif op == "/":
     print (a/b)
n=int(input())
xl=list(map(int,input().split()))
ans=[]
for p in range(xl[-1]-xl[0]+1):
    sum1=0
    for xi in xl:
        sum1+=(xi-xl[0]-p)**2
    ans.append(sum1)
print(min(ans))

### FIXED CODE ###

n=int(input())
xl=list(map(int,input().split()))
xl.sort()
ans=[]
for p in range(xl[-1]-xl[0]+1):
    sum1=0
    for xi in xl:
        sum1+=(xi-xl[0]-p)**2
    ans.append(sum1)
print(min(ans))
N = input()
ctr = 0
for i in range(0,len(N)-1):
	if N[i] = "1":ctr+=1
print(ctr)

### FIXED CODE ###

N = input()
ctr = 0
for i in N:
	if i == "1":ctr+=1
print(ctr)
a,b,c = raw_input().split()
a,b,c = c,a,b

print(a,b,c)

### FIXED CODE ###

a,b,c = input().split()
print(str(c)+" "+str(a)+" "+str(b))
N = input()
num = input().split()

count = 0
while(True):
	div = []
	for i in num:
		if(i % 2 == 0):
			div.append(i/2)
    	else:
	  		print(count)
        	break
	num = div
	count = count + 1



### FIXED CODE ###

n = input()
num = [int(i) for i in input().split()]
count = 0
end=False
while(True):
	div = []
	for i in num:
		if(i % 2 == 0):
			div.append(i/2)
		else:
			print(count)
			end = True
			break
	if(end == True):
		break
	num = div
	count = count + 1
N = int(input())
W = []
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    W.append([u - 1, v - 1, w])
color = [0] * N
tree = [[] for _ in range(N)]
for w in W:
    tree[w[0]].append([w[1], w[2]])
    tree[w[1]].append([w[0], w[2]])
for i, t in enumerate(tree):
    if len(t) == 1:
        start = i
        break


def rec(n, prev, w):
    if color[prev] == color[n]:
        if w % 2 == 1:
            color[n] = 1 if color[prev] == 0 else 0
    elif w % 2 == 0:
        color[n] = color[prev]
    for i in tree[n]:
        if i[0] == prev:
            continue
        else:
            rec(i[0], n, i[1])


rec(tree[start][0][0], start, tree[start][0][1])
for c in color:
    print(c)

### FIXED CODE ###

import sys

sys.setrecursionlimit(1000000)

N = int(input())
M = [[] for _ in range(N)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    M[u].append([v, w])
    M[v].append([u, w])

V = [0] * N
D = [0] * N
C = [0] * N


def dfs(n, c):
    if V[n] == 1:
        return
    C[n] = c
    V[n] = 1
    for w in M[n]:
        if w[1] % 2 == 0:
            dfs(w[0], c)
        else:
            dfs(w[0], (c + 1) % 2)

dfs(0, 0)
for c in C:
    print(c)
import math

x = int(input())

end = math.floor(x**0.2)

for i in range(1, x+1):
    if x % i == 0:
        for a in range(i//2,end,1):
            b = a - i
            if a**5 - b**5 == x:
                print(a, b)
                break

### FIXED CODE ###

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

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

way_list = []
for i in range(m):
    org = list(map(int, input().split()))
    org.sort()
    way_list.append(org)

bad = []

for j in range(m):
    way = way_list[j]
    if h_list[way[0]-1] > h_list[way[1]-1]:
        bad.append(way[1])
    elif h_list[way[0]-1] < h_list[way[1]-1]:
        bad.append(way[0])
    else:
        bad.append(way[0])
        bad.append(way[1])

bad = list(set(bad))
print(n - len(bad))
print("縦と横の長さを入力")

a=int(input())
b=int(input())

print(a*b,a*2+b*2)



### FIXED CODE ###


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

r=a*b
length=a*2+b*2
print(r,length)
N=input()
n=sum(map(int,N))
if N%n==0:
  print("Yes")
else :
  print("No")

### FIXED CODE ###

N=int(input())
n=sum(map(int,str(N)))
print("Yes" if N%n==0 else "No")
def main():
    n, m = map(int, input().split())
    p = [0] * m
    y = [0] * m
    dic = {}
    cities = [[] for _ in range(n)]
    x = [0] * m
    for i in range(m):
        p[i], y[i] = map(int, input().split())
        cities[p[i] - 1].append(y[i])
        dic[y[i]] = i
    for index, i in enumerate(cities):
        for ind, j in enumerate(sorted(i), 1):
            x[dic[j]] = ind
    for i in range(m):
        print(f"{p[i]:06}{x[i]:06}")


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, m = map(int, input().split())
    p = [0] * m
    y = [0] * m
    dic = {}
    cities = [[] for _ in range(n)]
    x = [0] * m
    for i in range(m):
        p[i], y[i] = map(int, input().split())
        cities[p[i] - 1].append(y[i])
        dic[y[i]] = i
    for i in cities:
        for ind, j in enumerate(sorted(i), 1):
            x[dic[j]] = ind
    for i in range(m):
        print("{:06}{:06}".format(p[i],x[i]))


if __name__ == '__main__':
    main()
N=int(input())
A=input().split()
 
for i in range(N)
  if A.count(A[i]) >1:
    print("NO")
    exit(0)
print("YES")

### FIXED CODE ###

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

A=sorted(A)

for i in range(0,N):
  if len(A) > i+1:
    if A[i] == A[i+1]:
      print("NO")
      exit(0)
print("YES")
S = input()
T = input()

flag = False
s_tmp = S
for cnt in range(len(s)):
    s_tmp = s_tmp[-1] + s_tmp[:-1]
    if s_tmp == T:
        flag = True
        break

if flag:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

S = input()
T = input()

flag = False
s_tmp = S
for cnt in range(len(S)):
    s_tmp = s_tmp[-1] + s_tmp[:-1]
    if s_tmp == T:
        flag = True
        break

if flag:
    print("Yes")
else:
    print("No")
N = int(input())
T = int(input())
A = int(input())
H = list(map(int, input().split()))

ans_l = []

for i in range(N):
    mater = H[i]
    Temp = (T - (mater*0.006))
    ans = abs(A - Temp)
    ans_l.append(ans)
 
ans_mini = min(ans_l)

ans_posi =[]

for h in range(N):
    if ans_l[h] == ans_mini:
        ans2 = h+1
        ans_posi.append(ans2)


for j in ans_posi:
    print(j,end="")

### FIXED CODE ###

X,Y = map(int, input().split())

Re_Y = Y//2


print(X + Re_Y)
import collections

N = int(input())
A = list(map(int, input().split()))
li = []
b = 0
if max(A) > (sum(A) - max(A):
  b = -max(A)
  for i in range(N):
    li.append(abs(A[i]-(b+i+1)))
  print(sum(li))
else :
  for i in range(N):
    li.append(abs(A[i]-(b+i+1)))
  c = collections.Counter(li)
  b = -c.most_common()[0][0]
  li.clear()
  for i in range(N):
    li.append(abs(A[i]-(b+i+1)))
  print(sum(li))

### FIXED CODE ###

import statistics

N = int(input())
A = list(map(int, input().split()))
B = []
li = []
for i in range(N):
  B.append(A[i] - (i+1))
b = int(statistics.median(B))
for i in range(N):
  li.append(abs(A[i] - (b+i+1)))
print(sum(li))
r = input()
print(3 * r * r)

### FIXED CODE ###

r = input()
r = int(r)
print(3 * r * r)
N = int(input())
H = list(map(int,input().split()))
ans=0
cnt=0
for i in range(1,n):
  if h[i]<=h[i-1]:
    cnt+=1
    if cnt>ans:
      ans=cnt
  else:
    cnt=0
print(ans)

### FIXED CODE ###

n = int(input())
h = list(map(int,input().split()))
ans=0
cnt=0
for i in range(1,n):
  if h[i]<=h[i-1]:
    cnt+=1
    if cnt>ans:
      ans=cnt
  else:
    cnt=0
print(ans)
N = int(input())
A = list(map(int, input().split()))
import numpy as np
B = np.prod(A)
if B <= 10 ** 18:
    print(B)
else:
    print(-1)

### FIXED CODE ###

A, B = map(int, input().split())
print(A * B)
return (int(input()) ** 3)

### FIXED CODE ###

print(int(input()) ** 3)
N = int(input()) #1行目のNを取得する
s_char = list(input().split())
s = [int(n) for n in s_char]
ans = 1

for num in s:
    if len(str(ans))+len(str(num))>20:
        #print('e')
        ans = -1
        break
    ans *= num
    if ans > 10**18:
        ans = -1
        break

for num in s:
    if num ==0:
        ans =0
        
print(ans)

### FIXED CODE ###

s = input().split()
print(int(s[0])*int(s[1]))
N,A=map(int,input().split())
a=list(map(int,input().split())
cnt=0
for i in range(1,N):
    tmp=max(0,(a[i-1]+a[i])-A)
    cnt+=tmp
    a[i]-=tmp
    
print(cnt)

### FIXED CODE ###

N,A=map(int,input().split())
a=list(map(int,input().split()))
cnt=0
for i in range(1,N):
    tmp=max(0,(a[i-1]+a[i])-A)
    if i==1:
        if a[1]<tmp:
            a[0]-=tmp-a[1]
            a[1]=0
            cnt+=tmp
            continue
    
    cnt+=tmp
    a[i]-=tmp
    
print(cnt)
import math
from itertools import accumulate
def is_prime(n):
  if n==2:
    return True
  for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
      return False
  return True
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=map(int,input().split(""))
min_l=min(l)
max_r=max(r)
a=[]
for i in range(min_l,max_l+1):
  if i%2==0:
    a.append(0)
  else:
    if is_prime(n) and is_prime((i+1)/2):
      a.append(1)
check=[0]+check
check=list(accumulate(check))
for i in range(q):
  print(check(r[i+1])-check(l[i]))
  
    
  

### FIXED CODE ###

import math
from itertools import accumulate
def is_prime(n):
  if n==1:
    return False
  for i in range(2,int(math.sqrt(n)+1)):
    if n%i==0:
      return False
  return True
q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
  l[i],r[i]=list(map(int,input().split()))
min_l=min(l)
max_r=max(r)
a=[]
for i in range(min_l,max_r+1):
  if i%2==0:
    a.append(0)
  else:
    if is_prime(i) and is_prime((i+1)/2):
      a.append(1)
    else:
      a.append(0)
check=[0]+a
check=list(accumulate(check))
for i in range(q):
  print(check[r[i]-min_l+1]-check[l[i]-min_l])
import numpy as np

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

A = np.zeros((N,N),dtype = int)

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

B = np.array(C)

def calc_double(n):
    return n * 2

X = np.linalg.solve(A,B)
Y = map(calc_double,X.tolist())
Z = map(str,map(int,Y))

print(' '.join(Z))




### FIXED CODE ###

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

X = []
temp = 0

for i in range(1,N,2):
    temp += C[i]
X.append( sum(C) - 2 * temp)

for j in range(N-1):
    X.append( 2 * C[j] - X[-1] )

Y = map(str,X)

print(' '.join(Y))
import numpy as np

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

sosu = []
count = 0

def loop(target, A):
  global count
  B = []
  flg = True
  for i in range(len(A)):
    if A[i] % target != 0:
      B.append(A[i])
    if target == A[i]:
      flg = False
  if flg:
    count+=1
  if len(B) == 1:
    count+=1
    return
  if len(B) == 0:
    return
  target = B.pop(0)
  loop(target, B)

target = A.pop(0)
loop(target, A)
print(count)

### FIXED CODE ###

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

m_a = max(A)+1
B = [0]*(m_a)

for i in A:
  B[i]+=1
  if B[i] == 1:
    for j in range(i*2, m_a, i):
      B[j]+=100
print(B.count(1))
x = input()
y = input()
if x[::-1] = y:
	print('YES')
else:
	print('NO')

### FIXED CODE ###

x = input()
y = input()
if x[::-1] == y:
	print('YES')
else:
	print('NO')
L, R = map(int, input().split())
if R-L >= 2020:
  print(0)
else:
  m = 2020
  for i in range(L, R):
    for j in range(i+1,R+1):
      m = min(m, (i*j)%2019)
print(m)

### FIXED CODE ###

L, R = map(int, input().split())
if R-L >= 2020:
  print(0)
else:
  m = 2020
  for i in range(L, R):
    for j in range(i+1,R+1):
      m = min(m, (i*j)%2019)
  print(m)
N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]
s_dict = {}
sum = 0
for i in range(N):
    if s[i] in s_dict.keys():
        sum +=s_dict(s[i])
        s_dict(s[i]) += 1
    else:
        s_dict(s[i]) = 1
print(sum)

### FIXED CODE ###

N = int(input())
s = [''.join(sorted(input())) for _ in range(N)]

s_dict ={}
ans = 0
for i in range(N) :
    if s[i] in s_dict.keys() :
        ans += s_dict[s[i]]
        s_dict[s[i]] += 1
    else :
        s_dict[s[i]] = 1
print(ans)
D, T, S = map(int, input())
if D <= T * S:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

D, T, S = map(int, input().split())
if D <= T * S:
  print('Yes')
else:
  print('No')
#!/usr/bin/env python

from sys import stdin

N,C,K=map(int,raw_input(),split(" "))
T=map(int,stdin.read().split())

T.sort()
t_star=t[0]
b_star=0
cnt=0
for b,t in enumerate(T):
    if t-t_star>K or b-b_star+1==C:
        cnt+=1
        t_star=t
        b_star=b

print cnt

### FIXED CODE ###

#!/usr/bin/env python

from sys import stdin

N,C,K=map(int,raw_input().split())
T=map(int,stdin.read().split())

T.sort()
t_star=T[0]
b_star=0
cnt=0
for b,t in enumerate(T):
    if t-t_star>K or b-b_star+1>C:
        cnt+=1
        t_star=t
        b_star=b

print cnt+1
# 解法 累積和とdfsを使うと探索が減ってなんかうまくいく．
N,Q = map(int,input().split())
E=[[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    E[a-1].append(b)
    E[b-1].append(a)
dic = {}
for _ in range(Q):
    p,x = map(int,input().split())
    if not p-1 in dic:
        dic[p-1] = x
        continue
    dic[p-1] += x

res = [0 for _ in range(N)]
def dfs(p,s,ans):
    global res
    # 終わり条件　最後まで行ったら，つまりE[k] = []になったら.
    # 再帰 累積和を計算して，自分がつながっているノードに接続している
    if s-1 in dic:
        ans += dic[s-1]

    res[s-1] = ans
    if E[s-1] == [p]:
        return
    for e in E[s-1]:
        if e == p:
            continue
        dfs(s,e,ans)
dfs(1,1,0)
print(res)





### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
# 解法 累積和とdfsを使うと探索が減ってなんかうまくいく．
N,Q = map(int,input().split())
E=[[] for _ in range(N)]
for _ in range(N-1):
    a,b = map(int,input().split())
    E[a-1].append(b)
    E[b-1].append(a)
dic = {}
for _ in range(Q):
    p,x = map(int,input().split())
    if not p-1 in dic:
        dic[p-1] = x
        continue
    dic[p-1] += x

res = [0 for _ in range(N)]
def dfs(p,s,ans):
    global res
    # 終わり条件　最後まで行ったら，つまりE[k] = []になったら.
    # 再帰 累積和を計算して，自分がつながっているノードに接続している
    if s-1 in dic:
        ans += dic[s-1]

    res[s-1] = str(ans)
    if E[s-1] == [p]:
        return
    for e in E[s-1]:
        if e == p:
            continue
        dfs(s,e,ans)
dfs(1,1,0)
print(' '.join(res))
import sys
from itertools import permutations
N, C = map(int, input().split())
D = [list(map(int, sys.stdin.readline().split())) for _ in range(C)]
CM = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

CG = [[0]*C for _ in range(3)]
for i in range(N):
    for j in range(N):
        nc = CM[i][j] - 1
        for c in range(C):
            CG[(i+j)%3][c] += D[nc][c]
ans = 10**10
for c1, c2, c3 in permutations(range(C), 3):
    ans = min(ans, CG[c1][0] + CG[c2][1] + CG[c3][2])
print(ans)    


### FIXED CODE ###

n,c = [int(i) for i in input().split()]
d = [[int(i) for i in input().split()]for i in range(c)]
#d[A][B] はAからBになるときの違和感
color = [[int(i) for i in input().split()]for i in range(n)]

devcol = [[0 for i in range(3)] for j in range(c)]
for l in range(n):
        for row in range(n):
            devcol[color[l][row]-1][(l+row)%3] += 1
Dsum = [[0 for i in range(3)] for j in range(c)]
for i in range(c):
    for j in range(c):
        for k in range(3):
            Dsum[i][k] += d[j][i]*devcol[j][k] 
D = Dsum[0][0]+Dsum[1][1]+Dsum[2][2]
for c0 in range (c):
    for c1 in range (c):
        if c1 == c0:
            continue
        for c2 in range (c):
            if c2 == c1 or c2 == c0:
                continue
            D = min(D,Dsum[c0][0]+Dsum[c1][1]+Dsum[c2][2])
#O(c^3)のつもり
print(D)