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

#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, d1[N], d2[N];
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) {
    int x = read(), y = read();
    d1[i] = x + y;
    d2[i] = x - y;
  }
  sort(d1 + 1, d1 + 1 + n);
  sort(d2 + 1, d2 + 1 + n);
  printf("%d\\n", max(d1[n] - d1[1], d2[n] - d2[1]));
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, x[N], y[N], cnt;
long long ans = -922337203685477587;
bool rem[1000000010][2];
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  for (register int i = 1; i <= n; i++) {
    int a = read(), b = read();
    if (rem[a][0] && rem[b][1])
      continue;
    x[++cnt] = a;
    y[cnt] = b;
    rem[a][0] = 1;
    rem[b][0] = 1;
  }
  for (register int i = 1; i < cnt; i++)
    for (register int j = i + 1; j <= cnt; j++)
      ans = max(ans, (long long)(abs(x[i] - x[j]) + abs(y[i] - y[j])));
  printf("%lld\\n", ans);
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

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

signed main() {
  int N;
  cin >> N;
  vector<pair<int, int>> p1(N), p2(N);
  double sum_x = 0, sum_y = 0;
  REP(i, N) {
    int x, y;
    cin >> x >> y;
    p1[i] = {x + y, x - y};
    p2[i] = {x - y, x + y};
  }
  sort(p1.begin(), p1.end());
  sort(p2.begin(), p2.end());

  int ans = 0;
  ans = max(ans, abs(p1[0].first - p1[N - 1].first));
  ans = max(ans, abs(p2[0].first - p2[N - 1].first));
  ans = max(ans, abs(p1[0].second - p1[N - 1].second));
  ans = max(ans, abs(p2[0].second - p2[N - 1].second));
  cout << ans << endl;

  return 0;
}


Error: 0

Fixed submission:

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

signed main() {
  int N;
  cin >> N;
  vector<pair<int, int>> p(N), plu, pru, pld, prd;
  double sum_x = 0, sum_y = 0;
  REP(i, N) {
    cin >> p[i].first >> p[i].second;
    sum_x += p[i].first, sum_y += p[i].second;
  }
  double avg_x = sum_x / N;
  double avg_y = sum_y / N;

  REP(i, N) {
    auto [x, y] = p[i];
    if (x < avg_x && y < avg_y)
      pld.push_back(p[i]);
    else if (x < avg_x && y > avg_y)
      plu.push_back(p[i]);
    else if (x > avg_x && y < avg_y)
      prd.push_back(p[i]);
    else
      pru.push_back(p[i]);
  }

  int ans = 0;
  vector<vector<pair<int, int>>> ps = {plu, pld, pru, prd};
  REP(i, N) {
    REP(j, N) {
      if (i == j)
        continue;
      for (auto [x1, y1] : ps[i]) {
        for (auto [x2, y2] : ps[j]) {
          ans = max(ans, abs(x1 - x2) + abs(y1 - y2));
        }
      }
    }
  }
  cout << ans << endl;

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

#include <iostream>
using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  cin >> N;
  int maxZ = 0, minZ = 0, maxW = 0, minW = 0;
  for (int i = 0; i < N; ++i) {
    int x, y;
    cin >> x;
    cin >> y;
    int z = x + y;
    int w = x - y;
    if (i == 0) {
      maxZ = minZ = z;
      maxW = minW = w;
    } else {
      if (maxZ < z) {
        maxZ = z;
      } else if (z < minZ) {
        minZ = z;
      }
      if (maxW < w) {
        maxW = w;
      } else if (w < minW) {
        minW = w;
      }
    }
  }
  long dz = (long)maxZ - minZ, dw = (long)maxW - minW;
  cout << ((dz < dw) ? dw : dz) << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
#define MOD 1000000007
#define _dist(x, y) (x < y ? (y - x) : (x - y))

int dist(int x1, int y1, int x2, int y2) {
  return _dist(x1, x2) + _dist(y1, y2);
}

int main(int argc, const char *argv[]) {
  int N;
  cin >> N;

  int *x = new int[N];
  int *y = new int[N];
  for (int i = 0; i < N; ++i) {
    cin >> x[i];
    cin >> y[i];
  }

  int max = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int d = dist(x[i], y[i], x[j], y[j]);
      if (max < d) {
        max = d;
      }
    }
  }
  cout << max << endl;

  delete[] x;
  delete[] y;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#define il inline
#define re register
using namespace std;
typedef double db;
const long long N = 200010;
struct P {
  long long x, y;
} a[N], s[N];
long long n, top = 0, ans = 0;
il P operator-(P a, P b) { return (P){a.x - b.x, a.y - b.y}; }
il long long operator*(P a, P b) { return a.x * b.y - a.y * b.x; }
il long long dis(P a) { return abs(a.x) + abs(a.y); }
il bool cmp(P x, P y) {
  if (abs((x - a[1]) * (y - a[1])) > 0)
    return (x - a[1]) * (y - a[1]) > 0;
  return dis(x - a[1]) < dis(y - a[1]);
}
il long long S(P a, P b, P c) { return abs((a - b) * (a - c)) / 2; }
int main() {
  scanf("%d", &n);
  for (long long i = 1; i <= n; i++)
    scanf("%d%d", &a[i].x, &a[i].y);
  for (long long i = 2; i <= n; i++)
    if (a[i].y < a[1].y || (a[i].y == a[1].y && a[i].x < a[1].x))
      swap(a[1], a[i]);
  sort(a + 2, a + n + 1, cmp);
  top = 2;
  s[1] = a[1];
  s[2] = a[2];
  for (long long i = 3; i <= n; i++) {
    while (top > 1 && (a[i] - s[top - 1]) * (s[top] - s[top - 1]) >= 0)
      top--;
    s[++top] = a[i];
  }
  for (long long i = 0; i < top; i++)
    s[i] = s[i + 1];
  n = top;
  for (long long i = 0, j = 2; i < n; i++) {
    while (S(s[i], s[(i + 1) % n], s[j]) <
           S(s[i], s[(i + 1) % n], s[(j + 1) % n]))
      j = (j + 1) % n;
    ans = max(dis(s[i] - s[j]), ans);
  }
  printf("%lld", ans);
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#define il inline
#define re register
using namespace std;
typedef double db;
const int N = 100001;
struct P {
  int x, y;
} a[N], s[N];
int n, top = 0, ans = 0;
il P operator-(P a, P b) { return (P){a.x - b.x, a.y - b.y}; }
il int operator*(P a, P b) { return a.x * b.y - a.y * b.x; }
il int dis(P a) { return abs(a.x) + abs(a.y); }
il bool cmp(P x, P y) {
  if (abs((x - a[1]) * (y - a[1])) > 0)
    return (x - a[1]) * (y - a[1]) > 0;
  return dis(x - a[1]) < dis(y - a[1]);
}
il int S(P a, P b, P c) { return abs((a - b) * (a - c)) / 2; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a[i].x, &a[i].y);
  for (int i = 2; i <= n; i++)
    if (a[i].y < a[1].y || (a[i].y == a[1].y && a[i].x < a[1].x))
      swap(a[1], a[i]);
  sort(a + 2, a + n + 1, cmp);
  top = 2;
  s[1] = a[1];
  s[2] = a[2];
  for (int i = 3; i <= n; i++) {
    while (top > 1 && (a[i] - s[top - 1]) * (s[top] - s[top - 1]) >= 0)
      top--;
    s[++top] = a[i];
  }
  for (int i = 0; i < top; i++)
    s[i] = s[i + 1];
  n = top;
  for (int i = 0, j = 2; i < n; i++) {
    while (S(s[i], s[(i + 1) % n], s[j]) <
           S(s[i], s[(i + 1) % n], s[(j + 1) % n]))
      j = (j + 1) % n;
    ans = max(dis(s[i] - s[j]), ans);
  }
  printf("%d", ans);
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define ull unsigned long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define ull unsigned long long
#define sc second
#define pb push_back
#define mp make_pair
#define sp << " "
#define all(a) (a).begin(), (a).end()
#define fi(i, a, n) for (int i = a; i < n; i++)
#define fd(i, n, a) for (int i = n - 1; i >= a; i--)
#define r0 return 0;
#define ln "\\n"
#define INF (int)1e15
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
void solve() {}
int main() {
  fast
      // ll t;cin>>t;
      // while(t--) solve();
      ll t;
  cin >> t;
  vector<int> x(t), y(t);
  for (int i = 0; i < t; i++) {
    cin >> x[i];
    cin >> y[i];
  }
  int 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 (int i = 1; i < n; ++i) {
        cur = p * x[i] + q * y[i];
        res = max(res, cur - smallest);
        smallest = min(smallest, cur);
      }
    }
  }
  cout << res;
  r0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define ull unsigned long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define ull unsigned long long
#define sc second
#define pb push_back
#define mp make_pair
#define sp << " "
#define all(a) (a).begin(), (a).end()
#define fi(i, a, n) for (int i = a; i < n; i++)
#define fd(i, n, a) for (int i = n - 1; i >= a; i--)
#define r0 return 0;
#define ln "\\n"
#define INF (int)1e15
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
void solve() {}
int main() {
  fast
      // ll t;cin>>t;
      // while(t--) solve();
      ll t;
  cin >> t;
  vector<pair<int, int>> v(t);
  for (ll i = 0; i < t; i++) {
    ll x, y;
    cin >> x >> y;
    v[i].fr = x;
    v[i].sc = y;
  }
  ll mx = 0;
  fi(i, 0, t - 1) {
    fi(j, i + 1, t) {
      ll p = (abs(v[i].fr - v[j].fr) + abs(v[j].sc - v[i].sc));
      mx = max(mx, p);
    }
  }
  cout << mx << "\\n";
  r0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

int main() {
  int n;
  cin >> n;
  vector<ll> xvec(n, 0);
  vector<ll> yvec(n, 0);
  for (int i = 0; i < n; ++i) {
    cin >> xvec[i] >> yvec[i];
  }

  vector<ll> xy0;
  vector<ll> xy1;
  for (int i = 0; i < n; ++i) {
    xy0.emplace_back(xvec[i] - yvec[i]);
    xy1.emplace_back(xvec[i] + yvec[i]);
  }

  sort(xy0.begin(), xy0.end());
  sort(xy1.begin(), xy1.end());
  ll ans = max((xy0[n - 1] - xy0[0]), (xy1[n - 1] - xy1[0]));
  cout << ans << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }

struct Data {
  ll x, y;
};

bool cmp(const Data &l, const Data &r) {
  return l.x == r.x ? l.y < r.y : l.x < r.y;
}

bool cmp2(const Data &l, const Data &r) {
  return l.y == r.y ? l.x < r.x : l.y < r.y;
}

int main() {
  int n;
  cin >> n;
  vector<Data> xy;
  for (int i = 0; i < n; ++i) {
    ll cx, cy;
    cin >> cx >> cy;
    Data indata;
    indata.x = cx;
    indata.y = cy;
    xy.emplace_back(indata);
  }

  sort(xy.begin(), xy.end(), cmp);
  ll ans = abs(xy[0].x - xy[n - 1].x) + abs(xy[0].y - xy[n - 1].y);
  sort(xy.begin(), xy.end(), cmp2);
  ll ans2 = abs(xy[0].x - xy[n - 1].x) + abs(xy[0].y - xy[n - 1].y);

  cout << max(ans, ans2) << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main(void) {
  static double p[220000][2];
  double min[32], max[32];
  int n;
  int i, j, k;
  double dat;
  double ans;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    for (j = 0; j < 2; j++) {
      scanf("%lf", &p[i][j]);
    }
  }

  ans = 0;
  for (i = 0; i < 1 << 2; i++) {
    for (j = 0; j < n; j++) {
      dat = 0;
      for (k = 0; k < 2; k++) {
        if ((i >> k) & 1) {
          dat += p[j][k];
        } else {
          dat -= p[j][k];
        }
      }
      if (j == 0) {
        min[i] = max[i] = dat;
      } else {
        if (dat < min[i]) {
          min[i] = dat;
        }
        if (dat > max[i]) {
          max[i] = dat;
        }
      }
    }
    ans = ans > max[i] - min[i] ? ans : max[i] - min[i];
  }

  printf("%.0f\\n", ans);

  return (0);
}


Error: 0

Fixed submission:

#include <stdio.h>

int main(void) {
  static double p[100000][2];
  double min[32], max[32];
  int n;
  int i, j, k;
  double dat;
  double ans;

  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    for (j = 0; j < 2; j++) {
      scanf("%lf", &p[i][j]);
    }
  }

  ans = 0;
  for (i = 0; i < 1 << 2; i++) {
    for (j = 0; j < n; j++) {
      dat = 0;
      for (k = 0; k < 2; k++) {
        if ((i >> k) & 1) {
          dat += p[j][k];
        } else {
          dat -= p[j][k];
        }
      }
      if (j == 0) {
        min[i] = max[i] = dat;
      } else {
        if (dat < min[i]) {
          min[i] = dat;
        }
        if (dat > max[i]) {
          max[i] = dat;
        }
      }
    }
    ans = ans > max[i] - min[i] ? ans : max[i] - min[i];
  }

  printf("%.0f\\n", ans);

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

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

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

  long long x[n];
  long long y[n];
  long long z[n];
  long long w[n];

  for (int i = 0; i < n; i++) {
    long long l, r;
    cin >> l >> r;
    x[i] = l + r;
    y[i] = l - r;
    z[i] = r - l;
    w[i] = -l - r;
  }
  sort(x, x + n);
  sort(y, y + n);
  sort(z, z + n);
  sort(w, w + n);
  cout << max({x[n - 1] - x[0], y[n - 1] - y[0], w[n - 1] - w[0],
               z[n - 1] - z[0]})
       << "\\n";
}


Error: TLE

Fixed submission:

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)x.size()
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main() {
  fast();
  long long n;
  cin >> n;
  long long x[n], y[n];

  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (abs(x[j] - x[i]) + abs(y[j] - y[i]) > ans) {
        ans = abs(x[j] - x[i]) + abs(y[j] - y[i]);
      }
    }
  }

  cout << ans << "\\n";
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v1, v2;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v1.push_back(x + y);
    v2.push_back(x - y);
  }
  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());
  cout << max(v1[n - 1] - v1[0], v2[n - 1] - v2[0]);
  return 0;
}

Error: -6
double free or corruption (out)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v1, v2;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v1.push_back(x + y);
    v2.push_back(x - y);
  }
  sort(v1.begin(), v2.end());
  sort(v2.begin(), v2.end());
  cout << max(v1[n - 1] - v1[0], v2[n - 1] - v2[0]);
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (long long i = 0; i < (n); i++)
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n), y(n), sum(n), sub(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
    sum[i] = x[i] + y[i];
    sub[i] = x[i] - y[i];
  }
  sort(sum.begin(), sum.end());
  sort(sub.begin(), sub.end());
  ll res = sum[n - 1] - sum[0];
  chmax(res, sub[n - 1] - sub[0]);
  cout << res << endl;
  return 0;
}

Error: 0

Fixed submission:

//
// Created by WUOG on 2020/9/13.
//

#include <algorithm>
#include <cstdio>
#define inf 0x3f3f3f3f
using namespace std;
int s[100009][6];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    scanf("%d %d", &s[i][0], &s[i][1]);
  int ans = 0;
  for (int i = 0; i < (1 << 2); i++) {
    int minn = inf, maxn = -inf;
    for (int j = 0; j < n; j++) {
      int t = 0;
      for (int k = 0; k < 2; k++) {
        if ((1 << k) & i)
          t += s[j][k];
        else
          t -= s[j][k];
      }
      minn = min(minn, t);
      maxn = max(maxn, t);
    }
    ans = max(ans, (maxn - minn));
  }
  printf("%d\\n", ans);
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#define LL long long
#define N 1000001
using namespace std;
const int NN = 2e5 + 7;
LL x[NN], y[NN];
LL p[4][NN];
LL i, j, k;
LL pd;
int main() {
  ios::sync_with_stdio(false);
  LL n;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    p[0][i] = x[i] + y[i], p[1][i] = y[i] - x[i], p[2][i] = x[i] - y[i],
    p[3][i] = -(x[i] + y[i]);
  }
  for (i = 0; i <= 3; i++)
    sort(p[i] + 1, p[i] + 1 + n);
  for (i = 0; i <= 3; i++) {
    pd = max(pd, p[i][n] - p[i][1]);
    // cout<<i<<"  "<<p[i][n]<<"  "<<p[i][1]<<endl;
  }
  cout << pd;
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#define LL long long
#define N 1000001
#define NN 2002
using namespace std;
LL x[NN], y[NN];
LL p[4][NN];
LL i, j, k;
LL pd;
int main() {
  ios::sync_with_stdio(false);
  LL n;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    p[0][i] = x[i] + y[i], p[1][i] = y[i] - x[i], p[2][i] = x[i] - y[i],
    p[3][i] = -(x[i] + y[i]);
  }
  for (i = 0; i <= 3; i++)
    sort(p[i] + 1, p[i] + 1 + n);
  for (i = 0; i <= 3; i++) {
    pd = max(pd, p[i][n] - p[i][1]);
    // cout<<i<<"  "<<p[i][n]<<"  "<<p[i][1]<<endl;
  }
  cout << pd;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int inf = 2e9;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int N = 3e5 + 10;
const int M = 1e6 + 10;
const int mod = 1e9 + 7;
inline LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
inline LL lcm(LL a, LL b) { return a * b / gcd(a, b); }
inline LL read() {
  LL x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-')
      f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * f;
}
inline LL qpow(LL x, LL k = mod - 2, LL m = mod) {
  LL res = 1;
  while (k) {
    if (k & 1)
      res = res * x % m;
    x = x * x % m;
    k >>= 1;
  }
  return res;
}
/*=================================================================================================================*/
int n, maxs = -inf, maxd = -inf, mins = inf, mind = inf;

int main() {
  scanf("%d", &n);
  int ans = -inf;
  for (int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &x, &y);
    maxs = max(maxs, x + y);
    mins = min(mins, x + y);
    maxd = max(maxd, x - y);
    mind = min(mind, x - y);
    ans = max(ans, maxs - mins);
    ans = max(ans, maxd - mind);
  }
  printf("%d\\n", ans);
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
#define il inline
#define re register
using namespace std;
typedef double db;
const int N = 100001;
struct P {
  int x, y;
} a[N], s[N];
int n, top = 0, ans = 0;
il P operator-(P a, P b) { return (P){a.x - b.x, a.y - b.y}; }
il int operator*(P a, P b) { return a.x * b.y - a.y * b.x; }
il int dis(P a) { return abs(a.x) + abs(a.y); }
il bool cmp(P x, P y) {
  if (abs((x - a[1]) * (y - a[1])) > 0)
    return (x - a[1]) * (y - a[1]) > 0;
  return dis(x - a[1]) < dis(y - a[1]);
}
il int S(P a, P b, P c) { return abs((a - b) * (a - c)) / 2; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &a[i].x, &a[i].y);
  for (int i = 2; i <= n; i++)
    if (a[i].y < a[1].y || (a[i].y == a[1].y && a[i].x < a[1].x))
      swap(a[1], a[i]);
  sort(a + 2, a + n + 1, cmp);
  top = 2;
  s[1] = a[1];
  s[2] = a[2];
  for (int i = 3; i <= n; i++) {
    while (top > 1 && (a[i] - s[top - 1]) * (s[top] - s[top - 1]) >= 0)
      top--;
    s[++top] = a[i];
  }
  for (int i = 0; i < top; i++)
    s[i] = s[i + 1];
  n = top;
  for (int i = 0, j = 2; i < n; i++) {
    while (S(s[i], s[(i + 1) % n], s[j]) <
           S(s[i], s[(i + 1) % n], s[(j + 1) % n]))
      j = (j + 1) % n;
    ans = max(dis(s[i] - s[j]), ans);
  }
  printf("%d", ans);
  return 0;
}