// File: /workspace/github_cpp_makefile_star2_O2/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 $0xf8, %rsp
movq %r9, 0xb0(%rsp)
movl %edx, 0xc(%rsp)
movq %rsi, %r15
movq %rdi, 0xa8(%rsp)
leaq 0xd0(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
xorpd %xmm0, %xmm0
leaq 0x90(%rsp), %rbx
movapd %xmm0, (%rbx)
andq $0x0, 0x10(%rbx)
xorl %ebp, %ebp
leaq 0x10(%rsp), %r14
leaq 0x48(%rsp), %r13
cmpl $0xa, %ebp
je 0x7580
movq %r14, %rdi
pushq $0xa
popq %rsi
movq %r13, %rdx
callq 0x9ffa
movq 0x10(%rsp), %rax
xorl %r12d, %r12d
movq 0x18(%rsp), %rcx
subq %rax, %rcx
shrq $0x3, %rcx
movslq %ecx, %rax
cmpq %rax, %r12
jge 0x7569
callq 0x3a22
addsd 0xab67(%rip), %xmm0     # 0x120c0
movq 0x10(%rsp), %rax
movsd %xmm0, (%rax,%r12,8)
incq %r12
jmp 0x7538
movq %rbx, %rdi
movq %r14, %rsi
callq 0xa09a
movq %r14, %rdi
callq 0xdf34
incl %ebp
jmp 0x751d
xorl %ebp, %ebp
pushq $-0x1
popq %rax
leaq 0x48(%rsp), %r14
leaq 0x70(%rsp), %rbx
leaq 0x10(%rsp), %r12
movl %eax, 0x8(%rsp)
cmpl $0x2710, %ebp           # imm = 0x2710
je 0x78e7
movq %rbp, 0x40(%rsp)
andq $0x0, 0x80(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x70(%rsp)
movq 0x90(%rsp), %r13
movq 0x98(%rsp), %rbp
cmpq %rbp, %r13
je 0x761d
andl $0x0, (%rsp)
movq %r12, %rdi
movq %r15, %rsi
movl 0xc(%rsp), %edx
movq %r13, %r9
callq 0x645d
movq %r14, %rdi
leaq 0x30(%rsp), %rsi
movq %r12, %rdx
callq 0xd02c
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0xa0c6
leaq 0x50(%rsp), %rdi
callq 0x3550
movq %r12, %rdi
callq 0x3550
addq $0x18, %r13
jmp 0x75cc
xorl %eax, %eax
movq 0x70(%rsp), %rcx
pushq $-0x1
popq %r13
xorl %ebp, %ebp
cmpq $0xa, %rax
je 0x7645
movl (%rcx), %edx
cmpl %r13d, %edx
cmovgl %edx, %r13d
cmovgl %eax, %ebp
incq %rax
addq $0x40, %rcx
jmp 0x762a
movq 0x1499c(%rip), %rdi     # 0x1bfe8
leaq 0xaf02(%rip), %rsi      # 0x12555
callq 0x32f0
movq %rax, %rdi
movq 0x40(%rsp), %rsi
callq 0x3490
movq %rax, %rdi
leaq 0xaeec(%rip), %rsi      # 0x1255b
callq 0x32f0
movq %rax, %rdi
movl %r13d, %esi
callq 0x3490
movq %rax, %rdi
callq 0x3130
cmpl %r13d, 0x8(%rsp)
jge 0x7736
movslq %ebp, %rax
movq 0x70(%rsp), %rcx
shlq $0x6, %rax
leaq (%rcx,%rax), %rsi
addq $0x8, %rsi
movl -0x8(%rsi), %eax
movl %eax, 0x8(%rsp)
leaq 0xc0(%rsp), %rdi
callq 0x3170
movq 0x14927(%rip), %rdi     # 0x1bfe8
leaq 0xae7c(%rip), %rsi      # 0x12544
callq 0x32f0
movl (%r15), %esi
movq %rax, %rdi
callq 0x3490
movq %rax, %rdi
leaq 0xadfb(%rip), %rsi      # 0x124dd
callq 0x32f0
movq %rax, %rdi
movl 0xc(%rsp), %esi
callq 0x3490
movq %rax, %rdi
leaq 0xae5b(%rip), %rsi      # 0x12558
callq 0x32f0
movq %rax, %rdi
movl 0x8(%rsp), %esi
callq 0x3490
movq %rax, %rdi
callq 0x3130
movl (%r15), %edi
movl 0xc(%rsp), %esi
movl 0x8(%rsp), %edx
leaq 0xc0(%rsp), %rcx
movq 0xb0(%rsp), %r8
callq 0x5d50
andq $0x0, 0x20(%rsp)
xorpd %xmm0, %xmm0
movapd %xmm0, 0x10(%rsp)
xorl %ecx, %ecx
xorl %eax, %eax
movq 0x40(%rsp), %rbp
subq %rcx, %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
cmpl $0x9, %eax
jg 0x78c0
callq 0x3a22
movsd 0xa958(%rip), %xmm1     # 0x120c8
ucomisd %xmm0, %xmm1
jbe 0x7791
movq %r14, %rdi
movq %rbx, %rsi
callq 0x73e8
movq %r12, %rdi
movq %r14, %rsi
callq 0xfe56
jmp 0x78a9
movsd 0xa937(%rip), %xmm1     # 0x120d0
ucomisd %xmm0, %xmm1
jbe 0x7837
movq 0x18(%rsp), %rax
subq 0x10(%rsp), %rax
cqto
pushq $0x18
popq %rcx
idivq %rcx
addq $-0x9, %rax
cmpq $0x2, %rax
jb 0x78b1
movq %r14, %rdi
movq %rbx, %rsi
callq 0x73e8
leaq 0xe0(%rsp), %rdi
movq %rbx, %rsi
callq 0x73e8
xorl %r13d, %r13d
movq 0x50(%rsp), %rax
subq 0x48(%rsp), %rax
shrq $0x3, %rax
cltq
cmpq %rax, %r13
jge 0x7883
callq 0x3a22
movsd 0xa889(%rip), %xmm1     # 0x12090
ucomisd %xmm0, %xmm1
jbe 0x7832
movq 0x48(%rsp), %rax
movq 0xe0(%rsp), %rcx
movsd (%rax,%r13,8), %xmm0
movsd (%rcx,%r13,8), %xmm1
movsd %xmm1, (%rax,%r13,8)
movsd %xmm0, (%rcx,%r13,8)
incq %r13
jmp 0x77e1
movq %r14, %rdi
movq %rbx, %rsi
callq 0x73e8
callq 0x3a22
addsd 0xa871(%rip), %xmm0     # 0x120c0
movsd %xmm0, 0xb8(%rsp)
callq 0x3a17
movq 0x48(%rsp), %rcx
movq 0x50(%rsp), %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
xorl %edx, %edx
divq %rsi
movsd 0xb8(%rsp), %xmm0
movsd %xmm0, (%rcx,%rdx,8)
jmp 0x78a9
movq %r12, %rdi
movq %r14, %rsi
callq 0xa09a
leaq 0xe0(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0xa09a
movq %r13, %rdi
callq 0xdf34
movq %r14, %rdi
callq 0xdf34
movq 0x10(%rsp), %rcx
movq 0x18(%rsp), %rax
jmp 0x774f
leaq 0x90(%rsp), %rdi
movq %r12, %rsi
callq 0xa0f8
movq %r12, %rdi
callq 0xa1c0
movq %rbx, %rdi
callq 0xa1e2
incl %ebp
jmp 0x7598
leaq 0xc0(%rsp), %rsi
movq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0x33a0
movl 0x8(%rsp), %eax
movl %eax, 0x20(%rbx)
leaq 0x90(%rsp), %rdi
callq 0xa1c0
leaq 0xc0(%rsp), %rdi
callq 0x3550
movq %rbx, %rax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7939
jmp 0x7976
movq %rax, %rbx
jmp 0x79b0
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xdf34
jmp 0x79b0
jmp 0x7967
jmp 0x7976
jmp 0x7976
movq %rax, %rbx
leaq 0xe0(%rsp), %rdi
callq 0xdf34
jmp 0x796a
jmp 0x7985
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0xdf34
jmp 0x7979
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0xa1c0
jmp 0x79a6
movq %rax, %rbx
jmp 0x79a6
movq %rax, %rbx
jmp 0x799c
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x3550
leaq 0x10(%rsp), %rdi
callq 0x3550
leaq 0x70(%rsp), %rdi
callq 0xa1e2
leaq 0x90(%rsp), %rdi
callq 0xa1c0
leaq 0xc0(%rsp), %rdi
callq 0x3550
movq %rbx, %rdi
callq 0x34a0