// File: kmyk[P]codevs-for-student-2016/Main.cpp
// Function: std::pair<int, std::vector<point_t, std::allocator<point_t>>> simulation::apply_erases<19ul, 10ul>(primitive::blocks_t<19ul, 10ul> const&, std::vector<std::pair<point_t, int>, std::allocator<std::pair<point_t, int>>> const&)
pair<int, vector<point_t> > apply_erases(blocks_t<H,W> const & field, vector<pair<point_t,int> > const & erases) {
        static const int dy[] = { -1, -1, 0, 1 }; // 下 右下 右 右上
        static const int dx[] = {  0,  1, 1, 1 };
        int erase_count = 0;
        vector<point_t> used;
        for (auto && it : erases) {
            point_t p; int j; tie(p, j) = it;
            int cnt = 0, acc = 0;
            for (; acc != erasing_sum; ++ cnt) {
                acc += field.at[p.x][p.y];
                used.push_back(p);
                p.y += dy[j];
                p.x += dx[j];
            }
            erase_count += cnt;
        }
        whole(sort, used);
        used.erase(whole(unique, used), used.end());
        return { erase_count, used };
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0xd0(%rbp)
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6770
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1fbe0
movq %rax, -0x48(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1fc10
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1fc40
testb $0x1, %al
jne 0x1cb80
jmp 0x1cc6e
leaq -0x48(%rbp), %rdi
callq 0x1fc80
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movq %rax, -0xd8(%rbp)
leaq -0x78(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x64(%rbp), %rdx
callq 0x1fca0
movq -0xd8(%rbp), %rsi
leaq -0x78(%rbp), %rdi
callq 0x1fce0
movl $0x0, -0x7c(%rbp)
movl $0x0, -0x80(%rbp)
cmpl $0xa, -0x80(%rbp)
je 0x1cc57
movq -0x10(%rbp), %rdi
movslq -0x5c(%rbp), %rsi
callq 0x1d1f0
movq %rax, %rdi
movslq -0x60(%rbp), %rsi
callq 0x1d220
movsbl (%rax), %ecx
movl -0x80(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x80(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1fd40
jmp 0x1cc04
movslq -0x64(%rbp), %rcx
leaq 0x9a21(%rip), %rax      # 0x26630
movl (%rax,%rcx,4), %eax
addl -0x60(%rbp), %eax
movl %eax, -0x60(%rbp)
movslq -0x64(%rbp), %rcx
leaq 0x9a1d(%rip), %rax      # 0x26640
movl (%rax,%rcx,4), %eax
addl -0x5c(%rbp), %eax
movl %eax, -0x5c(%rbp)
movl -0x7c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x7c(%rbp)
jmp 0x1cbc7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x88(%rbp)
movl %eax, -0x8c(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x6850
jmp 0x1cd44
movl -0x7c(%rbp), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x1c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1fdb0
jmp 0x1cb6a
leaq -0x8d(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1fdd0
jmp 0x1cc80
leaq -0xa1(%rbp), %rdi
leaq -0x38(%rbp), %rsi
callq 0x1fea0
movq %rax, -0xe0(%rbp)
jmp 0x1cc99
movq -0xe0(%rbp), %rax
movq %rax, -0xa0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x1fef0
leaq -0x38(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
callq 0x1bc60
movq %rax, -0xb8(%rbp)
leaq -0xb0(%rbp), %rdi
leaq -0xb8(%rbp), %rsi
callq 0x1fef0
movq -0xf0(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0xb0(%rbp), %rdx
callq 0x1fe10
movq %rax, -0xe8(%rbp)
jmp 0x1cd07
movq -0xd0(%rbp), %rdi
movq -0xe8(%rbp), %rax
movq %rax, -0xc0(%rbp)
leaq -0x1c(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x1ff30
jmp 0x1cd2b
leaq -0x38(%rbp), %rdi
callq 0x6850
movq -0xc8(%rbp), %rax
addq $0xf0, %rsp
popq %rbp
retq
movq -0x88(%rbp), %rdi
callq 0x22f0