// File: todo314[P]pruned-monte-carlo/src/pmc.cpp
// Function: PrunedEstimater::init(int, std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>>&, std::vector<int, std::allocator<int>>&)
void PrunedEstimater::init(const int _n, vector<pair<int, int> > &_es,
		vector<int> &_comp) {
	flag = true;
	n = _n;
	n1 = _comp.size();

	visited.resize(n, false);

	int m = _es.size();
	vector<int> outdeg(n), indeg(n);

	for (int i = 0; i < m; i++) {
		int a = _es[i].first, b = _es[i].second;
		outdeg[a]++;
		indeg[b]++;
	}
	es.resize(m, -1);
	rs.resize(m, -1);

	at_e.resize(n + 1, 0);
	at_r.resize(n + 1, 0);

	at_e[0] = at_r[0] = 0;
	for (int i = 1; i <= n; i++) {
		at_e[i] = at_e[i - 1] + outdeg[i - 1];
		at_r[i] = at_r[i - 1] + indeg[i - 1];
	}

	for (int i = 0; i < m; i++) {
		int a = _es[i].first, b = _es[i].second;
		es[at_e[a]++] = b;
		rs[at_r[b]++] = a;
	}

	at_e[0] = at_r[0] = 0;
	for (int i = 1; i <= n; i++) {
		at_e[i] = at_e[i - 1] + outdeg[i - 1];
		at_r[i] = at_r[i - 1] + indeg[i - 1];
	}

	sigmas.resize(n);
	comp = _comp;
	vector<pair<int, int> > ps;
	for (int i = 0; i < n1; i++) {
		ps.push_back(make_pair(comp[i], i));
	}
	sort(ps.begin(), ps.end());
	at_p.resize(n + 1);
	for (int i = 0; i < n1; i++) {
		pmoc.push_back(ps[i].second);
		at_p[ps[i].first + 1]++;
	}
	for (int i = 1; i <= n; i++) {
		at_p[i] += at_p[i - 1];
	}

	memo.resize(n);
	removed.resize(n);

	weight.resize(n1, 0);
	for (int i = 0; i < n1; i++) {
		weight[comp[i]]++;
	}

	first();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x190, %rsp            # imm = 0x190
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x108(%rbp)
movb $0x1, 0x1c8(%rax)
movl -0xc(%rbp), %ecx
movl %ecx, (%rax)
movq -0x20(%rbp), %rdi
callq 0x71f0
movq %rax, %rcx
movq -0x108(%rbp), %rax
movl %ecx, 0x4(%rax)
movq %rax, %rdi
addq $0x148, %rdi            # imm = 0x148
movslq (%rax), %rsi
xorl %edx, %edx
callq 0x7210
movq -0x18(%rbp), %rdi
callq 0x7330
movq %rax, %rcx
movq -0x108(%rbp), %rax
movl %ecx, -0x24(%rbp)
movslq (%rax), %rax
movq %rax, -0x100(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x2c70
movq -0x100(%rbp), %rsi
movq -0xf8(%rbp), %rdx
leaq -0x40(%rbp), %rdi
callq 0x7350
jmp 0x3c64
leaq -0x41(%rbp), %rdi
callq 0x3b90
movq -0x108(%rbp), %rax
movslq (%rax), %rax
movq %rax, -0x118(%rbp)
leaq -0x71(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x2c70
movq -0x118(%rbp), %rsi
movq -0x110(%rbp), %rdx
leaq -0x70(%rbp), %rdi
callq 0x7350
jmp 0x3ca7
leaq -0x71(%rbp), %rdi
callq 0x3b90
movl $0x0, -0x78(%rbp)
movl -0x78(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x3d4f
movq -0x18(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x73c0
movl (%rax), %eax
movl %eax, -0x7c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x78(%rbp), %rsi
callq 0x73c0
movl 0x4(%rax), %eax
movl %eax, -0x80(%rbp)
movslq -0x7c(%rbp), %rsi
leaq -0x40(%rbp), %rdi
callq 0x29c0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movslq -0x80(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x29c0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0x78(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x78(%rbp)
jmp 0x3cb7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x41(%rbp), %rdi
callq 0x3b90
jmp 0x4526
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x71(%rbp), %rdi
callq 0x3b90
jmp 0x451d
movq -0x108(%rbp), %rdi
addq $0xe8, %rdi
movslq -0x24(%rbp), %rsi
movl $0xffffffff, -0x84(%rbp) # imm = 0xFFFFFFFF
leaq -0x84(%rbp), %rdx
callq 0x73e0
jmp 0x3d79
movq -0x108(%rbp), %rdi
addq $0x100, %rdi            # imm = 0x100
movslq -0x24(%rbp), %rsi
movl $0xffffffff, -0x88(%rbp) # imm = 0xFFFFFFFF
leaq -0x88(%rbp), %rdx
callq 0x73e0
jmp 0x3da3
movq -0x108(%rbp), %rax
movq %rax, %rdi
addq $0x118, %rdi            # imm = 0x118
movl (%rax), %eax
incl %eax
movslq %eax, %rsi
movl $0x0, -0x8c(%rbp)
leaq -0x8c(%rbp), %rdx
callq 0x73e0
jmp 0x3dd3
movq -0x108(%rbp), %rax
movq %rax, %rdi
addq $0x130, %rdi            # imm = 0x130
movl (%rax), %eax
incl %eax
movslq %eax, %rsi
movl $0x0, -0x90(%rbp)
leaq -0x90(%rbp), %rdx
callq 0x73e0
jmp 0x3e03
movq -0x108(%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
xorl %eax, %eax
movl %eax, %esi
callq 0x29c0
movq -0x108(%rbp), %rdi
movl $0x0, (%rax)
addq $0x118, %rdi            # imm = 0x118
xorl %eax, %eax
movl %eax, %esi
callq 0x29c0
movl $0x0, (%rax)
movl $0x1, -0x94(%rbp)
movq -0x108(%rbp), %rcx
movl -0x94(%rbp), %eax
cmpl (%rcx), %eax
jg 0x3f5f
movq -0x108(%rbp), %rdi
addq $0x118, %rdi            # imm = 0x118
movl -0x94(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x29c0
movl (%rax), %eax
movl %eax, -0x128(%rbp)
movl -0x94(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x29c0
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl -0x128(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x124(%rbp)
addq $0x118, %rdi            # imm = 0x118
movslq -0x94(%rbp), %rsi
callq 0x29c0
movl -0x124(%rbp), %ecx
movq -0x108(%rbp), %rdi
movl %ecx, (%rax)
addq $0x130, %rdi            # imm = 0x130
movl -0x94(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x29c0
movl (%rax), %eax
movl %eax, -0x120(%rbp)
movl -0x94(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x29c0
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl -0x120(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x11c(%rbp)
addq $0x130, %rdi            # imm = 0x130
movslq -0x94(%rbp), %rsi
callq 0x29c0
movl -0x11c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x3e47
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x4514
movl $0x0, -0x98(%rbp)
movl -0x98(%rbp), %eax
cmpl -0x24(%rbp), %eax
jge 0x406f
movq -0x18(%rbp), %rdi
movslq -0x98(%rbp), %rsi
callq 0x73c0
movl (%rax), %eax
movl %eax, -0x9c(%rbp)
movq -0x18(%rbp), %rdi
movslq -0x98(%rbp), %rsi
callq 0x73c0
movq -0x108(%rbp), %rdi
movl 0x4(%rax), %eax
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
movl %eax, -0x13c(%rbp)
movq %rdi, %rax
addq $0xe8, %rax
movq %rax, -0x148(%rbp)
addq $0x118, %rdi            # imm = 0x118
movslq -0x9c(%rbp), %rsi
callq 0x29c0
movq -0x148(%rbp), %rdi
movq %rax, %rcx
movl (%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, (%rcx)
movslq %eax, %rsi
callq 0x29c0
movl -0x13c(%rbp), %ecx
movq -0x108(%rbp), %rdi
movl %ecx, (%rax)
movl -0x9c(%rbp), %eax
movl %eax, -0x12c(%rbp)
movq %rdi, %rax
addq $0x100, %rax            # imm = 0x100
movq %rax, -0x138(%rbp)
addq $0x130, %rdi            # imm = 0x130
movslq -0xa0(%rbp), %rsi
callq 0x29c0
movq -0x138(%rbp), %rdi
movq %rax, %rcx
movl (%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, (%rcx)
movslq %eax, %rsi
callq 0x29c0
movl -0x12c(%rbp), %ecx
movl %ecx, (%rax)
movl -0x98(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0x3f69
movq -0x108(%rbp), %rdi
addq $0x130, %rdi            # imm = 0x130
xorl %eax, %eax
movl %eax, %esi
callq 0x29c0
movq -0x108(%rbp), %rdi
movl $0x0, (%rax)
addq $0x118, %rdi            # imm = 0x118
xorl %eax, %eax
movl %eax, %esi
callq 0x29c0
movl $0x0, (%rax)
movl $0x1, -0xa4(%rbp)
movq -0x108(%rbp), %rcx
movl -0xa4(%rbp), %eax
cmpl (%rcx), %eax
jg 0x41ba
movq -0x108(%rbp), %rdi
addq $0x118, %rdi            # imm = 0x118
movl -0xa4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x29c0
movl (%rax), %eax
movl %eax, -0x158(%rbp)
movl -0xa4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x40(%rbp), %rdi
callq 0x29c0
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl -0x158(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x154(%rbp)
addq $0x118, %rdi            # imm = 0x118
movslq -0xa4(%rbp), %rsi
callq 0x29c0
movl -0x154(%rbp), %ecx
movq -0x108(%rbp), %rdi
movl %ecx, (%rax)
addq $0x130, %rdi            # imm = 0x130
movl -0xa4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x29c0
movl (%rax), %eax
movl %eax, -0x150(%rbp)
movl -0xa4(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x29c0
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl -0x150(%rbp), %eax
addl (%rcx), %eax
movl %eax, -0x14c(%rbp)
addq $0x130, %rdi            # imm = 0x130
movslq -0xa4(%rbp), %rsi
callq 0x29c0
movl -0x14c(%rbp), %ecx
movl %ecx, (%rax)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x40b3
movq -0x108(%rbp), %rax
movq %rax, %rdi
addq $0x38, %rdi
movslq (%rax), %rsi
callq 0x7490
jmp 0x41d2
movq -0x108(%rbp), %rdi
movq -0x20(%rbp), %rsi
addq $0x20, %rdi
callq 0x7520
jmp 0x41e8
leaq -0xc0(%rbp), %rdi
callq 0x7770
movl $0x0, -0xc4(%rbp)
movq -0x108(%rbp), %rcx
movl -0xc4(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x4296
movq -0x108(%rbp), %rdi
addq $0x20, %rdi
movslq -0xc4(%rbp), %rsi
callq 0x29c0
movq %rax, %rdi
leaq -0xc4(%rbp), %rsi
callq 0x2940
movq %rax, -0x160(%rbp)
jmp 0x4243
movq -0x160(%rbp), %rax
movq %rax, -0xcc(%rbp)
leaq -0xc0(%rbp), %rdi
leaq -0xcc(%rbp), %rsi
callq 0x7790
jmp 0x4266
jmp 0x4268
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x41fe
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x78d0
jmp 0x4514
leaq -0xc0(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x7800
movq -0x168(%rbp), %rdi
movq %rax, -0xd8(%rbp)
callq 0x7830
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0x77c0
jmp 0x42d8
movq -0x108(%rbp), %rax
movq %rax, %rdi
addq $0x68, %rdi
movl (%rax), %eax
incl %eax
movslq %eax, %rsi
callq 0x7490
jmp 0x42f4
movl $0x0, -0xe4(%rbp)
movq -0x108(%rbp), %rcx
movl -0xe4(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x43a2
movq -0x108(%rbp), %rax
addq $0x50, %rax
movq %rax, -0x170(%rbp)
movslq -0xe4(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x73c0
movq -0x170(%rbp), %rdi
movq %rax, %rsi
addq $0x4, %rsi
callq 0x7860
jmp 0x434e
movq -0x108(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x178(%rbp)
movslq -0xe4(%rbp), %rsi
leaq -0xc0(%rbp), %rdi
callq 0x73c0
movq -0x178(%rbp), %rdi
movl (%rax), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x29c0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0x42fe
movl $0x1, -0xe8(%rbp)
movq -0x108(%rbp), %rcx
movl -0xe8(%rbp), %eax
cmpl (%rcx), %eax
jg 0x4413
movq -0x108(%rbp), %rdi
addq $0x68, %rdi
movl -0xe8(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x29c0
movq -0x108(%rbp), %rdi
movl (%rax), %eax
movl %eax, -0x17c(%rbp)
addq $0x68, %rdi
movslq -0xe8(%rbp), %rsi
callq 0x29c0
movl -0x17c(%rbp), %ecx
addl (%rax), %ecx
movl %ecx, (%rax)
movl -0xe8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe8(%rbp)
jmp 0x43ac
movq -0x108(%rbp), %rax
movq %rax, %rdi
addq $0x98, %rdi
movslq (%rax), %rsi
xorl %edx, %edx
callq 0x7210
jmp 0x4430
movq -0x108(%rbp), %rax
movq %rax, %rdi
addq $0xc0, %rdi
movslq (%rax), %rsi
xorl %edx, %edx
callq 0x7210
jmp 0x444d
movq -0x108(%rbp), %rax
movq %rax, %rdi
addq $0x8, %rdi
movslq 0x4(%rax), %rsi
movl $0x0, -0xec(%rbp)
leaq -0xec(%rbp), %rdx
callq 0x73e0
jmp 0x4477
movl $0x0, -0xf0(%rbp)
movq -0x108(%rbp), %rcx
movl -0xf0(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x44df
movq -0x108(%rbp), %rdi
movq %rdi, %rax
addq $0x8, %rax
movq %rax, -0x188(%rbp)
addq $0x20, %rdi
movslq -0xf0(%rbp), %rsi
callq 0x29c0
movq -0x188(%rbp), %rdi
movslq (%rax), %rsi
callq 0x29c0
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movl -0xf0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xf0(%rbp)
jmp 0x4481
movq -0x108(%rbp), %rdi
callq 0x4530
jmp 0x44ed
leaq -0xc0(%rbp), %rdi
callq 0x78d0
leaq -0x70(%rbp), %rdi
callq 0x29e0
leaq -0x40(%rbp), %rdi
callq 0x29e0
addq $0x190, %rsp            # imm = 0x190
popq %rbp
retq
leaq -0x70(%rbp), %rdi
callq 0x29e0
leaq -0x40(%rbp), %rdi
callq 0x29e0
movq -0x50(%rbp), %rdi
callq 0x2280
nop