Language: C++

'''
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import csv
import argparse
import time
'''
import sys
import heapq

INF = sys.maxint/3

class Edge:
    def __init__(self, to, cap, cost, rev):
        self.to = to
        self.cap = cap
        self.cost = cost
        self.rev = rev

    def print_attributes(self):
        print "to: {0}, cap: {1}, cost: {2}, rev: {3}".format(self.to, self.cap, self.cost, self.rev)

class MinimumCostFlow:

    def __init__(self, V, E):
        self.V = V
        self.E = E
        self.G = [[] for i in range(V)]

    def add_edge(self, s, t, cap, cost):
        forward_edge = Edge(t, cap, cost, len(self.G[t]))
        self.G[s].append(forward_edge)
        backward_edge = Edge(s, 0, -cost, len(self.G[s])-1)
        self.G[t].append(backward_edge)

    def print_edges(self):
        print "==== print edges ===="
        for i in range(self.V):
            print "\nedges from {}".format(i)
            for e in self.G[i]:
                e.print_attributes()

    def minimum_cost_flow(self, s, t, f):
        res = 0
        h = [0] * self.V

        while f>0:
            pque = []
            dist = [INF for i in range(self.V)]
            prev_v = [0 for i in range(self.V)]
            prev_e = [0 for i in range(self.V)]

            dist[s] = 0
            heapq.heappush(pque, (0, s))
            while(len(pque)!=0):
                p = heapq.heappop(pque)
                v = p[1]
                if (dist[v] < p[0]):
                    continue
                for i in range(len(self.G[v])):
                    e = self.G[v][i]
                    if (e.cap>0 and dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]):
                        dist[e.to] = dist[v] + e.cost + h[v] - h[e.to]
                        prev_v[e.to] = v
                        prev_e[e.to] = i
                        heapq.heappush(pque, (dist[e.to], e.to))

            if dist[t] == INF:
                return -1

            for v in range(self.V):
                h[v] += dist[v]

            d = f

            v = t
            while v!=s:
                d = min(d, self.G[prev_v[v]][prev_e[v]].cap)
                v = prev_v[v]

            f -= d
            res += d * h[t]

            v = t
            while v!=s:
                e = self.G[prev_v[v]][prev_e[v]]
                e.cap -= d
                self.G[v][e.rev].cap += d
                v = prev_v[v]

        return res

def main():
    V, E, F = map(int, raw_input().split())
    mcf = MinimumCostFlow(V, E)
    for i in range(E):
        u, v, c, d = map(int, raw_input().split())
        mcf.add_edge(u, v, c, d)

    #print "minimum cost flow: {}".format(mcf.minimum_cost_flow(0, V-1, F))
    print mcf.minimum_cost_flow(0, V-1, F)

if __name__ == '__main__':
    main()


Compiler output:
a.cc:1:1: error: empty character constant
    1 | '''
      | ^~
a.cc:1:3: warning: missing terminating ' character
    1 | '''
      |   ^
a.cc:1:3: error: missing terminating ' character
a.cc:9:1: error: empty character constant
    9 | '''
      | ^~
a.cc:9:3: warning: missing terminating ' character
    9 | '''
      |   ^
a.cc:9:3: error: missing terminating ' character
a.cc:102:6: error: invalid preprocessing directive #print
  102 |     #print "minimum cost flow: {}".format(mcf.minimum_cost_flow(0, V-1, F))
      |      ^~~~~
a.cc:105:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
  105 | if __name__ == '__main__':
      |                ^~~~~~~~~~
a.cc:1:1: error: expected unqualified-id before '\x0'
    1 | '''
      | ^~