Language: C++

#ifndef POTTS_NETWORK_HPP
#define POTTS_NETWORK_HPP

#include <cassert>
#include <cstddef>
#include <vector>

namespace potts
{

class Network
{
public:
    struct Edge
    {
        std::size_t dst;
        std::uint64_t capacity;
        std::size_t rev_edge;
        
        Edge() = default;
        Edge(const std::size_t dst, const std::uint64_t capacity, const std::size_t rev_edge) : dst(dst), capacity(capacity), rev_edge(rev_edge) {}
    };
    
private:
     std::vector<std::vector<Edge>> edges;
     
public:
    Network() = default;
    Network(const std::size_t n) : edges(n) {}
    
    void clear()
    {
        edges.clear();
    }
    
    void resize(std::size_t n)
    {
        edges.resize(n);
    }
    
    std::size_t num_nodes() const noexcept
    {
        return edges.size();
    }
    
    std::vector<Edge>& operator[](const std::size_t i) noexcept
    {
        assert(i < num_nodes());
        return edges[i];
    }
    
    const std::vector<Edge>& operator[](const std::size_t i) const noexcept
    {
        assert(i < num_nodes());
        return edges[i];
    }
    
    void add_edge(const std::size_t src, const std::size_t dst, const std::uint64_t capacity)
    {
        edges[src].emplace_back(dst, capacity, edges[dst].size());
        edges[dst].emplace_back(src, 0, edges[src].size() - 1);
    }
};

} // end of namespace potts

#endif

#ifndef POTTS_DINIC_HPP
#define POTTS_DINIC_HPP

namespace potts
{

class Dinic
{
private:
    std::vector<int> level;
    std::vector<std::size_t> iter;
    
    void bfs(const Network& network, const std::size_t s);
    std::uint64_t dfs(Network& network, const std::size_t v, const std::size_t t, const std::uint64_t f);
    
public:
    Dinic() = default;
    std::uint64_t compute(Network& network, const std::size_t s, const std::size_t t);
};

} // end of namespace potts

#endif

#include <algorithm>
#include <queue>

namespace potts
{
    
void Dinic::bfs(const Network& network, const std::size_t s)
{
    std::fill(level.begin(), level.end(), -1);
    std::queue<std::size_t> Q;
    level[s] = 0;
    Q.push(s);
    
    while(!Q.empty()){
        const std::size_t v = Q.front();
        Q.pop();
        
        for(const Network::Edge& e : network[v]){
            if(e.capacity > 0 && level[e.dst] < 0){
                level[e.dst] = level[v] + 1;
                Q.push(e.dst);
            }
        }
    }
}

std::uint64_t Dinic::dfs(Network& network, const std::size_t v, const std::size_t t, const std::uint64_t f)
{
    if(v == t){
        return f;
    }
    
    for(std::size_t& i=iter[v]; i < network[v].size(); ++i){
        Network::Edge& e = network[v][i];
        if(e.capacity > 0 && level[v] < level[e.dst]){
            const std::uint64_t d = dfs(network, e.dst, t, std::min(f, e.capacity));
            if(d > 0){
                e.capacity -= d;
                network[e.dst][e.rev_edge].capacity += d;
                return d;
            }
        }
    }
    
    return 0;
}

std::uint64_t Dinic::compute(Network& network, const std::size_t s, const std::size_t t)
{
    level.resize(network.num_nodes());
    iter.resize(network.num_nodes());
    
    std::int64_t flow = 0;
    
    for(;;){
        bfs(network, s);
        if(level[t] < 0){
            return flow;
        }
        std::fill(iter.begin(), iter.end(), 0);
        
        int f;
        while((f = dfs(network, s, t, std::numeric_limits<std::uint64_t>::max())) > 0){
            flow += f;
        }
    }
}

} // end of namespace potts

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp

#include <iostream>

int main()
{
    int n, m;
    std::cin >> n >> m;
    
    potts::Network network(n);
    
    for(int i=0; i<m; ++i){
        int u, v, c;
        std::cin >> u >> v >> c;
        network.add_edge(u, v, c);
    }
    
    potts::Dinic dinic;
    std::cout << dinic.compute(network, 0, n-1) << std::endl;
}

Compiler output:
a.cc:17:14: error: 'uint64_t' in namespace 'std' does not name a type
   17 |         std::uint64_t capacity;
      |              ^~~~~~~~
a.cc:21:48: error: 'uint64_t' in namespace 'std' does not name a type
   21 |         Edge(const std::size_t dst, const std::uint64_t capacity, const std::size_t rev_edge) : dst(dst), capacity(capacity), rev_edge(rev_edge) {}
      |                                                ^~~~~~~~
a.cc:58:76: error: 'uint64_t' in namespace 'std' does not name a type
   58 |     void add_edge(const std::size_t src, const std::size_t dst, const std::uint64_t capacity)
      |                                                                            ^~~~~~~~
a.cc: In constructor 'potts::Network::Edge::Edge(std::size_t, int, std::size_t)':
a.cc:21:107: error: class 'potts::Network::Edge' does not have any field named 'capacity'
   21 |         Edge(const std::size_t dst, const std::uint64_t capacity, const std::size_t rev_edge) : dst(dst), capacity(capacity), rev_edge(rev_edge) {}
      |                                                                                                           ^~~~~~~~
a.cc: At global scope:
a.cc:82:10: error: 'uint64_t' in namespace 'std' does not name a type
   82 |     std::uint64_t dfs(Network& network, const std::size_t v, const std::size_t t, const std::uint64_t f);
      |          ^~~~~~~~
a.cc:86:10: error: 'uint64_t' in namespace 'std' does not name a type
   86 |     std::uint64_t compute(Network& network, const std::size_t s, const std::size_t t);
      |          ^~~~~~~~
a.cc: In member function 'void potts::Dinic::bfs(const potts::Network&, std::size_t)':
a.cc:111:18: error: 'const struct potts::Network::Edge' has no member named 'capacity'
  111 |             if(e.capacity > 0 && level[e.dst] < 0){
      |                  ^~~~~~~~
a.cc: At global scope:
a.cc:119:6: error: 'uint64_t' in namespace 'std' does not name a type
  119 | std::uint64_t Dinic::dfs(Network& network, const std::size_t v, const std::size_t t, const std::uint64_t f)
      |      ^~~~~~~~
a.cc:140:6: error: 'uint64_t' in namespace 'std' does not name a type
  140 | std::uint64_t Dinic::compute(Network& network, const std::size_t s, const std::size_t t)
      |      ^~~~~~~~
a.cc: In function 'int main()':
a.cc:181:24: error: 'class potts::Dinic' has no member named 'compute'
  181 |     std::cout << dinic.compute(network, 0, n-1) << std::endl;
      |                        ^~~~~~~