Language: C++

# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e5+10;
const long long Inf=1ll<<60;

int N,K;
long long DP[maxm],H[maxm];

inline long long abs(long long x){
	return x<0?-x:x;
}

int main(){
	register int i,j;
	register long long Now;
	scanf("%d%d",&N,&K);
	for(i=1;i<=N;i++) scanf("%lld",H+i);
	for(i=2;i<=N;i++){
		DP[i]=Inf;
		for(j=1;i-j && j<=K;j++){
			DP[i]=min(DP[i],DP[i-j]+abs(H[i]-H[i-j]));
		}
	}
	printf("%lld",DP[N]);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |         register int i,j;
      |                      ^
a.cc:17:24: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   17 |         register int i,j;
      |                        ^
a.cc:18:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 |         register long long Now;
      |                            ^~~
a.cc:24:52: error: call of overloaded 'abs(long long int)' is ambiguous
   24 |                         DP[i]=min(DP[i],DP[i-j]+abs(H[i]-H[i-j]));
      |                                                 ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
  980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
      |            ^~~
a.cc:12:18: note: candidate: 'long long int abs(long long int)'
   12 | inline long long abs(long long x){
      |                  ^~~
In file included from /usr/include/c++/14/cstdlib:81:
/usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)'
  137 |   abs(__float128 __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)'
   85 |   abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)'
   79 |   abs(long double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)'
   75 |   abs(float __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)'
   71 |   abs(double __x)
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)'
   61 |   abs(long long __x) { return __builtin_llabs (__x); }
      |   ^~~
/usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)'
   56 |   abs(long __i) { return __builtin_labs(__i); }
      |   ^~~