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

#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(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;
  else
    return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

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

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;

    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int i, n, h;
  char str[L], com[9];
  for (i = 0; i < M; i++)
    H[i][0] = '\\0';
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s %s", com, str);
    if (com[0] == 'i') {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\\n");
      } else {
        printf("no\\n");
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstring>
#include <iostream>
#define BIG 1000037
#define length 14

int search(char Array[BIG][length], char str[]);
void insert(char Array[BIG][length], char str[]);
int compute(char str[]);
int h1(char str[]);
int h2(char str[]);
int h(char str[], int i);

using namespace std;

char Array[BIG][length];

int main(void) {
  int n;
  char order[15], str[length];

  cin >> n;
  for (int i = 0; i < BIG; i++) {
    Array[i][0] = '\\0';
  }
  while (n--) {
    cin >> order;
    if (order[0] == 'i') {
      cin >> str;
      insert(Array, str);
    } else {
      cin >> str;
      if (search(Array, str))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }

  return 0;
}

int search(char Array[BIG][length], char str[]) {
  int i = 0;
  while (true) {
    int j = h(str, i);
    if (strcmp(Array[j], str) == 0) {
      return 1;
    } else if (Array[j][0] == '\\0' || i >= BIG)
      return 0;
    else
      i++;
  }
}

void insert(char Array[BIG][length], char str[]) {
  int i = 0;
  while (true) {
    int j = h(str, i);
    if (Array[j][0] == '\\0') {
      strcpy(Array[j], str);
      break;
    } else
      i++;
  }
}

int compute(char str[]) {
  int count = 0;
  for (int i = 0; i < strlen(str); i++) {
    if (str[i] == 'A')
      count += 1 * i;
    else if (str[i] == 'C')
      count += 2 * i;
    else if (str[i] == 'G')
      count += 3 * i;
    else
      count += 4 * i;
  }
  return count;
}

int h1(char str[]) { return compute(str) % BIG; }

int h2(char str[]) { return compute(str) % (BIG - 1); }

int h(char str[], int i) { return (h1(str) + i * h2(str)) % BIG; }
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;

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

  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    char op[20], s[20];
    scanf("%s %s", op, s);

    if (!strcmp(op, "find")) {
      cout << (mp[s] ? "yes" : "no") << endl;
    } else
      mp[s]++;
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

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

  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    string op, s;
    cin >> op >> s;

    if (op == "find") {
      cout << (mp[s] ? "yes" : "no") << endl;
    } else
      mp[s]++;
  }

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

#include <algorithm>
#include <iostream>
#include <math.h> /* pow */
#include <set>
#include <stdio.h> /* printf */
#include <stdlib.h>
#include <string>
#include <vector>

typedef std::string chaine;
typedef std::set<chaine> dic;
typedef dic::iterator iterateur;

int main(void) {

  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  int num;
  std::cin >> num;

  dic list;
  iterateur it;

  for (int i = 0; i < num; i++) {
    chaine value;
    std::cin >> value;

    chaine a;
    std::cin >> a;

    if (value == "insert") {
      list.insert(a);
    } else if (value == "find") {
      if (list.find(a) != list.end()) {
        std::cout << "yes" << std::endl;
      } else {
        std::cout << "no" << std::endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <math.h>  /* pow */
#include <stdio.h> /* printf */
#include <stdlib.h>
#include <string>
#include <vector>

void print_array(std::vector<std::string> list) {
  for (int i = 0; i < list.size(); ++i) {
    if (i > 0)
      std::cout << " ";
    std::cout << list[i];
  }
  std::cout << std::endl;
}

bool searchVector(std::vector<std::string> &dico, std::string key) {
  std::vector<std::string>::iterator it;
  it = find(dico.begin(), dico.end(), key);
  if (it != dico.end())
    return true;
  else
    return false;
}

int main(void) {

  int num;
  std::cin >> num;

  std::vector<std::string> dico;

  for (int i = 0; i < num; i++) {
    std::string cmd;
    std::cin >> cmd;
    std::string entry;
    std::cin >> entry;

    if (cmd.compare("insert") == 0) {
      if (!searchVector(dico, entry)) {
        dico.push_back(entry);
      }
    } else if (cmd.compare("find") == 0) {
      if (searchVector(dico, entry))
        std::cout << "yes" << std::endl;
      else
        std::cout << "no" << std::endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(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;
  else
    return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1;
  for (int i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

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

int find(char str[]) {
  long long key, h;
  key = getKey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}

int insert(char str[]) {
  long long key, h;
  key = getKey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(void) {
  int n, h;
  char str[L], com[9];

  // for (int i = 0; i < M; i++) H[i][0] = '\\0';
  scanf("%d ", &n);
  for (int i = 0; i < n; i++) {
    cin >> com >> str;
    if (com[0] == 'i') {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\\n");
      } else {
        printf("no\\n");
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <string>
#include <vector>
using namespace std;

void find(vector<string> a, string str) {
  int low = 0, high = a.size();
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == str) {
      printf("yes\\n");
      return;
    }
  }
  printf("no\\n");
}

int main(void) {
  int num;
  char command[8];
  char str[13];
  vector<string> a, c, g, t;

  scanf("%d", &num);
  for (int i = 0; i < num; i++) {
    scanf("%s", command);
    scanf("%s", str);
    if (command[0] == 'i') {
      if (str[0] == 'A')
        a.push_back(str);
      else if (str[0] == 'C')
        c.push_back(str);
      else if (str[0] == 'G')
        g.push_back(str);
      else
        t.push_back(str);
    } else {
      if (str[0] == 'A')
        find(a, str);
      else if (str[0] == 'C')
        find(c, str);
      else if (str[0] == 'G')
        find(g, str);
      else
        find(t, str);
    }
  }

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

#include <cstdio>

int translate(char *c) {
  int sum = -1, mlt = 1;
  for (int i = 0; c[i]; i++) {
    if (c[i] == 'A')
      sum += mlt;
    else if (c[i] == 'C')
      sum += 2 * mlt;
    else if (c[i] == 'G')
      sum += 3 * mlt;
    else if (c[i] == 'T')
      sum += 4 * mlt;
    else
      break;
    mlt *= 4;
  }
  return sum;
}

int main() {
  int n;
  char cmd[16], str[16];
  bool *words;

  words = new bool[16777216];
  for (int i = 0; i < 16777216; i++)
    words[i] = false;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s%s", cmd, str);
    if (cmd[0] == 'i')
      words[translate(str)] = true;
    else {
      if (words[translate(str)])
        printf("yes\\n");
      else
        printf("no\\n");
    }
  }
  delete[] words;
  return 0;
}


Error: -11

Fixed submission:

#include <cstdio>

long long translate(char *a) {
  long long ret = -1, mlt = 1;
  for (int i = 0; a[i]; i++) {
    if (a[i] == 'A')
      ret += mlt;
    else if (a[i] == 'C')
      ret += 2 * mlt;
    else if (a[i] == 'G')
      ret += 3 * mlt;
    else
      ret += 4 * mlt;
    mlt *= 5;
  }
  return ret;
}

int main() {
  int n;
  char cmd[16], key[16];
  bool words[195312500] = {};
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s %s", cmd, key);
    if (cmd[0] == 'i')
      words[translate(key)] = 1;
    else {
      if (words[translate(key)])
        printf("yes\\n");
      else
        printf("no\\n");
    }
  }

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

#include <bits/stdc++.h>
using namespace std;

#define m 1046527
#define L 14

char T[m][L];

int h1(long long key) { return key % m; }
int h2(long long key) { return 1 + key % (m - 1); }
int h(long long key, int i) { return (h1(key) + i * h2(key)) % m; }
int charTonum(char c) {
  switch (c) {
  case 'A':
    return 1;
  case 'C':
    return 2;
  case 'G':
    return 3;
  case 'T':
    return 4;
  default:
    return 0;
  }
}

long long getKey(char str[]) {
  int length = strlen(str);
  long long sum = 0, p = 1;
  for (int i = 0; i < length; ++i) {
    sum += p * charTonum(str[i]);
    p *= 5;
  }
  return sum;
}
void insert(char str[]) {
  long long key, pos, i = 0;
  key = getKey(str);
  while (1) {
    pos = h(key, i);
    if (strcmp(T[pos], str) == 0)
      break;
    else if (strlen(T[pos]) == 0) {
      strcpy(T[pos], str);
      break;
    }
    i++;
  }
}

int find(char str[]) {
  long long key, pos, i = 0;
  key = getKey(str);
  while (1) {
    pos = h(key, i);
    if (strcmp(T[pos], str) == 0)
      return 0;
    else if (strlen(T[pos]) == 0)
      return 1;
    i++;
  }
}

int main() {
  int n, key, ret;
  /*FILE *fpRead=fopen("In9.txt","r");

  fscanf(fpRead,"%d",&n);*/
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    T[i][0] = '\\0';
  char op[7], str[L];
  for (int i = 0; i < n; ++i) {
    // fscanf(fpRead,"%s %s",op,str);
    scanf("%s %s", op, str);
    if (op[0] == 'i') {
      insert(str);
      // printf("%s %s %d\\n",op,str,i);
    } else {
      ret = find(str);
      if (ret == 0)
        printf("yes\\n");
      else
        printf("no\\n");
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;

#define m 1046527
#define L 14

char T[m][L];

int h1(long long key) { return key % m; }
int h2(long long key) { return 1 + key % (m - 1); }
int h(long long key, int i) { return (h1(key) + i * h2(key)) % m; }
int charTonum(char c) {
  switch (c) {
  case 'A':
    return 1;
  case 'C':
    return 2;
  case 'G':
    return 3;
  case 'T':
    return 4;
  }
}

long long getKey(char str[]) {
  int length = strlen(str);
  long long sum = 0, p = 1;
  for (int i = 0; i < length; ++i) {
    sum += p * charTonum(str[0]);
    p *= 5;
  }
  return sum;
}
void insert(char str[]) {
  int pos, i = 0;
  long long key = getKey(str);
  while (1) {
    pos = h(key, i);
    if (strlen(T[pos]) == 0) {
      strcpy(T[pos], str);
      break;
    } else
      i++;
  }
}

int find(char str[]) {
  int pos, i = 0;
  long long key = getKey(str);
  while (1) {
    pos = h(key, i);
    if (strcmp(T[pos], str) == 0)
      return 0;
    else if (strlen(T[pos]) == 0)
      return 1;
    i++;
  }
}

int main() {
  int n, key, ret;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    T[i][0] = '\\0';
  char op[7], str[L];
  for (int i = 0; i < n; ++i) {
    scanf("%s %s", op, str);

    if (op[0] == 'i')
      insert(str);
    else {
      ret = find(str);
      if (ret == 0)
        printf("yes\\n");
      else
        printf("no\\n");
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
#include <string.h>

#define M 1006000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(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;
}

/* convert a string into an integer value */
long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

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

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}

int insert(char str[]) {

  long long key, i, h;
  key = getKey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int i, n, h;
  char str[L], com[9];
  for (i = 0; i < M; i++)
    H[i][0] = '\\0';

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s %s", com, str);

    if (com[0] == 'i') {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\\n");
      } else {
        printf("no\\n");
      }
    }
  }

  return 0;
}


Error: 0

Fixed submission:

#include <stdio.h>
#include <string.h>

#define M 122222
#define L 14

char H[M][L]; /* Hash Table */

int getChar(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;
}

/* convert a string into an integer value */
long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

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

int find(char str[]) {
  long long key, i, h;
  key = getKey(str);
  for (i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}

int insert(char str[]) {

  long long key, i, h;
  key = getKey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main() {
  int i, n, h;
  char str[L], com[9];
  for (i = 0; i < M; i++)
    H[i][0] = '\\0';

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    scanf("%s %s", com, str);

    if (com[0] == 'i') {
      insert(str);
    } else {
      if (find(str)) {
        printf("yes\\n");
      } else {
        printf("no\\n");
      }
    }
  }

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

#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
const int M = 1046527;
const int L = 14;
char H[M][L];
int getChar(char str) {
  if (str == 'A')
    return 1;
  else if (str == 'T')
    return 2;
  else if (str == 'C')
    return 3;
  else if (str == 'G')
    return 4;
  else
    return 0;
}
int getInt(char str[]) {
  int q;
  int sum = 0;
  for (int i = 0; i < strlen(str); i++) {
    q = getChar(str[i]);
    sum = sum * 5 + q;
  }
  return sum;
}
int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % M); }
int h(int key, int i) { return (h1(key) + i * h2(key)) % M; }
int insertKey(char str[]) {
  int key = getInt(str);
  int i = 0;
  while (true) {
    int position = h(key, i);
    if (strcmp(H[position], str) == 0)
      return 1;
    else if (strlen(H[position]) == 0) {
      strcpy(H[position], str);
      return 1;
    }
    i = i + 1;
  }
  return 0;
}
int findKey(char str[]) {
  int key = getInt(str);
  int i = 0;
  while (true) {
    int position = h(key, i);
    if (strcmp(H[position], str) == 0)
      return 1;
    else if (strlen(H[position]) == 0)
      return 0;
    i = i + 1;
  }
  return 0;
}
int main() {
  int n;
  char str[L], com[9];
  scanf("%d", &n);
  for (int i = 0; i < M; i++)
    H[i][0] = '\\0';
  while (n--) {
    scanf("%s %s", com, str);
    if (com[0] == 'i') {
      insertKey(str);
    } else {
      if (findKey(str)) {
        printf("yes\\n");
      } else {
        printf("no\\n");
      }
    }
  }
  return 0;
}

Error: MLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int node[1000100][120];
int num[1000010];
char str[20];
int cnt = 1;
void Insert() {
  cin >> str;
  int root = 0;
  for (int i = 0; str[i]; ++i) {
    if (!node[root][str[i] - 'A']) {
      node[root][str[i] - 'A'] = cnt++;
    }
    root = node[root][str[i] - 'A'];
    if (i == strlen(str) - 1) {
      num[root] += 1;
    }
  }
}
string Find() {
  cin >> str;
  int root = 0;
  for (int i = 0; str[i]; ++i) {
    if (!node[root][str[i] - 'A']) {
      return "no";
    }
    root = node[root][str[i] - 'A'];
  }
  // cout<<root<<endl;
  if (num[root] >= 1) {

    return "yes";
  } else {
    return "no";
  }
}
int main() {
  int n;
  cin >> n;
  while (n--) {
    string a;
    cin >> a;
    if (a == "insert") {
      Insert();
    } else {
      cout << Find() << endl;
    }
  }
  // cout<<num[0]<<num[1]<<num[2]<<num[3];
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <vector>

typedef long long ll;

using namespace std;

char H[1046527][15];

int getCharKey(char a) {
  if (a == 'A')
    return 1;
  else if (a == 'C') {
    return 2;
  } else if (a == 'G') {
    return 3;
  } else if (a == 'T') {
    return 4;
  } else
    return 0;
}

ll getKey(char a[]) {
  ll sum = 0;
  ll p = 1;
  for (ll i = 0; i < strlen(a); i++) {
    sum += p * getCharKey(a[i]);
    p *= 5;
  }
  return sum;
}

int h1(int key) { return key % 1046527; }
int h2(int key) { return 1 + (key % 1046526); }

int insert(char a[]) {
  ll key = getKey(a);
  for (ll i = 0;; i++) {
    ll h = (h1(key) + i * h2(key)) % 1046527;
    if (strcmp(H[h], a) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], a);
      return 0;
    }
  }
  return 0;
}

int find(char a[]) {
  ll key = getKey(a);
  for (ll i = 0;; i++) {
    ll h = (h1(key) + i * h2(key)) % 1046527;
    if (strcmp(H[h], a) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    H[i][0] = '\\0';

  char a[20], b[20];
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    if (a[0] == 'i')
      insert(b);
    else {
      if (find(b))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <string.h>
#define M 1000027
#define NIL (-1)
#define L 14
char H[M][L];
using namespace std;
int getchar(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;
  else
    return 0;
}
long long getkey(char str[]) {
  long long sum = 0, p = 1, i;
  for (int i = 0; i < strlen(str); i++) {
    sum += p * (getchar(str[i]));
    p *= 5;
  }
  return sum;
}
int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }
int find(char str[]) {
  long long key, i, h;
  key = getkey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0)
      return 0;
  }
  return 0;
}
int insert(char str[]) {
  long long key, i, h;
  key = getkey(str);
  for (int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if (strcmp(H[h], str) == 0)
      return 1;
    else if (strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}
int main() {
  int n, h;
  char str[L], com[9];
  for (int i = 0; i < M; i++) {
    H[i][0] = '\\0';
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%s %s", com, str);
      if (com[0] == 'i') {
        insert(str);
      } else {
        if (find(str)) {
          printf("yes\\n");
        } else {
          printf("no\\n");
        }
      }
    }
  }
  return 0;
}