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

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;

// defines
typedef long long ll;
typedef long double ld;

ll a, b, c, n, m, k;

ll t = 1;

void solve() {
  cin >> n;
  ll d;
  m = INT_MIN, k = INT_MAX, c = INT_MIN, d = INT_MAX;
  while (n--) {
    cin >> a >> b;
    m = max(m, a + b);
    k = min(k, a + b);

    c = max(c, a - b);
    d = min(d, a - b);
  }
  cout << max(abs(m - k), abs(c - d));
  if (t > 0)
    cout << "\\n";
}

int32_t main() {
#ifdef ONPC
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  // cin>>t;
  while (t--) {
    solve();
  }
  // cout<<sum;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;

// defines
typedef long long ll;
typedef long double ld;

ll a, b, c, n, m, k;

ll t = 1;

void solve() {
  cin >> n;
  vector<pair<ll, ll>> v(n), vv;
  map<pair<ll, ll>, ll> f;
  for (ll i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
    f[{v[i].first, v[i].second}]++;
    if (f[{v[i].first, v[i].second}] == 1)
      vv.emplace_back(make_pair(v[i].first, v[i].second));
  }
  sort(vv.begin(), vv.end());
  c = 0;
  for (ll i = 0; i < vv.size() - 1; i++) {
    for (ll j = i + 1; j < vv.size(); j++)
      c = max(c, abs(vv[i].first - vv[j].first) +
                     abs(vv[i].second - vv[j].second));
  }
  cout << c;
  if (t > 0)
    cout << "\\n";
}

int32_t main() {
#ifdef ONPC
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);

  // cin>>t;
  while (t--) {
    solve();
  }
  // cout<<sum;

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

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

// mannhattan distance => 45 degree rotation
// max( abs(x1-x2) + abs(y1-y2) )
// abs(x1-x2) = max( x1-x2, x2-x1)
// =>  max( abs(x1-x2) + abs(y1-y2) ) = max( x1-x2+y1-y2, x1-x2+y2-y1,
// x2-x1+y1-y2, x2-x1+y2-y1 ) X = x+y, Y = x-y max( abs(x1-x2) + abs(y1-y2) ) =
// max( X1-X2, Y1-Y2, Y2-Y1, X2-X1 ) = max( abs(X1-X2), abs(Y1-Y2) ) //

int main() {
  int N;
  cin >> N;
  vector<int> x45(N), y45(N);
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    x45[i] = x + y;
    y45[i] = x - y;
  }
  sort(x45.begin(), x45.end());
  sort(y45.begin(), y45.end());
  cout << max(abs(x45[N - 1] - x45[0]), abs(y45[N - 1] - y45[0]));
  return 0;
}

Error: -6
double free or corruption (out)


Fixed submission:

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

// mannhattan distance => 45 degree rotation
// max( abs(x1-x2) + abs(y1-y2) )
// abs(x1-x2) = max( x1-x2, x2-x1)
// =>  max( abs(x1-x2) + abs(y1-y2) ) = max( x1-x2+y1-y2, x1-x2+y2-y1,
// x2-x1+y1-y2, x2-x1+y2-y1 ) X = x+y, Y = x-y max( abs(x1-x2) + abs(y1-y2) ) =
// max( X1-X2, Y1-Y2, Y2-Y1, X2-X1 ) = max( abs(X1-X2), abs(Y1-Y2) ) //

int main() {
  int N;
  cin >> N;
  vector<int> x45(N), y45(N);
  rep(i, N) {
    int x, y;
    cin >> x >> y;
    x45[i] = x + y;
    y45[i] = x - y;
  }
  sort(x45.begin(), x45.end());
  sort(x45.begin(), y45.end());
  cout << max(abs(x45[N - 1] - x45[0]), abs(y45[N - 1] - y45[0]));
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

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

ll maxAbsValExpr(vector<ll> &x, vector<ll> &y) {
  ll res = 0, n = x.size(), smallest, cur;
  for (int p : {1, -1}) {
    for (int q : {1, -1}) {
      smallest = p * x[0] + q * y[0] + 0;
      for (ll i = 1; i < n; ++i) {
        cur = p * x[i] + q * y[i];
        res = max(res, cur - smallest);
        smallest = min(smallest, cur);
      }
    }
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> x;
  vector<ll> y;
  for (ll i = 0; i < n; i++) {
    ll xc, yc;
    cin >> xc;
    x.push_back(xc);
    cin >> yc;
    y.push_back(yc);
  }
  cout << maxAbsValExpr(x, y) << endl;
}

Error: TLE

Fixed submission:

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

/********************************************************************/
#define M1 1000000007 // Standard primes used in modulo operations
#define M2 998244353
#define PI 3.1415926536
const int INF = INT_MAX;
#define ll long long
#define pll pair<ll, ll>
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPR(i, a, b) for (ll i = b - 1; i >= a; i--)
#define forr(i, n) for (ll i = 0; i < n; i++)
#define ff first
#define ss second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\\n'
#define ce(ele) cout << ele << ' '
#define cs(ele) cout << ele << '\\n'
#define CASE(t)                                                                \\
  ll t;                                                                        \\
  cin >> t;                                                                    \\
  while (t--)
#define space ' '
#define yes cout << "Yes" << endl
#define no cout << "No" << endl

void FAST() { // FAST Input Output, DONT use both scnaf,printf / cin,cout , Use
              // any ONE system
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
ll gcd(ll x, ll y) { // returns gcd of two long long ints
  if (x == 0)
    return y;
  return gcd(y % x, x);
}

ll powM(ll x, ll y, ll m) { // returns (a^b)%m ( ^ is exponent )
  ll ans = 1, r = 1;
  x %= m;
  while (r > 0 && r <= y) {
    if (r & y) {
      ans *= x;
      ans %= m;
    }
    r <<= 1;
    x *= x;
    x %= m;
  }
  return ans;
}

map<long long, long long>
factorize(long long n) { // returns map containing factor and multiplicity, Eg:
                         // 60 = {{2,2},{3,1},{5,1}}
  map<long long, long long> ans;
  for (long long i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ans[i]++;
      n /= i;
    }
  }
  if (n > 1) {
    ans[n]++;
    n = 1;
  }
  return ans;
}
/* **********END OF TEMPLATE*********** */

int main() {
  /*  Codeforces #595 Div.3 :)*/
  FAST();
  ll n;
  cin >> n;
  ll a[n][2];
  REP(i, 0, n) { cin >> a[i][0] >> a[i][1]; }
  ll mx = 0;
  REP(i, 0, n - 1) {
    REP(j, i + 1, n) {
      ll d = abs(a[j][0] - a[i][0]) + abs(a[j][1] - a[i][1]);
      mx = max(mx, d);
    }
  }
  cout << mx << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define Phuong_                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);
#define REP(i, a, b) for (int i = a; i <= b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int, int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------

int main() {
  Phuong_; /// <3333
  int n;
  cin >> n;
  vector<pi> a(n);
  for (pi &x : a) {
    cin >> x.first >> x.second;
  }
  sort(a.begin(), a.end());
  int minn;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      minn = a[i].first + a[i].second;
    } else {
      ans = max(ans, a[i].first + a[i].second - minn);
      minn = min(minn, a[i].first + a[i].second);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      minn = a[i].first - a[i].second;
    } else {
      ans = max(ans, a[i].first - a[i].second - minn);
      minn = min(minn, a[i].first - a[i].second);
    }
  }
  cout << ans << '\\n';
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define Phuong_                                                                \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);
#define REP(i, a, b) for (int i = a; i <= b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int, int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------
const ll mod = 1e9 + 7;

int main() {
  Phuong_; /// <3333
  int n;
  cin >> n;
  vector<pi> a(n);
  int minn = 1e9 + 5;
  int maxx = 0;
  for (pi &x : a) {
    cin >> x.first >> x.second;
    minn = min(minn, x.second);
    maxx = max(maxx, x.second);
  }
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    int num = max(abs(a[i].second - minn), abs(a[i].second - maxx));
    for (int j = 0; j < i; ++j) {
      if (abs(a[i].first - a[j].first) + num < ans)
        break;
      ans = max(ans,
                abs(a[i].first - a[j].first) + abs(a[i].second - a[j].second));
    }
  }
  cout << ans;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = x + y;
    b[i] = x - y;
  }
  sort(a, a + n);
  sort(b, b + n);
  int ans = max(a[n - 1] - a[0], b[n - 1] - b[0]);
  cout << ans << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  int arrx[n];
  int arry[n];
  for (int i = 0; i < n; i++) {
    cin >> arrx[i] >> arry[i];
  }
  int count = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if ((abs(arrx[i] - arrx[j]) + abs(arry[i] - arry[j])) > count) {
        count = abs(arrx[i] - arrx[j]) + abs(arry[i] - arry[j]);
      }
    }
  }
  cout << count << endl;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N;
  cin >> N;
  vector<int> plus, minus;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    plus.push_back(x + y);
    minus.push_back(x - y);
  }
  sort(plus.begin(), plus.end());
  sort(minus.begin(), minus.end());
  cout << max(plus[N - 1] - plus[0], minus[N - 1] - minus[0]) << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
int main() {
  int N;
  cin >> N;
  set<ii> s;
  for (int i = 0; i < N; i++) {
    int x, y;
    cin >> x >> y;
    s.insert({x, y});
  }
  vector<ii> point;
  for (const auto &a : s) {
    point.push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < point.size() - 1; i++) {
    int xi, yi, xj, yj;
    xi = point[i].first;
    yi = point[i].second;
    for (int j = i + 1; j < point.size(); j++) {
      xj = point[j].first;
      yj = point[j].second;
      ans = max(ans, abs(xi - xj) + abs(yi - yj));
    }
  }
  cout << ans;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll inf = 1e7;
const int maxN = 2e5 + 4;

void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  int ans = 0;
  for (int tt = 0; tt < 2; tt++) {
    if (tt) {
      for (int i = 0; i < n; i++) {
        a[i].second *= -1;
      }
    }
    set<pair<int, int>> st;
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
      int sum = a[i].first + a[i].second;
      st.insert({sum, i});
    }
    for (int i = 0; i < n - 1; i++) {
      st.erase(st.lower_bound(make_pair(a[i].first + a[i].second, -1)));
      auto itr = st.rbegin();
      int best = (*itr).first;
      ans = max(ans, best - a[i].first - a[i].second);
    }
  }
  cout << ans << endl;
}

int main() {
  //  freopen("in.txt", "r", stdin);
  //  freopen("out.txt", "w", stdout);
  int q = 1;
  //  cin >> q;
  while (q--) {
    solve();
  }
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll inf = 1e7;
const int maxN = 2e5 + 4;

void solve() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first >> a[i].second;
  }
  int ans = 0;
  for (int tt = 0; tt < n; tt++) {
    if (tt) {
      for (int i = 0; i < n; i++) {
        a[i].second *= -1;
      }
    }
    set<pair<int, int>> st;
    map<int, int> mp;
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
      int sum = a[i].first + a[i].second;
      mp[i] = sum;
      st.insert({sum, i});
    }
    for (int i = 0; i < n - 1; i++) {
      st.erase(st.lower_bound(make_pair(a[i].first + a[i].second, -1)));
      auto itr = st.rbegin();
      int best = (*itr).first;
      ans = max(ans, best - a[i].first - a[i].second);
    }
  }
  cout << ans << endl;
}

int main() {
  //  freopen("in.txt", "r", stdin);
  //  freopen("out.txt", "w", stdout);
  int q = 1;
  //  cin >> q;
  while (q--) {
    solve();
  }
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#ifdef _MSC_VER
#define GC getchar
#else
#define GC getchar_unlocked
#endif
int input() {
  int x = 0;
  char c;
  bool minus = false;
  for (;;) {
    c = GC();
    if (c == '-') {
      minus = true;
      continue;
    }
    if (c == ' ' || c == '\\n')
      if (minus)
        return -x;
      else
        return x;
    x = 10 * x + c - '0';
  }
}
void fix() {
  char c;
  for (;;) {
    c = GC();
    if (c == -1 || c != ' ' && c != '\\n')
      break;
  }
  if (c != -1)
    ungetc(c, stdin);
}
int main() {
  int N, i, j, k, d;
  int a[6];
  int m[32];
  int M[32];
  for (i = 0; i < 32; i++) {
    m[i] = 1000000000;
    M[i] = -1000000000;
  }
  scanf("%d", &N);
  d = 2;
  fix();
  for (i = 0; i < N; i++) {
    for (j = 0; j < d; j++)
      a[j] = input(); //,fix();
    for (j = 0; j < 1 << (d - 1); j++) {
      int x = a[0];
      for (k = 0; k < d - 1; k++)
        if (j & (1 << k))
          x += a[k + 1];
        else
          x -= a[k + 1];
      if (m[j] > x)
        m[j] = x;
      if (M[j] < x)
        M[j] = x;
    }
  }
  int ans = 0;
  for (i = 0; i < 1 << (d - 1); i++)
    if (ans < M[i] - m[i])
      ans = M[i] - m[i];
  printf("%d\\n", ans);
  return 0;
}

Error: WA

Fixed submission:

#include <cstdio>
#ifdef _MSC_VER
#define GC getchar
#else
#define GC getchar_unlocked
#endif
int input() {
  int x = 0;
  char c;
  bool minus = false;
  for (;;) {
    c = GC();
    if (c == '-') {
      minus = true;
      continue;
    }
    if (c == ' ' || c == '\\n')
      if (minus)
        return -x;
      else
        return x;
    x = 10 * x + c - '0';
  }
}
void fix() {
  char c;
  for (;;) {
    c = GC();
    if (c == -1 || c != ' ' && c != '\\n')
      break;
  }
  if (c != -1)
    ungetc(c, stdin);
}
int main() {
  int N, i, j, k, d;
  int a[6];
  int m[32];
  int M[32];
  for (i = 0; i < 32; i++) {
    m[i] = 1000000000;
    M[i] = -1000000000;
  }
  scanf("%d %d", &N, &d);
  fix();
  for (i = 0; i < N; i++) {
    for (j = 0; j < d; j++)
      a[j] = input(); //,fix();
    for (j = 0; j < 1 << (d - 1); j++) {
      int x = a[0];
      for (k = 0; k < d - 1; k++)
        if (j & (1 << k))
          x += a[k + 1];
        else
          x -= a[k + 1];
      if (m[j] > x)
        m[j] = x;
      if (M[j] < x)
        M[j] = x;
    }
  }
  int ans = 0;
  for (i = 0; i < 1 << (d - 1); i++)
    if (ans < M[i] - m[i])
      ans = M[i] - m[i];
  printf("%d\\n", ans);
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> rect(4, 0);
  for (int i = 0; i < n; i++) {
    if (x[i] + y[i] > x[rect[0]] + y[rect[0]]) {
      rect[0] = i;
    }
    if (x[i] - y[i] > x[rect[1]] - y[rect[1]]) {
      rect[1] = i;
    }
    if (y[i] - x[i] > y[rect[2]] - x[rect[2]]) {
      rect[2] = i;
    }
    if (x[i] + y[i] < x[rect[3]] + y[rect[3]]) {
      rect[3] = i;
    }
  }
  cout << max(abs(x[rect[0]] - x[rect[3]]) + abs(y[rect[0]] - y[rect[3]]),
              abs(x[rect[1]] - x[rect[2]]) + abs(y[rect[1]] - y[rect[2]]))
       << endl;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> rect(4, 0);
  for (int i = 0; i < n; i++) {
    if (x[i] + y[i] > x[rect[0]] + y[rect[0]]) {
      rect[0] = i;
    }
    if (x[i] - y[i] > x[rect[1]] - y[rect[1]]) {
      rect[1] = i;
    }
    if (y[i] - x[i] > y[rect[2]] - x[rect[2]]) {
      rect[2] = i;
    }
    if (x[i] + y[i] < x[rect[3]] + y[rect[3]]) {
      rect[3] = i;
    }
  }
  cout << max(abs(x[rect[0]] - x[rect[3]]) + abs(y[rect[0]] - y[rect[3]]),
              abs(x[rect[1]] - x[rect[2]]) + abs(y[rect[1]] - y[rect[2]]))
       << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
const int mod = (int)1e9 + 7;
#define pb push_back

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

  int n;
  cin >> n;
  set<pair<int, int>> st;
  vector<lli> dist1, dist2;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (st.find(make_pair(a, b)) != st.end())
      continue;
    st.insert(make_pair(a, b));
    dist1.push_back(((lli)a + (lli)b));
    dist2.push_back(((lli)a - (lli)b));
  }
  sort(dist1.begin(), dist1.end());
  sort(dist2.begin(), dist2.end());
  cout << max(dist1.back() - dist1[0], abs(-dist2.back() + dist2[0]));
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
const int mod = (int)1e9 + 7;
#define pb push_back

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

  int n;
  cin >> n;
  vector<pair<int, int>> vec;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    vec.push_back(make_pair(a, b));
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (vec[i].first == vec[j].first && vec[i].second == vec[j].second)
        continue;
      else {
        ans = max(ans, abs(vec[i].first - vec[j].first) +
                           abs(vec[i].second - vec[j].second));
      }
    }
  }

  cout << ans;

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

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

void solve() {
  int n = 0, i = 0, x = 0, y = 0;
  int val = 0;

  cin >> n;

  vector<int> p;
  vector<int> m;

  for (i = 0; i < n; i++) {
    cin >> x >> y;
    p.push_back(x + y);
    m.push_back(x - y);
  }

  int max1 = *max_element(p.begin(), p.end());
  int min1 = *min_element(p.begin(), p.end());
  int val1 = max1 - min1;

  int max2 = *max_element(m.begin(), m.end());
  int min2 = *min_element(m.begin(), m.end());
  int val2 = max2 - min2;

  val = max(val1, val2);

  cout << val << "\\n";
}

int main() {

  solve();

  return 0;
}

Error: TLE

Fixed submission:

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

void solve() {
  int n = 0, i = 0, j = 0;

  cin >> n;

  int x = 0, y = 0;
  long long val = 0;

  int p[n][2];
  vector<long long> q;

  for (i = 0; i < n; i++) {
    cin >> p[i][0] >> p[i][1];
  }

  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      x = abs(p[i][0] - p[j][0]);
      y = abs(p[i][1] - p[j][1]);
      val = x + y;
      q.push_back(val);
    }
  }

  sort(q.rbegin(), q.rend());

  cout << q[0] << "\\n";
}

int main() {

  solve();

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

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

vector<int> cute, loli;
int n;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    cute.push_back(x - y);
    loli.push_back(x + y);
  }
  cout << max(*max_element(begin(cute), end(cute)) -
                  *min_element(begin(cute), end(cute)),
              *max_element(begin(loli), end(loli)) -
                  *min_element(begin(loli), end(loli)))
       << '\\n';
  return 0;
}


Error: -6
3de7fae1-6ee4-4422-81df-481c9f6c0805.out: /home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02556/C++/s999718130.cpp:44: int32_t main(): Assertion `0' failed.


Fixed submission:

#include <bits/stdc++.h>
#define int long long
#define maxn 200005
using namespace std;

const int INF = 1e18;

pair<int, int> arr[maxn];
int n;

struct ZKW {
  vector<int> arr;
  int n;
  ZKW(int sz) : arr(sz * 2, -INF), n(sz) {}
  void upd(int x, int v) {
    // printf("upd %lld %lld\\n", x, v);
    for (arr[x += n] = v; x > 1; x >>= 1) {
      arr[x >> 1] = max(arr[x], arr[x ^ 1]);
    }
  }
  int ask(int l, int r) { // [l, r)
    int ret = -INF;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1)
        ret = max(ret, arr[l++]);
      if (r & 1)
        ret = max(ret, arr[--r]);
    }
    return ret;
  }
  void clear() { fill(begin(arr), end(arr), -INF); }
};

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  vector<int> v;
  for (int i = 0; i < n; i++) {
    cin >> arr[i].first >> arr[i].second;
    v.emplace_back(arr[i].second);
  }
  int ans = 0;
  if (n <= 10000) {
    assert(0);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        ans = max(ans, abs(arr[i].first - arr[j].first) +
                           abs(arr[i].second - arr[j].second));
      }
    }
    cout << ans << '\\n';
    return 0;
  }
  sort(arr, arr + n);
  sort(begin(v), end(v));
  v.erase(unique(begin(v), end(v)), end(v));

  ZKW B(maxn), T(maxn);
  for (int i = 0; i < n; i++) {
    int x, y;
    x = arr[i].first;
    y = lower_bound(begin(v), end(v), arr[i].second) - begin(v);
    B.upd(y, -arr[i].second - x);
    T.upd(y, arr[i].second - x);
    int cur = max(B.ask(0, y) + x + arr[i].second,
                  T.ask(y, v.size()) + x - arr[i].second);
    ans = max(ans, cur);
  }

  B.clear();
  T.clear();
  for (int i = n - 1; i >= 0; i--) {
    int x, y;
    x = arr[i].first;
    y = lower_bound(begin(v), end(v), arr[i].second) - begin(v);
    B.upd(y, -arr[i].second + x);
    T.upd(y, arr[i].second + x);
    int cur = max(B.ask(0, y) - x + arr[i].second,
                  T.ask(y, v.size()) - x - arr[i].second);
    ans = max(ans, cur);
  }

  cout << ans << '\\n';
  return 0;
}