alexjercan/bugnet huggingface dataset:
Problem p02446 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
vector<int> v;
int main() {
  int n;
  cin >> n;
  rep(i, n) {
    int a;
    cin >> a;
    v.push_back(a);
  }
  v.erase(unique(v.begin(), v.end()), v.end());
  rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? "\\n" : " ");
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int a[1010];
vector<int> v;
int main() {
  int n;
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, n) {
    if (i == 0 || a[i] != a[i - 1])
      v.push_back(a[i]);
  }
  int N = v.size();
  rep(i, N) cout << v[i] << (i == N - 1 ? "\\n" : " ");
  return 0;
}
Problem p02446 (C++) — buggy submission, verdict: Runtime Error

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

long a[100000];

int main() {
  memset(a, 0, sizeof(a));

  int n, j = 0;
  cin >> n >> a[0];

  for (int i = 1; i < n; i++) {
    long k;
    cin >> k;

    if (k > a[j]) {
      a[j + 1] = k;
      j++;
    }
  }

  for (int i = 0; i < j; i++) {
    cout << a[i] << " ";
  }
  cout << a[j] << endl;

  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  long a[1000];
  memset(a, 0, sizeof(a));

  int n, j = 0;
  cin >> n >> a[0];

  for (int i = 1; i < n; i++) {
    long k;
    cin >> k;

    if (k > a[j]) {
      a[j + 1] = k;
      j++;
    }
  }

  for (int i = 0; i < j; i++) {
    cout << a[i] << " ";
  }
  cout << a[j] << endl;

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int n;
vector<vector<int>> v;
vector<int> a, c;
int kaijo(int x) {
  int ans = 1;
  for (int i = 1; i <= x; i++)
    ans *= i;
  return ans;
}
int main() {
  cin >> n;
  a.resize(n);
  c.resize(n);
  rep(i, n) cin >> a[i];
  if (n == 1) {
    puts("1");
    return 0;
  }
  rep(i, n) c[i] = i + 1;
  do {
    v.push_back(c);
  } while (next_permutation(c.begin(), c.end()));
  rep(i, v.size()) {
    if (v[i] == a) {
      if (i == 0) {
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        i++;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        return 0;
      } else if (i == v.size() - 1) {
        i--;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        i++;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        return 0;
      } else {
        i--;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        i++;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        i++;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        return 0;
      }
    }
  }
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
int n;
vector<vector<int>> v;
vector<int> a, c;
int kaijo(int x) {
  int ans = 1;
  for (int i = 1; i <= x; i++)
    ans *= i;
  return ans;
}
int main() {
  cin >> n;
  a.resize(n);
  c.resize(n);
  rep(i, n) cin >> a[i];
  rep(i, n) c[i] = i + 1;
  do {
    v.push_back(c);
  } while (next_permutation(c.begin(), c.end()));
  rep(i, v.size()) {
    if (v[i] == a) {
      if (i == 0) {
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        i++;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        return 0;
      } else if (i == v.size() - 1) {
        i--;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        i++;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        return 0;
      } else {
        i--;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        i++;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        i++;
        rep(j, v[i].size()) cout << v[i][j]
                                 << (j == v[i].size() - 1 ? "\\n" : " ");
        return 0;
      }
    }
  }
  return 0;
}
Problem p02451 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>

using namespace std;

int main() {
  ios ::sync_with_stdio(false);
  int n, q;
  int a[100001], t;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  cin >> q;
  for (int i = 0; i < q; ++i) {
    cin >> t;
    cout << binary_search(a, a + n, t) << endl;
  }
  return 0;
}


Error: 0

Fixed submission:


#include <iostream>
#define MAX_SIZE 102
using namespace std;
template <class Type> int BinarySearch(Type a[], const Type &x, int n) {
  int left = 0;
  int right = n - 1;
  while (left <= right) {
    int middle = (left + right) / 2;
    if (a[middle] == x)
      return middle;
    if (x >= a[middle])
      left = middle + 1;
    else
      right = middle - 1;
  }
  return -1;
}
int main() {
  int a[MAX_SIZE];
  int i, len, x, p;
  cin >> len;
  for (i = 0; i < len; i++)
    cin >> a[i];
  cin >> x;
  while (x--) {
    int m;
    cin >> m;
    p = BinarySearch(a, m, len);
    if (p == -1)
      cout << "0" << endl;
    else
      cout << "1" << endl;
  }
  return 0;
}
Problem p02451 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

#define REP(i, n) for (int i = 0; i < n; i++)
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

int main() {
  int n, a[100000], q, k, l, r, m, ans;
  cin >> n;
  REP(i, n) cin >> a[i];
  cin >> q;
  REP(i, q) {
    cin >> k;
    l = 0;
    r = n;
    m = -1;
    ans = 0;
    if (k < 0) {
      cout << 0 << endl;
      continue;
    }
    while (1) {
      m = (r + l) / 2;
      // printf("r=%d, l=%d, m=%d\\n", r, l, m);
      if (a[m] == k) {
        ans = 1;
        break;
      }
      if (m == r || m == l)
        break;
      if (k < a[m])
        r = m;
      else
        l = m;
    }
    cout << ans << endl;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

#define REP(i, n) for (int i = 0; i < n; i++)
#define debug(x) cerr << #x << " = " << (x) << endl;

using namespace std;

int main() {
  int n, a[100000], q, k, l, r, m, ans;
  cin >> n;
  REP(i, n) cin >> a[i];
  cin >> q;
  REP(i, q) {
    cin >> k;
    l = 0;
    r = n;
    ans = 0;
    if (k < 0 || k > n) {
      cout << 0 << endl;
      continue;
    }
    while (r - l > 0) {
      m = (r + l) / 2;
      // printf("r=%d, l=%d, m = %d\\n", r, l, m);
      if (a[m] == k) {
        ans = 1;
        break;
      }
      if (k < a[m])
        r = m;
      else
        l = m;
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p02452 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
using namespace std;
static const int MAX_N = 200000;

int n, a[MAX_N], m, b[MAX_N];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  cin >> m;
  for (int i = 0; i < m; i++)
    cin >> b[i];
  bool flag = true;
  for (int i = 0; i < m; i++) {
    if ((upper_bound(a, a + n, b[i])) - a == lower_bound(a, a + n, b[i]) - a)
      flag = false;
  }
  if (flag)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
static const int MAX_N = 100000;

int n, a[MAX_N], m, b[MAX_N];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  cin >> m;
  for (int i = 0; i < m; i++)
    cin >> b[i];
  bool flag = true;
  for (int i = 0; i < m; i++) {
    if ((upper_bound(a, a + n, b[i])) - a == lower_bound(a, a + n, b[i]) - a)
      flag = false;
  }
  if (flag)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}
Problem p02452 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

long long a[200000];

int main() {
  int n, m, j = 0;
  bool f = 1;

  cin >> n;

  for (int i = 0; i < n; i++)
    cin >> a[i];
  a[n] = 1000000001;

  cin >> m;

  for (int i = 0; i < m; i++) {
    long long b;
    cin >> b;

    while (b > a[j])
      j++;

    if (b < a[j]) {
      f = 0;
      break;
    }
  }

  cout << f << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <iostream>
using namespace std;

long long a[200000];

int main() {
  int n, m, j = 0;
  bool f = 1;

  cin >> n;

  for (int i = 0; i < n; i++)
    cin >> a[i];

  cin >> m;

  for (int i = 0; i < m; i++) {
    long long b;
    cin >> b;

    while (b > a[j])
      j++;

    if (b < a[j]) {
      f = 0;
      break;
    }
  }

  cout << f << endl;

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

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

int main() {
  int n, q, x;
  int cnt = 0;

  map<int, int> a;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> q >> x;
    if (q == 0) {
      if (a[x] == 0) {
        cnt++;
        a[x] = 1;
      }
      cout << cnt << endl;
    } else {
      if (a[x] == 1)
        cout << 1 << endl;
      else
        cout << 0 << endl;
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

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

bool insert(vector<int> &a, int x) {
  bool j = true;
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == x)
      j = false;
  }
  if (j == true)
    a.push_back(x);
}

bool find(vector<int> &a, int x) {
  for (int i = 0; i < a.size(); i++) {
    if (a[i] == x)
      return true;
  }
  return false;
}

int main() {
  int n, q, x;

  vector<int> a;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> q >> x;
    if (q == 0) {
      insert(a, x);
      cout << a.size() << endl;
    } else
      cout << find(a, x) << endl;
  }
  return 0;
}
Problem p02457 (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++)
set<int> st;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int Q, k;
    cin >> Q >> k;
    if (Q == 0) {
      st.insert(k);
      cout << st.size() << endl;
    } else if (Q == 1) {
      cout << st.count(k) << endl;
    } else if (Q == 2) {
      st.erase(k);
    } else {
      int y;
      cin >> y;
      auto nowitr = st.lower_bound(k);
      auto enditr = st.upper_bound(y);
      while (nowitr != enditr) {
        cout << *nowitr << endl;
        nowitr++;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
set<int> st;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int Q, k;
    cin >> Q >> k;
    if (Q == 0) {
      st.insert(k);
      cout << st.size() << endl;
    } else if (Q == 1) {
      cout << st.count(k) << endl;
    } else if (Q == 2) {
      st.erase(k);
    } else {
      int y;
      cin >> y;
      auto itr = st.lower_bound(k);
      while (*itr <= y) {
        cout << *itr << endl;
        itr++;
      }
    }
  }
  return 0;
}
Problem p02457 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <set>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::set<int> set;
  for (auto i = 0; i < n; ++i) {
    int o, x, r;
    std::cin >> o >> x;
    switch (o) {
    case 0:
      set.insert(x);
      std::cout << set.size() << std::endl;
      break;
    case 1:
      std::cout << set.count(x) << std::endl;
      break;
    case 2:
      set.erase(x);
      break;
    default:
      std::cin >> r;
      auto end = set.upper_bound(r);
      for (auto begin = set.lower_bound(x); begin != end; ++begin) {
        std::cout << *begin << std::endl;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  int q;
  std::cin >> q;
  std::set<int> set;
  int t, x;
  for (int i = 0; i < q; ++i) {
    std::cin >> t >> x;
    switch (t) {
    case 0:
      set.insert(x);
      std::cout << set.size() << '\\n';
      break;
    case 1:
      std::cout << set.count(x) << '\\n';
      break;
    case 2:
      set.erase(x);
      break;
    default:
      std::cin >> t;
      auto b = std::lower_bound(set.begin(), set.end(), x);
      for (; x <= *b && *b <= t; ++b) {
        std::cout << *b << '\\n';
      }
    }
  }
}
Problem p02457 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {

  int q, com, x, l, r;
  set<int> S;

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> com;

    if (com == 0) {
      cin >> x;
      S.insert(x);
      cout << S.size() << endl;
    } else if (com == 1) {
      cin >> x;
      cout << S.count(x) << endl;
    } else if (com == 2) {
      cin >> x;
      S.erase(x);
    } else if (com == 3) {
      set<int>::iterator itl, itr;

      cin >> l >> r;
      itl = S.lower_bound(l);
      itr = S.upper_bound(r);

      for (set<int>::iterator it = itl; it != itr; it++)
        cout << *it << endl;
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

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

int main() {

  int q, com, x, l, r;
  set<int> S;

  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> com;

    if (com == 0) {
      cin >> x;
      S.insert(x);
      cout << S.size() << endl;
    } else if (com == 1) {
      cin >> x;
      cout << S.count(x) << endl;
    } else if (com == 2) {
      cin >> x;
      S.erase(x);
    } else if (com == 3) {
      set<int>::iterator itl, itr;

      cin >> l >> r;
      itl = lower_bound(S.begin(), S.end(), l);
      itr = upper_bound(S.begin(), S.end(), r);

      for (set<int>::iterator it = itl; it != itr; it++)
        cout << *it << endl;
    }
  }

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

#include <iterator>
#include <set>
#include <stdio.h>
using namespace std;
int main() {
  int n, temp, k;
  set<int> s;
  set<int>::iterator u;
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &k, &temp);
    if (k == 0) {
      s.insert(temp);
      printf("%ld\\n", s.size());
    } else if (k == 1) {
      if (s.find(temp) == s.end())
        printf("0\\n");
      else
        printf("1\\n");
    } else if (k == 2)
      s.erase(temp);
    else {
      u = s.lower_bound(temp);
      scanf("%d", &temp);
      while (u != s.end()) {
        if (*u > temp)
          break;
        printf("%d\\n", *u);
        u++;
      }
    }
  }
}


Error: TLE

Fixed submission:

#include <iterator>
#include <set>
#include <stdio.h>
using namespace std;
int main() {
  int n, temp, k;
  set<int> s;
  set<int>::iterator u;
  scanf("%d", &n);
  while (n--) {
    scanf("%d%d", &k, &temp);
    if (k == 0) {
      s.insert(temp);
      printf("%ld\\n", s.size());
    } else if (k == 1) {
      if (s.find(temp) == s.end())
        printf("0\\n");
      else
        printf("1\\n");
    } else if (k == 2)
      s.erase(temp);
    else {
      u = s.lower_bound(temp);
      scanf("%d", &temp);
      while (u != s.end()) {
        if (*u > temp)
          break;
        printf("%d\\n", *u);
      }
    }
  }
}
Problem p02457 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int q;
  cin >> q;
  set<int> st;
  for (int i = 0; i < q; i++) {
    int cmd;
    cin >> cmd;
    if (cmd == 0) {
      int x;
      cin >> x;
      st.insert(x);
      cout << st.size() << endl;
    }
    if (cmd == 1) {
      int x;
      cin >> x;
      cout << st.count(x) << endl;
    }
    if (cmd == 2) {
      int x;
      cin >> x;
      st.erase(x);
    }
    if (cmd == 3) {
      int l, r;
      cin >> l >> r;
      for (auto itr = st.lower_bound(l), end = st.upper_bound(r); itr != end;
           itr++) {
        cout << *itr << endl;
      }
    }
  }
}


Error: TLE

Fixed submission:

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

int main() {
  int q;
  cin >> q;
  set<int> st;
  for (int i = 0; i < q; i++) {
    int cmd;
    cin >> cmd;
    if (cmd == 0) {
      int x;
      cin >> x;
      st.insert(x);
      cout << st.size() << endl;
    }
    if (cmd == 1) {
      int x;
      cin >> x;
      cout << st.count(x) << endl;
    }
    if (cmd == 2) {
      int x;
      cin >> x;
      st.erase(x);
    }
    if (cmd == 3) {
      int l, r;
      cin >> l >> r;
      for (int i = l; i <= r; i++) {
        if (st.count(i)) {
          auto itr = st.find(i);
          cout << *itr << endl;
        }
      }
    }
  }
}
Problem p02457 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  set<int> S;
  int q, com, x, y;
  cin >> q;
  while (q--) {
    cin >> com;
    switch (com) {
    case 0:
      cin >> x;
      S.insert(x);
      cout << S.size() << endl;
      break;
    case 1:
      cin >> x;
      if (S.find(x) != S.end()) {
        cout << "1\\n";
      } else {
        cout << "0\\n";
      }
      break;
    case 2:
      cin >> x;
      S.erase(x);
      break;
    case 3:
      cin >> x >> y;
      set<int>::iterator it = S.lower_bound(x);
      set<int>::iterator end = S.upper_bound(y);
      while (it != end) {
        cout << *it << endl;
        it++;
      }
      break;
    }
  }
}


Error: TLE

Fixed submission:

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

int main(void) {
  set<int> S;
  int q, com, x, y;
  cin >> q;
  while (q--) {
    cin >> com;
    switch (com) {
    case 0:
      cin >> x;
      S.insert(x);
      cout << S.size() << endl;
      break;
    case 1:
      cin >> x;
      if (S.find(x) != S.end()) {
        cout << "1\\n";
      } else {
        cout << "0\\n";
      }
      break;
    case 2:
      cin >> x;
      S.erase(x);
      break;
    case 3:
      cin >> x >> y;
      for (int i = x; i <= y; i++) {
        if (S.find(i) != S.end()) {
          cout << i << endl;
        }
      }
      break;
    }
  }
}
Problem p02461 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
map<string, int> mp;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int Q;
    cin >> Q;
    string s, l, r;
    int x;
    switch (Q) {
    case 0:
      cin >> s >> x;
      mp[s] = x;
      break;
    case 1:
      cin >> s;
      cout << mp[s] << endl;
      break;
    case 2:
      cin >> s;
      mp.erase(s);
      break;
    case 3:
      cin >> l >> r;
      auto now = mp.lower_bound(l);
      auto end = mp.upper_bound(r);
      while (now != end) {
        if (now->second)
          cout << now->first << " " << now->second << endl;
        ++now;
      }
    }
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
map<string, int> mp;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int Q;
    cin >> Q;
    string s, l, r;
    int x;
    switch (Q) {
    case 0:
      cin >> s >> x;
      mp[s] = x;
      break;
    case 1:
      cin >> s;
      cout << mp[s] << endl;
      break;
    case 2:
      cin >> s;
      mp.erase(s);
      break;
    case 3:
      cin >> s >> l >> r;
      auto now = mp.lower_bound(l);
      auto end = mp.upper_bound(r);
      while (now != end) {
        cout << now->first << " " << now->second << endl;
        ++now;
      }
    }
  }
  return 0;
}
Problem p02461 (C++) — buggy submission, verdict: Time Limit Exceeded

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

#define ll long long
#define pb push_back
#define MOD 1000000007
#define MAX 200005

char str[100010];
char str1[10010], str2[10010];

int main() {
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);

  int q, com, key;
  map<string, int> mp;
  string ss, s1, s2;

  scanf("%d", &q);

  while (q--) {
    scanf("%d", &com);
    if (com == 0) {
      scanf("%s %d", str, &key);
      ss = str;
      mp[ss] = key;
    } else if (com == 1) {
      scanf("%s", str);
      ss = str;
      int res = 0;
      if (mp.find(ss) != mp.end())
        res = mp[ss];
      printf("%d\\n", res);
    } else if (com == 2) {
      scanf("%s", str);
      ss = str;
      if (mp.find(ss) != mp.end()) {
        mp.erase(ss);
      }
    } else if (com == 3) {
      scanf("%s %s", str1, str2);
      s1 = str1;
      s2 = str2;
      vector<string> res;
      auto low = mp.lower_bound(s1);
      auto upper = mp.upper_bound(s2);

      if (low != upper) {
        for (auto it = low; it != upper; ++it) {
          cout << it->first << ' ' << it->second << "\\n";
        }
      }
    }
  }

  return 0;
}


Error: TLE

Fixed submission:

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

#define ll long long
#define pb push_back
#define MOD 1000000007
#define MAX 200005

char str[100010];
char str1[10010], str2[10010];

int main() {
  // freopen("in.txt","r",stdin);
  // freopen("out.txt","w",stdout);
  int q, com, key;
  map<string, int> mp;

  scanf("%d", &q);

  while (q--) {
    scanf("%d", &com);
    if (com == 0) {
      scanf("%s %d", str, &key);
      string ss;
      ss = str;
      mp[ss] = key;
    } else if (com == 1) {
      scanf("%s", str);
      string ss;
      ss = str;
      int res = 0;
      if (mp.find(ss) != mp.end())
        res = mp[ss];
      printf("%d\\n", res);
    } else if (com == 2) {
      scanf("%s", str);
      string ss;
      ss = str;
      if (mp.find(ss) != mp.end()) {
        mp.erase(ss);
      }
    } else if (com == 3) {
      scanf("%s %s", str1, str2);
      string s1 = str1;
      string s2 = str2;
      vector<string> res;
      for (auto it : mp) {
        if (it.first >= s1 && it.first <= s2)
          res.push_back(it.first);
      }
      sort(res.begin(), res.end());
      for (auto it : res) {
        cout << it << " " << mp[it] << "\\n";
      }
    }
  }

  return 0;
}