Language: C++

#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

const string AGC("AGC");

bool NotAGC(const string& str) {
  // swapしてAGCが現れるかチェック
  bool ret = true;
  for (int i = 0; i < 3; i++) {
    auto tmp = str;
    swap(tmp[i], tmp[i + 1]);
    if (tmp.substr(0, 3) == AGC || tmp.substr(1, 3) == AGC) {
      ret = false;
      break;
    }
  }
  // swapしないでAGCが現れるかチェック
  if (str.substr(0, 3) == AGC || str.substr(1, 3) == AGC) {
    ret = false;
  }
  return ret;
}

// We like AGC
int main() {
  constexpr uint64_t mod = 1e9 + 7;
  string base[4];
  base[0] = "A";
  base[1] = "T";
  base[2] = "G";
  base[3] = "C";
  map<string, uint64_t> mp[2];
  for (uint32_t i = 0; i < 4 * 4 * 4; i++) {
    auto c1 = base[i % 4];
    auto c2 = base[(i >> 2) % 4];
    auto c3 = base[(i >> 4) % 4];
    string tmp = c1 + c2 + c3;
    if (tmp == "AGC" || tmp == "ACG" || tmp == "GAC") continue;
    mp[0][tmp] = 1;
    mp[1][tmp] = 0;
  }

  size_t N;
  cin >> N;

  for (uint32_t i = 4; i <= N; i++) {
    uint32_t prev = i % 2;
    uint32_t now = (i + 1) % 2;
    // nowの初期化
    for (auto&& [key, value] : mp[now]) {
      value = 0;
    }
    // mp[prev]からmp[now]を作る
    for (const auto& [key, value] : mp[prev]) {
      for (uint32_t c = 0; c < 4; c++) {
        string tmp = key + base[c];
        if (NotAGC(tmp)) {
          mp[now][tmp.substr(1, 3)] = (mp[now][tmp.substr(1, 3)] + value) % mod;
        }
      }
    }
  }

  uint64_t ans = 0;
  for (const auto& [key, value] : mp[(N + 1) % 2]) {
    ans = (ans + value) % mod;
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:34:13: error: 'uint64_t' does not name a type
   34 |   constexpr uint64_t mod = 1e9 + 7;
      |             ^~~~~~~~
a.cc:7:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
    6 | #include <set>
  +++ |+#include <cstdint>
    7 | #include <string>
a.cc:40:15: error: 'uint64_t' was not declared in this scope
   40 |   map<string, uint64_t> mp[2];
      |               ^~~~~~~~
a.cc:40:15: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:40:23: error: template argument 2 is invalid
   40 |   map<string, uint64_t> mp[2];
      |                       ^
a.cc:40:23: error: template argument 4 is invalid
a.cc:41:8: error: 'uint32_t' was not declared in this scope
   41 |   for (uint32_t i = 0; i < 4 * 4 * 4; i++) {
      |        ^~~~~~~~
a.cc:41:8: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:41:24: error: 'i' was not declared in this scope
   41 |   for (uint32_t i = 0; i < 4 * 4 * 4; i++) {
      |                        ^
a.cc:47:10: error: no match for 'operator[]' (operand types are 'int' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   47 |     mp[0][tmp] = 1;
      |          ^
a.cc:48:10: error: no match for 'operator[]' (operand types are 'int' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   48 |     mp[1][tmp] = 0;
      |          ^
a.cc:54:8: error: 'uint32_t' was not declared in this scope
   54 |   for (uint32_t i = 4; i <= N; i++) {
      |        ^~~~~~~~
a.cc:54:8: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc:54:24: error: 'i' was not declared in this scope
   54 |   for (uint32_t i = 4; i <= N; i++) {
      |                        ^
a.cc:55:13: error: expected ';' before 'prev'
   55 |     uint32_t prev = i % 2;
      |             ^~~~~
      |             ;
a.cc:56:13: error: expected ';' before 'now'
   56 |     uint32_t now = (i + 1) % 2;
      |             ^~~~
      |             ;
a.cc:58:35: error: 'now' was not declared in this scope
   58 |     for (auto&& [key, value] : mp[now]) {
      |                                   ^~~
a.cc:62:39: error: invalid types 'int [2][<unresolved overloaded function type>]' for array subscript
   62 |     for (const auto& [key, value] : mp[prev]) {
      |                                       ^
a.cc:63:20: error: expected ';' before 'c'
   63 |       for (uint32_t c = 0; c < 4; c++) {
      |                    ^~
      |                    ;
a.cc:63:28: error: 'c' was not declared in this scope
   63 |       for (uint32_t c = 0; c < 4; c++) {
      |                            ^
a.cc:66:14: error: 'now' was not declared in this scope
   66 |           mp[now][tmp.substr(1, 3)] = (mp[now][tmp.substr(1, 3)] + value) % mod;
      |              ^~~
a.cc:66:77: error: 'mod' was not declared in this scope
   66 |           mp[now][tmp.substr(1, 3)] = (mp[now][tmp.substr(1, 3)] + value) % mod;
      |                                                                             ^~~
a.cc:72:11: error: expected ';' before 'ans'
   72 |   uint64_t ans = 0;
      |           ^~~~
      |           ;
a.cc:73:49: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
   73 |   for (const auto& [key, value] : mp[(N + 1) % 2]) {
      |                                                 ^
      |                                                 std::begin
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
  114 |   template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
      |                                     ^~~~~
a.cc:73:49: error: 'end' was not declared in this scope; did you mean 'std::end'?
   73 |   for (const auto& [key, value] : mp[(N + 1) % 2]) {
      |                                                 ^
      |                                                 std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
a.cc:74:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   74 |     ans = (ans + value) % mod;
      |     ^~~
      |     abs
a.cc:74:27: error: 'mod' was not declared in this scope
   74 |     ans = (ans + value) % mod;
      |                           ^~~
a.cc:76:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   76 |   cout << ans << endl;
      |           ^~~
      |           abs