class Solution(object):
def kIncreasing(self, arr, k):
"""
:type arr: List[int]
:type k: int
:rtype: int
"""
n = len(arr)
ans = 0
for i in range(k):
dp = []
j, cur_len = i, 0
while j < n:
cur_len += 1
ind = bisect.bisect_right(dp, arr[j])
if ind == len(dp):
dp.append(arr[j])
else:
dp[ind] = arr[j]
j += k
ans += cur_len - len(dp)
return ans