Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, K; cin >> N >> K;
    vector<ll> a(N+1);
    for(int i=1; i<=N; i++) cin >> a[i];

    vector<ll> cum(N+1, 0);
    vector<ll> cum2(N+1, 0);
    for(int i=1; i<=N; i++) cum[i] = cum[i-1]+a[i];
    for(int i=1; i<=N; i++) cum2[i] = cum2[i-1]+max(0, a[i]);

    ll ans = -(1LL<<59);
    for(int i=1; i<=N+1-K; i++){
        ll tmp = cum[i+K-1]-cum[i-1];
        ll tmp2 = 0;
        tmp += cum2[i-1] + cum2[N]-cum2[i+K-1];
        tmp2 += cum2[i-1] + cum2[N]-cum2[i+K-1];

        ans = max(ans, max(tmp, tmp2));
    }

    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:52: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
   20 |     for(int i=1; i<=N; i++) cum2[i] = cum2[i-1]+max(0, a[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:20:52: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
   20 |     for(int i=1; i<=N; i++) cum2[i] = cum2[i-1]+max(0, a[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:20:52: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   20 |     for(int i=1; i<=N; i++) cum2[i] = cum2[i-1]+max(0, a[i]);
      |                                                 ~~~^~~~~~~~~