Language: C++

#include <array>
#include <iostream>
#include <map>

#define M 1046527;

const std::map<char, int> charint{
    {'A', 1},
    {'C', 2},
    {'G', 3},
    {'T', 4},
};

int getChar(char ch) { return charint.at(ch); }

long long getKey(std::string str) {
  long long sum = 0, p = 1;
  for (std::size_t i = 0; i < str.size(); ++i) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

struct Dict {
  std::array<std::string, M> v{};

  bool insert(std::string item) {
    auto key = h1(getKey(item));
    if (v[key].empty()) {
      v[key] = item;
      return true;
    }
    for (int i = 0; i < M; i++) {
      key = h2(getKey(item));
      if (v[key].empty()) {
        v[key] = item;
        return true;
      }
    }
    return false;
  }

  bool find(std::string item) { return v[getKey(item)] == item; }

private:
  int h1(int key) { return key % M; }
  int h2(int key) { return 1 + (key % (M - 1)); }
};

int main() {
  int n;
  std::cin >> n;

  std::string cmd, data;
  Dict *d = new Dict{};
  for (int i = 0; i < n; i++) {
    std::cin >> cmd >> data;
    if (cmd == "insert") {
      d->insert(data);
    } else {
      std::cout << (d->find(data) ? "yes" : "no") << std::endl;
    }
  }
}



Compiler output:
a.cc:26:8: error: parse error in template argument list
   26 |   std::array<std::string, M> v{};
      |        ^
a.cc:26:8: error: declaration does not declare anything [-fpermissive]
a.cc:26:28: error: expected unqualified-id before '>' token
   26 |   std::array<std::string, M> v{};
      |                            ^
a.cc: In member function 'bool Dict::insert(std::string)':
a.cc:30:9: error: 'v' was not declared in this scope
   30 |     if (v[key].empty()) {
      |         ^
a.cc:34:26: error: expected primary-expression before ';' token
   34 |     for (int i = 0; i < M; i++) {
      |                          ^
a.cc:34:26: error: expected ')' before ';' token
a.cc:34:9: note: to match this '('
   34 |     for (int i = 0; i < M; i++) {
      |         ^
a.cc:34:28: error: 'i' was not declared in this scope
   34 |     for (int i = 0; i < M; i++) {
      |                            ^
a.cc: In member function 'bool Dict::find(std::string)':
a.cc:44:40: error: 'v' was not declared in this scope
   44 |   bool find(std::string item) { return v[getKey(item)] == item; }
      |                                        ^
a.cc: In member function 'int Dict::h2(int)':
a.cc:5:18: error: expected ')' before ';' token
    5 | #define M 1046527;
      |                  ^
a.cc:48:40: note: in expansion of macro 'M'
   48 |   int h2(int key) { return 1 + (key % (M - 1)); }
      |                                        ^
a.cc:48:39: note: to match this '('
   48 |   int h2(int key) { return 1 + (key % (M - 1)); }
      |                                       ^
a.cc:5:18: error: expected ')' before ';' token
    5 | #define M 1046527;
      |                  ^
a.cc:48:40: note: in expansion of macro 'M'
   48 |   int h2(int key) { return 1 + (key % (M - 1)); }
      |                                        ^
a.cc:48:32: note: to match this '('
   48 |   int h2(int key) { return 1 + (key % (M - 1)); }
      |                                ^
a.cc:48:45: error: expected ';' before ')' token
   48 |   int h2(int key) { return 1 + (key % (M - 1)); }
      |                                             ^