Language: C++

#include<bits/stdc++.h>
using namespace std;
template<unsigned N,unsigned M> struct Maxcost_Maxflow
{
    #define int long long
    int const inf=1e15;
    int target[M],pre[M],last[N],tot=1,flow[M],maxflow,
    cost,deep[N],w[M],ef[M],upd[M],dis[N],pr[N],s,t;
    void add(int x,int y,int z,int co)
    {
        tot++;
        target[tot]=y;
        pre[tot]=last[x];
        last[x]=tot;
        flow[tot]=z;
        w[tot]=co;
        target[++tot]=x;
        pre[tot]=last[y];
        last[y]=tot;
        w[tot]=-co;
    }
    queue<int>q;
    bool inq[N];
    bool spfa()
    {
        q.push(s);
        for(register int i=s;i<=t;i++)
            dis[i]=-inf,ef[i]=inf,pr[i]=0,upd[i]=0;
        dis[s]=0;
        inq[s]=1;
        while(!q.empty())
        {
            int now=q.front();inq[now]=0;q.pop();
            for(register int i=last[now];i;i=pre[i])
            {
                int tar=target[i];
                if(flow[i]&&(dis[now]+w[i]>dis[tar]))
                {
                    dis[tar]=dis[now]+w[i];
                    pr[tar]=now;
                    upd[tar]=i;
                    ef[tar]=min(ef[now],flow[i]);
                    if(!inq[tar])q.push(tar),inq[tar]=1;
                }
            }
        }
        return pr[t];
    }
    void ek()
    {
        while(spfa())
        {
            maxflow+=ef[t];
            cost+=dis[t]*ef[t];
            for(register int i=t;i!=s;i=pr[i])
            {
                flow[upd[i]]-=ef[t];
                flow[upd[i]^1]+=ef[t];
            }
        }
    }
    #undef int
};
Maxcost_Maxflow<4005,400005>g;
int main()
{
    int n,x,y,z;
    scanf("%d",&n);
    g.t=2*n+5;
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        g.add(i,2*n+1,1e9,x+y);
        g.add(i,2*n+2,1e9,x-y);
        g.add(i,2*n+3,1e9,-x+y);
        g.add(i,2*n+4,1e9,-x-y);
        g.add(0,i,z,0);
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d%d",&x,&y,&z);
        g.add(2*n+1,i+n,1e9,-x-y);
        g.add(2*n+2,i+n,1e9,-x+y);
        g.add(2*n+3,i+n,1e9,x-y);
        g.add(2*n+4,i+n,1e9,x+y);
        g.add(i+n,g.t,z,0);
    }
    g.ek();
    printf("%lld\n",g.cost);cout<<clock()-ttt<<endl;
    return 0;
}

Compiler output:
a.cc: In member function 'bool Maxcost_Maxflow<N, M>::spfa()':
a.cc:27:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |         for(register int i=s;i<=t;i++)
      |                          ^
a.cc:34:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   34 |             for(register int i=last[now];i;i=pre[i])
      |                              ^
a.cc: In member function 'void Maxcost_Maxflow<N, M>::ek()':
a.cc:55:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   55 |             for(register int i=t;i!=s;i=pr[i])
      |                              ^
a.cc: In function 'int main()':
a.cc:89:43: error: 'ttt' was not declared in this scope
   89 |     printf("%lld\n",g.cost);cout<<clock()-ttt<<endl;
      |                                           ^~~
a.cc: In instantiation of 'void Maxcost_Maxflow<N, M>::ek() [with unsigned int N = 4005; unsigned int M = 400005]':
a.cc:88:9:   required from here
   88 |     g.ek();
      |     ~~~~^~
a.cc:55:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   55 |             for(register int i=t;i!=s;i=pr[i])
      |                              ^
a.cc: In instantiation of 'bool Maxcost_Maxflow<N, M>::spfa() [with unsigned int N = 4005; unsigned int M = 400005]':
a.cc:51:15:   required from 'void Maxcost_Maxflow<N, M>::ek() [with unsigned int N = 4005; unsigned int M = 400005]'
   51 |         while(spfa())
      |               ^~~~
a.cc:88:9:   required from here
   88 |     g.ek();
      |     ~~~~^~
a.cc:27:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |         for(register int i=s;i<=t;i++)
      |                          ^
a.cc:34:30: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   34 |             for(register int i=last[now];i;i=pre[i])
      |                              ^