Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define int ll
#define se second

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
VI e[MAXN];
int a[MAXN],b[MAXN],f[MAXN],sum[MAXN],vis[MAXN],id[MAXN],ans[MAXN];
int compare(int x,int y) { return a[id[x]]<a[id[y]]; }
int find(int x) { return f[x]==x?f[x]:f[x]=find(f[x]); }
int main()
{
	int 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);
		id[i]=i;
	}
	sort(id+1,id+n+1,compare);
	for (int i=1,u,v;i<=m;i++) u=read(),v=read(),e[u].PB(v),e[v].PB(u);
	for (int i=1;i<=n;i++) f[i]=i;
	for (int i=1;i<=m;i++)
	{
		VI to; int x=id[i];
		vis[x]=1,sum[x]=b[x];
		for (auto v:e[x])
		{
			if (!vis[v]||find(x)==find(v)) continue;
			to.PB(find(v));
			sum[x]+=sum[find(v)];
			f[find(v)]=x;
		}
		ans[x]=sum[x]+a[x];
		for (auto v:to) ans[x]=min(ans[x],sum[x]-sum[v]+max(a[x],ans[v]));
	}
	printf("%d\n",ans[id[n]]);
	return 0;
}


Compiler output:
a.cc:35:13: error: '::main' must return 'int'
   35 | #define int ll
      |             ^~
a.cc:68:1: note: in expansion of macro 'int'
   68 | int main()
      | ^~~
a.cc: In function 'int main()':
a.cc:74:25: error: no matching function for call to 'max(ll, int)'
   74 |                 a[i]=max(a[i]-b[i],0);
      |                      ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/vector:62,
                 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:74:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   74 |                 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,
                 from a.cc:9:
/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:74:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   74 |                 a[i]=max(a[i]-b[i],0);
      |                      ~~~^~~~~~~~~~~~~