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

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e12;

ll f(ll a, ll b, ll c, ll d) { return abs(a - b) + abs(c - d); }

int main() {
  ll n, ans = 0, mx1 = 0, mx0 = 0, mn0 = INF, mn1 = INF;
  cin >> n;
  vector<pair<ll, ll>> v(n), x(n);
  set<pair<ll, ll>> st;

  rep(i, n) {
    cin >> v[i].first >> v[i].second;
    st.insert(v[i]);
    x[i].first = v[i].first - v[i].second;
    x[i].second = v[i].first + v[i].second;
    mx0 = max(mx0, x[i].first);
    mn0 = min(mn0, x[i].first);
    mx1 = max(mx1, x[i].second);
    mn1 = min(mn1, x[i].second);
  }
  // cout << mx0 << " " << mx1 << " " << mn0 << " " << mn1 << endl;
  if (st.size() == 1) {
    cout << 0 << endl;
    return 0;
  }
  ans = max({mx0 - mn0, mx1 - mn1});
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll f(ll a, ll b, ll c, ll d) { return abs(a - b) + abs(c - d); }

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<pair<ll, ll>> v(n);

  rep(i, n) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());

  for (int i = 0; i <= n / 4; ++i) {
    for (int j = n / 4; j < n; ++j) {
      ans = max(ans, f(v[i].first, v[j].first, v[i].second, v[j].second));
    }
  }

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

#include <bits/stdc++.h> //AtCoder
#include <iostream>      //Codeforces
#include <vector>        //Codeforces

#define int long long
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repeq(i, a, b) for (int i = a; i <= b; i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout << "YES" << endl
#define cNO cout << "NO" << endl
#define cYes cout << "Yes" << endl
#define cNo cout << "No" << endl
#define cyes cout << "yes" << endl
#define cno cout << "no" << endl

using namespace std;

const int MOD = 1000000007; // 10^9 + 7
/****************************** START ******************************/
signed main() {
  int N;
  cin >> N;
  Vi x(N), y(N), z(N), w(N);
  rep(i, 0, N) {
    cin >> x.at(i) >> y.at(i);
    z.at(i) = x.at(i) + y.at(i);
    w.at(i) = x.at(i) - y.at(i);
  }
  int zmax, zmin, wmax, wmin;
  zmax = z.at(0);
  zmin = z.at(0);
  wmax = w.at(0);
  wmin = w.at(0);
  rep(i, 1, N) {
    if (z.at(i) > zmax) {
      zmax = z.at(i);
    }
    if (z.at(i) < zmin) {
      zmin = z.at(i);
    }
    if (w.at(i) > wmax) {
      wmax = w.at(i);
    }
    if (w.at(i) < wmin) {
      wmin = w.at(i);
    }
  }
  cout << max(zmax - zmin, wmax - wmin);
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h> //AtCoder
#include <iostream>      //Codeforces
#include <vector>        //Codeforces

#define int long long
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repeq(i, a, b) for (int i = a; i <= b; i++)
#define Vi vector<int>
#define VVi vector<Vi>
#define Vs vector<string>
#define Vc vector<char>
#define cYES cout << "YES" << endl
#define cNO cout << "NO" << endl
#define cYes cout << "Yes" << endl
#define cNo cout << "No" << endl
#define cyes cout << "yes" << endl
#define cno cout << "no" << endl

using namespace std;

const int MOD = 1000000007; // 10^9 + 7
/****************************** START ******************************/
signed main() {
  int N;
  cin >> N;
  Vi x(N), y(N);
  rep(i, 0, N) { cin >> x.at(i) >> y.at(i); }
  int ans = 0;
  rep(i, 0, N) {
    rep(j, 0, N) {
      if (abs(x.at(i) - x.at(j)) + abs(y.at(i) - y.at(j)) > ans) {
        ans = abs(x.at(i) - x.at(j)) + abs(y.at(i) - y.at(j));
      }
    }
  }
  cout << ans;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define INF 9999999999999
#define D 2      // 空间维数
#define M 200005 // 坐标个数
struct Point {
  int x[D];
} pt[M];
int dis[1 << D][M], minx[1 << D], maxx[1 << D];

// 去掉绝对值后有2^D种可能
void Get(int N) // 取得所有点在指定状态（S）下的“本点有效距离”
{
  int tot = (1 << D);
  for (int s = 0; s < tot; s++) // 遍历所有维数正负状态
  {
    int coe[D];
    for (int i = 0; i < D; i++) // 设定当前状态的具体正负参数
      if (s & (1 << i))
        coe[i] = -1.0;
      else
        coe[i] = 1.0;

    for (int i = 0; i < N;
         i++) // 遍历所有点，确定每个点在当前状态下的“本点有效距离”
    {
      dis[s][i] = 0.0;
      for (int j = 0; j < D; j++)
        dis[s][i] = dis[s][i] + coe[j] * pt[i].x[j];
    }
  }
}
// 取每种可能中的最大差距
void Solve(int N) {
  int tot = (1 << D);
  int tmp, ans;
  for (int s = 0; s < tot; s++) {
    minx[s] = INF;
    maxx[s] = -INF;
    for (int i = 0; i < N; i++) {
      if (minx[s] > dis[s][i])
        minx[s] = dis[s][i];
      if (maxx[s] < dis[s][i])
        maxx[s] = dis[s][i];
    }
  }
  ans = 0;
  for (int s = 0; s < tot; s++) {
    tmp = maxx[s] - minx[s];
    if (tmp > ans)
      ans = tmp;
  }

  cout << ans << endl;
}

int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++)
      cin >> pt[i].x[0] >> pt[i].x[1];
    Get(n);
    Solve(n);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define INF 9999999999999
#define D 2      // 空间维数
#define M 100005 // 坐标个数
struct Point {
  int x[D];
} pt[M];
int dis[1 << D][M], minx[1 << D], maxx[1 << D];

// 去掉绝对值后有2^D种可能
void Get(int N) // 取得所有点在指定状态（S）下的“本点有效距离”
{
  int tot = (1 << D);
  for (int s = 0; s < tot; s++) // 遍历所有维数正负状态
  {
    int coe[D];
    for (int i = 0; i < D; i++) // 设定当前状态的具体正负参数
      if (s & (1 << i))
        coe[i] = -1.0;
      else
        coe[i] = 1.0;

    for (int i = 0; i < N;
         i++) // 遍历所有点，确定每个点在当前状态下的“本点有效距离”
    {
      dis[s][i] = 0.0;
      for (int j = 0; j < D; j++)
        dis[s][i] = dis[s][i] + coe[j] * pt[i].x[j];
    }
  }
}
// 取每种可能中的最大差距
void Solve(int N) {
  int tot = (1 << D);
  int tmp, ans;
  for (int s = 0; s < tot; s++) {
    minx[s] = INF;
    maxx[s] = -INF;
    for (int i = 0; i < N; i++) {
      if (minx[s] > dis[s][i])
        minx[s] = dis[s][i];
      if (maxx[s] < dis[s][i])
        maxx[s] = dis[s][i];
    }
  }
  ans = 0;
  for (int s = 0; s < tot; s++) {
    tmp = maxx[s] - minx[s];
    if (tmp > ans)
      ans = tmp;
  }

  cout << ans << endl;
}

int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; i++)
      cin >> pt[i].x[0] >> pt[i].x[1];
    Get(n);
    Solve(n);
  }
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
#define ll long long
#define nes                                                                    \\
  ios_base ::sync_with_stdio(0);                                               \\
  cin.tie(0);
using namespace std;
ll mo = 1e9 + 7;
ll mod(ll n) { return (n % mo + mo) % mo; }
ll modadd(ll a, ll b) { return mod(mod(a) + mod(b)); }
int main() {
  nes;
  int n;
  cin >> n;
  vector<int> v1(n), v2(n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    v1[i] = x + y;
    v2[i] = 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: TLE

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define nes                                                                    \\
  ios_base ::sync_with_stdio(0);                                               \\
  cin.tie(0);
using namespace std;
ll mo = 1e9 + 7;
ll mod(ll n) { return (n % mo + mo) % mo; }
ll modadd(ll a, ll b) { return mod(mod(a) + mod(b)); }
int main() {
  nes;
  int n;
  cin >> n;
  vector<pair<int, int>> v(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i].first >> v[i].second;
  }
  int p = INT_MIN;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      p = max(abs(v[i].first - v[j].first) + abs(v[i].second - v[j].second), p);
    }
  }
  cout << p;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
ll pts[200005][6] = {0};

ll mnht(ll pt[200005][6], int kth, int idx, int d) {
  ll dist = 0;

  for (int i = 0; i < d; i++) {
    dist += abs(pt[kth][i] - pt[idx][i]);
  }

  return dist;
}
/*
10
-70 -64 -6 -56 64 61 -57 16 48 -98
*/
ll max_cmb(ll cmbn[6], ll pt[200005][6], int n, int d) {
  ll pk = 0;
  ll idx = 0;

  for (int i = 0; i < n; i++) {
    ll val = 0;

    for (int j = 0; j < d; j++) {
      val += (1 - 2 * cmbn[j]) * pt[i][j];
    }

    if (val > pk) {
      pk = val;
      idx = i;
    }
  }

  return idx;
}

int main() {
  int n, d;
  cin >> n;
  d = 2;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++)
      cin >> pts[i][j];
  }

  ll pk[2 << d];

  for (int j = 0; j < 1 << (d); j++) {
    ll cmbn[6] = {0};
    for (int dig = 0; dig < d; dig++) {
      if (j & 1 << dig)
        cmbn[dig] = 1;
      // cout<<cmbn[dig]<<" ";
    }
    // cout<<endl;
    pk[j] = max_cmb(cmbn, pts, n, d);
  }

  ll maxd = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 1 << (d); j++)
      maxd = max(maxd, mnht(pts, i, pk[j], d));
  }

  cout << maxd << endl;
  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
ll pts[100005][6] = {0};

ll mnht(ll pt[100005][6], int kth, int idx, int d) {
  ll dist = 0;

  for (int i = 0; i < d; i++) {
    dist += abs(pt[kth][i] - pt[idx][i]);
  }

  return dist;
}
/*
10
-70 -64 -6 -56 64 61 -57 16 48 -98
*/
ll max_cmb(ll cmbn[6], ll pt[100005][6], int n, int d) {
  ll pk = 0;
  ll idx = 0;

  for (int i = 0; i < n; i++) {
    ll val = 0;

    for (int j = 0; j < d; j++) {
      val += (1 - 2 * cmbn[j]) * pt[i][j];
    }

    if (val > pk) {
      pk = val;
      idx = i;
    }
  }

  return idx;
}

int main() {
  int n, d;
  cin >> n;
  d = 2;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < d; j++)
      cin >> pts[i][j];
  }

  ll pk[2 << d];

  for (int j = 0; j < 1 << (d); j++) {
    ll cmbn[6] = {0};
    for (int dig = 0; dig < d; dig++) {
      if (j & 1 << dig)
        cmbn[dig] = 1;
      // cout<<cmbn[dig]<<" ";
    }
    // cout<<endl;
    pk[j] = max_cmb(cmbn, pts, n, d);
  }

  ll maxd = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 1 << (d); j++)
      maxd = max(maxd, mnht(pts, i, pk[j], d));
  }

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

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

const int inf = 2e9;

int main() {
  int n;
  cin >> n;
  int umax = -inf, umin = inf;
  int vmax = -inf, vmin = inf;

  rep(i, n) {
    int x, y;
    cin >> x >> y;
    int u = x - y;
    int v = x + y;
    umax = max(umax, u);
    umin = min(umin, u);
    vmax = max(vmax, v);
    vmin = min(vmin, v);
  }

  int ans = max(umax - umin, vmax - vmin);
  cout << ans << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  rep(i, n) cin >> x[i] >> y[i];
  int ans = 0;
  rep(i, n) for (int j = i + 1; j < n; ++j) {
    int distx = x[i] - x[j];
    int disty = y[i] - y[j];
    int dist = abs(distx) + abs(disty);
    ans = max(ans, dist);
  }
  cout << ans << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define D(x) cout << (#x) << " is " << x << endl;
#define Q                                                                      \\
  int t;                                                                       \\
  scanf("%d", &t);                                                             \\
  for (int q = 1; q <= t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, lli> pii;

int main() {
  int n;
  cin >> n;
  lli a, b;
  lli mx1 = -1e10, mx2 = -1e10, mn1 = 1e10, mn2 = 1e10;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    mx1 = max(mx1, a + b);
    mx2 = max(mx2, a - b);
    mn2 = min(mn2, a - b);
    mn1 = min(mn1, a + b);
  }
  cout << max(mx1 - mn1, mx2 - mn2) << endl;

  return 0;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define D(x) cout << (#x) << " is " << x << endl;
#define Q                                                                      \\
  int t;                                                                       \\
  scanf("%d", &t);                                                             \\
  for (int q = 1; q <= t; q++)
typedef long long int lli;
typedef pair<int, int> pi;
typedef pair<lli, lli> pii;

int main() {
  int n;
  cin >> n;
  lli a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  lli mx1 = -1, mx2 = -1, mn1 = 1e10, mn2 = 1e10;
  int mxi1, mxi2, mni2, mni1;

  for (int i = 0; i < n; i++) {
    if (a[i] + b[i] > mx1) {
      mx1 = a[i] + b[i];
      mxi1 = i;
    }
    if (a[i] + b[i] < mn1) {
      mn1 = a[i] + b[i];
      mni1 = i;
    }
    if (a[i] - b[i] > mx2) {
      mx2 = a[i] + b[i];
      mxi2 = i;
    }
    if (a[i] - b[i] < mn2) {
      mn2 = a[i] + b[i];
      mni2 = i;
    }
  }

  cout << max(abs(a[mxi1] - a[mni1]) + abs(b[mxi1] - b[mni1]),
              abs(a[mxi2] - a[mni2]) + abs(b[mxi2] - b[mni2]))
       << endl;

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

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re register
#define ls (o << 1)
#define rs (o << 1 | 1)
#define pb push_back
const double PI = acos(-1.0);
const int M = 2e5 + 7;
/*
int head[M],cnt=1;
void init(int n){cnt=1;for(int i=0;i<=n;i++)head[i]=0;}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int
w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
int x[M], y[M];
int p[4][M];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    p[0][i] = x[i] + y[i];
    p[1][i] = -x[i] + y[i];
    p[2][i] = x[i] - y[i];
    p[3][i] = -x[i] - y[i];
  }
  for (int i = 0; i < 4; i++)
    sort(p[i] + 1, p[i] + 1 + n);
  int mx = 0;
  for (int i = 0; i < 4; i++) {
    mx = max(mx, p[i][n] - p[i][1]);
    // cout<<i<<"  "<<p[i][n]<<"  "<<p[i][1]<<endl;
  }
  cout << mx << endl;
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re register
#define ls (o << 1)
#define rs (o << 1 | 1)
#define pb push_back
const double PI = acos(-1.0);
const int M = 1e5 + 7;
/*
int head[M],cnt=1;
void init(int n){cnt=1;for(int i=0;i<=n;i++)head[i]=0;}
struct EDGE{int to,nxt,w;}ee[M*2];
void add(int x,int y,int
w){ee[++cnt].nxt=head[x],ee[cnt].w=w,ee[cnt].to=y,head[x]=cnt;}
*/
int x[M], y[M];
int p[4][M];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i];
    p[0][i] = x[i] + y[i];
    p[1][i] = -x[i] + y[i];
    p[2][i] = x[i] - y[i];
    p[3][i] = -x[i] - y[i];
  }
  for (int i = 0; i < 4; i++)
    sort(p[i] + 1, p[i] + 1 + n);
  int mx = 0;
  for (int i = 0; i < 4; i++) {
    mx = max(mx, p[i][n] - p[i][1]);
    // cout<<i<<"  "<<p[i][n]<<"  "<<p[i][1]<<endl;
  }
  cout << mx << endl;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const int maxn = 200100;
int n, x, y, mx1 = -inf, mx2 = -inf, mn1 = inf, mn2 = inf, ans = -inf,
             sum[maxn] = {}, diff[maxn] = {};
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &x, &y), sum[i] = x + y, diff[i] = x - y;
  for (int i = 1; i <= n; i++)
    mx1 = max(mx1, sum[i]), mx2 = max(mx2, diff[i]), mn1 = min(mn1, sum[i]),
    mn2 = min(mn2, diff[i]), ans = max(ans, max(mx1 - mn1, mx2 - mn2));
  printf("%d", ans);
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
const long long maxn = 201000;
long long n, ans = -maxn;
struct point {
  long long x, y;
} p[maxn];
bool cmp(point a, point b) { return (a.x < b.x) || (a.x == b.x && a.y < b.y); }
long long myabs(long long x) {
  if (x > 0)
    return x;
  return -x;
}
long long mymax(long long a, long long b) {
  if (a > b)
    return a;
  return b;
}
long long dis(long long a, long long b) {
  return myabs(p[a].x - p[b].x) + myabs(p[a].y - p[b].y);
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld", &p[i].x, &p[i].y);
  sort(p + 1, p + 1 + n, cmp);
  if (n == 1)
    printf("0");
  else if (n == 2)
    printf("%lld", dis(1, 2));
  else if (n <= 51000) {
    for (long long i = 1; i < n; i++)
      for (long long j = i + 1; j <= n; j++)
        ans = mymax(ans, dis(i, j));
    printf("%lld", ans);
  } else {
    for (long long i = 1; i <= 50000; i++)
      for (long long j = n - 50000; j <= n; j++)
        ans = mymax(ans, dis(i, j));
    printf("%lld", ans);
  }
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

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

int32_t main() {
  // freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);

  int n;
  cin >> n;
  vector<int> p(n, 0), q(n);
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    p[i] = x + y;
    q[i] = x - y;
  }
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  cout << abs(max(abs(p[0] - p[n - 1]), abs(q[0] - q[n - 1]))) << '\\n';
}

Error: -6
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans(vector<int> &x, vector<int> &y) {
  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] + i;
        res = max(res, cur - smallest);
        smallest = min(smallest, cur);
      }
    }
  }
  return res;
}
int32_t main() {
  freopen("input.txt", "r", stdin);
  // freopen("output.txt", "w", stdout);
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  int p[n];
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    p[i] = x[i] + y[i];
  }
  sort(p, p + n);
  cout << abs(p[0] - p[n - 1]) << '\\n';
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(), x.end()
#define MOD (1000000000 + 7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x, y) make_pair(x, y)

int main() {
  ll N;
  cin >> N;

  vector<ll> x(N);
  vector<ll> y(N);
  for (ll i = 0; i < N; i++)
    cin >> x[i] >> y[i];
  vector<ll> W(N), K(N);

  for (ll i = 0; i < N; i++) {
    W[i] = x[i] + y[i];
    K[i] = x[i] - y[i];
  }
  sort(ALL(W));
  sort(ALL(K));
  W.front();
  cout << max(W.back() - W.front(), K.back() - K.front()) << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(), x.end()
#define MOD (1000000000 + 7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x, y) make_pair(x, y)

int main() {
  ll N;
  cin >> N;

  vector<ll> x(N);
  vector<ll> y(N);
  vector<vector<ll>> dis(N, vector<ll>(N));

  for (ll i = 0; i < N; i++)
    cin >> x[i] >> y[i];

  ll maxx = 0;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < N; j++) {
      dis[i][j] = abs(x[i] - x[j]) + abs(y[i] - y[j]);
      maxx = max(maxx, dis[i][j]);
    }
  }

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

#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
using namespace std;

const int N = (int)(2e5 + 500);

int x[N], y[N];

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

#ifndef _LOCAL
#endif // _LOCAL

  int n;
  int mx1, mx2, mx3, mx4;

  mx1 = mx2 = mx3 = mx4 = -2e9;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    mx1 = max(mx1, -x[i] - y[i]);
    mx2 = max(mx2, -x[i] + y[i]);
    mx3 = max(mx3, x[i] - y[i]);
    mx4 = max(mx4, x[i] + y[i]);
  }

  int ans = -2e9;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, x[i] + y[i] + mx1);
    ans = max(ans, x[i] - y[i] + mx2);
    ans = max(ans, -x[i] + y[i] + mx3);
    ans = max(ans, -x[i] - y[i] + mx4);
  }

  cout << ans << "\\n";

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
using namespace std;

const int N = (int)(1e5 + 500);

int x[N], y[N];

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

#ifndef _LOCAL
#endif // _LOCAL

  int n;
  int mx1, mx2, mx3, mx4;

  mx1 = mx2 = mx3 = mx4 = -2e9;

  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    mx1 = max(mx1, -x[i] - y[i]);
    mx2 = max(mx2, -x[i] + y[i]);
    mx3 = max(mx3, x[i] - y[i]);
    mx4 = max(mx4, x[i] + y[i]);
  }

  int ans = -2e9;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, x[i] + y[i] + mx1);
    ans = max(ans, x[i] - y[i] + mx2);
    ans = max(ans, -x[i] + y[i] + mx3);
    ans = max(ans, -x[i] - y[i] + mx4);
  }

  cout << ans << "\\n";

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

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;
const int M = 2e5 + 5;
int a[M], b[M];
int n, ans = 0;
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = x + y;
    b[i] = y - x;
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  ans = max(a[n] - a[1], b[n] - b[1]);
  printf("%d\\n", ans);
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;
const int M = 2e4 + 5;
int a[M], b[M];
int n, ans = 0;
int main() {
  int i;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    a[i] = x + y;
    b[i] = y - x;
  }
  sort(a + 1, a + n + 1);
  sort(b + 1, b + n + 1);
  ans = max(a[n] - a[1], b[n] - b[1]);
  printf("%d\\n", ans);
  return 0;
}