// File: /workspace/github_cpp_makefile_star2_O1/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, %r13
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, 0x18(%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 0x3a63
movq %rax, %xmm0
punpckldq 0xc638(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xc640(%rip), %xmm0     # 0x15020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xc6cc(%rip), %xmm1     # 0x150c0
addsd 0xc6fc(%rip), %xmm1     # 0x150f8
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 0x89c6
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc4a8
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x8a38
callq 0x32f0
incl %r15d
cmpl $0xa, %r15d
jne 0x896f
movq %r13, 0xc8(%rsp)
leaq 0x60(%rsp), %rbp
movl $0xffffffff, 0x8(%rsp)  # imm = 0xFFFFFFFF
movq $0x0, 0x38(%rsp)
leaq 0x48(%rsp), %r14
leaq 0x90(%rsp), %r12
xorpd %xmm0, %xmm0
movapd %xmm0, 0x90(%rsp)
movq $0x0, 0xa0(%rsp)
movq 0xb0(%rsp), %r13
movq 0xb8(%rsp), %rbx
cmpq %rbx, %r13
je 0x8b16
movl $0x0, (%rsp)
leaq 0x10(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl 0xc(%rsp), %edx
movq %r13, %r9
callq 0x74ca
movl 0x30(%rsp), %eax
movl %eax, 0x48(%rsp)
movq %rbp, 0x50(%rsp)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
addq %rsi, %rdx
leaq 0x50(%rsp), %rdi
callq 0xeda4
movq %r12, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xc4d4
movq 0x50(%rsp), %rdi
cmpq %rbp, %rdi
je 0x8afc
callq 0x32f0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x8b10
callq 0x32f0
addq $0x18, %r13
jmp 0x8a99
movl $0xffffffff, %r13d      # imm = 0xFFFFFFFF
xorl %eax, %eax
movq 0x90(%rsp), %rcx
xorl %r15d, %r15d
movl (%rcx), %edx
cmpl %r13d, %edx
cmovgl %edx, %r13d
cmovgl %eax, %r15d
incq %rax
addq $0x40, %rcx
cmpq $0xa, %rax
jne 0x8b29
movl $0x5, %edx
movq 0x14499(%rip), %rdi     # 0x1cfe8
leaq 0xca27(%rip), %rsi      # 0x1557d
callq 0x3350
movq 0x14486(%rip), %rdi     # 0x1cfe8
movq 0x38(%rsp), %rsi
callq 0x34a0
movq %rax, %rbx
movl $0xa, %edx
movq %rax, %rdi
leaq 0xca05(%rip), %rsi      # 0x15583
callq 0x3350
movq %rbx, %rdi
movl %r13d, %esi
callq 0x34a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3300
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3200
cmpl %r13d, 0x8(%rsp)
jge 0x8ca7
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 0x143f1(%rip), %rdi     # 0x1cfe8
leaq 0xc96e(%rip), %rsi      # 0x1556c
callq 0x3350
movq 0x40(%rsp), %rax
movl (%rax), %esi
movq 0x143d7(%rip), %rdi     # 0x1cfe8
callq 0x34a0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0xc8dd(%rip), %rsi      # 0x15505
callq 0x3350
movq %rbx, %rdi
movl 0xc(%rsp), %esi
callq 0x34a0
movq %rax, %rbx
movl $0x2, %edx
movq %rax, %rdi
leaq 0xc935(%rip), %rsi      # 0x15580
callq 0x3350
movq %rbx, %rdi
movl 0x8(%rsp), %esi
callq 0x34a0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3300
movsbl %al, %esi
movq %rbx, %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 0x69f2
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
movq $0x0, 0x20(%rsp)
movq 0x18(%rsp), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
cmpl $0x9, %eax
jg 0x8ee8
callq 0x3a63
movq %rax, %xmm1
punpckldq 0xc32c(%rip), %xmm1 # xmm1 = xmm1[0],mem[0],xmm1[1],mem[1]
subpd 0xc334(%rip), %xmm1     # 0x15020
movapd %xmm1, %xmm0
unpckhpd %xmm1, %xmm0            # xmm0 = xmm0[1],xmm1[1]
addsd %xmm1, %xmm0
mulsd 0xc3c0(%rip), %xmm0     # 0x150c0
movsd 0xc400(%rip), %xmm1     # 0x15108
ucomisd %xmm0, %xmm1
jbe 0x8d30
movq %r14, %rdi
movq %r12, %rsi
callq 0x87cf
leaq 0x10(%rsp), %rdi
movq %r14, %rsi
callq 0x126a4
movq 0x48(%rsp), %rdi
jmp 0x8ec1
movsd 0xc3d8(%rip), %xmm1     # 0x15110
ucomisd %xmm0, %xmm1
jbe 0x8e4b
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 0x8ecb
movq %r14, %rdi
movq %r12, %rsi
callq 0x87cf
leaq 0xd8(%rsp), %rdi
movq %r12, %rsi
callq 0x87cf
movq 0x50(%rsp), %rax
subq 0x48(%rsp), %rax
shrq $0x3, %rax
testl %eax, %eax
jle 0x8e10
xorl %ebx, %ebx
callq 0x3a63
movq %rax, %xmm0
punpckldq 0xc263(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xc26b(%rip), %xmm0     # 0x15020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xc2f7(%rip), %xmm1     # 0x150c0
movsd 0xc2ff(%rip), %xmm0     # 0x150d0
ucomisd %xmm1, %xmm0
jbe 0x8df8
movq 0x48(%rsp), %rax
movq 0xd8(%rsp), %rcx
movsd (%rax,%rbx,8), %xmm0
movsd (%rcx,%rbx,8), %xmm1
movsd %xmm1, (%rax,%rbx,8)
movsd %xmm0, (%rcx,%rbx,8)
movq 0x50(%rsp), %rax
subq 0x48(%rsp), %rax
incq %rbx
shrq $0x3, %rax
cltq
cmpq %rax, %rbx
jl 0x8d9b
leaq 0x10(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0xc4a8
movq %rbx, %rdi
leaq 0xd8(%rsp), %rsi
callq 0xc4a8
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8d26
callq 0x32f0
jmp 0x8d26
movq %r14, %rdi
movq %r12, %rsi
callq 0x87cf
callq 0x3a63
movq %rax, %xmm0
punpckldq 0xc1a8(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xc1b0(%rip), %xmm0     # 0x15020
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
mulsd 0xc23c(%rip), %xmm1     # 0x150c0
addsd 0xc26c(%rip), %xmm1     # 0x150f8
movapd %xmm1, 0xf0(%rsp)
callq 0x3a63
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)
testq %rdi, %rdi
je 0x8ecb
callq 0x32f0
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
shrq $0x3, %rax
imull $0xaaaaaaab, %eax, %eax # imm = 0xAAAAAAAB
cmpl $0xa, %eax
jl 0x8cd2
leaq 0xb0(%rsp), %rdi
leaq 0x10(%rsp), %rbx
movq %rbx, %rsi
callq 0xc506
movq %rbx, %rdi
callq 0xc668
movq %r12, %rdi
callq 0xc6a8
movq 0x38(%rsp), %rax
incl %eax
movq %rax, 0x38(%rsp)
cmpl $0x2710, %eax           # imm = 0x2710
jne 0x8a70
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 0xeda4
movl 0x8(%rsp), %eax
movl %eax, 0x20(%rbx)
leaq 0xb0(%rsp), %rdi
callq 0xc668
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x8f73
callq 0x32f0
movq %rbx, %rax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x8f8c
jmp 0x8fc9
movq %rax, %rbx
jmp 0x902b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x902b
callq 0x32f0
jmp 0x902b
jmp 0x8fc9
jmp 0x8fce
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
testq %rdi, %rdi
je 0x8fd1
callq 0x32f0
jmp 0x8fd1
jmp 0x8fc9
movq %rax, %rbx
jmp 0x8fe0
movq %rax, %rbx
movq 0x48(%rsp), %rdi
testq %rdi, %rdi
je 0x8fe0
callq 0x32f0
leaq 0x10(%rsp), %rdi
callq 0xc668
jmp 0x901e
jmp 0x9002
movq %rax, %rbx
movq 0x50(%rsp), %rdi
cmpq %rbp, %rdi
je 0x900a
callq 0x32f0
jmp 0x900a
movq %rax, %rbx
jmp 0x901e
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x901e
callq 0x32f0
leaq 0x90(%rsp), %rdi
callq 0xc6a8
leaq 0xb0(%rsp), %rdi
callq 0xc668
movq 0x70(%rsp), %rdi
leaq 0x80(%rsp), %rax
cmpq %rax, %rdi
je 0x904f
callq 0x32f0
movq %rbx, %rdi
callq 0x34b0