Language: C++

#include<bits/stdc++.h>
#define fir first
#define sec second
#define db double
#define ll long long
#define ev eg[i].v
#define pb push_back
#define INF 1000000007
#define pir pair<int,int>
#define Rep(i,l,r) for(int i=(l);i<=(r);++i)
#define RepD(i,r,l) for(int i=(r);i>=(l);--i)
#define RepG(i,x) for(int i=hd[x];i;i=eg[i].nxt)
using namespace std;

const int N=1e5+5;

ll hd[N],cnt=0;bool vis[N];
struct Eg{ll v,nxt;}eg[N*2];
ll a[N],b[N],c[N],fa[N],f[N],g[N];

ll find(ll x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void add(ll u,ll v){eg[++cnt]=(Eg){v,hd[u]},hd[u]=cnt;}

bool cmp(ll x,ll y){return a[x]<a[y];}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll n,m;
	scanf("%lld%lld",&n,&m);
	Rep(i,1,n) scanf("%lld%lld",&a[i],&b[i]),a[i]=max(a[i]-b[i],0);
	Rep(i,1,m){
		ll u,v;
		scanf("%lld%lld",&u,&v);
		add(u,v),add(v,u);	
	}
	Rep(i,1,n) c[i]=fa[i]=i;
	sort(c+1,c+n+1,cmp);
	Rep(k,1,n){
		ll x=c[k];
		vis[x]=1,f[x]=a[x],g[x]=b[x];
		RepG(i,x)
			if(vis[ev]){
				ll ff=find(ev);
				if(x==ff) continue;
				fa[ff]=x,g[x]+=g[ff];
				f[x]=min(f[x],max(f[ff],a[x]-g[ff]));	
			}
	}
	printf("%lld\n",f[c[n]]+g[c[n]]);
	return 0;
}




Compiler output:
a.cc: In function 'int main()':
a.cc:31:58: error: no matching function for call to 'max(long long int, int)'
   31 |         Rep(i,1,n) scanf("%lld%lld",&a[i],&b[i]),a[i]=max(a[i]-b[i],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:31:58: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   31 |         Rep(i,1,n) scanf("%lld%lld",&a[i],&b[i]),a[i]=max(a[i]-b[i],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:31:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   31 |         Rep(i,1,n) scanf("%lld%lld",&a[i],&b[i]),a[i]=max(a[i]-b[i],0);
      |                                                       ~~~^~~~~~~~~~~~~