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

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

int main() {

  set<string> acgt;

  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    char op[10], str[20];
    scanf("%s%s", op, str);
    if (op[0] == 'f') {
      if (acgt.find(str) != acgt.end())
        printf("yes\\n");
      else
        printf("no\\n");
    } else
      acgt.insert(str);
  }
}

Error: TLE

Fixed submission:

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

int main() {

  set<string> acgt;

  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string op, str;
    cin >> op >> str;
    if (op.size() == 4) {
      if (acgt.find(str) != acgt.end())
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    } else
      acgt.insert(str);
  }
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string s1, s2;
    cin >> s1 >> s2;
    if (s1[0] == 'i')
      s.insert(s2);
    else {
      if (s.find(s2) == s.end())
        printf("no\\n");
      else
        printf("yes\\n");
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  string s1, s2;
  set<string> s;
  for (int i = 0; i < n; i++) {
    cin >> s1 >> s2;
    if (s1 == "insert")
      s.insert(s2);
    else {
      if (s.find(s2) == s.end())
        cout << "no\\n";
      else
        cout << "yes\\n";
    }
  }
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string s1, s2;
    cin >> s1 >> s2;
    if (s1[0] == 'i')
      s.insert(s2);
    else {
      if (s.find(s2) == s.end())
        printf("no\\n");
      else
        printf("yes\\n");
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {

  int n;
  cin >> n;
  set<string> s;
  for (int i = 0; i < n; i++) {
    string s1, s2;
    cin >> s1 >> s2;
    if (s1[0] == 'i')
      s.insert(s2);
    else {
      if (s.find(s2) == s.end())
        printf("no\\n");
      else
        printf("yes\\n");
    }
  }
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;
int main() {
  unordered_set<string> A;
  int counter;
  string order, word;
  cin >> counter;
  for (int i = 0; i < counter; i++) {
    cin >> order;
    if (order == "insert") {
      cin >> word;
      A.insert(word);
    } else if (order == "find") {
      cin >> word;
      if (A.count(word) == 0)
        cout << "no" << endl;
      else
        cout << "yes" << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <set>
#include <string>
using namespace std;
int main() {
  set<string> A;
  int counter;
  string order, word;
  cin >> counter;
  for (int i = 0; i < counter; i++) {
    cin >> order;
    if (order == "insert") {
      cin >> word;
      A.insert(word);
    } else if (order == "find") {
      cin >> word;
      if (A.count(word) == 0)
        cout << "no" << endl;
      else
        cout << "yes" << endl;
    }
  }
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

int main() {

  int n;

  scanf("%d", &n);

  map<string, int> mp;

  string s1, s2;

  while (n--) {
    cin >> s1 >> s2;

    if (s1[0] == 'i') {
      mp[s2]++;
    } else if (s1[0] == 'f') {
      if (mp.find(s2) != mp.end()) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }

  return 0;
}


Error: 0

Fixed submission:

#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

#define M 1046527
#define L 14

char a[M][L];

int h1(int key) { return key % M; }

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

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

int getkey(char s[]) {
  int sum = 0, p = 1;
  int len = strlen(s);
  for (int i = 0; i < len; i++) {
    sum += p * (getchar(s[i]));
    p *= 5;
  }

  return sum;
}

void insert(char *s) {
  int key, h;
  key = getkey(s);

  for (int i = 0;; i++) {
    h = (h1(key) + i * (h2(key))) % M;
    if (strcmp(a[h], s) == 0) {
      break;
    } else if (!strlen(a[h])) {
      strcpy(a[h], s);
      break;
    }
  }
}

bool find(char *s) {
  int h, key;

  key = getkey(s);

  for (int i = 0;; i++) {
    h = h1(key) + i * (h2(key));
    if (strcmp(a[h], s) == 0) {
      return true;
    } else if (!strlen(a[h])) {
      return false;
    }
  }
}

int main() {
  int n;

  char ch[7], b[14];

  cin >> n;

  for (int i = 0; i < n; i++) {
    scanf("%s %s", ch, b);

    if (ch[0] == 'i') {
      insert(b);
    } else if (ch[0] == 'f') {
      if (find(b)) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }

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

// alds_dictionary
#include <bits/stdc++.h>
using namespace std;
bool d[99999999];
int number(char a) {
  switch (a) {
  case 'A':
    return 1;
    break;
  case 'C':
    return 2;
    break;
  case 'G':
    return 3;
    break;
  case 'T':
    return 4;
    break;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  vector<string> v;
  for (int i = 0; i < n; i++) {
    string o, s;
    cin >> o >> s;
    int tmp = 1, index = 0;
    if (o == "insert") {
      // v.push_back(s);
      for (int j = 0; j < s.length(); j++) {
        index += tmp * number(s[j]);
        tmp *= 5;
      }
      // cout << index << endl;
      d[index] = true;
    } else { // find
      // if(find(v.begin(), v.end(), s) != v.end()) puts("yes");
      for (int j = 0; j < s.length(); j++) {
        index += tmp * number(s[j]);
        tmp *= 5;
      }
      // cout << index << "  ";
      if (d[index])
        puts("yes");
      else
        puts("no");
    }
  }
}


Error: TLE

Fixed submission:

// alds_dictionary
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<string> v;
  for (int i = 0; i < n; i++) {
    string o, s;
    cin >> o >> s;
    if (o == "insert") {
      v.push_back(s);
    } else { // find
      if (find(v.begin(), v.end(), s) != v.end())
        puts("yes");
      else
        puts("no");
    }
  }
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int getKey(const string &s) {
  int res = 0;
  for (int i = 0; i < s.size(); i++) {
    res *= 5;
    switch (s[i]) {
    case 'A':
      res += 1;
      break;
    case 'C':
      res += 2;
      break;
    case 'G':
      res += 3;
      break;
    case 'T':
      res += 4;
      break;
    }
  }
  return res;
}

int main() {
  set<int> s;
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string op;
    string str;
    cin >> op >> str;

    if (op == "insert") {
      s.insert(getKey(str));
    } else if (s.find(getKey(str)) != s.end()) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}

Error: TLE

Fixed submission:

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

int main() {
  set<string> s;
  int n;
  cin >> n;

  for (int i = 0; i < n; i++) {
    string op;
    string str;
    cin >> op >> str;

    if (op == "insert") {
      s.insert(str);
    } else if (s.find(str) != s.end()) {
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <unordered_set>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

int n;
unordered_set<string> s;

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  rep(i, n) {
    string c, d;
    cin >> c >> d;
    if (c == "insert") {
      s.insert(d);
    } else {
      cout << (s.find(d) != s.end() ? "yes" : "no") << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

int n;
set<string> s;

int main() {
  cin >> n;
  rep(i, n) {
    string c, d;
    cin >> c >> d;
    if (c == "insert") {
      s.insert(d);
    } else {
      cout << (s.find(d) != s.end() ? "yes" : "no") << endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#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(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;
}

Error: TLE

Fixed submission:

#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(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 < num1; i++)
    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 <cstring>
#include <iostream>
#include <string>
using namespace std;
const int MAXT = 1000003;
const int MAXN = 1000010;
int n;
string s;
int head[1000003], nex[MAXN], to[MAXN], top, top1, ans[MAXN];
void input() {
  cin >> n;
  memset(head, -1, sizeof(head));
  memset(nex, -1, sizeof(nex));
}

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

void insert(int k) {
  nex[top] = head[k % MAXT];
  head[k % MAXT] = top;
  to[top++] = k;
}

int k(string ss) {
  int s(1);
  int sum(0);
  for (int i = 0; i < ss.size(); i++) {
    sum += s * jisuan(ss[i]);
    s *= 5;
  }
  return sum;
}

bool ff(int k) {
  int u = head[k % MAXT];
  while (u != -1) {
    if (to[u] == k)
      return true;
    u = nex[u];
  }
  return false;
}

void xxj() {
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "insert") {
      cin >> s;
      int tmp = k(s);
      insert(tmp);
    } else {
      cin >> s;
      int tmp = k(s);
      ans[top1++] = ff(tmp);
    }
  }
}

void output() {
  for (int i = 0; i < top1; i++)
    if (ans[i])
      cout << "yes" << '\\n';
    else
      cout << "no" << '\\n';
}

int main() {
  input();
  xxj();
  output();
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <string>
using namespace std;
const int MAXN = 3;
int s[MAXN][MAXN][MAXN][MAXN][MAXN][MAXN][MAXN][MAXN][MAXN][MAXN][MAXN][MAXN];
int v[12];
int main() {
  int n;
  string a, b;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a >> b;
    if (a[0] == 'i') {
      for (int i1 = 0; i1 < b.size(); i1++) {
        if (b[i1] == 'A') {
          v[i1] = 1;
          continue;
        }
        if (b[i1] == 'C') {
          v[i1] = 2;
          continue;
        }
        if (b[i1] == 'G') {
          v[i1] = 3;
          continue;
        }
        if (b[i1] == 'T') {
          v[i1] = 4;
          continue;
        }
      }
    }
    s[v[0]][v[1]][v[2]][v[3]][v[4]][v[5]][v[6]][v[7]][v[8]][v[9]][v[10]]
     [v[11]] = 1;
    for (int i1 = 0; i1 < 12; i1++)
      v[i1] = 0;
    if (a[0] == 'f') {
      for (int i1 = 0; i1 < b.size(); i1++) {
        if (b[i1] == 'A') {
          v[i1] = 1;
          continue;
        }
        if (b[i1] == 'C') {
          v[i1] = 2;
          continue;
        }
        if (b[i1] == 'G') {
          v[i1] = 3;
          continue;
        }
        if (b[i1] == 'T') {
          v[i1] = 4;
          continue;
        }
      }
      if (s[v[0]][v[1]][v[2]][v[3]][v[4]][v[5]][v[6]][v[7]][v[8]][v[9]][v[10]]
           [v[11]] == 1)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
      for (int i1 = 0; i1 < 12; i1++)
        v[i1] = 0;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  set<string> st;
  while (n--) {
    string order;
    string str;

    cin >> order;
    cin >> str;

    if (order == "insert") {
      st.insert(str);
    } else {
      if (st.find(str) != st.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() {
  int n;
  cin >> n;
  set<string> st;
  while (n--) {
    string order;
    string str;

    cin >> order;
    cin >> str;

    if (order == "insert") {
      st.insert(str);
    } else {
      if (st.find(str) != st.end()) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int CommandNum;
  set<string> List;
  string Command, ss;

  List.clear();
  cin >> CommandNum;
  for (int i = 0; i < CommandNum; i++) {
    cin >> Command;
    cin >> ss;
    if (Command == "insert") {
      List.insert(ss);
    } else if (Command == "find") {
      set<string>::iterator itr = List.find(ss);
      if (itr != List.end())
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <set>
using namespace std;
int main(void) {
  int CommandNum;
  set<string> List;
  string Command, ss;

  List.clear();

  cin >> CommandNum;
  for (int i = 0; i < CommandNum; i++) {
    cin >> Command;
    cin >> ss;
    if (Command == "insert") {
      List.insert(ss);
    } else if (Command == "find") {
      set<string>::iterator itr = List.find(ss);
      if (itr != List.end())
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int CommandNum;
  set<string> List;
  string Command, ss;

  List.clear();
  cin >> CommandNum;
  for (int i = 0; i < CommandNum; i++) {
    cin >> Command >> ss;
    if (Command[0] == 'i') {
      List.insert(ss);
    } else if (Command[0] == 'f') {
      set<string>::iterator itr = List.find(ss);
      if (itr != List.end())
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
}

Error: TLE

Fixed submission:

#include <iostream>
#include <math.h>
#include <string>
#include <vector>
using namespace std;

long long Convert(string ss);

long long Convert(string ss) {
  long long Number = 0;
  int Value;
  for (int i = 0; i < ss.size(); i++) {
    if (ss[i] == 'A') {
      Value = 1;
    } else if (ss[i] == 'C') {
      Value = 2;
    } else if (ss[i] == 'G') {
      Value = 3;
    } else {
      Value = 4;
    }
    Number += Value * pow(10, i);
  }
  return Number;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long CommandNum, ConvertResult;
  vector<long long> List;
  string Command, ss;

  List.clear();
  cin >> CommandNum;
  for (int i = 0; i < CommandNum; i++) {
    cin >> Command;
    cin >> ss;
    ConvertResult = Convert(ss);
    if (Command == "insert") {
      List.push_back(ConvertResult);
    } else {
      string Ans = "no";
      for (int j = 0; j < List.size(); j++) {
        if (ConvertResult == List[j]) {
          Ans = "yes";
          break;
        }
      }
      cout << Ans << endl;
    }
  }
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int hs(string);
int matoi(char);
int main() {
  int nma = 1;
  for (int i = 0; i < 12; i++) {
    nma *= 4;
  }
  vector<int> a(nma + 5, 0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string fu;
    string st;
    cin >> fu >> st;
    int h = hs(st);
    if (fu == "insert") {
      a[h] = 1;
    } else {
      if (a[h])
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}
int hs(string st) {
  int re = 0;
  for (int i = st.size() - 1; i >= 0; i--) {
    re *= 4;
    int a = matoi(st[i]);
    re += a;
  }
  return re;
}
int matoi(char ch) {
  if (ch == 'A')
    return 1;
  if (ch == 'C')
    return 2;
  if (ch == 'G')
    return 3;
  return 4;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string st, wo;
  vector<string> s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> st >> wo;

    if (st == "insert") {
      s.push_back(wo);
    }

    else {
      sort(s.begin(), s.end());
      int l = 0, r = s.size(), m, f = 0;
      while (l < r) {
        m = (l + r) / 2;
        if (s[m] == wo) {
          cout << "yes" << endl;
          f = 1;
          break;
        }
        if (wo < s[m])
          r = m;
        else
          l = m + 1;
      }
      if (f == 0)
        cout << "no" << endl;
    }
  }

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

#include <iostream>
#include <vector>
#define SIZE 1000039
using namespace std;

string hashTable[SIZE];

int hashValue(string str) {
  int res = 0;
  int v = 1;
  for (int i = 0; i < str.length(); i++) {
    res += v * (str[i] - '0');
    v *= 7;
  }
  return res;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < SIZE; i++)
    hashTable[i] = "";

  int n;
  cin >> n;
  while (n--) {
    string query, str;
    cin >> query >> str;
    if (query == "insert") {
      int hash = hashValue(str);
      int place = hash % SIZE;
      int v = 1;
      while (hashTable[place] != "") {
        place = (hash % SIZE + v * (1 + hash % (SIZE - 1))) % SIZE;
        v++;
      }
      hashTable[place] = str;
    }
    if (query == "find") {
      int hash = hashValue(str);
      int place = hash % SIZE;
      int v = 1;
      bool yes = true;
      while (hashTable[place] != str) {
        if (hashTable[place] == "") {
          yes = false;
          break;
        }
        place = (hash % SIZE + v * (1 + hash % (SIZE - 1))) % SIZE;
        v++;
      }
      if (yes)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <vector>
#define SIZE 1000039
using namespace std;

string hashTable[SIZE];

int hashValue(string str) {
  int res = 0;
  int v = 1;
  for (int i = 0; i < str.length(); i++) {
    res += v * (str[i] - '0');
    v *= 7;
  }
  return res;
}

int main(void) {
  for (int i = 0; i < SIZE; i++)
    hashTable[i] = "";

  int n;
  cin >> n;
  while (n--) {
    string query, str;
    cin >> query >> str;
    if (query == "insert") {
      int hash = hashValue(str);
      int place = hash % SIZE;
      int v = 1;
      while (hashTable[place] != "") {
        place = (hash % SIZE + v * (1 + hash % (SIZE - 1))) % SIZE;
        v++;
      }
      hashTable[place] = str;
    }
    if (query == "find") {
      int hash = hashValue(str);
      int place = hash % SIZE;
      int v = 1;
      bool yes = true;
      while (hashTable[place] != str) {
        if (hashTable[place] == "") {
          yes = false;
          break;
        }
        place = (hash % SIZE + v * (1 + hash % (SIZE - 1))) % SIZE;
        v++;
      }
      if (yes)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <list>
#include <set>
#include <stdio.h>
#include <string>

using namespace std;
set<string> lst;

int main() {
  int dataset;
  scanf("%d", &dataset);
  for (int i = 0; i < dataset; i++) {
    string order;
    cin >> order;
    if (order[0] == 'i') {
      string a;
      cin >> a;
      lst.insert(a);
    } else {
      string finder;
      cin >> finder;
      if (lst.find(finder) == lst.end()) {
        cout << "no" << endl;
      } else {
        cout << "yes" << endl;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;
list<string> lst;

int main() {
  int dataset;
  scanf("%d", &dataset);
  for (int i = 0; i < dataset; i++) {
    char order[10];
    scanf("%s", order);
    if (order[0] == 'i') {
      string a;
      cin >> a;
      lst.push_front(a);
    } else {
      string finder;
      cin >> finder;
      bool a = true;
      for (auto itr = lst.begin(); itr != lst.end(); itr++) {
        if (*itr == finder) {
          cout << "yes" << endl;
          a = false;
          break;
        }
      }
      if (a == true) {
        cout << "no" << endl;
      }
    }
  }
  return 0;
}