Language: C++

#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i = j; i <= k; i ++)
#define FORD(i,j,k) for(int i = j; i >= k; i --)
#define mp make_pair
#define maxn 100005
//#define f first
//#define s second
#define int long long
#define AMAZINGCODE""
using namespace std;
int n, dp[maxn], a[maxn], k;
const int oo = 5e9+7;
main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen(AMAZINGCODE".inp","r",stdin);
    //freopen(AMAZINGCODE".out","w",stdout);
    cin >> n >> k;
    FOR(i,1,n)
    {
        cin >> a[i];
    }
    dp[1] = 0;
    FOR(i,2,n)
    {
        dp[i] = oo;
        FORD(j,i-1,max(i-k,0))
        {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    cout << dp[n];
}


Compiler output:
a.cc:9:9: warning: ISO C++11 requires whitespace after the macro name
    9 | #define AMAZINGCODE""
      |         ^~~~~~~~~~~
a.cc:13:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   13 | main()
      | ^~~~
a.cc: In function 'int main()':
a.cc:29:23: error: no matching function for call to 'max(long long int, int)'
   29 |         FORD(j,i-1,max(i-k,0))
      |                    ~~~^~~~~~~
a.cc:3:41: note: in definition of macro 'FORD'
    3 | #define FORD(i,j,k) for(int i = j; i >= k; i --)
      |                                         ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:29:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   29 |         FORD(j,i-1,max(i-k,0))
      |                    ~~~^~~~~~~
a.cc:3:41: note: in definition of macro 'FORD'
    3 | #define FORD(i,j,k) for(int i = j; i >= k; i --)
      |                                         ^
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:29:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   29 |         FORD(j,i-1,max(i-k,0))
      |                    ~~~^~~~~~~
a.cc:3:41: note: in definition of macro 'FORD'
    3 | #define FORD(i,j,k) for(int i = j; i >= k; i --)
      |                                         ^