Language: C++

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
#define MAXN 100020
#define MAXM 1000010
#define INF 2147483647
typedef long long ll;
int S,T,T1,T2,T3;
int en,u[MAXM],v[MAXM],first[MAXN],next[MAXM],cap[MAXM],cost[MAXM];//Next Array
bool inq[MAXN];
ll d[MAXN]/*spfa*/;
int p[MAXN]/*spfa*/,a[MAXN]/*????*/;
queue<int>q;
void Init_MCMF(){memset(first,-1,sizeof(first));en=0;}
void AddEdge(const int &U,const int &V,const int &W,const int &C)
{
    u[en]=U; v[en]=V; cap[en]=W; cost[en]=C;
    next[en]=first[U]; first[U]=en++;
    u[en]=V; v[en]=U; cap[en]=0; cost[en]=-C;
    next[en]=first[V]; first[V]=en++;
}
bool Spfa(int &Flow,ll &Cost)
{
    memset(d,0x7f,sizeof(d));
    memset(inq,0,sizeof(inq));
    d[S]=0; inq[S]=1; p[S]=0; a[S]=INF; q.push(S);
    while(!q.empty())
      {
          int U=q.front(); q.pop(); inq[U]=0;
          for(int i=first[U];i!=-1;i=next[i])
            if(cap[i] && d[v[i]]>d[U]+cost[i])
              {
                d[v[i]]=d[U]+cost[i];
                p[v[i]]=i;
                a[v[i]]=min(a[U],cap[i]);
                if(!inq[v[i]]) {q.push(v[i]); inq[v[i]]=1;}
              }
      }
    if(d[T]>2000000000ll) return 0;
    Flow+=a[T]; Cost+=d[T]*a[T]; int U=T;
    while(U!=S)
      {
          cap[p[U]]-=a[T]; cap[p[U]^1]+=a[T];
          U=u[p[U]];
      }
    return 1;
}
ll Mincost()
{
    int Flow=0;
	ll Cost=0;
    while(Spfa(Flow,Cost));
    return Cost;
}
int X,Y,Z;
int main(){
	Init_MCMF();
	scanf("%d%d%d",&X,&Y,&Z);
	int x,y,z;
	T1=X+Y+Z+1;
	T2=T1+1;
	T3=T2+1;
	S=T3+1;
	T=S+1;
	for(int i=1;i<=X+Y+Z;++i){
		scanf("%d%d%d",&x,&y,&z);
		AddEdge(S,i,1,0);
		AddEdge(i,T1,1,-x);
		AddEdge(i,T2,1,-y);
		AddEdge(i,T3,1,-z);
	}
	AddEdge(T1,T,X,0);
	AddEdge(T2,T,Y,0);
	AddEdge(T3,T,Z,0);
	cout<<(-Mincost())<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'void AddEdge(const int&, const int&, const int&, const int&)':
a.cc:21:5: error: reference to 'next' is ambiguous
   21 |     next[en]=first[U]; first[U]=en++;
      |     ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:12:36: note:                 'int next [1000010]'
   12 | int en,u[MAXM],v[MAXM],first[MAXN],next[MAXM],cap[MAXM],cost[MAXM];//Next Array
      |                                    ^~~~
a.cc:23:5: error: reference to 'next' is ambiguous
   23 |     next[en]=first[V]; first[V]=en++;
      |     ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:12:36: note:                 'int next [1000010]'
   12 | int en,u[MAXM],v[MAXM],first[MAXN],next[MAXM],cap[MAXM],cost[MAXM];//Next Array
      |                                    ^~~~
a.cc: In function 'bool Spfa(int&, ll&)':
a.cc:33:38: error: reference to 'next' is ambiguous
   33 |           for(int i=first[U];i!=-1;i=next[i])
      |                                      ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:12:36: note:                 'int next [1000010]'
   12 | int en,u[MAXM],v[MAXM],first[MAXN],next[MAXM],cap[MAXM],cost[MAXM];//Next Array
      |                                    ^~~~