Language: C++

#include <iostream>
#include <set>
#include <vector>
#decine mp make_pair
#decine NM 305
#decine INF 1e9

using namespace std;

long long n;
vector < pair<long long ,long long> > V[NM];
set < pair<long long, long long> > St;
long long M[NM][NM];

bool RF()
{
    long long i, j, k;
    for (k=1; k<=n; k++)
        for (i=1; i<=n; i++)
            for (j=1; j<=n; j++)
            {
                if (i==j || j==k || k==i) continue;
                if (M[i][j]>M[i][k]+M[j][k])
                    return 0;
            }
    return 1;
}

bool DJ(long long x)
{
    long long d[n+1], i, dist, nod, to, dt;
    for (i=1; i<=n; i++)
        d[i]=INF;
    St.insert(mp(0, x));
    d[1]=0;
    while (!St.empty())
    {
        dist=St.begin()->first;
        nod=St.begin()->second;
        St.erase(St.begin());
        for (i=1; i<=n; i++)
        {
            to=i;
            if (to==nod) continue;
            dt=M[nod][to];
            if (d[to]>dist+dt)
            {
                d[to]=dist+dt;
                St.insert(mp(M[nod][to], to));
            }
        }
    }
    for (i=1; i<=n; i++)
        if (M[x][i]!=d[i])
            return 0;
    return 1;
}

long long sum;

long long main()
{
    long long i, j;
    cin>>n;
    for (i=1; i<=n; i++)
    {
        for (j=1; j<=n; j++)
        {
            cin>>M[i][j];
            if (i!=j)
                V[i].push_back(mp(M[i][j], j));
        }
    }
    if (!RF())
    {
        cout<<-1;
        return 0;
    }
    for (i=1; i<=n; i++)
    {
        for (j=i+1; j<=n; j++)
        {
            long long aux=M[i][j];
            M[i][j]=INF;
            M[j][i]=INF;
            if (DJ(i))
            {
                M[i][j]=aux;
                M[j][i]=aux;
                sum+=M[i][j];
            }
        }
    }
    cout<<sum;
    return 0;
}


Compiler output:
a.cc:4:2: error: invalid preprocessing directive #decine; did you mean #define?
    4 | #decine mp make_pair
      |  ^~~~~~
      |  define
a.cc:5:2: error: invalid preprocessing directive #decine; did you mean #define?
    5 | #decine NM 305
      |  ^~~~~~
      |  define
a.cc:6:2: error: invalid preprocessing directive #decine; did you mean #define?
    6 | #decine INF 1e9
      |  ^~~~~~
      |  define
a.cc:11:41: error: 'NM' was not declared in this scope
   11 | vector < pair<long long ,long long> > V[NM];
      |                                         ^~
a.cc:13:13: error: 'NM' was not declared in this scope
   13 | long long M[NM][NM];
      |             ^~
a.cc:13:17: error: 'NM' was not declared in this scope
   13 | long long M[NM][NM];
      |                 ^~
a.cc: In function 'bool RF()':
a.cc:23:21: error: 'M' was not declared in this scope
   23 |                 if (M[i][j]>M[i][k]+M[j][k])
      |                     ^
a.cc: In function 'bool DJ(long long int)':
a.cc:33:14: error: 'INF' was not declared in this scope
   33 |         d[i]=INF;
      |              ^~~
a.cc:34:15: error: 'mp' was not declared in this scope
   34 |     St.insert(mp(0, x));
      |               ^~
a.cc:45:16: error: 'M' was not declared in this scope
   45 |             dt=M[nod][to];
      |                ^
a.cc:54:13: error: 'M' was not declared in this scope
   54 |         if (M[x][i]!=d[i])
      |             ^
At global scope:
cc1plus: error: '::main' must return 'int'
a.cc: In function 'int main()':
a.cc:69:18: error: 'M' was not declared in this scope
   69 |             cin>>M[i][j];
      |                  ^
a.cc:71:17: error: 'V' was not declared in this scope
   71 |                 V[i].push_back(mp(M[i][j], j));
      |                 ^
a.cc:71:32: error: 'mp' was not declared in this scope
   71 |                 V[i].push_back(mp(M[i][j], j));
      |                                ^~
a.cc:83:27: error: 'M' was not declared in this scope
   83 |             long long aux=M[i][j];
      |                           ^
a.cc:84:21: error: 'INF' was not declared in this scope
   84 |             M[i][j]=INF;
      |                     ^~~