Language: C++

#pragma G++ optimize(2)
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define LL long long
#define O4 __inline__ __attribute__((always_inline))
#define inf 0x7fffffff
#define UL unsigned LL
#define LD long double
#ifdef ONLINE_JUDGE
#define getchar nc
#endif
#define int LL
namespace FastIO{
	O4 char nc(){
		static char buf[100000],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	}
	O4 int read(){
		char t;int u=0,k=1;t=getchar();
		while(t<'0'||t>'9'){if(t=='-')k=-1;t=getchar();}
		while(t>='0'&&t<='9'){u=u*10+t-'0';t=getchar();}
		return u*k;
	}
	template <typename T>
	O4 void read(T &u){
		char t;T k=1;u=0;t=getchar();
		while(t<'0'||t>'9'){if(t=='-')k=-1;t=getchar();}
		while(t>='0'&&t<='9'){u=u*10+t-'0';t=getchar();}
		if(t=='.'){
			T mass=0.1;t=getchar();
			while(t>='0'&&t<='9'){u+=mass*(t-'0');mass/=10;t=getchar();}
		}u*=k;
	}
	O4 int read(char asd[]){
		char t=getchar();int u=0;
		while(t==' '||t=='\n'||t=='\r')t=getchar();
		if(t==EOF)return -1;
		while(t!=' '&&t!='\n'&&t!=EOF&&t!='\r')asd[u++]=t,t=getchar();
		asd[u]='\0';return u;
	}
	char sr[1<<23],z[23];int C=-1,Z;
	O4 void wer(int x,char T){
		int y=0;if(x<0)y=1,x=-x;
		while(z[++Z]=x%10+'0',x/=10);if(y)z[++Z]='-';
		while(sr[++C]=z[Z],--Z);sr[++C]=T;
	}
	O4 void wer(char T[],char QWQ){
		for(int i=0;T[i]!='\0';i++)sr[++C]=T[i];
		sr[++C]=QWQ;
	}
	O4 void wer(char T){sr[++C]=T;}
	O4 void out(){fwrite(sr,1,C+1,stdout);C=-1;}
}
using namespace std;
using namespace FastIO;
const int N=1e5+5;
int n,m;
int val[N],sum[N],A[N],B[N],fa[N],id[N],F[N];
bool vis[N];
vector <int> Map[N];
int get_fa(int x){return fa[x]==x?x:fa[x]=get_fa(fa[x]);}
signed main(){
	n=read();m=read();
	for(int i=1;i<=n;i++){
		A[i]=read();B[i]=read();
		A[i]=max(A[i]-B[i],0);
		fa[i]=id[i]=i;
	}
	while(m--){
		int a=read(),b=read();
		Map[a].push_back(b);
		Map[b].push_back(a);
	}
	sort(id+1,id+1+n,[](int a,int b){return A[a]<A[b];});
	for(int i=1;i<=n;i++){
		int x=id[i];sum[x]=B[x];
		vector <int> load;vis[x]=1;
		for(int to:Map[x]){
			if(!vis[to])continue;
			int a=get_fa(x),b=get_fa(to);
			if(a==b)continue;
			load.push_back(b);
			sum[x]+=sum[b];fa[b]=a;
		}
		F[x]=sum[x]+A[x];
		for(int to:load)F[x]=min(F[x],sum[x]-sum[to]+max(F[to],A[x]));
	}
	cout<<F[id[n]];
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:25: error: no matching function for call to 'max(long long int, int)'
   66 |                 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:3:
/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:66:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   66 |                 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:66:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   66 |                 A[i]=max(A[i]-B[i],0);
      |                      ~~~^~~~~~~~~~~~~