// File: /workspace/github_cpp_makefile_star2_O1/todo314[P]pruned-monte-carlo/src/pmc.cpp
// Function: InfluenceMaximizer::run(std::vector<std::pair<std::pair<int, int>, double>, std::allocator<std::pair<std::pair<int, int>, double>>>&, int, int)
vector<int> InfluenceMaximizer::run(vector<pair<pair<int, int>, double> > &es,
		const int k, const int R) {
	n = 0;
	m = es.size();
	for (int i = 0; i < (int) es.size(); i++) {
		n = max(n, max(es[i].first.first, es[i].first.second) + 1);
	}

	sort(es.begin(), es.end());

	es1.resize(m);
	rs1.resize(m);
	at_e.resize(n + 1);
	at_r.resize(n + 1);

	vector<PrunedEstimater> infs(R);
	vector<int> seeds;

	for (int t = 0; t < R; t++) {
		Xorshift xs = Xorshift(t);

		int mp = 0;
		at_e.assign(n + 1, 0);
		at_r.assign(n + 1, 0);
		vector<pair<int, int> > ps;
		for (int i = 0; i < m; i++) {
			if (xs.gen_double() < es[i].second) {
				es1[mp++] = es[i].first.second;
				at_e[es[i].first.first + 1]++;
				ps.push_back(make_pair(es[i].first.second, es[i].first.first));
			}
		}
		at_e[0] = 0;
		sort(ps.begin(), ps.end());
		for (int i = 0; i < mp; i++) {
			rs1[i] = ps[i].second;
			at_r[ps[i].first + 1]++;
		}
		for (int i = 1; i <= n; i++) {
			at_e[i] += at_e[i - 1];
			at_r[i] += at_r[i - 1];
		}

		vector<int> comp(n);

		int nscc = scc(comp);

		vector<pair<int, int> > es2;
		for (int u = 0; u < n; u++) {
			int a = comp[u];
			for (int i = at_e[u]; i < at_e[u + 1]; i++) {
				int b = comp[es1[i]];
				if (a != b) {
					es2.push_back(make_pair(a, b));
				}
			}
		}

		sort(es2.begin(), es2.end());
		es2.erase(unique(es2.begin(), es2.end()), es2.end());

		infs[t].init(nscc, es2, comp);
	}

	vector<long long> gain(n);
	vector<int> S;

	for (int t = 0; t < k; t++) {
		for (int j = 0; j < R; j++) {
			infs[j].update(gain);
		}
		int next = 0;
		for (int i = 0; i < n; i++) {
			if (gain[i] > gain[next]) {
				next = i;
			}
		}

		S.push_back(next);
		for (int j = 0; j < R; j++) {
			infs[j].add(next);
		}
		seeds.push_back(next);
	}
	return seeds;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movl %r8d, 0xc(%rsp)
movl %ecx, 0x74(%rsp)
movq %rsi, %r13
movq %rdi, (%rsp)
movl $0x0, (%rsi)
movq (%rdx), %r14
movq %rdx, 0xb0(%rsp)
movq 0x8(%rdx), %rbx
movq %rbx, %rax
subq %r14, %rax
sarq $0x4, %rax
movl %eax, 0x4(%rsi)
testl %eax, %eax
jle 0x418e
movl (%r13), %ecx
movl %eax, %edx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
shlq $0x4, %rdx
xorl %esi, %esi
movl (%r14,%rsi), %edi
movl 0x4(%r14,%rsi), %r8d
cmpl %r8d, %edi
cmovgl %edi, %r8d
incl %r8d
cmpl %r8d, %ecx
cmovlel %r8d, %ecx
movl %ecx, (%r13)
addq $0x10, %rsi
cmpq %rsi, %rdx
jne 0x4167
cmpq %rbx, %r14
je 0x41b6
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6668
movq %r14, %rdi
movq %rbx, %rsi
callq 0x671b
leaq 0x8(%r13), %r15
movslq 0x4(%r13), %rsi
movq %r15, %rdi
callq 0x4f10
leaq 0x38(%r13), %rdi
movslq 0x4(%r13), %rsi
movq %rdi, 0xa0(%rsp)
callq 0x4f10
leaq 0x20(%r13), %r14
movslq (%r13), %rsi
incq %rsi
movq %r14, %rdi
callq 0x4f10
leaq 0x50(%r13), %rdi
movslq (%r13), %rsi
incq %rsi
movq %rdi, 0x78(%rsp)
callq 0x4f10
movl 0xc(%rsp), %ebp
movslq %ebp, %rbx
leaq 0xc0(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq %rbx, %rsi
callq 0x5018
xorpd %xmm0, %xmm0
movq (%rsp), %rax
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl %ebp, %eax
movq %rax, 0x90(%rsp)
testl %ebx, %ebx
movq %r13, 0x80(%rsp)
jle 0x4686
movq %r15, %rbp
xorl %ebx, %ebx
leaq 0x10(%rsp), %r15
movq %rbp, 0x98(%rsp)
movslq (%r13), %rsi
incq %rsi
movl $0x0, 0x10(%rsp)
movq %r14, %rdi
movq %r15, %rdx
callq 0x6e62
movslq (%r13), %rsi
incq %rsi
movl $0x0, 0x10(%rsp)
movq 0x78(%rsp), %rdi
movq %r15, %rdx
callq 0x6e62
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
cmpl $0x0, 0x4(%r13)
movq %rbx, 0xa8(%rsp)
jle 0x442d
movl %ebx, %eax
shrl $0x1e, %eax
xorl %ebx, %eax
imull $0x6c078965, %eax, %esi # imm = 0x6C078965
incl %esi
movl %esi, %eax
sarl $0x1e, %eax
xorl %esi, %eax
imull $0x6c078965, %eax, %r15d # imm = 0x6C078965
addl $0x2, %r15d
movl %r15d, %eax
sarl $0x1e, %eax
xorl %r15d, %eax
imull $0x6c078965, %eax, %r13d # imm = 0x6C078965
addl $0x3, %r13d
movl %r13d, %eax
sarl $0x1e, %eax
xorl %r13d, %eax
imull $0x6c078965, %eax, %r12d # imm = 0x6C078965
addl $0x4, %r12d
xorl %ebp, %ebp
xorl %ebx, %ebx
movl $0x0, 0x8(%rsp)
movl %esi, %eax
movl %r13d, %esi
movl %r15d, %ecx
shll $0xb, %ecx
xorl %r15d, %ecx
movl %r12d, %r15d
movl %eax, %r13d
shll $0xb, %r13d
xorl %eax, %r13d
movl %r12d, %eax
shrl $0x13, %eax
xorl %r13d, %eax
shrl $0x8, %r13d
xorl %eax, %r13d
xorl %r12d, %r13d
movl %r13d, %eax
shrl $0x5, %eax
movl %r13d, %edx
shrl $0x13, %edx
movl %ecx, %r12d
shrl $0x8, %r12d
xorl %ecx, %r12d
xorl %r13d, %r12d
xorl %edx, %r12d
movl %r12d, %ecx
shrl $0x6, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd 0x3cf2(%rip), %xmm0     # 0x8068
addsd %xmm1, %xmm0
mulsd 0x3cee(%rip), %xmm0     # 0x8070
movq 0xb0(%rsp), %rax
movq (%rax), %rax
movsd 0x8(%rax,%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x440f
movl %r15d, 0x88(%rsp)
movl %esi, 0x8c(%rsp)
movl 0x4(%rax,%rbp), %ecx
movq %r14, %rdi
movl 0x8(%rsp), %r14d
movslq %r14d, %rdx
movq 0x98(%rsp), %rsi
movq (%rsi), %rsi
movl %ecx, (%rsi,%rdx,4)
movslq (%rax,%rbp), %rcx
movq %rdi, %r15
movq (%rdi), %rdx
incl 0x4(%rdx,%rcx,4)
movl (%rax,%rbp), %ecx
movl 0x4(%rax,%rbp), %eax
shlq $0x20, %rcx
orq %rax, %rcx
movq %rcx, 0x50(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x5b40
incl %r14d
movl %r14d, 0x8(%rsp)
movq %r15, %r14
movl 0x8c(%rsp), %esi
movl 0x88(%rsp), %r15d
incq %rbx
movq 0x80(%rsp), %rax
movslq 0x4(%rax), %rax
addq $0x10, %rbp
cmpq %rax, %rbx
jl 0x4310
jmp 0x4435
movl $0x0, 0x8(%rsp)
movq (%r14), %rax
movl $0x0, (%rax)
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r15
cmpq %r15, %rbx
je 0x447a
movq %r15, %rax
subq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5cb5
movq %rbx, %rdi
movq %r15, %rsi
callq 0x5d68
movl 0x8(%rsp), %esi
testl %esi, %esi
movq 0x80(%rsp), %r13
movq 0x98(%rsp), %rbp
leaq 0x50(%rsp), %rbx
jle 0x44cd
movq 0x10(%rsp), %rax
movq 0xa0(%rsp), %rcx
movq (%rcx), %rcx
movq 0x78(%rsp), %rdx
movq (%rdx), %rdx
movl %esi, %esi
xorl %edi, %edi
movl 0x4(%rax,%rdi,8), %r8d
movl %r8d, (%rcx,%rdi,4)
movslq (%rax,%rdi,8), %r8
incl 0x4(%rdx,%r8,4)
incq %rdi
cmpq %rdi, %rsi
jne 0x44b3
movl (%r13), %ecx
testl %ecx, %ecx
jle 0x44fc
movq (%r14), %rax
movq 0x78(%rsp), %rcx
movq (%rcx), %rdx
xorl %esi, %esi
movl (%rax,%rsi,4), %ecx
addl %ecx, 0x4(%rax,%rsi,4)
movl (%rdx,%rsi,4), %ecx
addl %ecx, 0x4(%rdx,%rsi,4)
movslq (%r13), %rcx
incq %rsi
cmpq %rcx, %rsi
jl 0x44e2
movslq %ecx, %rsi
movq %rbx, %rdi
leaq 0x30(%rsp), %rdx
callq 0x4e52
movq %r13, %rdi
movq %rbx, %rsi
callq 0x48ce
movl %eax, 0x8(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x30(%rsp)
movq $0x0, 0x40(%rsp)
cmpl $0x0, (%r13)
jle 0x45a2
xorl %ebx, %ebx
movq %rbx, %rax
movq (%r14), %rcx
movslq (%rcx,%rbx,4), %r15
incq %rbx
cmpl 0x4(%rcx,%rax,4), %r15d
jge 0x4599
movq 0x50(%rsp), %rcx
movl (%rcx,%rax,4), %r12d
movq (%rbp), %rax
movslq (%rax,%r15,4), %rax
movq 0x50(%rsp), %rcx
movl (%rcx,%rax,4), %eax
cmpl %eax, %r12d
je 0x458a
shlq $0x20, %rax
orq %r12, %rax
movq %rax, 0xb8(%rsp)
leaq 0x30(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x5b40
incq %r15
movq (%r14), %rax
movslq (%rax,%rbx,4), %rax
cmpq %rax, %r15
jl 0x4554
movslq (%r13), %rax
cmpq %rax, %rbx
jl 0x4537
movq 0x30(%rsp), %rcx
movq 0x38(%rsp), %r12
cmpq %r12, %rcx
movq 0xa8(%rsp), %rbx
leaq 0x10(%rsp), %r15
je 0x45f3
movq %r12, %rax
subq %rcx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rcx, %r15
movq %rcx, %rdi
movq %r12, %rsi
callq 0x5cb5
movq %r15, %rdi
leaq 0x10(%rsp), %r15
movq %r12, %rsi
callq 0x5d68
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x6fcf
cmpq %rax, 0x38(%rsp)
je 0x460e
movq %rax, 0x38(%rsp)
imulq $0x1d0, %rbx, %rdi      # imm = 0x1D0
addq 0xc0(%rsp), %rdi
movl 0x8(%rsp), %esi
leaq 0x30(%rsp), %rdx
leaq 0x50(%rsp), %rcx
callq 0x29c0
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x4647
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x465e
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x4675
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
incq %rbx
cmpq 0x90(%rsp), %rbx
jne 0x425f
movslq (%r13), %rsi
leaq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rdx
callq 0x5096
xorpd %xmm0, %xmm0
movapd %xmm0, 0x50(%rsp)
movq $0x0, 0x60(%rsp)
cmpl $0x0, 0x74(%rsp)
jle 0x47bf
imulq $0x1d0, 0x90(%rsp), %r13 # imm = 0x1D0
xorl %ebp, %ebp
leaq 0x10(%rsp), %rbx
leaq 0x50(%rsp), %r14
leaq 0x30(%rsp), %r12
cmpl $0x0, 0xc(%rsp)
jle 0x46fd
xorl %r15d, %r15d
movq 0xc0(%rsp), %rdi
addq %r15, %rdi
movq %rbx, %rsi
callq 0x389c
addq $0x1d0, %r15            # imm = 0x1D0
cmpq %r15, %r13
jne 0x46de
movl $0x0, 0x30(%rsp)
movq 0x80(%rsp), %rax
movslq (%rax), %rax
testq %rax, %rax
jle 0x473b
movl 0x30(%rsp), %esi
movq 0x10(%rsp), %rcx
xorl %edx, %edx
movq (%rcx,%rdx,8), %rdi
movslq %esi, %r8
cmpq (%rcx,%r8,8), %rdi
jle 0x4733
movl %edx, 0x30(%rsp)
movl %edx, %esi
incq %rdx
cmpq %rdx, %rax
jne 0x4720
movq 0x58(%rsp), %rsi
cmpq 0x60(%rsp), %rsi
je 0x4758
movl 0x30(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x58(%rsp)
jmp 0x4763
movq %r14, %rdi
movq %r12, %rdx
callq 0x6140
cmpl $0x0, 0xc(%rsp)
jle 0x478d
xorl %r15d, %r15d
movq 0xc0(%rsp), %rdi
addq %r15, %rdi
movl 0x30(%rsp), %esi
callq 0x3966
addq $0x1d0, %r15            # imm = 0x1D0
cmpq %r15, %r13
jne 0x476d
movq (%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x47ab
movl 0x30(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x47b3
movq %r12, %rdx
callq 0x6140
incl %ebp
cmpl 0x74(%rsp), %ebp
jne 0x46d4
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x47d6
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x47ed
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xc0(%rsp), %rdi
callq 0x5120
movq (%rsp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x481f
jmp 0x482f
jmp 0x4855
jmp 0x4828
movq %rax, %rbx
jmp 0x486f
jmp 0x481f
movq %rax, %rbx
jmp 0x48a1
jmp 0x4828
jmp 0x4855
movq %rax, %rbx
jmp 0x4886
jmp 0x482f
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x4849
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
jne 0x4894
jmp 0x48a1
movq %rax, %rbx
movq 0x30(%rsp), %rdi
testq %rdi, %rdi
je 0x486f
movq 0x40(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x4886
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq (%rsp), %rax
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x48a5
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq (%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x48b9
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xc0(%rsp), %rdi
callq 0x5120
movq %rbx, %rdi
callq 0x2200