// File: fpavetic[P]lcskpp/lcskpp.cpp
// Function: valid_lcskpp(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, int, int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>> const&)
bool valid_lcskpp(const string& a, const string& b,
                  const int k, const int lcskpp_len,
                  const vector<pair<int, int> >& lcskpp_recon) {
  // 1) Ensure correct length.
  if (lcskpp_len != lcskpp_recon.size()) {
    return false;
  }

  // 2) Ensure chars corresponding to the indices match.
  for (auto match: lcskpp_recon) {
    int i = match.first;
    int j = match.second;
    
    if (i < 0 || i >= a.size()) { return false; }
    if (j < 0 || j >= b.size()) { return false; }
    if (a[i] != b[j]) { return false; }
  }

  // 3) Ensure runs of indices have at least length of k.
  int run_a = 1;
  int run_b = 1;
  for (size_t i = 1; i < lcskpp_recon.size(); ++i) {
    if (lcskpp_recon[i-1].first >= lcskpp_recon[i].first) { return false; }
    if (lcskpp_recon[i-1].second >= lcskpp_recon[i].second) { return false; }

    if (lcskpp_recon[i-1].first+1 == lcskpp_recon[i].first) { ++run_a; }
    if (lcskpp_recon[i-1].second+1 == lcskpp_recon[i].second) { ++run_b; }

    if (i+1 == lcskpp_recon.size() || 
        lcskpp_recon[i-1].first+1 != lcskpp_recon[i].first) {
      if (run_a < k) { return false; }
      run_a = 1;
    }

    if (i+1 == lcskpp_recon.size() ||
        lcskpp_recon[i-1].second+1 != lcskpp_recon[i].second) {
      if (run_b < k) { return false; }
      run_b = 1;
    }
  }

  return true;
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movl %edx, 0x9c(%rsp)
movl %ecx, 0x98(%rsp)
movq %r8, 0x90(%rsp)
movslq 0x98(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x90(%rsp), %rdi
callq 0x7350
movq %rax, %rcx
movq 0x50(%rsp), %rax
cmpq %rcx, %rax
je 0x63b1
movb $0x0, 0xb7(%rsp)
jmp 0x6779
movq 0x90(%rsp), %rax
movq %rax, 0x88(%rsp)
movq 0x88(%rsp), %rdi
callq 0x7370
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rdi
callq 0x73a0
movq %rax, 0x78(%rsp)
leaq 0x80(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x73d0
testb $0x1, %al
jne 0x6403
jmp 0x64f2
leaq 0x80(%rsp), %rdi
callq 0x7410
movq (%rax), %rax
movq %rax, 0x70(%rsp)
movl 0x70(%rsp), %eax
movl %eax, 0x6c(%rsp)
movl 0x74(%rsp), %eax
movl %eax, 0x68(%rsp)
cmpl $0x0, 0x6c(%rsp)
jl 0x6453
movslq 0x6c(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0xa8(%rsp), %rdi
callq 0x2110
movq %rax, %rcx
movq 0x48(%rsp), %rax
cmpq %rcx, %rax
jb 0x6460
movb $0x0, 0xb7(%rsp)
jmp 0x6779
cmpl $0x0, 0x68(%rsp)
jl 0x648b
movslq 0x68(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0xa0(%rsp), %rdi
callq 0x2110
movq %rax, %rcx
movq 0x40(%rsp), %rax
cmpq %rcx, %rax
jb 0x6498
movb $0x0, 0xb7(%rsp)
jmp 0x6779
movq 0xa8(%rsp), %rdi
movslq 0x6c(%rsp), %rsi
callq 0x21a0
movsbl (%rax), %eax
movl %eax, 0x3c(%rsp)
movq 0xa0(%rsp), %rdi
movslq 0x68(%rsp), %rsi
callq 0x21a0
movq %rax, %rcx
movl 0x3c(%rsp), %eax
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x64de
movb $0x0, 0xb7(%rsp)
jmp 0x6779
jmp 0x64e0
leaq 0x80(%rsp), %rdi
callq 0x7420
jmp 0x63e8
movl $0x1, 0x64(%rsp)
movl $0x1, 0x60(%rsp)
movq $0x1, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x90(%rsp), %rdi
callq 0x7350
movq %rax, %rcx
movq 0x30(%rsp), %rax
cmpq %rcx, %rax
jae 0x6771
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
subq $0x1, %rsi
callq 0x7440
movl (%rax), %eax
movl %eax, 0x2c(%rsp)
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x7440
movq %rax, %rcx
movl 0x2c(%rsp), %eax
cmpl (%rcx), %eax
jl 0x6579
movb $0x0, 0xb7(%rsp)
jmp 0x6779
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
subq $0x1, %rsi
callq 0x7440
movl 0x4(%rax), %eax
movl %eax, 0x28(%rsp)
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x7440
movq %rax, %rcx
movl 0x28(%rsp), %eax
cmpl 0x4(%rcx), %eax
jl 0x65c1
movb $0x0, 0xb7(%rsp)
jmp 0x6779
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
subq $0x1, %rsi
callq 0x7440
movl (%rax), %eax
addl $0x1, %eax
movl %eax, 0x24(%rsp)
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x7440
movq %rax, %rcx
movl 0x24(%rsp), %eax
cmpl (%rcx), %eax
jne 0x6608
movl 0x64(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x64(%rsp)
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
subq $0x1, %rsi
callq 0x7440
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, 0x20(%rsp)
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x7440
movq %rax, %rcx
movl 0x20(%rsp), %eax
cmpl 0x4(%rcx), %eax
jne 0x6651
movl 0x60(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x60(%rsp)
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x18(%rsp)
movq 0x90(%rsp), %rdi
callq 0x7350
movq %rax, %rcx
movq 0x18(%rsp), %rax
cmpq %rcx, %rax
je 0x66b5
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
subq $0x1, %rsi
callq 0x7440
movl (%rax), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x7440
movq %rax, %rcx
movl 0x14(%rsp), %eax
cmpl (%rcx), %eax
je 0x66d7
movl 0x64(%rsp), %eax
cmpl 0x9c(%rsp), %eax
jge 0x66cf
movb $0x0, 0xb7(%rsp)
jmp 0x6779
movl $0x1, 0x64(%rsp)
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x8(%rsp)
movq 0x90(%rsp), %rdi
callq 0x7350
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
je 0x673d
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
subq $0x1, %rsi
callq 0x7440
movl 0x4(%rax), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
movq 0x90(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0x7440
movq %rax, %rcx
movl 0x4(%rsp), %eax
cmpl 0x4(%rcx), %eax
je 0x675c
movl 0x60(%rsp), %eax
cmpl 0x9c(%rsp), %eax
jge 0x6754
movb $0x0, 0xb7(%rsp)
jmp 0x6779
movl $0x1, 0x60(%rsp)
jmp 0x675e
movq 0x58(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x58(%rsp)
jmp 0x650b
movb $0x1, 0xb7(%rsp)
movb 0xb7(%rsp), %al
andb $0x1, %al
addq $0xb8, %rsp
retq
nopw (%rax,%rax)