Language: C++

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, -1, sizeof(mat))
typedef long long ll;
int a[100005];
int t[100005];
int N, L; 
int dfs(int x) {
  if(t[x] != -1) return t[x];
  if(x == 0) {
    if(a[x] > a[x+1]) {
      return t[x] = L - a[x];
    } else {
      return t[x] = L - a[x] + dfs(x+1);
    }
  } else if(x == N - 1) {
    if(a[x] > a[x-1]) {
      return t[x] = L - a[x];
    } else {
      return t[x] = L - a[x] + dfs(x-1);
    }
  } else {
    if(a[x] > a[x-1] && a[x] > a[x+1]) {
      return t[x] = L - a[x];
    } else if(a[x] > a[x-1]){
      return t[x] = L - a[x] + dfs(x+1);
    } else if(a[x] > a[x+1]) {
      return t[x] = L - a[x] + dfs(x-1);
    } else {
      return t[x] = L - a[x] + dfs(a[x-1] < a[x+1] ? x - 1 : x + 1);
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> L;
  CLR(t);
  FOR(i,0,N) cin >> a[i];
  FOR(i,0,N) {
    if(t[i] == -1) {
      t[i] = dfs(i);
    }
    cout << t[i] << endl;
  }
  ll ans = 0;
  FOR(i,0,N) ans = max(ans, t[i]);
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:64:23: error: no matching function for call to 'max(ll&, int&)'
   64 |   FOR(i,0,N) ans = max(ans, t[i]);
      |                    ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 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:64:23: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   64 |   FOR(i,0,N) ans = max(ans, t[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:64:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   64 |   FOR(i,0,N) ans = max(ans, t[i]);
      |                    ~~~^~~~~~~~~~~