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

#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
const int dem = 2;
const long long INF = 1e18;
struct Point {
  long long x[dem];
} p[maxn];
int n;
long long minx[1 << dem], maxx[1 << dem];
long long solve() {
  int tmp = (1 << dem);
  for (int i = 0; i < tmp; i++) {
    minx[i] = INF;
    maxx[i] = -INF;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < tmp; j++) {
      int t = j;
      long long s = 0;
      for (int k = 0; k < dem; k++) {
        if (t & 1)
          s += p[i].x[k];
        else
          s -= p[i].x[k];
        t >>= 1;
      }
      if (maxx[j] < s)
        maxx[j] = s;
      if (minx[j] > s)
        minx[j] = s;
    }
  }
  long long ans = -INF;
  for (int i = 0; i < tmp; i++) {
    if (maxx[i] - minx[i] > ans)
      ans = maxx[i] - minx[i];
  }
  return ans;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < dem; j++) {
        scanf("%lld", &p[i].x[j]);
      }
    }
    printf("%lld\\n", solve());
    return 0;
  }
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
const int dem = 2;
const long long INF = 1e18;
struct Point {
  long long x[dem];
} p[maxn];
int n;
long long minx[1 << dem], maxx[1 << dem];
long long solve() {
  int tmp = (1 << dem);
  for (int i = 0; i < tmp; i++) {
    minx[i] = INF;
    maxx[i] = -INF;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < tmp; j++) {
      int t = j;
      long long s = 0;
      for (int k = 0; k < dem; k++) {
        if (t & 1)
          s += p[i].x[k];
        else
          s -= p[i].x[k];
        t >>= 1;
      }
      if (maxx[j] < s)
        maxx[j] = s;
      if (minx[j] > s)
        minx[j] = s;
    }
  }
  long long ans = -INF;
  for (int i = 0; i < tmp; i++) {
    if (maxx[i] - minx[i] > ans)
      ans = maxx[i] - minx[i];
  }
  return ans;
}
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < dem; j++) {
        scanf("%lld", &p[i].x[j]);
      }
    }
    printf("%lld\\n", solve());
    return 0;
  }
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

#define ll long long
#define fi first
#define se second
#define mp make_pair

#define fastio()                                                               \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define endl "\\n"

using namespace std;

const int mod = 1e9 + 7;
ll MAX = 100000000009;

int main() {
  fastio();
  int n, ans = 0, a1, a2, a3, a4;
  cin >> n;
  a1 = -1;
  a2 = -MAX;
  a3 = MAX;
  a4 = MAX;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a1 = max(a1, (x + y));
    a2 = max(a2, (x - y));
    a3 = min(a3, (x + y));
    a4 = min(a4, (x - y));
  }
  ans = max((a1 - a3), abs(a4 - a2));
  cout << ans << endl;
  // max ( (max(xi+yi)-min(xi+yi)), (max(xi-yi) - min(xi-yi)) )
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define ll long long
#define fi first
#define se second
#define mp make_pair

#define fastio()                                                               \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define endl "\\n"

using namespace std;

const int mod = 1e9 + 7;

int main() {
  vector<pair<ll, ll>> a;
  fastio();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    a.push_back(make_pair(x, y));
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans = max(ans, abs(a[i].fi - a[j].fi) + abs(a[i].se - a[j].se));
    }
  }
  cout << ans << endl;

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

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) > (b)) ? (b) : (a))
#define abs(a) (((a) > 0) ? (a) : (-(a)))
#define ll long long

void solve() {
  int n;
  cin >> n;
  vector<ll> a, b;
  while (n--) {
    ll x, y;
    cin >> x >> y;
    a.push_back(x + y);
    b.push_back(x - y);
  }
  cout << max((*max_element(a.begin(), a.end())) -
                  (*min_element(a.begin(), a.end())),
              (*max_element(b.begin(), b.end())) -
                  (*min_element(b.begin(), b.end())))
       << '\\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>

using namespace std;

#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) > (b)) ? (b) : (a))
#define abs(a) (((a) > 0) ? (a) : (-(a)))
#define ll long long

void solve() {
  int n;
  cin >> n;
  vector<ll> a(2 * n);
  for (int i = 0, j = 1; i < 2 * n, j < 2 * n; i += 2, j += 2) {
    int x, y;
    cin >> x >> y;
    a[i] = x, a[j] = y;
  }
  ll ans = 0;
  for (int i = 0, j = 1; i < 2 * n; i += 2, j += 2) {
    for (int k = i + 2, l = j + 2; k < 2 * n; k += 2, l += 2) {
      ans = max(ans, abs(a[i] - a[k]) + abs(a[j] - a[l]));
    }
  }
  cout << ans << '\\n';
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#define fi first
#define se second
#define debug printf(" I am here\\n");
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 1000 + 5, inf = 0x3f3f3f3f;
const double eps = 1e-10;
int n;
signed main() {
  scanf("%d", &n);
  int ma1 = -inf, mi1 = inf, ma2 = -inf, mi2 = inf;
  for (int i = 1, x, y; i <= n; i++) {
    scanf("%d%d", &x, &y);
    ma1 = max(ma1, x - y);
    mi1 = min(mi1, x - y);
    ma2 = max(ma2, x + y);
    mi2 = min(mi2, x + y);
  }
  printf("%d\\n", max(ma1 - mi1, ma2 - mi2));
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 2e5 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f;
int n;
pii pa[maxn];
inline int max(int a, int b) { return a > b ? a : b; }
inline int abs(int x) { return x > 0 ? x : -x; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &pa[i].fi, &pa[i].se);
  }
  int ans = 0;
  int t = 1e8;
  while (t--) {
    //        cout<<t<<endl;
    //        srand(time(NULL));
    int a = rand() % n + 1, b = rand() % n + 1;
    ans = max(ans, abs(pa[a].fi - pa[b].fi) + abs(pa[a].se - pa[b].se));
  }
  printf("%d\\n", ans);
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<long long> x(n), y(n);
  for (int i = 0; i < n; ++i)
    cin >> x[i] >> y[i];
  long long minxpy = 1e18, minxmy = 1e18;
  long long maxxpy = -1e18, maxxmy = -1e18;
  for (int i = 0; i < n; ++i) {
    minxpy = min(minxpy, x[i] + y[i]);
    minxmy = min(minxmy, x[i] - y[i]);
    maxxpy = max(maxxpy, x[i] + y[i]);
    maxxmy = max(maxxmy, x[i] - y[i]);
  }
  cout << max(maxxpy - minxpy, -minxmy + maxxmy) << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

struct Point {
  int x, y;

  Point() {}
  Point(int x, int y) : x(x), y(y) {}

  Point operator+(const Point &p) const { return Point(x + p.x, y + p.y); }
  Point operator-(const Point &p) const { return Point(x - p.x, y - p.y); }

  friend istream &operator>>(istream &is, Point &p) {
    is >> p.x >> p.y;
    return is;
  }

  bool operator==(const Point &p) const { return (x == p.x && y == p.y); }
  bool operator<(const Point &p) const {
    return (x != p.x ? x < p.x : y < p.y);
  }
};

typedef Point Vector;
int abs(Vector a) { return abs(a.x) + abs(a.y); }
int cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }
typedef vector<Point> Polygon;

Polygon convexHull(Polygon p) {
  int n = p.size();
  sort(p.begin(), p.end(), [](const Point &a, const Point &b) {
    return (a.y != b.y ? a.y < b.y : a.x < b.x);
  });
  Polygon a(2 * n);
  int k = 0;
  for (int i = 0; i < n; ++i) {
    while (k > 1 && cross(a[k - 1] - a[k - 2], p[i] - a[k - 1]) < 0)
      k--;
    a[k++] = p[i];
  }
  for (int i = n - 2, t = k; i >= 0; --i) {
    while (k > t && cross(a[k - 1] - a[k - 2], p[i] - a[k - 1]) < 0)
      k--;
    a[k++] = p[i];
  }
  a.resize(k - 1);
  return a;
}

int convexDiameter(Polygon p) {
  int n = p.size();
  if (n == 2)
    return abs(p[0] - p[1]);
  int i = 0, j = 0;
  for (int k = 0; k < n; ++k) {
    if (p[i] < p[k])
      i = k;
    if (!(p[j] < p[k]))
      j = k;
  }
  int res = 0;
  int ti = i, tj = j;
  while (i != tj || j != ti) {
    res = max(res, abs(p[i] - p[j]));
    if (cross(p[(i + 1) % n] - p[i], p[(j + 1) % n] - p[j]) < 0.0)
      i = (i + 1) % n;
    else
      j = (j + 1) % n;
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  vector<Point> xy(n);
  for (auto &e : xy)
    cin >> e;
  cout << convexDiameter(convexHull(xy)) << 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;
  long long m = 1000000000;
  long long lbmax = 0, lbmin = 2 * m, ltmax = 0, ltmin = 2 * m;
  for (int i = 0; i < n; i++) {
    long long x, y, lt, lb;
    cin >> x >> y;
    lb = x + y;
    lt = x + (m - y);
    lbmax = max(lbmax, lb);
    lbmin = min(lbmin, lb);
    ltmax = max(ltmax, lt);
    ltmin = min(ltmin, lt);
  }
  long long ans = max(ltmax - ltmin, lbmax - lbmin);
  cout << ans << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<long long> x(n);
  vector<long long> y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  long long ans = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      long long dx = x[i] - x[j];
      long long dy = y[i] - y[j];
      if (dx < 0)
        dx *= -1;
      if (dy < 0)
        dy *= -1;
      ans = max(ans, dx + dy);
    }
  }
  cout << ans << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<long long, long long>> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i].first >> A[i].second;
  }
  long long ans = 0;
  /* O(n^2) approach
  for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
          ans=max(ans, abs(A[i].second-A[j].second)+abs(A[i].first-A[j].first));
      }
  }
  */
  long long maxSum = INT_MIN, minSum = INT_MAX;
  long long maxDiff = INT_MIN, minDiff = INT_MAX;

  for (int i = 0; i < n; i++) {
    long long curr = A[i].first + A[i].second;
    maxSum = max(maxSum, curr);
    minSum = min(minSum, curr);
    curr = (A[i].first - A[i].second);
    maxDiff = max(maxDiff, curr);
    minDiff = min(minDiff, curr);
  }

  cout << max(maxSum - minSum, maxDiff - minDiff) << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<pair<long long, long long>> A(n);
  for (int i = 0; i < n; i++) {
    cin >> A[i].first >> A[i].second;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans = max(ans,
                abs(A[i].second - A[j].second) + abs(A[i].first - A[j].first));
    }
  }

  cout << ans << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
// #include <atcoder/all>

using boost::multiprecision::cpp_int;
using namespace std;
// using namespace atcoder;

#if __has_include("print.hpp")
#include "print.hpp"
#endif

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
typedef pair<ll, ll> p;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> y(n), x(n);
  rep(i, n) cin >> x[i] >> y[i];
  vector<ll> v1(n), v2(n);
  rep(i, n) {
    v1[i] = x[i] + y[i];
    v2[i] = x[i] - y[i];
  }
  sort(ALL(v1));
  ll res = v1[n - 1] - v1[0];
  sort(ALL(v2));
  chmax(res, v2[n - 1] - v2[0]);

  cout << res << endl;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Point {
  Point(double arg_x, double arg_y) {
    x = arg_x;
    y = arg_y;
  }

  Point() { x = y = 0.0; }

  Point operator+(Point p) { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) { return Point(x - p.x, y - p.y); }
  Point operator*(double a) { return Point(a * x, a * y); }
  Point operator/(double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }

  bool operator<(const Point &p) const { return x != p.x ? x < p.x : y < p.y; }

  bool operator==(const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }

  void debug() { printf("(%.3lf,%.3lf)\\n", x, y); }

  double x, y;
};

typedef Point Vector;
typedef vector<Point> Polygon;

double calc_dist(Point A, Point B) { return abs(A.x - B.x) + abs(A.y - B.y); }

double cross(Vector a, Vector b) { return a.x * b.y - a.y * b.x; }

double Caliper(Polygon P) {

  int N = P.size();
  if (N == 1)
    return 0;

  int a = 0, b = 0;

  for (int i = 1; i < N; i++) {

    if (P[a].y < P[i].y) {
      a = i;
    }
    if (P[b].y > P[i].y) {

      b = i;
    }
  }

  double max_dist = calc_dist(P[a], P[b]);

  int work_a = a, work_b = b;

  while (work_a != b || work_b != a) {

    double tmp_dist = calc_dist(P[work_a], P[work_b]);
    max_dist = max(max_dist, tmp_dist);
    if (cross(P[(work_a + 1) % N] - P[work_a],
              P[(work_b + 1) % N] - P[work_b]) < 0) {

      work_a = (work_a + 1) % N;
    } else {

      work_b = (work_b + 1) % N;
    }
  }
  return max_dist;
}

int main() {

  int N;
  Polygon P;
  scanf("%d", &N);

  double x, y;

  for (int i = 0; i < N; i++) {
    scanf("%lf %lf", &x, &y);
    P.push_back(Point(x, y));
  }

  cout << Caliper(P) << endl;

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200000 + 10;
const int dem = 2;
const int INF = 0x3f3f3f3f;

struct Point {
  int x[dem];
} p[maxn];

int n;
int minx[1 << dem], maxx[1 << dem];

ll solve() {
  int tmp = 1 << dem;

  for (int i = 0; i < tmp; i++) {
    minx[i] = INF;
    maxx[i] = -INF;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < tmp; j++) {
      int t = j;
      int s = 0;
      for (int k = 0; k < dem; k++) {
        if (t & 1)
          s += p[i].x[k];
        else
          s -= p[i].x[k];
        t >>= 1;
      }
      if (maxx[j] < s)
        maxx[j] = s;
      if (minx[j] > s)
        minx[j] = s;
    }
  }
  ll ans = -1 * INF;
  for (int i = 0; i < tmp; i++) {
    if (maxx[i] - minx[i] > ans)
      ans = maxx[i] - minx[i];
  }

  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < dem; j++) {
      cin >> p[i].x[j];
    }
  }
  cout << solve() << endl;

  return 0;
}

Error: 0

Fixed submission:

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

const int maxn = 100000 + 10;
const int dem = 2; // 维数
const int INF = 0x3f3f3f3f;

struct Point {
  int x[dem];
} p[maxn];

int n;
int minx[1 << dem], maxx[1 << dem];

double solve() {
  int tmp = 1 << dem;

  for (int i = 0; i < tmp; i++) {
    minx[i] = INF;
    maxx[i] = -INF;
  }

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < tmp; j++) {
      int t = j;
      int s = 0;
      for (int k = 0; k < dem; k++) {
        if (t & 1)
          s += p[i].x[k];
        else
          s -= p[i].x[k];
        t >>= 1;
      }
      if (maxx[j] < s)
        maxx[j] = s;
      if (minx[j] > s)
        minx[j] = s;
    }
  }
  int ans = -1 * INF;
  for (int i = 0; i < tmp; i++) {
    if (maxx[i] - minx[i] > ans)
      ans = maxx[i] - minx[i];
  }

  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < dem; j++) {
      cin >> p[i].x[j];
    }
  }
  cout << solve() << endl;

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

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

typedef long long ll;
typedef pair<ll, ll> pii;
const int N = 2e5 + 10, mod = 1e9 + 7;

void solve() {
  int n;
  cin >> n;

  set<pii> s;
  ll mxa = LLONG_MIN;
  ll mna = LLONG_MAX;
  ll mxb = LLONG_MIN;
  ll mnb = LLONG_MAX;
  ll mxc = LLONG_MIN;
  ll mnc = LLONG_MAX;

  for (int i = 0; i < n; ++i) {
    ll x, y;
    cin >> x >> y;
    if (s.count({x, y}) == 0) {
      s.insert({x, y});
      mxa = max(mxa, x + y);
      mna = min(mna, x + y);
      mxb = max(mxb, x - y);
      mnb = min(mnb, x - y);
      mxc = max(mxc, y - x);
      mnc = min(mnc, y - x);
    }
  }

  cout << max(mxa - mna, max(mxb - mnb, mxc - mnc)) << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--)
    solve();
  return 0;
}


Error: TLE

Fixed submission:

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

typedef long long ll;
typedef pair<int, int> pii;
const int N = 2e5 + 10, mod = 1e9 + 7;

void solve() {
  int n;
  cin >> n;

  pii a[n];
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    a[i] = {x, y};
  }

  int mx = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      mx = max(mx,
               abs(a[j].first - a[i].first) + abs(a[j].second - a[i].second));
    }
  }

  cout << mx << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--)
    solve();
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#define ll long long
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\\n'
ll dist(ll x1, ll x2, ll y1, ll y2) { return abs(x2 - x1) + abs(y2 - y1); }
int main() {
  int N;
  cin >> N;
  vector<ll> X(N), Y(N), P(N), Q(N);
  rep(i, 0, N) cin >> X[i] >> Y[i];
  rep(i, 0, N) {
    P[i] = X[i] - Y[i];
    Q[i] = X[i] + Y[i];
  }
  sort(P.begin(), P.end());
  sort(Q.begin(), Q.end());
  ll ans = max(abs(P.back() - P.front()), abs(Q.back() - Q.front()));
  cout << ans << endl;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#define ll long long
#define rep(i, s, e) for (int i = s; i < e; i++)
#define endl '\\n'
ll dist(ll x1, ll x2, ll y1, ll y2) { return abs(x2 - x1) + abs(y2 - y1); }
int main() {
  int N;
  cin >> N;
  ll ans = 0;
  vector<ll> X(N), Y(N);
  rep(i, 0, N) cin >> X[i] >> Y[i];
  rep(i, 0, N) {
    rep(j, 1, N) { ans = max(ans, dist(X[i], X[j], Y[i], Y[j])); }
  }
  cout << ans << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair

using namespace std;

typedef long long ll;

const int nax = 2e5 + 5;
int xx[nax];
int yy[nax];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    xx[i] = a + b;
    yy[i] = b - a;
  }
  sort(xx, xx + n);
  sort(yy, yy + n);
  cout << max(abs(xx[0] - xx[n - 1]), abs(yy[0] - yy[n - 1]));
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair

using namespace std;

typedef long long ll;

const int nax = 1e5 + 5;
int xx[nax];
int yy[nax];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    xx[i] = a + b;
    yy[i] = b - a;
  }
  sort(xx, xx + n);
  sort(yy, yy + n);
  cout << max(abs(xx[0] - xx[n - 1]), abs(yy[0] - yy[n - 1]));
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

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

#define ll long long
#define ld long double
#define precision(x, d) cout << fixed << setprecision(d) << x
#define all(x) x.begin(), x.end()
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);                   \\
  srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define endl "\\n"
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

int main() {
  IOS;
  ll t, k, n, d, m, u, v;
  t = 1;
  // cin >> t;
  while (t--) {
    cin >> n;
    vector<pair<ll, ll>> v(n);
    vector<ll> b(n);
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i].first >> v[i].second;
      b[i] = v[i].first + v[i].second;
      a[i] = v[i].first - v[i].second;
    }
    sort(all(b));
    sort(all(a));
    ll ans1 = abs(b[0] - b[n - 1]);
    ll ans2 = abs(a[0] - a[n - 1]);
    ll ans = max(ans1, ans2);
    cout << ans << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

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

#define ll long long
#define ld long double
#define precision(x, d) cout << fixed << setprecision(d) << x
#define all(x) x.begin(), x.end()
#define IOS                                                                    \\
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);                   \\
  srand(time(NULL));
#define MOD 1000000007
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define endl "\\n"
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

bool comp(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.first + a.second <= b.first + b.second)
    return true;
  else
    return false;
}

int main() {
  IOS;
  ll t, k, n, d, m, u, v;
  t = 1;
  // cin >> t;
  while (t--) {
    cin >> n;
    vector<pair<ll, ll>> v(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i].first >> v[i].second;
    }
    sort(all(v), comp);
    ll ans = abs(v[0].first + v[0].second - v[n - 1].first - v[n - 1].second);
    cout << ans << endl;
  }
  return 0;
}