Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define INF 100000000000
ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    while(cin >> n >> m){
        ll list[n + 1];
        rep(i, 1, n + 1){
            cin >> list[i];
        }
        ll dp[n + 1];
        dp[1] = 0;
        dp[2] = abs(list[1] - list[2]);
        rep(i, 3, n + 1){
            dp[i] = INF;
            rep(j, 1, min(i, m + 1)){
                dp[i] = min(dp[i], dp[i - j] + abs(list[i - j] - list[i]));
            }
        }
        cout << dp[n] << endl;
    }
}



Compiler output:
a.cc: In function 'int main()':
a.cc:27:26: error: no matching function for call to 'min(int&, ll)'
   27 |             rep(j, 1, min(i, m + 1)){
      |                       ~~~^~~~~~~~~~
a.cc:6:51: note: in definition of macro 'repi'
    6 | #define repi(i, a, b) for(int i = int(a); i < int(b); i++)
      |                                                   ^
a.cc:27:13: note: in expansion of macro 'rep'
   27 |             rep(j, 1, min(i, m + 1)){
      |             ^~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:27:26: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   27 |             rep(j, 1, min(i, m + 1)){
      |                       ~~~^~~~~~~~~~
a.cc:6:51: note: in definition of macro 'repi'
    6 | #define repi(i, a, b) for(int i = int(a); i < int(b); i++)
      |                                                   ^
a.cc:27:13: note: in expansion of macro 'rep'
   27 |             rep(j, 1, min(i, m + 1)){
      |             ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:27:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   27 |             rep(j, 1, min(i, m + 1)){
      |                       ~~~^~~~~~~~~~
a.cc:6:51: note: in definition of macro 'repi'
    6 | #define repi(i, a, b) for(int i = int(a); i < int(b); i++)
      |                                                   ^
a.cc:27:13: note: in expansion of macro 'rep'
   27 |             rep(j, 1, min(i, m + 1)){
      |             ^~~