// File: 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:
subq $0xc8, %rsp
movl %edi, 0xc4(%rsp)
movl %esi, 0xc0(%rsp)
leaq 0x7acdb4(%rip), %rdi    # 0x7ae060
movl $0x3f, %esi
movl $0xfa0, %edx            # imm = 0xFA0
movq %rdx, 0x38(%rsp)
callq 0x1070
movq 0x38(%rsp), %rdx
leaq 0x7add34(%rip), %rdi    # 0x7af000
movl $0xff, %esi
callq 0x1070
leaq 0xa0(%rsp), %rdi
callq 0x1a80
movl $0x0, 0x94(%rsp)
leaq 0x94(%rsp), %rdi
leaq 0xc4(%rsp), %rsi
callq 0x1b10
movq %rax, 0x40(%rsp)
jmp 0x130a
movq 0x40(%rsp), %rax
movq %rax, 0x98(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x1ab0
jmp 0x132e
movslq 0xc4(%rsp), %rcx
leaq 0x7acd23(%rip), %rax    # 0x7ae060
movl $0x0, (%rax,%rcx,4)
leaq 0xa0(%rsp), %rdi
callq 0x1b40
movb %al, 0x37(%rsp)
jmp 0x1357
movb 0x37(%rsp), %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1366
jmp 0x16e2
leaq 0xa0(%rsp), %rdi
callq 0x1b60
movq %rax, 0x28(%rsp)
jmp 0x137a
movq 0x28(%rsp), %rax
movl 0x4(%rax), %eax
movl %eax, 0x80(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x1b70
jmp 0x1398
movslq 0x80(%rsp), %rcx
leaq 0x7adc59(%rip), %rax    # 0x7af000
cmpl $0x0, (%rax,%rcx,4)
jl 0x13d5
jmp 0x1344
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x88(%rsp)
movl %eax, 0x84(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x1cd0
jmp 0x175a
movslq 0x80(%rsp), %rcx
xorl %edx, %edx
leaq 0x7adc1a(%rip), %rax    # 0x7af000
subl (%rax,%rcx,4), %edx
subl $0x1, %edx
movslq 0x80(%rsp), %rcx
leaq 0x7adc05(%rip), %rax    # 0x7af000
movl %edx, (%rax,%rcx,4)
movslq 0x80(%rsp), %rcx
leaq 0x5c93(%rip), %rax      # 0x70a0
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
callq 0x1bc0
movq %rax, 0x70(%rsp)
movq 0x78(%rsp), %rdi
callq 0x1bf0
movq %rax, 0x68(%rsp)
leaq 0x70(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x1c20
testb $0x1, %al
jne 0x144f
jmp 0x16dd
leaq 0x70(%rsp), %rdi
callq 0x1c60
movl (%rax), %eax
movl %eax, 0x64(%rsp)
movslq 0x64(%rsp), %rcx
leaq 0x7adb95(%rip), %rax    # 0x7af000
cmpl $0x0, (%rax,%rcx,4)
jl 0x1476
jmp 0x16ce
movslq 0x64(%rsp), %rcx
leaq 0x7afabe(%rip), %rax    # 0x7b0f40
imulq $0xfa0, %rcx, %rcx      # imm = 0xFA0
addq %rcx, %rax
movslq 0x80(%rsp), %rcx
cmpl $0x0, (%rax,%rcx,4)
je 0x1591
movl 0x80(%rsp), %edi
movl 0x64(%rsp), %esi
callq 0x1c70
movl %eax, 0x24(%rsp)
jmp 0x14b4
movl 0x24(%rsp), %eax
movslq 0x64(%rsp), %rdx
leaq 0xb99c(%rip), %rcx      # 0xce60
imulq $0xfa0, %rdx, %rdx      # imm = 0xFA0
addq %rdx, %rcx
movslq 0x80(%rsp), %rdx
subl (%rcx,%rdx,4), %eax
movslq 0x64(%rsp), %rdx
leaq 0x7acb7b(%rip), %rcx    # 0x7ae060
cmpl (%rcx,%rdx,4), %eax
jge 0x1591
movl 0x80(%rsp), %edi
movl 0x64(%rsp), %esi
callq 0x1c70
movl %eax, 0x20(%rsp)
jmp 0x1504
movl 0x20(%rsp), %edx
movslq 0x64(%rsp), %rcx
imulq $0xfa0, %rcx, %rsi      # imm = 0xFA0
leaq 0xb945(%rip), %rax      # 0xce60
addq %rsi, %rax
movslq 0x80(%rsp), %rsi
movl (%rax,%rsi,4), %eax
subl %eax, %edx
leaq 0x7acb2e(%rip), %rax    # 0x7ae060
movl %edx, (%rax,%rcx,4)
movl 0x80(%rsp), %esi
notl %esi
movslq 0x64(%rsp), %rdx
leaq 0x7adab6(%rip), %rcx    # 0x7af000
movl %esi, (%rcx,%rdx,4)
movslq 0x64(%rsp), %rcx
movl (%rax,%rcx,4), %eax
negl %eax
movl %eax, 0x58(%rsp)
leaq 0x58(%rsp), %rdi
leaq 0x64(%rsp), %rsi
callq 0x1b10
movq %rax, 0x18(%rsp)
jmp 0x1571
movq 0x18(%rsp), %rax
movq %rax, 0x5c(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x5c(%rsp), %rsi
callq 0x1ab0
jmp 0x158f
jmp 0x1591
movslq 0x80(%rsp), %rcx
leaq 0x7af9a0(%rip), %rax    # 0x7b0f40
imulq $0xfa0, %rcx, %rcx      # imm = 0xFA0
addq %rcx, %rax
movslq 0x64(%rsp), %rcx
movl (%rax,%rcx,4), %eax
movslq 0x80(%rsp), %rdx
leaq 0x3dc19f(%rip), %rcx    # 0x3dd760
imulq $0xfa0, %rdx, %rdx      # imm = 0xFA0
addq %rdx, %rcx
movslq 0x64(%rsp), %rdx
cmpl (%rcx,%rdx,4), %eax
jge 0x16cc
movl 0x80(%rsp), %edi
movl 0x64(%rsp), %esi
callq 0x1c70
movl %eax, 0x14(%rsp)
jmp 0x15ef
movl 0x14(%rsp), %eax
movslq 0x80(%rsp), %rdx
leaq 0xb85e(%rip), %rcx      # 0xce60
imulq $0xfa0, %rdx, %rdx      # imm = 0xFA0
addq %rdx, %rcx
movslq 0x64(%rsp), %rdx
addl (%rcx,%rdx,4), %eax
movslq 0x64(%rsp), %rdx
leaq 0x7aca40(%rip), %rcx    # 0x7ae060
cmpl (%rcx,%rdx,4), %eax
jge 0x16cc
movl 0x80(%rsp), %edi
movl 0x64(%rsp), %esi
callq 0x1c70
movl %eax, 0x10(%rsp)
jmp 0x163f
movl 0x10(%rsp), %edx
movslq 0x80(%rsp), %rax
imulq $0xfa0, %rax, %rcx      # imm = 0xFA0
leaq 0xb807(%rip), %rax      # 0xce60
addq %rcx, %rax
movslq 0x64(%rsp), %rcx
movl (%rax,%rcx,4), %eax
addl %eax, %edx
leaq 0x7ac9f3(%rip), %rax    # 0x7ae060
movl %edx, (%rax,%rcx,4)
movl 0x80(%rsp), %esi
notl %esi
movslq 0x64(%rsp), %rdx
leaq 0x7ad97b(%rip), %rcx    # 0x7af000
movl %esi, (%rcx,%rdx,4)
movslq 0x64(%rsp), %rcx
movl (%rax,%rcx,4), %eax
negl %eax
movl %eax, 0x4c(%rsp)
leaq 0x4c(%rsp), %rdi
leaq 0x64(%rsp), %rsi
callq 0x1b10
movq %rax, 0x8(%rsp)
jmp 0x16ac
movq 0x8(%rsp), %rax
movq %rax, 0x50(%rsp)
leaq 0xa0(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x1ab0
jmp 0x16ca
jmp 0x16cc
jmp 0x16ce
leaq 0x70(%rsp), %rdi
callq 0x1cb0
jmp 0x1437
jmp 0x1344
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
cmpl 0x599c(%rip), %eax      # 0x7090
jge 0x172b
movslq 0x48(%rsp), %rcx
leaq 0x7ac95e(%rip), %rax    # 0x7ae060
movl (%rax,%rcx,4), %edx
movslq 0x48(%rsp), %rcx
leaq 0x7ae88f(%rip), %rax    # 0x7affa0
addl (%rax,%rcx,4), %edx
leaq 0x7ae885(%rip), %rax    # 0x7affa0
movl %edx, (%rax,%rcx,4)
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0x16ea
movslq 0xc0(%rsp), %rcx
leaq 0x7ac926(%rip), %rax    # 0x7ae060
movl (%rax,%rcx,4), %eax
movl %eax, 0x4(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x1cd0
movl 0x4(%rsp), %eax
addq $0xc8, %rsp
retq
movq 0x88(%rsp), %rdi
callq 0x10c0
nopw (%rax,%rax)