Language: C++

#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#define MAX_V 1000
#define INF 999999
using namespace std;

typedef struct edge{
  int to,cap,rev;
}edge;
vector<edge> G[2*MAX_V+2];
int d[MAX_V][MAX_V];
bool used[MAX_V];
int n,m,cost;

void floyed(int n){
  for(int i=0;i<n;i++)d[i][i]=0;

  for(int k=0;k<n;k++){
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  // cout << "result of floyed" << endl;
  // for(int i=0;i<n;i++){
  //   for(int j=0;j<n;j++){
  //     cout << d[i][j] << " ";
  //   }
  //   cout << endl;
  // }
 }

bool makeG(){
  memset(G,0,sizeof(G));
  memset(d,1,sizeof(d));
  if(scanf("%d%d%d",&n,&m,&cost)==EOF)return false;
  for(int i=0;i<m;i++){
    int to,from,cap;
    cin>>from>>to>>cap;
    d[from-1][to-1]=cap;
    d[to-1][from-1]=cap;
  }
  floyed(n);
  int bef[n],aft[n];
  for(int i=0;i<n;i++){
    cin>>bef[i];
  }
  for(int i=0;i<n;i++){
    cin>>aft[i];
   }
  for(int i=0;i<n;i++){
    for(int j=n;j<2*n;j++){
      if(d[i][j-n]<cost){
	G[i].push_back((edge){j,bef[i],G[j].size()});
	G[j].push_back((edge){i,0,G[i].size()-1});
      }
    }
  }
  for(int i=0;i<n;i++){
    G[2*n].push_back((edge){i,bef[i],G[i].size()});
    G[i].push_back((edge){2*n,0,G[2*n].size()-1});
  }
  for(int i=n;i<2*n;i++){
     G[i].push_back((edge){2*n+1,aft[i-n],G[2*n+1].size()});
    G[2*n+1].push_back((edge){i,0,G[i].size()-1});
  }
  return true;
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to] && e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow= 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0) return flow;
    flow += f;
  }
}

int main(){
  while(makeG()!=false){
    // for(int i=0;i<2*n+2;i++){
    //   cout << i << ": ";
    //   for(int j=0;j<G[i].size();j++){
    // 	cout << "{" << G[i][j].to << "," << G[i][j].cap<<"} ";
    //   }
    //   cout << endl;
    // }
    // cout  << endl;
    int ans=max_flow(2*n,2*n+1);
    cout << ans << endl;
  }
  return 0;
}

Compiler output:
a.cc: In function 'bool makeG()':
a.cc:37:3: error: 'memset' was not declared in this scope
   37 |   memset(G,0,sizeof(G));
      |   ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    4 | #include<algorithm>
  +++ |+#include <cstring>
    5 | #define MAX_V 1000
a.cc:57:49: warning: narrowing conversion of 'G[j].std::vector<edge>::size()' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   57 |         G[i].push_back((edge){j,bef[i],G[j].size()});
      |                                        ~~~~~~~~~^~
a.cc:58:46: warning: narrowing conversion of '(G[i].std::vector<edge>::size() - 1)' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   58 |         G[j].push_back((edge){i,0,G[i].size()-1});
      |                                   ~~~~~~~~~~~^~
a.cc:63:47: warning: narrowing conversion of 'G[i].std::vector<edge>::size()' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   63 |     G[2*n].push_back((edge){i,bef[i],G[i].size()});
      |                                      ~~~~~~~~~^~
a.cc:64:46: warning: narrowing conversion of '(G[(2 * n)].std::vector<edge>::size() - 1)' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   64 |     G[i].push_back((edge){2*n,0,G[2*n].size()-1});
      |                                 ~~~~~~~~~~~~~^~
a.cc:67:56: warning: narrowing conversion of 'G[((2 * n) + 1)].std::vector<edge>::size()' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   67 |      G[i].push_back((edge){2*n+1,aft[i-n],G[2*n+1].size()});
      |                                           ~~~~~~~~~~~~~^~
a.cc:68:46: warning: narrowing conversion of '(G[i].std::vector<edge>::size() - 1)' from 'std::vector<edge>::size_type' {aka 'long unsigned int'} to 'int' [-Wnarrowing]
   68 |     G[2*n+1].push_back((edge){i,0,G[i].size()-1});
      |                                   ~~~~~~~~~~~^~
a.cc: In function 'int max_flow(int, int)':
a.cc:93:5: error: 'memset' was not declared in this scope
   93 |     memset(used,0,sizeof(used));
      |     ^~~~~~
a.cc:93:5: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'