Language: C++

import sys
#import unittest
#import collections


def frog_k(h, n, k):
	"""
	Errichto's code
	""" 
	dp = [float("inf")] * n 
	dp[0] = 0
	for i in xrange(0, n):
		for j in xrange(i+1, i+k+1):
			if j < n:
				dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
	return (dp[n-1])


def frog_k_1(h, n, k): 
	"""
	#This is top down approach
	"""
	dp = [float("inf")] * n 
	dp[0] = 0
	dp[1] = abs(h[0] - h[1])
	
	for i in xrange(2, n):
		for j in xrange(1, k+1):
			if i-j >= 0:
				dp[i] = min(dp[i], dp[i-j] + abs(h[i-j] - h[i]))
	return (dp[n-1])

def read_input():
	#Read the input N
	a = sys.stdin.readline().split()
	n = int(a[0])
	k = int(a[1])
	#Read the height line
	a = sys.stdin.readline().split()
	 
	#Convert into int List
	h = []
	for i in range(0, n):
		h.append(int(a[i]))

	result = frog_k(h, n, k)
	print result
	
class TestFrogJump(unittest.TestCase):
	def test_1(self):
		res = frog_k([10,30,40,50,20], 5, 3)
		self.assertEqual(res, 30)
		
	def test_2(self):
		res = frog_k([10, 20, 10], 3, 1)
		self.assertEqual(res, 20)
	
	def test_3(self):
		res = frog_k([10, 10], 2, 100)
		self.assertEqual(res, 0)
	
	def test_4(self):
		res = frog_k([40,10,20,70,80,10,20,70,80,60], 10, 4)
		self.assertEqual(res, 40)
	
if __name__ == '__main__':
	 read_input()
	 #unittest.main()


Compiler output:
a.cc:2:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    2 | #import unittest
      |  ^~~~~~
a.cc:2:9: error: #import expects "FILENAME" or <FILENAME>
    2 | #import unittest
      |         ^~~~~~~~
a.cc:3:2: warning: #import is a deprecated GCC extension [-Wdeprecated]
    3 | #import collections
      |  ^~~~~~
a.cc:3:9: error: #import expects "FILENAME" or <FILENAME>
    3 | #import collections
      |         ^~~~~~~~~~~
a.cc:7:11: warning: missing terminating " character
    7 |         """
      |           ^
a.cc:7:11: error: missing terminating " character
a.cc:8:17: warning: missing terminating ' character
    8 |         Errichto's code
      |                 ^
a.cc:8:17: error: missing terminating ' character
    8 |         Errichto's code
      |                 ^~~~~~~
a.cc:9:11: warning: missing terminating " character
    9 |         """
      |           ^
a.cc:9:11: error: missing terminating " character
    9 |         """
      |           ^ 
a.cc:20:11: warning: missing terminating " character
   20 |         """
      |           ^
a.cc:20:11: error: missing terminating " character
a.cc:21:10: error: invalid preprocessing directive #This
   21 |         #This is top down approach
      |          ^~~~
a.cc:22:11: warning: missing terminating " character
   22 |         """
      |           ^
a.cc:22:11: error: missing terminating " character
a.cc:34:10: error: invalid preprocessing directive #Read
   34 |         #Read the input N
      |          ^~~~
a.cc:38:10: error: invalid preprocessing directive #Read
   38 |         #Read the height line
      |          ^~~~
a.cc:41:10: error: invalid preprocessing directive #Convert
   41 |         #Convert into int List
      |          ^~~~~~~
a.cc:66:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
   66 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:68:11: error: invalid preprocessing directive #unittest
   68 |          #unittest.main()
      |           ^~~~~~~~
a.cc:1:1: error: 'import' does not name a type
    1 | import sys
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'