// File: /workspace/github_cpp_makefile_star2_O2/ruippeixotog[P]algo-lib/min-cost-max-flow.cpp
// Function: dijkstra(int, int)
int dijkstra(int src, int dest) {
  memset(dist, 0x3f, sizeof(dist));
  memset(parent, -1, sizeof(parent));

  priority_queue<pair<int, int>> q;
  q.push(make_pair(0, src)); dist[src] = 0;

  while(!q.empty()) {
    int curr = q.top().second; q.pop();

    if(parent[curr] >= 0) continue;
    parent[curr] = -parent[curr] - 1;

    for(int adj : adjs[curr]) {
      if(parent[adj] >= 0) continue;

      if(flow[adj][curr] && pot(curr, adj) - cost[adj][curr] < dist[adj]) {
        dist[adj] = pot(curr, adj) - cost[adj][curr];
        parent[adj] = -curr - 1;
        q.push(make_pair(-dist[adj], adj));
      }

      if(flow[curr][adj] < cap[curr][adj] && pot(curr, adj) + cost[curr][adj] < dist[adj]) {
        dist[adj] = pot(curr, adj) + cost[curr][adj];
        parent[adj] = -curr - 1;
        q.push(make_pair(-dist[adj], adj));
      }
    }
  }

  for(int i = 0; i < n; i++) { pi[i] += dist[i]; }
  return dist[dest];
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %esi, 0x14(%rsp)
movl %edi, %ebx
leaq 0x7a9e29(%rip), %r14    # 0x7ab050
pushq $0x3f
popq %rsi
movl $0xfa0, %edx            # imm = 0xFA0
movq %r14, %rdi
callq 0x1050
leaq 0x7aadb2(%rip), %r15    # 0x7abff0
movl $0xfa0, %edx            # imm = 0xFA0
movq %r15, %rdi
movl $0xff, %esi
callq 0x1050
xorps %xmm0, %xmm0
leaq 0x20(%rsp), %rdi
movaps %xmm0, (%rdi)
andq $0x0, 0x10(%rdi)
movq %rbx, %rax
shlq $0x20, %rax
leaq 0x8(%rsp), %rsi
movq %rax, (%rsi)
callq 0x15e4
movslq %ebx, %rax
andl $0x0, (%r14,%rax,4)
movq 0x20(%rsp), %rax
cmpq 0x28(%rsp), %rax
je 0x1423
movslq 0x4(%rax), %rbp
leaq 0x20(%rsp), %rdi
callq 0x15fa
movl (%r15,%rbp,4), %eax
testl %eax, %eax
jns 0x127c
notl %eax
movl %eax, (%r15,%rbp,4)
imulq $0x18, %rbp, %rax
leaq 0x2ddd(%rip), %rcx      # 0x4090
movq (%rax,%rcx), %r12
movq 0x8(%rax,%rcx), %rax
movq %rax, 0x50(%rsp)
movl %ebp, %eax
notl %eax
movl %eax, 0x4(%rsp)
imulq $0xfa0, %rbp, %rcx      # imm = 0xFA0
leaq 0x7acc59(%rip), %rax    # 0x7adf30
addq %rcx, %rax
movq %rax, 0x48(%rsp)
leaq 0x3d946a(%rip), %rax    # 0x3da750
addq %rcx, %rax
movq %rax, 0x40(%rsp)
leaq 0x8b5b(%rip), %rax      # 0x9e50
addq %rax, %rcx
movq %rcx, 0x18(%rsp)
cmpq 0x50(%rsp), %r12
je 0x127c
movslq (%r12), %r13
cmpl $0x0, (%r15,%r13,4)
jns 0x141a
movq %r15, %r14
movl %r13d, %ebx
imulq $0xfa0, %r13, %r15      # imm = 0xFA0
leaq 0x7acc05(%rip), %rax    # 0x7adf30
addq %r15, %rax
cmpl $0x0, (%rax,%rbp,4)
je 0x139c
movl %ebp, %edi
movl %ebx, %esi
callq 0x1611
leaq 0x8b0c(%rip), %rcx      # 0x9e50
addq %rcx, %r15
subl (%r15,%rbp,4), %eax
leaq 0x7a9cfe(%rip), %rcx    # 0x7ab050
cmpl (%rcx,%r13,4), %eax
jge 0x139c
leaq (%r15,%rbp,4), %r15
movl %ebp, %edi
movl %r13d, %esi
callq 0x1611
subl (%r15), %eax
leaq 0x7a9ce0(%rip), %rcx    # 0x7ab050
movl %eax, (%rcx,%r13,4)
movl 0x4(%rsp), %ecx
movl %ecx, (%r14,%r13,4)
negl %eax
movq %rbx, %rcx
shlq $0x20, %rcx
orq %rcx, %rax
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x15e4
movq 0x48(%rsp), %rax
movl (%rax,%r13,4), %eax
movq 0x40(%rsp), %rcx
cmpl (%rcx,%r13,4), %eax
movq %r14, %r15
jge 0x141a
movl %ebp, %edi
movl %ebx, %esi
callq 0x1611
movq 0x18(%rsp), %rcx
addl (%rcx,%r13,4), %eax
leaq 0x7a9c84(%rip), %rcx    # 0x7ab050
cmpl (%rcx,%r13,4), %eax
jge 0x141a
movq 0x18(%rsp), %rax
leaq (%rax,%r13,4), %r15
movl %ebp, %edi
movl %ebx, %esi
callq 0x1611
addl (%r15), %eax
movq %r14, %r15
leaq 0x7a9c5f(%rip), %rcx    # 0x7ab050
movl %eax, (%rcx,%r13,4)
movl 0x4(%rsp), %ecx
movl %ecx, (%r14,%r13,4)
negl %eax
shlq $0x20, %rbx
orq %rbx, %rax
movq %rax, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x15e4
addq $0x4, %r12
jmp 0x12fd
movl 0x2c57(%rip), %eax      # 0x4080
xorl %ecx, %ecx
testl %eax, %eax
cmovlel %ecx, %eax
shlq $0x2, %rax
leaq 0x7abb55(%rip), %rdx    # 0x7acf90
leaq 0x7a9c0e(%rip), %rdi    # 0x7ab050
cmpq %rcx, %rax
je 0x1453
movl (%rcx,%rdi), %esi
addl %esi, (%rcx,%rdx)
addq $0x4, %rcx
jmp 0x1442
movslq 0x14(%rsp), %rax
movl (%rdi,%rax,4), %ebx
leaq 0x20(%rsp), %rdi
callq 0x1630
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x147c
jmp 0x147c
jmp 0x147c
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x1630
movq %rbx, %rdi
callq 0x10a0