// File: /workspace/github_cpp_makefile_star2_O3/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, 0x3c(%rsp)
movl %ecx, 0x7c(%rsp)
movq %rsi, %r15
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 0x4113
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
shlq $0x4, %rcx
xorl %edx, %edx
xorl %esi, %esi
movl (%r14,%rdx), %edi
movl 0x4(%r14,%rdx), %r8d
cmpl %r8d, %edi
cmovgl %edi, %r8d
incl %r8d
cmpl %r8d, %esi
cmovlel %r8d, %esi
movl %esi, (%r15)
addq $0x10, %rdx
cmpq %rdx, %rcx
jne 0x40ed
cmpq %rbx, %r14
je 0x413f
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x69c7
movq %r14, %rdi
movq %rbx, %rsi
callq 0x6a7a
movl 0x4(%r15), %eax
leaq 0x8(%r15), %r13
movslq %eax, %rsi
movq %r13, %rdi
callq 0x4e76
leaq 0x38(%r15), %rdi
movslq 0x4(%r15), %rsi
movq %rdi, 0xa8(%rsp)
callq 0x4e76
leaq 0x20(%r15), %rdi
movslq (%r15), %rsi
incq %rsi
movq %rdi, 0x30(%rsp)
callq 0x4e76
leaq 0x50(%r15), %rdi
movslq (%r15), %rsi
incq %rsi
movq %rdi, 0x88(%rsp)
callq 0x4e76
movq %r15, 0x80(%rsp)
movl 0x3c(%rsp), %ebp
movslq %ebp, %rbx
leaq 0xc0(%rsp), %rdi
leaq 0x10(%rsp), %rdx
movq %rbx, %rsi
callq 0x4f8c
xorpd %xmm0, %xmm0
movq (%rsp), %rax
movupd %xmm0, (%rax)
movq $0x0, 0x10(%rax)
movl %ebp, %eax
movq %rax, 0xa0(%rsp)
movq 0x80(%rsp), %rbp
testl %ebx, %ebx
jle 0x4650
xorl %ebx, %ebx
leaq 0x10(%rsp), %r14
movslq (%rbp), %rsi
incq %rsi
movl $0x0, 0x10(%rsp)
movq 0x30(%rsp), %rdi
movq %r14, %rdx
callq 0x714a
movslq (%rbp), %rsi
incq %rsi
movl $0x0, 0x10(%rsp)
movq 0x88(%rsp), %rdi
movq %r14, %rdx
callq 0x714a
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl 0x4(%rbp), %eax
testl %eax, %eax
movq %rbx, 0x90(%rsp)
jle 0x4459
movl %ebx, %ecx
shrl $0x1e, %ecx
xorl %ebx, %ecx
imull $0x6c078965, %ecx, %edi # imm = 0x6C078965
incl %edi
movl %edi, %ecx
sarl $0x1e, %ecx
xorl %edi, %ecx
imull $0x6c078965, %ecx, %r12d # imm = 0x6C078965
addl $0x2, %r12d
movl %r12d, %ecx
sarl $0x1e, %ecx
xorl %r12d, %ecx
imull $0x6c078965, %ecx, %r14d # imm = 0x6C078965
addl $0x3, %r14d
movl %r14d, %ecx
sarl $0x1e, %ecx
xorl %r14d, %ecx
imull $0x6c078965, %ecx, %r15d # imm = 0x6C078965
addl $0x4, %r15d
xorl %ebp, %ebp
xorl %ebx, %ebx
movl $0x0, 0xc(%rsp)
movl %edi, %ecx
movl %r14d, %edi
movl %r12d, %edx
shll $0xb, %edx
xorl %r12d, %edx
movl %r15d, %r12d
movl %ecx, %r14d
shll $0xb, %r14d
xorl %ecx, %r14d
movl %r15d, %ecx
shrl $0x13, %ecx
xorl %r14d, %ecx
shrl $0x8, %r14d
xorl %ecx, %r14d
xorl %r15d, %r14d
movl %r14d, %ecx
shrl $0x5, %ecx
movl %r14d, %esi
shrl $0x13, %esi
movl %edx, %r15d
shrl $0x8, %r15d
xorl %edx, %r15d
xorl %r14d, %r15d
xorl %esi, %r15d
movl %r15d, %edx
shrl $0x6, %edx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
xorps %xmm1, %xmm1
cvtsi2sd %edx, %xmm1
mulsd 0x3d65(%rip), %xmm0     # 0x8068
addsd %xmm1, %xmm0
mulsd 0x3d61(%rip), %xmm0     # 0x8070
movq 0xb0(%rsp), %rcx
movq (%rcx), %rcx
movsd 0x8(%rcx,%rbp), %xmm1
ucomisd %xmm0, %xmm1
jbe 0x43a4
movl %r12d, 0x98(%rsp)
movl %edi, 0x9c(%rsp)
movl 0x4(%rcx,%rbp), %eax
movq %r13, %rsi
movl 0xc(%rsp), %r13d
movslq %r13d, %rdx
movq %rsi, %r12
movq (%rsi), %rsi
movl %eax, (%rsi,%rdx,4)
movslq (%rcx,%rbp), %rax
movq 0x30(%rsp), %rdx
movq (%rdx), %rdx
incl 0x4(%rdx,%rax,4)
movl (%rcx,%rbp), %eax
movl 0x4(%rcx,%rbp), %ecx
shlq $0x20, %rax
orq %rcx, %rax
movq %rax, 0x40(%rsp)
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x5ea4
incl %r13d
movl %r13d, 0xc(%rsp)
movq 0x80(%rsp), %rax
movl 0x4(%rax), %eax
movq %r12, %r13
movl 0x9c(%rsp), %edi
movl 0x98(%rsp), %r12d
incq %rbx
movslq %eax, %rcx
addq $0x10, %rbp
cmpq %rcx, %rbx
jl 0x429d
movq 0x10(%rsp), %rbx
movq 0x18(%rsp), %r12
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl $0x0, (%rax)
cmpq %r12, %rbx
je 0x4401
movq %r12, %rax
subq %rbx, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6021
movq %rbx, %rdi
movq %r12, %rsi
callq 0x60d4
movl 0xc(%rsp), %esi
testl %esi, %esi
movq 0x80(%rsp), %rbp
movq 0x90(%rsp), %rbx
leaq 0x10(%rsp), %r14
jle 0x4467
movq 0x10(%rsp), %rax
movq 0xa8(%rsp), %rcx
movq (%rcx), %rcx
movq 0x88(%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 0x443d
jmp 0x4467
movq 0x30(%rsp), %rax
movq (%rax), %rax
movl $0x0, (%rax)
movslq (%rbp), %rsi
testq %rsi, %rsi
jle 0x449f
movq 0x30(%rsp), %rax
movq (%rax), %rax
movq 0x88(%rsp), %rcx
movq (%rcx), %rcx
xorl %edx, %edx
movl (%rax,%rdx,4), %esi
addl %esi, 0x4(%rax,%rdx,4)
movl (%rcx,%rdx,4), %esi
addl %esi, 0x4(%rcx,%rdx,4)
movslq (%rbp), %rsi
incq %rdx
cmpq %rsi, %rdx
jl 0x4485
leaq 0x40(%rsp), %r15
movq %r15, %rdi
leaq 0x60(%rsp), %rdx
callq 0x4db6
movq %rbp, %rdi
movq %r15, %rsi
callq 0x4898
movl %eax, 0xc(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x60(%rsp)
movq $0x0, 0x70(%rsp)
movl (%rbp), %ecx
testl %ecx, %ecx
jle 0x45ac
movq 0x30(%rsp), %rax
movq (%rax), %rax
xorl %ebx, %ebx
movq %rbx, %rdx
movslq (%rax,%rbx,4), %r14
incq %rbx
cmpl 0x4(%rax,%rdx,4), %r14d
jge 0x454f
movq 0x40(%rsp), %rcx
movl (%rcx,%rdx,4), %r15d
movq (%r13), %rcx
movslq (%rcx,%r14,4), %rcx
movq 0x40(%rsp), %rdx
movl (%rdx,%rcx,4), %ecx
cmpl %ecx, %r15d
je 0x4540
shlq $0x20, %rcx
orq %r15, %rcx
movq %rcx, 0xb8(%rsp)
leaq 0x60(%rsp), %rdi
leaq 0xb8(%rsp), %rsi
callq 0x5ea4
movq 0x30(%rsp), %rax
movq (%rax), %rax
incq %r14
movslq (%rax,%rbx,4), %rcx
cmpq %rcx, %r14
jl 0x4502
movl (%rbp), %ecx
movslq %ecx, %rdx
cmpq %rdx, %rbx
jl 0x44e8
movq 0x60(%rsp), %r15
movq 0x68(%rsp), %r12
cmpq %r12, %r15
je 0x45b4
movq %r12, %rax
subq %r15, %rax
sarq $0x3, %rax
bsrq %rax, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x6021
movq 0x90(%rsp), %rbx
leaq 0x10(%rsp), %r14
movq %r15, %rdi
movq %r12, %rsi
callq 0x60d4
movq 0x60(%rsp), %r15
movq 0x68(%rsp), %r12
jmp 0x45c1
xorl %r12d, %r12d
xorl %r15d, %r15d
jmp 0x45c1
movq 0x90(%rsp), %rbx
leaq 0x10(%rsp), %r14
movq %r15, %rdi
movq %r12, %rsi
callq 0x767e
cmpq %rax, 0x68(%rsp)
je 0x45d8
movq %rax, 0x68(%rsp)
imulq $0x1d0, %rbx, %rdi      # imm = 0x1D0
addq 0xc0(%rsp), %rdi
movl 0xc(%rsp), %esi
leaq 0x60(%rsp), %rdx
leaq 0x40(%rsp), %rcx
callq 0x29c8
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x4611
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x4628
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x463f
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
incq %rbx
cmpq 0xa0(%rsp), %rbx
jne 0x41e7
movslq (%rbp), %rsi
leaq 0x10(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x500a
xorpd %xmm0, %xmm0
movapd %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
cmpl $0x0, 0x7c(%rsp)
jle 0x479f
imulq $0x1d0, 0xa0(%rsp), %r15 # imm = 0x1D0
xorl %r13d, %r13d
leaq 0x10(%rsp), %rbx
leaq 0x40(%rsp), %r14
leaq 0x60(%rsp), %r12
cmpl $0x0, 0x3c(%rsp)
jle 0x46c7
xorl %ebp, %ebp
movq 0xc0(%rsp), %rdi
addq %rbp, %rdi
movq %rbx, %rsi
callq 0x383e
addq $0x1d0, %rbp            # imm = 0x1D0
cmpq %rbp, %r15
jne 0x46a8
movl $0x0, 0x60(%rsp)
movq 0x80(%rsp), %rax
movslq (%rax), %rax
testq %rax, %rax
jle 0x4705
xorl %edx, %edx
movq 0x10(%rsp), %rsi
xorl %ecx, %ecx
movq (%rsi,%rdx,8), %rdi
movslq %ecx, %r8
cmpq (%rsi,%r8,8), %rdi
jle 0x46fb
movl %edx, 0x60(%rsp)
movl %edx, %ecx
incq %rdx
cmpq %rdx, %rax
jne 0x46e8
jmp 0x4707
xorl %ecx, %ecx
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x4720
movl %ecx, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x472b
movq %r14, %rdi
movq %r12, %rdx
callq 0x6498
cmpl $0x0, 0x3c(%rsp)
jle 0x4754
xorl %ebp, %ebp
movq 0xc0(%rsp), %rdi
addq %rbp, %rdi
movl 0x60(%rsp), %esi
callq 0x38fa
addq $0x1d0, %rbp            # imm = 0x1D0
cmpq %rbp, %r15
jne 0x4734
movq (%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x4772
movl 0x60(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rdi)
jmp 0x477a
movq %r12, %rdx
callq 0x6498
incl %r13d
cmpl 0x7c(%rsp), %r13d
jne 0x469f
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x479f
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x47b6
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xc0(%rsp), %rdi
callq 0x5098
movq (%rsp), %rax
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x47ea
jmp 0x47f8
jmp 0x47f1
jmp 0x481e
jmp 0x47f1
movq %rax, %rbx
jmp 0x4838
jmp 0x47ea
movq %rax, %rbx
jmp 0x486a
jmp 0x481e
movq %rax, %rbx
jmp 0x484f
jmp 0x47f8
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x4812
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
jne 0x485d
jmp 0x486a
movq %rax, %rbx
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x4838
movq 0x70(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x484f
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq (%rsp), %rax
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x486e
movq 0x20(%rsp), %rsi
subq %rdi, %rsi
callq 0x2170
movq (%rsp), %rax
movq (%rax), %rdi
testq %rdi, %rdi
je 0x4882
movq 0x10(%rax), %rsi
subq %rdi, %rsi
callq 0x2170
leaq 0xc0(%rsp), %rdi
callq 0x5098
movq %rbx, %rdi
callq 0x2200
nop