Language: C++

#include <bits/stdc++.h>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const int inf = 1e9;

vector<ll> a;
ll b, c, N ,Z, W;
string s;
ll sum;
int main() {
    cin>>N;
    REP(i,0,N) {
        cin>>b;
        a.push_back(b);
    }
    REP(i,0,N) sum+=a[i];
    while(1){
        ll tmp=inf;
        ll ttmp;
        int baisu = 0;
        REP(i,1,a.size()+1){
            ttmp=0;
            ll idx=i;
            while(idx<a.size()+1){
                ttmp+=a[idx-1];
                idx+=i;
            }
            if(tmp>ttmp){
                tmp=ttmp;
                baisu=i;
            }
            
        }
        if(tmp>=0) break;
        sum -= tmp;
        vector<int> eidx;
        for(int i=baisu;i<a.size()+1;i+=baisu){
            eidx.push_back(i-1);
        }
        reverse(eidx.begin(),eidx.end());
        for(auto idx:eidx){
            a.erase(a.begin()+idx);
        }
    }
    p(max(sum,0));
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:10: error: no matching function for call to 'max(ll&, int)'
   51 |     p(max(sum,0));
      |       ~~~^~~~~~~
a.cc:2:21: note: in definition of macro 'p'
    2 | #define p(s) cout<<(s)<<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: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:51:10: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   51 |     p(max(sum,0));
      |       ~~~^~~~~~~
a.cc:2:21: note: in definition of macro 'p'
    2 | #define p(s) cout<<(s)<<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:51:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   51 |     p(max(sum,0));
      |       ~~~^~~~~~~
a.cc:2:21: note: in definition of macro 'p'
    2 | #define p(s) cout<<(s)<<endl
      |                     ^