Language: C++

#include<bits/stdc++.h>
#define N (5000+10)
#define next Next
#define inf (0x3f3f3f3f)
using namespace std;
const int maxn=50000+10;
int to[maxn<<1],next[maxn<<1],head[N<<1],v[maxn<<1],w[maxn<<1];
int ans=0,e=1,dis[N],vis[N];
int a[50][50][2];
inline void add(int x,int y,int z,int zz){
    to[++e]=y;
    next[e]=head[x];
    head[x]=e;
    w[e]=z;
    v[e]=zz;
}
int n,m,s,t,x,y,z,zz;
inline bool spfa(){
    queue<int> q;
    memset(vis,0,sizeof(vis));
    memset(dis,inf,sizeof(dis));
    dis[vis[s]=s]=0;
    q.push(s);
    while(!q.empty()){
        int k=q.front();
        q.pop();
        for(register int i=head[k];i;i=next[i]){
            if(w[i]&&dis[to[i]]>dis[k]+v[i]){
                dis[to[i]]=dis[k]+v[i];
                if(!vis[to[i]])
                    q.push(vis[to[i]]=to[i]);
            }
        }
        vis[k]=0;
    }
    return dis[t]<inf;
}
inline int dfs(int x,int flow){
    vis[x]=1;
	if(x==t||!flow)
        return vis[x];
    for(register int i=head[x];i;i=next[i])
        if(!vis[to[i]]&&w[i]&&dis[to[i]]==dis[x]+v[i]){
            int ovo=dfs(to[i],min(flow,w[i]));
            if(ovo>0){
                ans+=v[i]*ovo;
                w[i]-=ovo;
                w[i^1]+=ovo;
                return ovo;
            }
        }
    return 0;
}
inline int dinic(){
    int flow=0;
    while(spfa()){
        vis[t]=1;
        while(vis[t]){
            memset(vis,0,sizeof(vis));
            flow+=dfs(s,inf);
        }
    }
    return flow;
}

int main(){
  //  freopen("1559.in","r",stdin);
  //  freopen("1559.out","w",stdout);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	printf("%d\n",min(a,b)+min(c,d));
	return 0;
    scanf("%d",&n);
	for(int k=0;k<2;++k)
		for(register int i=1;i<=n;++i)
			for(int j=1;j<=n;++j)
				scanf("%d",&a[i][j][k]);
	s=n*2+1;t=s+1;
	for(int i=1;i<=n;++i){
		add(s,i,1,0);
		add(i,s,0,0);
		add(i+n,t,1,0);
		add(t,i+n,0,0);
	}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j){
			add(i,j+n,1,-a[i][j][0]*a[j][i][1]);
			add(j+n,i,0,a[i][j][0]*a[j][i][1]);
		}
    dinic();
    printf("%d",-ans);
    return 0;
}




Compiler output:
a.cc: In function 'bool spfa()':
a.cc:27:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |         for(register int i=head[k];i;i=next[i]){
      |                          ^
a.cc: In function 'int dfs(int, int)':
a.cc:42:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   42 |     for(register int i=head[x];i;i=next[i])
      |                      ^
a.cc: In function 'int main()':
a.cc:75:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   75 |                 for(register int i=1;i<=n;++i)
      |                                  ^
a.cc:77:46: error: invalid types 'int[int]' for array subscript
   77 |                                 scanf("%d",&a[i][j][k]);
      |                                              ^
a.cc:87:39: error: invalid types 'int[int]' for array subscript
   87 |                         add(i,j+n,1,-a[i][j][0]*a[j][i][1]);
      |                                       ^
a.cc:87:50: error: invalid types 'int[int]' for array subscript
   87 |                         add(i,j+n,1,-a[i][j][0]*a[j][i][1]);
      |                                                  ^
a.cc:88:38: error: invalid types 'int[int]' for array subscript
   88 |                         add(j+n,i,0,a[i][j][0]*a[j][i][1]);
      |                                      ^
a.cc:88:49: error: invalid types 'int[int]' for array subscript
   88 |                         add(j+n,i,0,a[i][j][0]*a[j][i][1]);
      |                                                 ^