Language: C++

#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back

#define ll __int64
//#define ll long long
#define P pair<ll,ll>

int n,m,r;
ll x[110000],y[110000];
P t[110000],t2[110000];
vector<P>G[110000];//to,cost
bool used[110000];
ll dist[110000];
priority_queue<P,vector<P>,greater<P> >bfs;
int main(){
cin>>n;
rep(i,n){

cin>>x[i]>>y[i];
x[i]--;
y[i]--;
}
rep(i,n){
t[i]=mp(x[i],i);
t2[i]=mp(y[i],i);
}
sort(t,t+n);
sort(t2,t2+n);

ll ans=0;

for(int i=1;i<n;i++){
	ll a=t[i].second,b=t[i-1].second,c=abs(t[i].first-t[i-1].first);
	G[a].push_back(mp(b,c));
	G[b].push_back(mp(a,c));
	//cout<<a<<" "<<b<<" "<<c<<endl;
	a=t2[i].second,b=t2[i-1].second,c=abs(t2[i].first-t2[i-1].first);
	G[a].push_back(mp(b,c));
	G[b].push_back(mp(a,c));
}
/*
rep(i,n){
	if(G[i].size()>0){
		cout<<i<<":";
		rep(j,G[i].size())cout<<G[i][j].first<<" ";
		cout<<endl;
	}
}*/

bfs.push(mp(0,0));//cost,number

while(!bfs.empty()){
	ll next=bfs.top().second,cost=bfs.top().first;
	bfs.pop();
	if(used[next])continue;
	used[next]=1;
	ans+=cost;
	//cout<<next<<" "<<cost<<endl;

	rep(i,G[next].size()){
		bfs.push(mp(G[next][i].second,G[next][i].first));
	}
}

cout<<ans<<endl;
 
 
	return 0;
}

Compiler output:
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:21:1: note: in expansion of macro 'll'
   21 | ll x[110000],y[110000];
      | ^~
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:16: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                ^~
a.cc:22:1: note: in expansion of macro 'P'
   22 | P t[110000],t2[110000];
      | ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:19: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                   ^~
a.cc:22:1: note: in expansion of macro 'P'
   22 | P t[110000],t2[110000];
      | ^
a.cc:18:21: error: template argument 1 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:22:1: note: in expansion of macro 'P'
   22 | P t[110000],t2[110000];
      | ^
a.cc:18:21: error: template argument 2 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:22:1: note: in expansion of macro 'P'
   22 | P t[110000],t2[110000];
      | ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:16: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                ^~
a.cc:23:8: note: in expansion of macro 'P'
   23 | vector<P>G[110000];//to,cost
      |        ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:19: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                   ^~
a.cc:23:8: note: in expansion of macro 'P'
   23 | vector<P>G[110000];//to,cost
      |        ^
a.cc:18:21: error: template argument 1 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:23:8: note: in expansion of macro 'P'
   23 | vector<P>G[110000];//to,cost
      |        ^
a.cc:18:21: error: template argument 2 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:23:8: note: in expansion of macro 'P'
   23 | vector<P>G[110000];//to,cost
      |        ^
a.cc:23:9: error: template argument 1 is invalid
   23 | vector<P>G[110000];//to,cost
      |         ^
a.cc:23:9: error: template argument 2 is invalid
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:25:1: note: in expansion of macro 'll'
   25 | ll dist[110000];
      | ^~
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:16: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                ^~
a.cc:26:16: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:19: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                   ^~
a.cc:26:16: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                ^
a.cc:18:21: error: template argument 1 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:26:16: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                ^
a.cc:18:21: error: template argument 2 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:26:16: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:16: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                ^~
a.cc:26:25: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                         ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:19: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                   ^~
a.cc:26:25: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                         ^
a.cc:18:21: error: template argument 1 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:26:25: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                         ^
a.cc:18:21: error: template argument 2 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:26:25: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                         ^
a.cc:26:26: error: template argument 1 is invalid
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                          ^
a.cc:26:26: error: template argument 2 is invalid
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:16: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                ^~
a.cc:26:36: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                                    ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:18:19: note: in expansion of macro 'll'
   18 | #define P pair<ll,ll>
      |                   ^~
a.cc:26:36: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                                    ^
a.cc:18:21: error: template argument 1 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:26:36: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                                    ^
a.cc:18:21: error: template argument 2 is invalid
   18 | #define P pair<ll,ll>
      |                     ^
a.cc:26:36: note: in expansion of macro 'P'
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                                    ^
a.cc:26:37: error: template argument 1 is invalid
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                                     ^
a.cc:26:39: error: template argument 1 is invalid
   26 | priority_queue<P,vector<P>,greater<P> >bfs;
      |                                       ^
a.cc:26:39: error: template argument 2 is invalid
a.cc:26:39: error: template argument 3 is invalid
a.cc: In function 'int main()':
a.cc:31:6: error: 'x' was not declared in this scope
   31 | cin>>x[i]>>y[i];
      |      ^
a.cc:31:12: error: 'y' was not declared in this scope
   31 | cin>>x[i]>>y[i];
      |            ^
a.cc:36:9: error: 'x' was not declared in this scope
   36 | t[i]=mp(x[i],i);
      |         ^
a.cc:37:10: error: 'y' was not declared in this scope
   37 | t2[i]=mp(y[i],i);
      |          ^
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:42:1: note: in expansion of macro 'll'
   42 | ll ans=0;
      | ^~
a.cc:45:12: error: expected ';' before 'a'
   45 |         ll a=t[i].second,b=t[i-1].second,c=abs(t[i].first-t[i-1].first);
      |            ^
a.cc:46:11: error: 'a' was not declared in this scope
   46 |         G[a].push_back(mp(b,c));
      |           ^
a.cc:46:27: error: 'b' was not declared in this scope
   46 |         G[a].push_back(mp(b,c));
      |                           ^
a.cc:46:29: error: 'c' was not declared in this scope
   46 |         G[a].push_back(mp(b,c));
      |                             ^
a.cc:49:17: error: request for member 'second' in 't2[i]', which is of non-class type 'int'
   49 |         a=t2[i].second,b=t2[i-1].second,c=abs(t2[i].first-t2[i-1].first);
      |                 ^~~~~~
a.cc:49:34: error: request for member 'second' in 't2[(i - 1)]', which is of non-class type 'int'
   49 |         a=t2[i].second,b=t2[i-1].second,c=abs(t2[i].first-t2[i-1].first);
      |                                  ^~~~~~
a.cc:49:53: error: request for member 'first' in 't2[i]', which is of non-class type 'int'
   49 |         a=t2[i].second,b=t2[i-1].second,c=abs(t2[i].first-t2[i-1].first);
      |                                                     ^~~~~
a.cc:49:67: error: request for member 'first' in 't2[(i - 1)]', which is of non-class type 'int'
   49 |         a=t2[i].second,b=t2[i-1].second,c=abs(t2[i].first-t2[i-1].first);
      |                                                                   ^~~~~
a.cc:62:5: error: request for member 'push' in 'bfs', which is of non-class type 'int'
   62 | bfs.push(mp(0,0));//cost,number
      |     ^~~~
a.cc:64:12: error: request for member 'empty' in 'bfs', which is of non-class type 'int'
   64 | while(!bfs.empty()){
      |            ^~~~~
a.cc:65:12: error: expected ';' before 'next'
   65 |         ll next=bfs.top().second,cost=bfs.top().first;
      |            ^~~~
a.cc:66:13: error: request for member 'pop' in 'bfs', which is of non-class type 'int'
   66 |         bfs.pop();
      |             ^~~
a.cc:67:16: error: invalid types 'bool [110000][<unresolved overloaded function type>]' for array subscript
   67 |         if(used[next])continue;
      |                ^
a.cc:68:13: error: invalid types 'bool [110000][<unresolved overloaded function type>]' for array subscript
   68 |         used[next]=1;
      |             ^
a.cc:69:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   69 |         ans+=cost;
      |         ^~~
      |         abs
a.cc:69:14: error: 'cost' was not declared in this scope; did you mean 'const'?
   69 |         ans+=cost;
      |