Language: C++

// https://atcoder.jp/contests/agc008/tasks/agc008_b
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define MOD (1000000007)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define LEN(x) (sizeof(x) / sizeof(*(x)))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> v(n);
    ll sum = 0, pos = 0, now = 0, minv = 0, ncnt = 0;
    bool nflag = false;
    REP(i, n) {
        cin >> v[i];
        if (v[i] > 0)
            sum += v[i];
        if (v[i] <= 0) {
            ncnt++;
            if (ncnt >= k) {
                nflag = true;
            }
        } else {
            ncnt = 0;
        }
    }
    // マイナスがK個以上連続したら、プラスのみ加算
    if (nflag) {
        cout << sum << endl;
        return 0;
    }
    sum = 0;
    REP(i, k) now += v[i];
    minv = now;
    for (int i = k; i < n; i++) {
        now += v[i] - v[i - k];
        if (minv < now) {
            minv = now;
            pos = i - k + 1;
        }
    }
    for (int i = 0; i < pos; i++) {
        if (v[i] > 0)
            sum += v[i];
    }
    for (int i = pos + k; i < n; i++) {
        if (v[i] > 0)
            sum += v[i];
    }

    // 求めた最大値がマイナスなら、白にして加算しない
    cout << sum + max(0, minv) << endl;

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:68:22: error: no matching function for call to 'max(int, ll&)'
   68 |     cout << sum + max(0, minv) << endl;
      |                   ~~~^~~~~~~~~
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:2:
/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:68:22: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   68 |     cout << sum + max(0, minv) << endl;
      |                   ~~~^~~~~~~~~
/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:68:22: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   68 |     cout << sum + max(0, minv) << endl;
      |                   ~~~^~~~~~~~~