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

#include <iostream>
#include <vector>
#define MAX 1046527
using namespace std;

vector<string> dictionaly(MAX);
int cnt = 0;

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

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

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

long long int Key(string s) {
  long long int ans = 0;
  long long int p = 1;

  for (long long int i = 0; i < s.size(); i++) {
    ans += p * (toInt(s[i]));
    p *= 5;
  }

  return ans;
}

void insert(string s) {
  long long int key, h;
  key = Key(s);

  for (long long int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % MAX;

    if (dictionaly[h] == s)
      break;

    else if (dictionaly[h].size() == 0) {
      dictionaly[h] = s;
      break;
    }
  }
}

int find(string s) {
  long long int key, h;

  key = Key(s);

  for (long long int i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % MAX;

    if (dictionaly[h] == s)
      return 1;

    else if (dictionaly[h].size() == 0)
      return 0;
  }

  return 0;
}

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

  dictionaly.resize(n);

  string check;
  string s;

  for (int i = 0; i < n; i++) {
    cin >> check >> s;

    if (check == "insert")
      insert(s);

    else {
      if (find(s))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

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

vector<string> dictionaly;
int cnt = 0;

int find(string s) {
  for (int i = 0; i < cnt; i++) {
    if (dictionaly[i] == s)
      return 1;
  }

  return 0;
}

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

  dictionaly.resize(n);

  string s;
  string str;

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

    if (s == "insert")
      dictionaly[cnt++] = str;

    else {
      if (find(str))
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }

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

#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int Hash(std::string Text) {
  int Hash = 0;
  for (std::size_t i = 0; i < Text.size(); ++i) {
    if (i) {
      Hash *= 5;
    }
    switch (Text[i]) {
    case 'A':
      Hash += 1;
      break;
    case 'C':
      Hash += 2;
      break;
    case 'G':
      Hash += 3;
      break;
    case 'T':
      Hash += 4;
      break;
    default:
      assert(false);
    }
  }
  return Hash;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::vector<bool> dic(std::pow(5, 12), false);
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::string command, str;
    std::cin >> command >> str;
    if (command[0] == 'i') {
      dic[Hash(str)] = true;
    } else if (command[0] == 'f') {
      std::cout << (dic[Hash(str)] ? "yes" : "no") << std::endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cassert>
#include <iostream>
#include <string>
#include <vector>

int Hash(std::string Text) {
  int Hash = 0;
  for (std::size_t i = 0; i < Text.size(); ++i) {
    if (i) {
      Hash *= 5;
    }
    switch (Text[i]) {
    case 'A':
      Hash += 1;
      break;
    case 'C':
      Hash += 2;
      break;
    case 'G':
      Hash += 3;
      break;
    case 'T':
      Hash += 4;
      break;
    default:
      assert(false);
    }
  }
  return Hash;
}
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::vector<bool> dic(5 * 5 * 5 * 5, false);
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::string command, str;
    std::cin >> command >> str;
    if (command[0] == 'i') {
      dic[Hash(str)] = true;
    } else if (command[0] == 'f') {
      std::cout << (dic[Hash(str)] ? "yes" : "no") << std::endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <string>
#include <utility>

template <typename T> struct Node {
  T value;
  Node *left;
  Node *right;
  Node() { left = right = NULL; }
};

template <typename T> class MySet {
  Node<T> *root_;
  std::pair<Node<T> *, bool> insert(const T &value, Node<T> *node) {
    if (node->value == value) {
      return std::make_pair(node, false);
    }
    Node<T> *&p = node->value < value ? node->right : node->left;
    if (p)
      return insert(value, p);
    p = new Node<T>;
    p->value = value;
    return std::make_pair(p, true);
  }
  Node<T> *find(const T &value, Node<T> *node) {
    if (node->value == value) {
      return node;
    }
    Node<T> *p = node->value < value ? node->right : node->left;
    if (p)
      return find(value, p);
    return NULL;
  }
  void delete_node(Node<T> *node) {
    if (node == NULL)
      return;
    delete_node(node->left);
    delete_node(node->right);
    delete node;
  }

public:
  MySet() : root_(NULL) {}
  ~MySet() { delete_node(root_); }
  std::pair<Node<T> *, bool> insert(const T &value) {
    if (root_)
      return insert(value, root_);
    root_ = new Node<T>;
    root_->value = value;
    return std::make_pair(root_, true);
  }
  Node<T> *find(const T &value) {
    if (root_)
      return find(value, root_);
    return NULL;
  }
  Node<T> *end() { return NULL; }
};

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  // std::set<std::string> dic;
  MySet<std::string> dic;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::string command, str;
    std::cin >> command >> str;
    if (command == "insert") {
      dic.insert(str);
    } else if (command == "find") {
      std::cout << (dic.find(str) != dic.end() ? "yes" : "no") << std::endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::vector<std::string> dic;
  int n;
  std::cin >> n;
  dic.reserve(n);
  for (int i = 0; i < n; ++i) {
    std::string command, str;
    std::cin >> command >> str;
    if (command == "insert") {
      std::vector<std::string>::iterator It =
          std::lower_bound(dic.begin(), dic.end(), str);
      dic.insert(It, str);
    } else if (command == "find") {
      bool IsFind = std::binary_search(dic.begin(), dic.end(), str);
      std::cout << (IsFind ? "yes" : "no") << std::endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>
#include <string>

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::set<std::string> dic;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::string command, str;
    std::cin >> command >> str;
    if (command[0] == 'i') {
      dic.insert(str);
    } else if (command[0] == 'f') {
      std::cout << (dic.find(str) != dic.end() ? "yes" : "no") << std::endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <list>
#include <string>

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::list<std::string> dic;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::string command, str;
    std::cin >> command >> str;
    std::list<std::string>::iterator It =
        std::lower_bound(dic.begin(), dic.end(), str);
    bool IsFind = It != dic.end() && *It == str;
    if (command == "insert" && IsFind == false) {
      dic.insert(It, str);
    } else if (command == "find") {
      std::cout << (IsFind ? "yes" : "no") << std::endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>
#include <string>

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::set<std::string> dic;
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::string command, str;
    std::cin >> command >> str;
    if (command == "insert") {
      dic.insert(str);
    } else if (command == "find") {
      std::cout << (dic.find(str) != dic.end() ? "yes" : "no") << std::endl;
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <set>
#include <string>

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

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

int main() {
  int n;
  cin >> n;
  string op, des;
  set<string> v;
  while (n--) {
    cin >> op >> des;
    if (op == "insert") {
      v.insert(des);
    } else {
      if (v.count(des) != 0)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

/*#include<iostream>
#include<string>
using namespace std;
int main(){
    static const size_t npos = -1;
    size_t pos;
    int n;
    cin>>n;
    string a,b,str;
    while(n--){
        cin>>a>>b;
        if(a=="insert"){
            str+=b;
        }
        else if(a=="find"){
            pos=str.find(b);
            if(pos!=string::npos)
                cout<<"yes"<<endl;
            else
                cout<<"no"<<endl;
            }
        }
    return 0;
}
*/

#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  string *s = new string[n];
  int u = 0;
  while (n--) {
    string a, b;
    cin >> a >> b;
    if (a == "insert") {
      s[u] = b;
      u++;
    } else {
      for (int i = 0; i < u; i++) {
        if (s[i] == b) {
          cout << "yes" << endl;
          goto loop;
        }
      }
      cout << "no" << endl;
    }
  loop:
    continue;
  }
  delete[] s;
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_set>
#include <utility>
using namespace std;

enum Command { INSERT, FIND };

int main() {
  int n;
  int which_command;
  unordered_set<string> A;
  string word;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> word;
    if (word == "insert") {
      which_command = INSERT;
    } else if (word == "find") {
      which_command = FIND;
    } else {
      switch (which_command) {
      case INSERT:
        A.insert(word);
        break;
      case FIND:
        if (A.count(word) > 0)
          cout << "yes" << endl;
        else
          cout << "no" << endl;
        break;
      default:
        break;
      }
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

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

enum Command { INSERT, FIND };

int main() {
  int n;
  int which_command;
  set<string> A;
  string word;
  cin >> n;
  for (int i = 0; i < 2 * n; i++) {
    cin >> word;
    if (word == "insert") {
      which_command = INSERT;
    } else if (word == "find") {
      which_command = FIND;
    } else {
      switch (which_command) {
      case INSERT:
        A.insert(word);
        break;
      case FIND:
        if (A.count(word) > 0)
          cout << "yes" << endl;
        else
          cout << "no" << endl;
        break;
      default:
        break;
      }
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

  map<string, bool> mp;
  REP(i, n) {
    string s, w;
    cin >> s >> w;
    if (s == "find") {
      if (mp[w])
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    } else {
      mp[w] = true;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <ctype.h>
#include <math.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
struct omt {
  omt() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
} star;

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

  vector<string> D;
  string s, v;
  REP(i, n) {
    cin >> s >> v;
    if (s == "insert")
      D.push_back(v);
    else {
      auto itr = find(D.begin(), D.end(), v);
      if (itr != D.end())
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }

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

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
  int n;
  char str[10], com[13];
  map<string, bool> mp;
  cin >> n;
  rep(i, n) {
    cin >> com >> str;
    if (com[0] == 'i')
      mp[string(str)] = true;
    else {
      if (mp[string(str)])
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
  int n;
  cin >> n;
  bool flag;
  string s, t;
  vector<string> str(n);
  rep(i, n) {
    flag = false;
    cin >> s >> t;
    if (s == "insert") {
      str.push_back(t);
    } else if (s == "find") {
      for (int j = 0; j < (int)str.size(); j++) {
        if (str[j] == t) {
          cout << "yes" << endl;
          flag = true;
          break;
        }
        if (str[(int)str.size() - 1 - j] == t) {
          cout << "yes" << endl;
          flag = true;
          break;
        }
      }
      if (flag == false)
        cout << "no" << endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#define m 1000003
using namespace std;

int T[m];

int h(int k, int i) { return (k % m + i * (1 + k % (m - 1))) % m; }

int insert(int k) {
  int i = 0;
  while (1) {
    int j = h(k, i);
    if (j < m && T[j] == 0) {
      T[j] = k;
      return j;
    } else
      i++;
  }
}

int find(int k) {
  int i = 0;
  while (1) {
    int j = h(k, i);
    if (j < m && T[j] == k)
      return 1;
    else if ((j < m && T[j] == 0) || i >= m)
      return 0;
    else
      i++;
  }
}

int change(string str1) {
  int k = 0;
  for (int i = str1.size(); i >= 0; i--) {
    if (str1[i] == 'A')
      k += 1;
    else if (str1[i] == 'C')
      k += 2;
    else if (str1[i] == 'G')
      k += 3;
    else if (str1[i] == 'T')
      k += 4;
    if (i > 0)
      k *= 5;
  }
  return k;
}

int main() {
  int n, k, f;
  string str, str1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str >> str1;
    k = change(str1);
    if (str[0] == 'i')
      insert(k);
    else {
      f = find(k);
      if (f == 1)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#define m 1000003
using namespace std;

int T[1000000];

int h(int k, int i) { return (k % m + i * (1 + k % (m - 1))) % m; }

int insert(int k) {
  int i = 0;
  while (1) {
    int j = h(k, i);
    if (T[j] == 0) {
      T[j] = k;
      return j;
    } else
      i++;
  }
}

int find(int k) {
  int i = 0;
  while (1) {
    int j = h(k, i);
    if (T[j] == k)
      return 1;
    else if (T[j] == 0 || i >= m)
      return 0;
    else
      i = i + 1;
  }
}

int change(string str1) {
  int k = 0;
  for (int i = str1.size(); i >= 0; i--) {
    if (str1[i] == 'A')
      k += 1;
    else if (str1[i] == 'C')
      k += 2;
    else if (str1[i] == 'G')
      k += 3;
    else if (str1[i] == 'T')
      k += 4;
    if (i > 0)
      k *= 10;
  }
  return k;
}

int main() {
  int n, k, f;
  string str, str1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str >> str1;
    k = change(str1);
    if (str == "insert")
      insert(k);
    else {
      f = find(k);
      if (f == 1)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

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

void insert(const std::string &str, std::set<std::string> &dctnry) {
  dctnry.insert(str);
}

void find(const std::string &str, const std::set<std::string> &dctnry) {
  std::cout << (dctnry.find(str) != dctnry.end() ? "yes" : "no") << std::endl;
}

int main(void) {
  int n;
  std::set<std::string> dctnry;
  std::string str, inst;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> inst >> str;
    if (inst == "insert") {
      insert(str, dctnry);
    } else {
      find(str, dctnry);
    }
  }
}


Error: TLE

Fixed submission:

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

void insert(const std::string &str, std::vector<std::string> &dctnry) {
  dctnry.push_back(str);
}

void find(const std::string &str, const std::vector<std::string> &dctnry) {
  auto it = std::find(dctnry.begin(), dctnry.end(), str);
  if (it == dctnry.end())
    std::cout << "no" << std::endl;
  else
    std::cout << "yes" << std::endl;
}

int main(void) {
  int n;
  std::vector<std::string> dctnry;
  std::string str, inst;
  std::cin >> n;
  for (int i = 0; i < n; i++) {
    std::cin >> inst >> str;
    if (inst == "insert") {
      insert(str, dctnry);
    } else {
      find(str, dctnry);
    }
  }
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  int N;
  map<string, bool> T;
  cin >> N;
  for (int i = 0; i < N; i++) {
    char s[16], t[16];
    scanf("%s %s", s, t);
    if (s[0] == 'i') {
      T[t] = true;
    } else {
      if (T[t])
        printf("yes\\n");
      else
        printf("no\\n");
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  int N;
  map<string, bool> T;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s, t;
    cin >> s >> t;
    if (s[0] == 'i') {
      T[t] = true;
    } else {
      if (T[t])
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }

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

#include <bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL << ((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s, f, t) ((s).substr((f)-1, (t) - (f) + 1))
#define ALL(a) (a).begin(), (a).end()
using namespace std;

map<string, int> ma;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s, ss;
    cin >> s >> ss;
    if (s == "insert") {
      ma[ss] = 1;
    } else {
      if (ma[ss])
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  string str, dic;
  vector<string> s;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> str >> dic;
    if (str == "insert") {
      s.push_back(dic);
    } else if (str == "find") {
      int flag = 0;
      for (int j = 0; j < s.size(); j++) {
        if (s[j] == dic)
          flag = 1;
      }
      if (flag)
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <vector>

#define M 100000

long long StrToID(std::string str) {
  long long id = 0;
  for (int i = 0; i < str.length(); ++i) {
    switch (str[i]) {
    case 'A':
      id = 1 + id * 10;
      break;
    case 'C':
      id = 2 + id * 10;
      break;
    case 'G':
      id = 3 + id * 10;
      break;
    case 'T':
      id = 4 + id * 10;
      break;
    default:
      break;
    }
  }
  return id;
}

bool includeNum(long long fig, std::vector<long long> S) {
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == fig)
      return true;
  }
  return false;
}

int main(int argc, char const *argv[]) {
  std::vector<std::vector<long long>> Dictionary(M);
  int N, key;
  long long id;
  std::string cmd, str;
  std::cin >> N;

  for (int i = 0; i < N; ++i) {
    std::cin >> cmd >> str;
    id = StrToID(str);
    key = id % M;
    if (cmd == "insert") {
      if (!includeNum(id, Dictionary[key]))
        Dictionary[key].push_back(id);
    } else if (cmd == "find") {
      if (includeNum(id, Dictionary[key])) {
        std::cout << "yes" << std::endl;
      } else {
        std::cout << "no" << std::endl;
      }
    } else {
      // exception
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
#include <vector>

#define M 100000

int StrToID(std::string str) {
  int id = 0;
  for (int i = 0; i < str.length(); ++i) {
    switch (str[i]) {
    case 'A':
      id = 1 + id * 10;
      break;
    case 'C':
      id = 2 + id * 10;
      break;
    case 'G':
      id = 3 + id * 10;
      break;
    case 'T':
      id = 4 + id * 10;
      break;
    default:
      break;
    }
  }
  return id;
}

bool includeNum(int fig, std::vector<int> S) {
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == fig)
      return true;
  }
  return false;
}

int main(int argc, char const *argv[]) {
  std::vector<std::vector<int>> Dictionary(M);
  int N, id, key;
  std::string cmd, str;
  std::cin >> N;

  for (int i = 0; i < N; ++i) {
    std::cin >> cmd >> str;
    id = StrToID(str);
    key = id % M;
    if (cmd == "insert") {
      if (!includeNum(id, Dictionary[key]))
        Dictionary[key].push_back(id);
    } else if (cmd == "find") {
      if (includeNum(id, Dictionary[key])) {
        std::cout << "yes" << std::endl;
      } else {
        std::cout << "no" << std::endl;
      }
    } else {
      // exception
    }
  }
  return 0;
}
Problem p02269 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <stdio.h>
#include <vector>
using namespace std;

typedef long long int ll;
ll S[100001];
ll T[50001];
int n, q;

int bin_search(ll *X, ll a, int s, int e) {

  if (e - s == 1) {
    if (X[s] == a)
      return 1;
    else
      return 0;
  }

  int mid = (s + e) / 2;
  if (a < X[mid])
    bin_search(X, a, s, mid);
  else
    bin_search(X, a, mid, e);
}

int main() {

  /*  cin>>n;
  for(int i=0;i<n;i++) cin>>S[i];
  cin>>q;
  for(int i=0;i<q;i++) cin>>T[i];

  int cnt = 0;
  for(int i=0;i<q;i++){
    cnt += bin_search(S,T[i],0,n);
  }
  cout<<cnt<<endl;
  */

  ios_base::sync_with_stdio(false);
  map<string, int> mp;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string op, str;
    cin >> op >> str;
    if (op == "insert") {
      mp[str] = 1;
    }
    if (op == "find") {
      if (mp[str])
        cout << "yes\\n";
      else
        cout << "no\\n";
    }
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>
#include <limits.h>
#include <map>
#include <queue>
#include <vector>
using namespace std;

typedef long long int ll;
ll S[100001];
ll T[50001];
int n, q;

int bin_search(ll *X, ll a, int s, int e) {

  if (e - s == 1) {
    if (X[s] == a)
      return 1;
    else
      return 0;
  }

  int mid = (s + e) / 2;
  if (a < X[mid])
    bin_search(X, a, s, mid);
  else
    bin_search(X, a, mid, e);
}

int main() {

  /*  cin>>n;
  for(int i=0;i<n;i++) cin>>S[i];
  cin>>q;
  for(int i=0;i<q;i++) cin>>T[i];

  int cnt = 0;
  for(int i=0;i<q;i++){
    cnt += bin_search(S,T[i],0,n);
  }
  cout<<cnt<<endl;
  */

  map<string, int> mp;
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    string op, str;
    cin >> op >> str;
    if (op == "insert") {
      mp[str] = 1;
    }
    if (op == "find") {
      if (mp[str])
        cout << "yes" << endl;
      else
        cout << "no" << endl;
    }
  }
  return 0;
}