// File: /workspace/github_cpp_makefile_star2_O3/tanakh[P]icfpc2015/main.cpp
// Function: ga(problem const&, int, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
pair<string, int> ga(const problem &p, int seed, int tle, int mle, const string &tag)
{
  int best_score = -1;
  string best_move;

  int num_cands = 10;
  vector<vector<double>> cands;

  for (int i = 0; i < num_cands; i++) {
    vector<double> pp(NUM_FEATURES);
    for (int i = 0; i < (int)pp.size(); i++)
      pp[i] = genrand_real1() - 0.5;
    cands.push_back(pp);
  }

  for (int gen = 0; gen < 10000; gen++) {
    vector<pair<pair<int, string>, vector<double>>> ord;
    for (auto &ncand: cands) {
      auto rr = solve(p, seed, tle, mle, ncand, false);
      ord.emplace_back(make_pair(rr.second, rr.first), ncand);
    }

    int cur_best = -1, cur_best_ix = 0;
    for (int i = 0; i < num_cands; i++) {
      if (ord[i].first.first > cur_best) {
        cur_best = ord[i].first.first;
        cur_best_ix = i;
      }
    }
    cerr << "GEN: " << gen << ", score = " << cur_best << endl;

    if (best_score < cur_best) {
      best_score = ord[cur_best_ix].first.first;
      best_move = ord[cur_best_ix].first.second;

      cerr << "*BEST* " << p.id << "-" << seed << ": " << best_score << endl;
      output_solution(p.id, seed, best_score, best_move, tag);
    }

    vector<vector<double>> next_cands;

    while ((int)next_cands.size() < num_cands) {
      double x = genrand_real1();

      if (x < 0.1) {
        next_cands.push_back(select(ord));
      }
      else if (x < 0.97) {
        if (num_cands - next_cands.size() < 2) continue;

        vector<double> sa = select(ord);
        vector<double> sb = select(ord);

        for (int i = 0; i < (int)sa.size(); i++) {
          if (genrand_real1() < 0.5)
            swap(sa[i], sb[i]);
        }
        next_cands.push_back(sa);
        next_cands.push_back(sb);
      }
      else {
        vector<double> sa = select(ord);
        sa[genrand_int31()%sa.size()] = genrand_real1() - 0.5;
      }
    }

    cands = next_cands;
  }

  return make_pair(best_move, best_score);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movq %r9, 0xd0(%rsp)
movl %edx, 0xc(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdi, 0xc8(%rsp)
leaq 0x80(%rsp), %rax
movq %rax, -0x10(%rax)
xorl %r15d, %r15d
movq %r15, -0x8(%rax)
movb $0x0, (%rax)
leaq 0xb0(%rsp), %rbx
movq %r15, 0x10(%rbx)
xorpd %xmm0, %xmm0
movapd %xmm0, (%rbx)
leaq 0x10(%rsp), %r14
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movl $0x50, %edi
callq 0x3310
movq %rax, 0x10(%rsp)
movq %rax, %rcx
addq $0x50, %rcx
movq %rcx, 0x20(%rsp)
xorpd %xmm0, %xmm0
movupd %xmm0, 0x40(%rax)
movupd %xmm0, 0x30(%rax)
movupd %xmm0, 0x20(%rax)
movupd %xmm0, 0x10(%rax)
movupd %xmm0, (%rax)
movq %rcx, 0x18(%rsp)
xorl %r12d, %r12d
callq 0x3a53
movq %rax, %xmm0
punpckldq 0xc672(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xc67a(%rip), %xmm0     # 0x15020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xc6e6(%rip), %xmm1     # 0x150a0
addsd 0xc716(%rip), %xmm1     # 0x150d8
movq 0x10(%rsp), %rax
movsd %xmm1, (%rax,%r12,8)
incq %r12
movq 0x18(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rax
cmpq %rax, %r12
jl 0x898c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc526
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x89fe
callq 0x32f0
incl %r15d
cmpl $0xa, %r15d
jne 0x893a
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movq $0x0, 0x38(%rsp)
leaq 0x48(%rsp), %r14
leaq 0x90(%rsp), %r12
leaq 0x10(%rsp), %rbx
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movq 0xb0(%rsp), %r13
movq 0xb8(%rsp), %r15
cmpq %r15, %r13
je 0x8af1
movl $0x0, (%rsp)
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
movl 0xc(%rsp), %edx
movq %r13, %r9
callq 0x748f
movl 0x30(%rsp), %eax
movl %eax, 0x48(%rsp)
leaq 0x60(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0xeed8
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xc552
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x8ac6
callq 0x32f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x8ada
callq 0x32f0
addq $0x18, %r13
cmpq %r15, %r13
jne 0x8a60
movq 0x90(%rsp), %rax
jmp 0x8af3
xorl %eax, %eax
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %ecx, %ecx
xorl %r15d, %r15d
movl (%rax), %edx
cmpl %r13d, %edx
cmovgl %edx, %r13d
cmovgl %ecx, %r15d
incq %rcx
addq $0x40, %rax
cmpq $0xa, %rcx
jne 0x8afe
movl $0x5, %edx
movq 0x144c4(%rip), %rdi     # 0x1cfe8
leaq 0xca32(%rip), %rsi      # 0x1555d
callq 0x3350
movq 0x144b1(%rip), %rdi     # 0x1cfe8
movq 0x38(%rsp), %rsi
callq 0x3490
movq %rax, %rbp
movl $0xa, %edx
movq %rax, %rdi
leaq 0xca10(%rip), %rsi      # 0x15563
callq 0x3350
movq %rbp, %rdi
movl %r13d, %esi
callq 0x3490
movq %rax, %rbp
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbp, %rdi
movl $0xa, %esi
callq 0x3300
movsbl %al, %esi
movq %rbp, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3200
cmpl %r13d, 0x8(%rsp)
jge 0x8c7c
movslq %r15d, %rax
movq 0x90(%rsp), %rcx
shlq $0x6, %rax
leaq (%rcx,%rax), %rsi
addq $0x8, %rsi
movl -0x8(%rsi), %eax
movl %eax, 0x8(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x3180
movl $0x7, %edx
movq 0x1441c(%rip), %rdi     # 0x1cfe8
leaq 0xc979(%rip), %rsi      # 0x1554c
callq 0x3350
movq 0x40(%rsp), %rax
movl (%rax), %esi
movq 0x14402(%rip), %rdi     # 0x1cfe8
callq 0x3490
movq %rax, %r13
movl $0x1, %edx
movq %rax, %rdi
leaq 0xc8e8(%rip), %rsi      # 0x154e5
callq 0x3350
movq %r13, %rdi
movl 0xc(%rsp), %esi
callq 0x3490
movq %rax, %r13
movl $0x2, %edx
movq %rax, %rdi
leaq 0xc940(%rip), %rsi      # 0x15560
callq 0x3350
movq %r13, %rdi
movl 0x8(%rsp), %esi
callq 0x3490
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3300
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3200
movq 0x40(%rsp), %rax
movl (%rax), %edi
movl 0xc(%rsp), %esi
movl 0x8(%rsp), %edx
leaq 0x70(%rsp), %rcx
movq 0xd0(%rsp), %r8
callq 0x699c
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
callq 0x3a53
movq %rax, %xmm1
punpckldq 0xc36f(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xc377(%rip), %xmm1     # 0x15020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0xc3e3(%rip), %xmm0     # 0x150a0
movsd 0xc423(%rip), %xmm1     # 0x150e8
ucomisd %xmm0, %xmm1
jbe 0x8cf4
movq %r14, %rdi
movq %r12, %rsi
callq 0x87d0
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1274e
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
jne 0x8e84
jmp 0x8e89
movsd 0xc3f4(%rip), %xmm1     # 0x150f0
ucomisd %xmm0, %xmm1
jbe 0x8e0e
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
sarq $0x3, %rax
movabsq $-0x5555555555555555, %rcx # imm = 0xAAAAAAAAAAAAAAAB
imulq %rcx, %rax
addq $-0x9, %rax
cmpq $0x2, %rax
jb 0x8e89
movq %r14, %rdi
movq %r12, %rsi
callq 0x87d0
leaq 0xd8(%rsp), %rdi
movq %r12, %rsi
callq 0x87d0
movq 0x50(%rsp), %rax
subq 0x48(%rsp), %rax
shrq $0x3, %rax
testl %eax, %eax
jle 0x8dd8
xorl %r15d, %r15d
callq 0x3a53
movq %rax, %xmm0
punpckldq 0xc29e(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xc2a6(%rip), %xmm0     # 0x15020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xc312(%rip), %xmm1     # 0x150a0
movsd 0xc31a(%rip), %xmm0     # 0x150b0
ucomisd %xmm1, %xmm0
movq 0x48(%rsp), %rax
jbe 0x8dc1
movq 0xd8(%rsp), %rcx
movsd (%rax,%r15,8), %xmm0
movsd (%rcx,%r15,8), %xmm1
movsd %xmm1, (%rax,%r15,8)
movsd %xmm0, (%rcx,%r15,8)
incq %r15
movq 0x50(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rax
cmpq %rax, %r15
jl 0x8d60
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc526
movq %rbx, %rdi
leaq 0xd8(%rsp), %rsi
callq 0xc526
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8ce1
callq 0x32f0
jmp 0x8ce1
movq %r14, %rdi
movq %r12, %rsi
callq 0x87d0
callq 0x3a53
movq %rax, %xmm0
punpckldq 0xc1e5(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xc1ed(%rip), %xmm0     # 0x15020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xc259(%rip), %xmm1     # 0x150a0
addsd 0xc289(%rip), %xmm1     # 0x150d8
movapd %xmm1, 0xf0(%rsp)
callq 0x3a53
shrq %rax
movq 0x48(%rsp), %rdi
movq 0x50(%rsp), %rcx
subq %rdi, %rcx
sarq $0x3, %rcx
xorl %edx, %edx
divq %rcx
movapd 0xf0(%rsp), %xmm0
movsd %xmm0, (%rdi,%rdx,8)
callq 0x32f0
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
cmpl $0xa, %eax
jl 0x8c8f
leaq 0xb0(%rsp), %rdi
movq %rbx, %rsi
callq 0xc584
movq %rbx, %rdi
callq 0xc70c
movq %r12, %rdi
callq 0xc752
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
cmpl $0x2710, %eax           # imm = 0x2710
jne 0x8a2e
movq 0xc8(%rsp), %rbx
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0xeed8
movl 0x8(%rsp), %eax
movl %eax, 0x20(%rbx)
leaq 0xb0(%rsp), %rdi
callq 0xc70c
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x8f2c
callq 0x32f0
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8f60
jmp 0x8f87
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8fec
callq 0x32f0
jmp 0x8fec
movq %rax, %rbx
jmp 0x8fec
jmp 0x8f8c
jmp 0x8f87
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8f8f
callq 0x32f0
jmp 0x8f8f
jmp 0x8f87
jmp 0x8fdc
movq %rax, %rbx
jmp 0x8f9e
movq %rax, %rbx
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x8f9e
callq 0x32f0
leaq 0x10(%rsp), %rdi
callq 0xc70c
jmp 0x8fdf
movq %rax, %rbx
movq 0x50(%rsp), %rdi
leaq 0x60(%rsp), %rax
cmpq %rax, %rdi
je 0x8fc6
callq 0x32f0
jmp 0x8fc6
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x8fdf
callq 0x32f0
jmp 0x8fdf
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0xc752
leaq 0xb0(%rsp), %rdi
callq 0xc70c
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x9010
callq 0x32f0
movq %rbx, %rdi
callq 0x34a0