alexjercan/bugnet huggingface dataset:
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
using namespace std;
int main() {
  int num;
  string com, key;
  map<string, int> a;
  cin >> num;
  for (int i = 0; i < num; i++) {
    cin >> com >> key;
    if (com == "insert")
      a.insert(make_pair(key, i));
    if (com == "find")
      cout << (a.find(key) != a.end() ? "yes" : "no") << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int num;
  string com, key;
  vector<string> a;
  cin >> num;
  for (int i = 0; i < num; i++) {
    cin >> com >> key;
    if (com == "insert")
      a.push_back(key);
    if (com == "find")
      cout << (find(a.begin(), a.end(), key) != a.end() ? "yes" : "no") << endl;
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>

#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13

using namespace std;

int translateChar(char ch) {
  int ret;
  switch (ch) {
  case 'A':
    ret = 1;
    break;
  case 'C':
    ret = 2;
    break;
  case 'G':
    ret = 3;
    break;
  case 'T':
    ret = 4;
    break;
  }
  return ret;
}

int calc(int num) {
  if (num == 0) {
    return 1;
  } else {
    return 4 * calc(num - 1);
  }
}

int translateStr(char buf[]) {
  int sum = 0;
  for (int i = 0; buf[i] != '\\0'; i++) {
    sum += translateChar(buf[i]) * calc(i);
  }
  return sum - 1;
}

int main() {

  queue<string> Messages;
  int n;
  scanf("%d", &n);
  char order[ORDER_LENGTH], str[STR_LENGTH];

  char *check_table = new char[TABLE_SIZE];

  for (int i = 0; i < n; i++) {
    scanf("%s %s", order, str);
    if (strcmp(order, "insert") == 0) {
      check_table[translateStr(str)] = 'Y';
    } else {
      if (check_table[translateStr(str)] == 'Y') {
        Messages.push("yes");
      } else {
        Messages.push("no");
      }
    }
  }

  while (!Messages.empty()) {
    cout << Messages.front() << endl;
    Messages.pop();
  }

  delete[] check_table;
}

Error: 0

Fixed submission:

#include <iostream>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>

#define TABLE_SIZE 16777216
#define ORDER_LENGTH 7
#define STR_LENGTH 13

using namespace std;

int translateChar(char ch) {
  int ret;
  switch (ch) {
  case 'A':
    ret = 1;
    break;
  case 'C':
    ret = 2;
    break;
  case 'G':
    ret = 3;
    break;
  case 'T':
    ret = 4;
    break;
  }
  return ret;
}

int calc(int num) {
  if (num == 0) {
    return 1;
  } else {
    return 4 * calc(num - 1);
  }
}

int translateStr(char buf[]) {
  int sum = 0;
  for (int i = 0; buf[i] != '\\0'; i++) {
    sum += translateChar(buf[i]) * calc(i);
  }
  return sum - 1;
}

int main() {

  queue<string> Messages;
  int n;
  scanf("%d", &n);
  char order[ORDER_LENGTH], str[STR_LENGTH];

  char *check_table = new char[n];

  for (int i = 0; i < n; i++) {
    scanf("%s %s", order, str);
    if (strcmp(order, "insert") == 0) {
      check_table[translateStr(str)] = 'Y';
    } else {
      if (check_table[translateStr(str)] == 'Y') {
        Messages.push("yes");
      } else {
        Messages.push("no");
      }
    }
  }

  while (!Messages.empty()) {
    cout << Messages.front() << endl;
    Messages.pop();
  }

  delete[] check_table;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

// vector には.find() がなぜかないのでアルゴリズムを使う (線形？　オーダー不明)
// set map のメンバのfind はlogn保障らしい。

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  int i, j;
  int n, q, C = 0;
  int buf;
  set<string> dictionary;
  set<string>::iterator itr;
  string com, str;

  // 入力
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> com;
    cin >> str;

    if (com == "insert") {
      dictionary.insert(str);
    } else { //"find"の場合
      if (dictionary.find(str) != dictionary.end())
        printf("yes\\n");
      else
        printf("no\\n");
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

// vector には.find() がなぜかないのでアルゴリズムを使う (線形？　オーダー不明)
// set map のメンバのfind はlogn保障らしい。

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <set>
#include <string>
#include <vector>

using namespace std;

int main() {
  int i, j;
  int n, q, C = 0;
  int buf;
  set<string> dictionary;
  set<string>::iterator itr;
  string com, str;

  // 入力
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> com;
    cin >> str;

    if (com == "insert") {
      dictionary.insert(str);
    } else { //"find"の場合
      if (dictionary.find(str) != dictionary.end())
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }

  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  int n;
  string o, s;
  set<string> set;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> o >> s;
    if (o == "insert") {
      set.insert(s);
    } else {
      if (set.find(s) != set.end()) {
        cout << "yes" << endl;
      } else
        cout << "no" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <set>
#include <string>
using namespace std;
int main(void) {
  int n;
  string o, s;
  set<string> set;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> o >> s;
    if (o == "insert") {
      set.insert(s);
    } else {
      if (set.find(s) != set.end()) {
        cout << "yes" << endl;
      } else
        cout << "no" << endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>
using namespace std;

vector<string> myhash(10000000);

void set(string &a) {
  int x = 0;
  for (int i = 0; i < a.size(); i++) {
    x *= 11;
    x += a[i];
    x %= 10000000;
  }

  while (true) {
    if (myhash[x].empty()) {
      myhash[x] = a;
      break;
    } else if (myhash[x].compare(a) == 0) {
      break;
    } else {
      x++;
      if (x > 10000000)
        x -= 10000000;
    }
  }
}

void find(string &a) {
  int x = 0;
  for (int i = 0; i < a.size(); i++) {
    x *= 11;
    x += a[i];
    x %= 10000000;
  }

  while (true) {
    if (myhash[x].compare(a) == 0) {
      cout << "yes\\n";
      break;
    } else if (myhash[x].empty()) {
      cout << "no\\n";
      break;
    } else {
      x++;
      if (x > 10000000)
        x -= 10000000;
    }
  }
}

int main() {
  string a, b;
  int n;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    if (a.compare("insert") == 0)
      set(b);
    else
      find(b);
  }

  return 0;
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <iostream>
#include <vector>
using namespace std;

vector<string> myhash(10000000);

void set(string &a) {
  int x = 0;
  for (int i = 0; i < a.size(); i++) {
    x *= 11;
    x += a[i];
  }
  x %= 10000000;

  while (true) {
    if (myhash[x].empty()) {
      myhash[x] = a;
      break;
    } else if (myhash[x].compare(a) == 0) {
      break;
    } else {
      x++;
      if (x > 10000000)
        x -= 10000000;
    }
  }
}

void find(string &a) {
  int x = 0;
  for (int i = 0; i < a.size(); i++) {
    x *= 11;
    x += a[i];
  }
  x %= 10000000;

  while (true) {
    if (myhash[x].compare(a) == 0) {
      cout << "yes\\n";
      break;
    } else if (myhash[x].empty()) {
      cout << "no\\n";
      break;
    } else {
      x++;
      if (x > 10000000)
        x -= 10000000;
    }
  }
}

int main() {
  string a, b;
  int n;
  cin >> n;
  while (n--) {
    cin >> a >> b;
    if (a.compare("insert") == 0)
      set(b);
    else
      find(b);
  }

  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define RFOR(i, m, n) for (int i = m - 1; i >= n; --i)
#define ALL(v) v.begin(), v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;

int ch(char c) {
  switch (c) {
  case 'A':
    return 1;
  case 'C':
    return 2;
  case 'G':
    return 3;
  default:
    return 4;
  }
}

long long gethash(string s) {
  long long sum = 0;
  int p = 1;
  REP(i, s.size()) {
    sum += ch(s[i]) * p;
    p *= 4;
  }
  return sum;
}

int main() {
  vector<int> h(1 << 24, 0);
  int n;

  cin >> n;
  REP(i, n) {

    string s, t;
    cin >> s >> t;
    if (s[0] == 'i') {
      h[gethash(t) - 1] = 1;
    } else if (s[0] == 'f') {
      if (h[gethash(t) - 1])
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define RREP(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define RFOR(i, m, n) for (int i = m - 1; i >= n; --i)
#define ALL(v) v.begin(), v.end()
#define PB(a) push_back(a)
#define INF 1000000001
#define MOD 1000000007

using namespace std;

int ch(char c) {
  if (c == 'A')
    return 1;
  else if (c == 'T')
    return 2;
  else if (c == 'C')
    return 3;
  else
    return 4;
}

int main() {
  int n;
  cin >> n;
  bool hash[1 << 23];
  REP(i, 1 << 23) { hash[i] = false; }
  REP(i, n) {
    string s, t;
    cin >> s >> t;
    if (s[0] == 'i') {
      long long h = 0;
      int p = 1;
      REP(i, t.size()) {
        h = h * p + ch(t[i]);
        p *= 5;
      }
      h %= (1 << 23);
      hash[h] = true;
    } else if (s[0] == 'f') {
      long long h = 0;
      int p = 1;
      REP(i, t.size()) {
        h = h * p + ch(t[i]);
        p *= 5;
      }
      h %= (1 << 23);
      if (hash[h])
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }

  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#define _CRT_SECURE_NO_WARNINGS
#include <cstring>
#include <iostream>
using namespace std;
const int num1 = 1046527;
const int num2 = 13;
char c[num1][num2];
inline int getInt(char ch) {
  if (ch == 'A')
    return 1;
  else if (ch == 'C')
    return 2;
  else if (ch == 'G')
    return 3;
  else if (ch == 'T')
    return 4;
  return 0;
}
inline int getKey(char str[]) {
  int p = 1, sum = 0;
  for (int i = 0; i < strlen(str); i++) {
    sum += p * getInt(str[i]);
    p *= 5;
  }
  return sum;
}
int h1(char str[]) { return getKey(str) % num1; }
int h2(char str[]) { return 1 + getKey(str) % (num1 - 1); }
inline int insert(char str[]) {
  int i;
  for (i = 0;; i++) {
    int h = (h1(str) + i * h2(str)) % num1;
    if (strcmp(c[h], str) == 0)
      return 0; //?????´??????return 0
    else if (strlen(c[h]) == 0) {
      strcpy(c[h], str);
      return 0;
    }
  }
  return 0;
}
inline int find(char str[]) {
  int i;
  int sum = 0;
  for (i = 0; sum < 104538; i++) {
    int h = (h1(str) + i * h2(str)) % num1;
    if (strcmp(c[h], str) == 0)
      return 1;
    else if (strlen(c[h]) == 0)
      return 0;
    sum++;
  }
  return 0;
}
int main() {
  int n;
  char com[7], str[num2];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> com >> str;
    if (com[0] == 'i')
      insert(str);
    else if (find(str))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#include <cstring>
#include <iostream>
using namespace std;
const int num1 = 104537;
const int num2 = 13;
char c[num1][num2];
inline int getInt(char ch) {
  if (ch == 'A')
    return 1;
  else if (ch == 'C')
    return 2;
  else if (ch == 'G')
    return 3;
  else if (ch == 'T')
    return 4;
  return 0;
}
inline int getKey(char str[]) {
  int p = 1, sum = 0;
  for (int i = 0; i < strlen(str); i++) {
    sum += p * getInt(str[i]);
    p *= 5;
  }
  return sum;
}
int h1(int key) { return key % num1; }
int h2(int key) { return 1 + key % (num1 - 1); }
inline int insert(char str[]) {
  int i, key = getKey(str);
  for (i = 0;; i++) {
    int h = (h1(key) + i * h2(key)) % num1;
    if (strcmp(c[h], str) == 0)
      return 1; //?????´??????return 0
    else if (strlen(c[h]) == 0) {
      strcpy(c[h], str);
      return 0;
    }
  }
  return 0;
}
inline int find(char str[]) {
  int i;
  int sum = 0, key = getKey(str);
  for (i = 0;; i++) {
    int h = (h1(key) + i * h2(key)) % num1;
    if (strcmp(c[h], str) == 0)
      return 1;
    else if (strlen(c[h]) == 0)
      return 0;
  }
  return 0;
}
int main() {
  int n;
  char com[9], str[num2];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> com >> str;
    if (com[0] == 'i')
      insert(str);
    else {
      if (find(str))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int main() {
  bool dic[10000000] = {0};
  long n = 0;
  long long k = 0;
  string st1, st2;

  cin >> n;

  for (long i = 0; i < n; i++) {
    cin >> st1 >> st2;
    k = 0;

    for (unsigned int j = 0; j < st2.size(); j++)
      switch (st2[j]) {
      case 'A':
        k += (long long)pow(5, j);
        break;
      case 'C':
        k += (long long)pow(5, j) * 2;
        break;
      case 'G':
        k += (long long)pow(5, j) * 3;
        break;
      case 'T':
        k += (long long)pow(5, j) * 4;
        break;
      }

    if (st1 == "insert")
      dic[k] = 1;
    else if (st1 == "find") {
      if (dic[k] == 1)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int main() {
  bool dic[1000000] = {0};
  long n = 0;
  long long k = 0;
  string st1, st2;

  cin >> n;

  for (long i = 0; i < n; i++) {
    cin >> st1 >> st2;
    k = 0;

    for (unsigned int j = 0; j < st2.size(); j++)
      switch (st2[j]) {
      case 'A':
        k += (long long)pow(5, j);
        break;
      case 'C':
        k += (long long)pow(5, j) * 2;
        break;
      case 'G':
        k += (long long)pow(5, j) * 3;
        break;
      case 'T':
        k += (long long)pow(5, j) * 4;
        break;
      }

    if (st1 == "insert")
      dic[k] = 1;
    else if (st1 == "find") {
      if (dic[k] == 1)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <cstring>
#include <set>
using namespace std;

set<int> S;

inline int get(char c) {
  char T[5] = "ACGT";
  for (int i = 0; i < 4; ++i) {
    if (c == T[i])
      return i + 1;
  }
  return 0;
}

void insert(char *s) {
  int n = strlen(s);
  int sum = 0;
  int t = 1;
  for (int i = 0; i < n; ++i) {
    sum += get(s[i]) * t;
    t *= 4;
  }
  S.insert(sum);
}

bool find(char *s) {
  int n = strlen(s);
  int sum = 0;
  int t = 1;
  for (int i = 0; i < n; ++i) {
    sum += get(s[i]) * t;
    t *= 4;
  }
  return S.count(sum) > 0;
}

int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    S.clear();
    char cmd[13], data[13];
    for (int i = 0; i < n; ++i) {
      scanf("%s%s", cmd, data);
      if (strcmp(cmd, "find") != 0) {
        insert(data);
      } else {
        puts(find(data) ? "yes" : "no");
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <set>
#include <sstream>
using namespace std;

int main() {
  int n;
  while (cin >> n) {
    set<string> S;
    string line;
    for (int i = 0; i < n; ++i) {
      string cmd, data;
      cin >> cmd >> data;
      if (cmd == "insert") {
        S.insert(data);
      } else if (cmd == "find") {
        cout << (S.count(data) ? "yes" : "no") << endl;
      }
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded


#include <cstdio>
#include <cstring>
#include <set>
using namespace std;

typedef int INT;
set<INT> S;

inline INT get(char c) {
  char T[5] = "ACGT";
  for (INT i = 0; i < 4; ++i) {
    if (c == T[i])
      return i + 1;
  }
  return 0;
}

inline INT get(char *s) {
  INT n = strlen(s);
  INT sum = 0;
  INT t = 1;
  for (INT i = 0; i < n; ++i) {
    sum += get(s[i]) * t;
    t *= 4;
  }
  return sum;
}

inline void insert(char *s) { S.insert(get(s)); }

inline bool find(char *s) { return S.count(get(s)) > 0; }

int main() {
  INT n;
  while (scanf("%d", &n) != EOF) {
    S.clear();
    char cmd[13], data[13];
    for (register INT i = 0; i < n; ++i) {
      scanf("%s%s", cmd, data);
      if (cmd[0] == 'i') {
        insert(data);
      } else {
        puts(find(data) ? "yes" : "no");
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:


#include <cstdio>
#include <cstring>
#include <set>
using namespace std;

typedef int INT;
set<INT> S;

inline INT get(char c) {
  char T[5] = "ACGT";
  for (INT i = 0; i < 4; ++i) {
    if (c == T[i])
      return i + 1;
  }
  return 0;
}

inline INT get(char *s) {
  INT n = strlen(s);
  INT sum = 0;
  INT t = 1;
  for (INT i = 0; i < n; ++i) {
    sum += get(s[i]) * t;
    t *= 4;
  }
  return sum;
}

inline void insert(char *s) { S.insert(get(s)); }

inline bool find(char *s) { return S.count(get(s)) > 0; }

int main() {
  INT n;
  while (scanf("%hd", &n) != EOF) {
    S.clear();
    char cmd[13], data[13];
    for (register INT i = 0; i < n; ++i) {
      scanf("%s%s", cmd, data);
      if (cmd[0] == 'i') {
        insert(data);
      } else {
        puts(find(data) ? "yes" : "no");
      }
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error


#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int U;
#define L 1548576
bool HA[L];
char T[256];

int main() {
  U n, s, t;
  char c;
  T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
  scanf("%d", &n);
  while (getchar() != '\\n')
    ;
  for (register U i = 0; i++ < n;) {
    s = 0;
    t = 1;
    bool flag = (c = getchar()) == 'i';
    while ((c = getchar()) != ' ')
      ;
    while ((c = T[getchar()]) != 0) {
      s += c * t;
      t *= 4;
    }
    if (flag) {
      HA[s] = true;
    } else {
      puts(HA[s] ? "yes" : "no");
    }
  }
  return 0;
}

Error: 0

Fixed submission:


#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int U;
#define L 1048576
bool HA[L];
char T[256];

int main() {
  U n, s, t;
  char c;
  T['A'] = (char)4, T['C'] = (char)3, T['G'] = (char)2, T['T'] = (char)1;
  scanf("%d", &n);
  while (getchar() != '\\n')
    ;
  for (register U i = 0; i++ < n;) {
    s = 0;
    t = 1;
    bool flag = (c = getchar()) == 'i';
    while ((c = getchar()) != ' ')
      ;
    while ((c = T[getchar()]) != 0) {
      s += c * t;
      t *= 4;
    }
    if (flag) {
      HA[s] = true;
    } else {
      puts(HA[s] ? "yes" : "no");
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error


#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int U;
#define L 1 << 20 + 1
bool HA[L];
char T[256];

int main() {
  U n, s, t;
  char c;
  T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
  scanf("%d", &n);
  while (getchar() != '\\n')
    ;
  for (register U i = 0; i++ < n;) {
    s = 0;
    t = 1;
    bool flag = (c = getchar()) == 'i';
    while ((c = getchar()) != ' ')
      ;
    while ((c = T[getchar()]) != 0) {
      s += c * t;
      t *= 4;
    }
    if (flag) {
      HA[s] = true;
    } else {
      puts(HA[s] ? "yes" : "no");
    }
  }
  return 0;
}

Error: 0

Fixed submission:


#include <cstdio>
#include <cstring>
using namespace std;

typedef unsigned int U;
#define L 1 << 20
bool HA[L];
char T[256];

int main() {
  U n, s, t;
  char c;
  T['A'] = (char)1, T['C'] = (char)2, T['G'] = (char)3, T['T'] = (char)4;
  scanf("%d", &n);
  while (getchar() != '\\n')
    ;
  for (register U i = 0; i++ < n;) {
    s = 0;
    t = 1;
    bool flag = (c = getchar()) == 'i';
    while ((c = getchar()) != ' ')
      ;
    while ((c = T[getchar()]) != 0) {
      s += c * t;
      t *= 4;
    }
    if (flag) {
      HA[s] = true;
    } else {
      puts(HA[s] ? "yes" : "no");
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 1e7 + 8;
#define MOD 1046527
int n;
char H[maxn][15];

int getChar(char ch) { return ch - 'A' + 1; }
ll getValue(char t[]) {
  int len = strlen(t);
  ll sum = 0, p = 1, i;
  for (i = 0; i < len; ++i) {
    sum += p * getChar(t[i]);
    p *= 5;
  }
  return sum;
}
ll h1(ll k) { return k % MOD; }
ll h2(ll k) { return 1 + (k % (MOD - 1)); }
int solve_insert(char c[]) {
  ll key, i, h;
  key = getValue(c);
  i = 0;
  while (true) {
    h = (h1(key) + i * h2(key)) % MOD;
    if (strcmp(H[h], c) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], c);
      return 0;
    }
    i++;
  }
}
int solve_find(char c[]) {
  ll key, i, h;
  i = 0;
  key = getValue(c);
  while (true) {
    h = (h1(key) + i * h2(key)) % MOD;
    if (strcmp(H[h], c) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      return 0;
    }
    i++;
  }
}
int main() {
  scanf("%d", &n);
  char s[15], t[15];
  for (int i = 0; i < n; ++i) {
    scanf("%s%s", s, t);
    if (s[0] == 'i') {
      solve_insert(t);
    } else {
      if (solve_find(t))
        printf("yes\\n");
      else
        printf("no\\n");
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 8;
#define MOD 1046527
int n;
char H[maxn][15];

int getChar(char ch) { return ch - 'A' + 1; }
ll getValue(char t[]) {
  int len = strlen(t);
  ll sum = 0, p = 1, i;
  for (i = 0; i < len; ++i) {
    sum += p * getChar(t[i]);
    p *= 5;
  }
  return sum;
}
ll h1(ll k) { return k % MOD; }
ll h2(ll k) { return 1 + (k % (MOD - 1)); }
int solve_insert(char c[]) {
  ll key, i, h;
  key = getValue(c);
  i = 0;
  while (true) {
    h = (h1(key) + i * h2(key)) % MOD;
    if (strcmp(H[h], c) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], c);
      return 0;
    }
    i++;
  }
}
int solve_find(char c[]) {
  ll key, i, h;
  i = 0;
  key = getValue(c);
  while (true) {
    h = (h1(key) + i * h2(key)) % MOD;
    if (strcmp(H[h], c) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      return 0;
    }
    i++;
  }
}
int main() {
  scanf("%d", &n);
  char s[15], t[15];
  for (int i = 0; i < n; ++i) {
    scanf("%s%s", s, t);
    if (s[0] == 'i') {
      solve_insert(t);
    } else {
      if (solve_find(t))
        printf("yes\\n");
      else
        printf("no\\n");
    }
  }
  return 0;
}