Language: C++

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

long long int a[111111];
long long int kuro[111111];
long long int b[111111];
int main(void){
  int N,K,x,i,j,k;
  long long int res,tmp;
  res=tmp=0;
  scanf("%d %d",&N,&K);

  for(i=1;i<=N;i++){
    scanf("%d",&a[i]);
  }
  for(i=1;i<=K;i++){
    kuro[1]+=a[i];
  }
  for(i=2;i<=N-K+1;i++){
    kuro[i]=kuro[i-1]+a[i+K-1]-a[i-1];
  }
  b[1]=max(0,a[1]);
  for(i=2;i<=N;i++){
    b[i]=b[i-1]+max(0,a[i]);
  }

  for(i=1;i<=N-K+1;i++){
    tmp=kuro[i]+b[i-1]+(b[N]-b[i+K-1]);
    res=max(res,tmp);
  }
  for(i=1;i<=N-K+1;i++){
    tmp=b[i-1]+(b[N]-b[i+K-1]);
    res=max(res,tmp);
  }

  printf("%lld\n",res);
  return 0;
}

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