Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;

using namespace std;
struct A
{
    int l;
    int r;
    int q;
};
A aa[100005];
int d[100005][100005];
int a[100005], b[100005];
int f[100005];
int finds(int x)
{
    return f[x] == x?x:f[x] = finds(f[x]);
}
int cmp(A a, A b)
{
    return a.q < b.q;
}
int main()
{
    int n;
    scanf("%d", &n);
    FOR(i,1,n)
    {
        scanf("%d%d", &a[i], &b[i]);
    }
    int ji = 0;
    FOR(i,1,n)
    {
        FOR(j,i+1,n)
        {
            aa[ji].l = i;
            aa[ji].r = j;
            aa[ji++].q = min(abs(a[i]-a[j]), abs(b[i]-b[j]));
        }
    }
    sort(aa, aa+ji, cmp);
    FOR(i,1,n)
    f[i] = i;
    int ans = 0;
    for(int i = 0; i < ji; i++)
    {
        int x = finds(aa[i].l);
        int y = finds(aa[i].r);
        if(x != y)
        {
            f[x] = y;
            ans += aa[i].q;
        }
    }
    printf("%d\n", ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   42 |     FOR(i,1,n)
      |         ^
a.cc:15:38: note: in definition of macro 'FOR'
   15 | # define FOR(i,a,n) for(register int i=a; i<=n; ++i)
      |                                      ^
a.cc:47:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   47 |     FOR(i,1,n)
      |         ^
a.cc:15:38: note: in definition of macro 'FOR'
   15 | # define FOR(i,a,n) for(register int i=a; i<=n; ++i)
      |                                      ^
a.cc:49:13: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   49 |         FOR(j,i+1,n)
      |             ^
a.cc:15:38: note: in definition of macro 'FOR'
   15 | # define FOR(i,a,n) for(register int i=a; i<=n; ++i)
      |                                      ^
a.cc:57:9: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   57 |     FOR(i,1,n)
      |         ^
a.cc:15:38: note: in definition of macro 'FOR'
   15 | # define FOR(i,a,n) for(register int i=a; i<=n; ++i)
      |                                      ^
/tmp/ccdpg6AQ.o: in function `finds(int)':
a.cc:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdpg6AQ.o
a.cc:(.text+0x37): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdpg6AQ.o
a.cc:(.text+0x56): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdpg6AQ.o
a.cc:(.text+0x6d): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccdpg6AQ.o
/tmp/ccdpg6AQ.o: in function `main':
a.cc:(.text+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdpg6AQ.o
a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccdpg6AQ.o
a.cc:(.text+0x18c): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdpg6AQ.o
a.cc:(.text+0x1a1): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdpg6AQ.o
a.cc:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccdpg6AQ.o
a.cc:(.text+0x1d7): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccdpg6AQ.o
a.cc:(.text+0x291): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status