Language: C++

#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 105;
int n, a[N];
struct Dinic {
   int n, s, t;
   struct Edge {
      int to, cap, flow, rev;
      Edge(int to = 0, int cap = 0, int flow = 0, int rev = 0) :
         to(to), cap(cap), flow(flow), rev(rev) {}
   };
   vector<int> d;
   vector<int> ptr;
   vector<vector<Edge>> g;
   Dinic(int n = 0, int s = 0, int t = 0) :
      n(n), s(s), t(t), d(n), ptr(n), g(n) {}
   void addEdge(int u, int v, int cap) {
      g[u].emplace_back(v, cap, 0, g[v].size());
      g[v].emplace_back(u, 0, 0, g[u].size() - 1);
   }
   bool bfs() {
      fill(d.begin(), d.end(), -1);
      fill(ptr.begin(), ptr.end(), 0);
      queue<int> q;
      d[s] = 0;
      q.push(s);
      while (!q.empty()) {
         int u = q.front();
         q.pop();
         for (auto e : g[u]) {
            if (d[e.to] == -1 && e.cap > e.flow) {
               d[e.to] = d[u] + 1;
               q.push(e.to);
            }
         }
      }
      return d[t] != -1;
   }
   int dfs(int u, int flow) {
      if (u == t) {
         return flow;
      }
      for (int &i = ptr[u]; i < g[u].size(); ++i) {
         auto &e = g[u][i];
         if (e.cap <= e.flow || d[e.to] != d[u] + 1) continue;
         int nxt = dfs(e.to, min(flow, e.cap - e.flow));
         if (nxt) {
            e.flow += nxt;
            g[e.to][e.rev].flow -= nxt;
            return nxt;
         }
      }
      return 0;
   }
   	int maxFlow() {
      	int ans = 0;
      	while (bfs()) {
       	  while (true) {
            int now = dfs(s, inf);
            if (now) ans += now;
            else break;
         }
      }
      return ans;
   }
} mf;
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) cin >> a[i];
	fw (i, 0, n) a[i] = -a[i];
	mf = Dinic(n + 2, 0, n + 1);
	//Get rid of gemstones so that the sum of the destroyed gems is maximum.
	fw (i, 0, n) {
		if (a[i] <= 0) mf.addEdge(i + 1, n + 1, -a[i]);
		else mf.addEdge(0, i + 1, a[i]); 
	}
	fw (i, 1, n + 1) {
		fw (j, i, n + 1) if (j % i == 0) mf.addEdge(i, j, inf);
	}
	//Min cut of graph now represents the selected gems.
	int sumA = 0;
	fw (i, 0, n) sumA += a[i];
	int destroyed = 0;
	fw (i, 0, n) if (a[i] >= 0) destroyed += a[i];
	destroyed -= mf.maxFlow();
	sumA -= destroyed;
//	cout << "max flow = " << mf.maxFlow() << "\n";
	cout << max(-sumA, 0);
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:106:20: error: no matching function for call to 'max(long long int, int)'
  106 |         cout << max(-sumA, 0);
      |                 ~~~^~~~~~~~~~
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:106:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
  106 |         cout << max(-sumA, 0);
      |                 ~~~^~~~~~~~~~
/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:106:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  106 |         cout << max(-sumA, 0);
      |                 ~~~^~~~~~~~~~