Language: C++

//--------------------
typedef int Cost;
struct Edge{int to,cap,rev;Cost cost;};
typedef vector<Edge> Edges;
typedef vector<vector<Edge> > Graph;

void add_edge(Graph &g,int from,int to,int cap,Cost cost=0){
  g[from].pb((Edge){to,cap,g[to].size(),cost});
  g[to].pb((Edge){from,0,g[from].size()-1,-cost});
}
Cost INF=1e7;

//max_flow

vector<int> used;

int dfs(Graph &g,int v,int t,int f){
  if(v==t) return f;
  used[v]=1;
  int re,i,j,k;
  for(i=0;i<=g[v].size();i++){
    edge &e=g[v][i];
    if(e.cap<=0||used[e.to])continue;
    int d=dfs(g,eto, t, ,min(f,e.cap));
   // used[p]=0;
    if(d>0){
      e.cap-=d;
      g[e.to][e.rev].cap+=d;
      return d;
    }
  }
  return 0;
}

int max_flow(Graph &g,int s,int t){
  int sum=0,f,V=g.size();
  while(1){
    used.resize(V);
    fill(all(used),0);
    sum+=f=dfs(g,s,t,INF);
    if(!f)return sum;
  }
}

//min_cost,bf

double min_cost_flow(Graph &g,int s,int t,int f){
  int V=g.size();
  vector<Cost> dist(V);
  vector<int> used(V),prevv(V),preve(V);
  double res=0;
  int v,i;
  while(f>0){
    fill(all(dist),INF);
    dist[s]=0;
    bool upd=1;
    while(upd){
      upd=0;
      rep(v,V){
        if(dist[v]==INF)continue;
        rep(i,g[v].size()){
          Edge &e=g[v][i];
          if(e.cap>0 && dist[e.to]>dist[v]+e.cost){
            dist[e.to]=dist[v]+e.cost;
            prevv[e.to]=v;
            preve[e.to]=i;
            upd=1;
          }
        }
      }
    }
    if(dist[t]==INF)
      return -1;
    int d=f;
    for(v=t;v!=s;v=prevv[v]){
      d=min(d,g[prevv[v]][preve[v]].cap);
    }
    f-=d;
    res+=d*dist[t];
    for(v=t;v!=s;v=prevv[v]){
      Edge &e=g[prevv[v]][preve[v]];
      e.cap-=d;
      g[v][e.rev].cap+=d;
    }
  }
  return res;
}


//min-cost,dij
//aoj2429

typedef pair<Cost,int> Que;

//f流せなければINF
Cost min_cost_flow(Graph &g,int s,int t,int f){
  int V=g.size(),res=0;
  vector<Cost> h(V,0),d(V);
  vector<int> prevv(V),preve(V);
  while(f>0){
    priority_queue<Que,vector<Que>,greater<Que> > que;
    int V=g.size();
    d.resize(V);
    fill(all(d),INF);
    d[s]=0;
    que.push(Que(0,s));
    while(!que.empty()){
      Que p=que.top();que.pop();
      int v=p.Y;
      if(d[v]<p.X)continue;
      rep(i,g[v].size()){
        Edge &e=g[v][i];
        if(e.cap>0 && d[e.to]>d[v]+e.cost+h[v]-h[e.to]){
          d[e.to]=d[v]+e.cost+h[v]-h[e.to];
          prevv[e.to]=v;
          preve[e.to]=i;
          que.push(Que(d[e.to],e.to));
        }
      }
    }
    if(d[t] == INF){
      return INF;
    }
    rep(v,V)
      h[v]+=d[v];
    int flow=f;
    for(int v=t;v!=s;v=prevv[v]){
      flow=min(flow,g[prevv[v]][preve[v]].cap);
    }
    f-=flow;
    res+=flow*h[t];
    for(int v=t;v!=s;v=prevv[v]){
      Edge &e=g[prevv[v]][preve[v]];
      e.cap-=flow;
      g[v][e.rev].cap+=flow;
    }
  }
  return res;
}

Compiler output:
a.cc:4:9: error: 'vector' does not name a type
    4 | typedef vector<Edge> Edges;
      |         ^~~~~~
a.cc:5:9: error: 'vector' does not name a type
    5 | typedef vector<vector<Edge> > Graph;
      |         ^~~~~~
a.cc:7:6: error: variable or field 'add_edge' declared void
    7 | void add_edge(Graph &g,int from,int to,int cap,Cost cost=0){
      |      ^~~~~~~~
a.cc:7:15: error: 'Graph' was not declared in this scope
    7 | void add_edge(Graph &g,int from,int to,int cap,Cost cost=0){
      |               ^~~~~
a.cc:7:22: error: 'g' was not declared in this scope
    7 | void add_edge(Graph &g,int from,int to,int cap,Cost cost=0){
      |                      ^
a.cc:7:24: error: expected primary-expression before 'int'
    7 | void add_edge(Graph &g,int from,int to,int cap,Cost cost=0){
      |                        ^~~
a.cc:7:33: error: expected primary-expression before 'int'
    7 | void add_edge(Graph &g,int from,int to,int cap,Cost cost=0){
      |                                 ^~~
a.cc:7:40: error: expected primary-expression before 'int'
    7 | void add_edge(Graph &g,int from,int to,int cap,Cost cost=0){
      |                                        ^~~
a.cc:7:53: error: expected primary-expression before 'cost'
    7 | void add_edge(Graph &g,int from,int to,int cap,Cost cost=0){
      |                                                     ^~~~
a.cc:15:1: error: 'vector' does not name a type
   15 | vector<int> used;
      | ^~~~~~
a.cc:17:9: error: 'Graph' was not declared in this scope
   17 | int dfs(Graph &g,int v,int t,int f){
      |         ^~~~~
a.cc:17:16: error: 'g' was not declared in this scope
   17 | int dfs(Graph &g,int v,int t,int f){
      |                ^
a.cc:17:18: error: expected primary-expression before 'int'
   17 | int dfs(Graph &g,int v,int t,int f){
      |                  ^~~
a.cc:17:24: error: expected primary-expression before 'int'
   17 | int dfs(Graph &g,int v,int t,int f){
      |                        ^~~
a.cc:17:30: error: expected primary-expression before 'int'
   17 | int dfs(Graph &g,int v,int t,int f){
      |                              ^~~
a.cc:17:35: error: expression list treated as compound expression in initializer [-fpermissive]
   17 | int dfs(Graph &g,int v,int t,int f){
      |                                   ^
a.cc:35:14: error: 'Graph' was not declared in this scope
   35 | int max_flow(Graph &g,int s,int t){
      |              ^~~~~
a.cc:35:21: error: 'g' was not declared in this scope
   35 | int max_flow(Graph &g,int s,int t){
      |                     ^
a.cc:35:23: error: expected primary-expression before 'int'
   35 | int max_flow(Graph &g,int s,int t){
      |                       ^~~
a.cc:35:29: error: expected primary-expression before 'int'
   35 | int max_flow(Graph &g,int s,int t){
      |                             ^~~
a.cc:35:34: error: expression list treated as compound expression in initializer [-fpermissive]
   35 | int max_flow(Graph &g,int s,int t){
      |                                  ^
a.cc:47:22: error: 'Graph' was not declared in this scope
   47 | double min_cost_flow(Graph &g,int s,int t,int f){
      |                      ^~~~~
a.cc:47:29: error: 'g' was not declared in this scope
   47 | double min_cost_flow(Graph &g,int s,int t,int f){
      |                             ^
a.cc:47:31: error: expected primary-expression before 'int'
   47 | double min_cost_flow(Graph &g,int s,int t,int f){
      |                               ^~~
a.cc:47:37: error: expected primary-expression before 'int'
   47 | double min_cost_flow(Graph &g,int s,int t,int f){
      |                                     ^~~
a.cc:47:43: error: expected primary-expression before 'int'
   47 | double min_cost_flow(Graph &g,int s,int t,int f){
      |                                           ^~~
a.cc:47:48: error: expression list treated as compound expression in initializer [-fpermissive]
   47 | double min_cost_flow(Graph &g,int s,int t,int f){
      |                                                ^
a.cc:93:9: error: 'pair' does not name a type
   93 | typedef pair<Cost,int> Que;
      |         ^~~~
a.cc:96:6: error: conflicting declaration 'Cost min_cost_flow'
   96 | Cost min_cost_flow(Graph &g,int s,int t,int f){
      |      ^~~~~~~~~~~~~
a.cc:47:8: note: previous declaration as 'double min_cost_flow'
   47 | double min_cost_flow(Graph &g,int s,int t,int f){
      |        ^~~~~~~~~~~~~
a.cc:96:20: error: 'Graph' was not declared in this scope
   96 | Cost min_cost_flow(Graph &g,int s,int t,int f){
      |                    ^~~~~
a.cc:96:27: error: 'g' was not declared in this scope
   96 | Cost min_cost_flow(Graph &g,int s,int t,int f){
      |                           ^
a.cc:96:29: error: expected primary-expression before 'int'
   96 | Cost min_cost_flow(Graph &g,int s,int t,int f){
      |                             ^~~
a.cc:96:35: error: expected primary-expression before 'int'
   96 | Cost min_cost_flow(Graph &g,int s,int t,int f){
      |                                   ^~~
a.cc:96:41: error: expected primary-expression before 'int'
   96 | Cost min_cost_flow(Graph &g,int s,int t,int f){
      |                                         ^~~