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

#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long LL;
int main() {
  int N, i;
  cin >> N;
  set<pair<LL, LL>> P;
  set<pair<LL, LL>>::iterator sit;
  LL x, y;
  for (i = 0; i < N; i++) {
    cin >> x >> y;
    P.insert(pair<LL, LL>(x, y));
  }
  vector<LL> X, Y;
  for (sit = P.begin(); sit != P.end(); sit++) {
    X.push_back((*sit).first);
    Y.push_back((*sit).second);
  }
  LL MaxD = 0;
  N = X.size();
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  vector<LL> XYP(N), XYM(N);
  for (i = 0; i < N; i++) {
    XYP[i] = X[i] + Y[i];
    XYM[i] = X[i] - Y[i];
  }
  sort(XYP.begin(), XYP.end());
  sort(XYM.begin(), XYM.end());
  cout << max(XYP[N - 1] - XYP[0], XYM[N - 1] - XYM[0]) << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long LL;
LL GetDist(LL x1, LL y1, LL x2, LL y2) {
  LL Dx = x1 - x2;
  if (Dx < 0) {
    Dx = -Dx;
  }
  LL Dy = y1 - y2;
  if (Dy < 0) {
    Dy = -Dy;
  }
  return Dx + Dy;
}
int main() {
  int N, i, j;
  cin >> N;
  set<pair<LL, LL>> P;
  set<pair<LL, LL>>::iterator sit;
  LL x, y;
  for (i = 0; i < N; i++) {
    cin >> x >> y;
    P.insert(pair<LL, LL>(x, y));
  }
  vector<LL> X, Y;
  for (sit = P.begin(); sit != P.end(); sit++) {
    X.push_back((*sit).first);
    Y.push_back((*sit).second);
  }
  LL MaxD = 0;
  N = X.size();
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (i = 0; i < N - 1; i++) {
    for (j = i + 1; j < N; j++) {
      LL dist = GetDist(X[i], Y[i], X[j], Y[j]);
      if (MaxD < dist) {
        MaxD = dist;
      }
    }
  }
  cout << MaxD << endl;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back

int main() {
  ll n;
  cin >> n;
  ll x, y;
  // vector<pair<ll,ll>> vp;
  // vector<ll> v1;
  // vector<ll> v2;
  vector<int> a, b;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    a.pb(x + y);
    b.pb(x - y);
    // vp.push_back({x,y});
    // v1.pb(x);
    // v2.pb(y);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ll ans = 0;
  // sort(vp.begin(),vp.end());
  // for(int i=0;i<n;i++){
  //     for(int j=i+1;j<n;j++){
  //         ans = max(ans, (abs(vp[i].f-vp[j].f) + abs(vp[i].s-vp[j].s)));
  //     }
  // }
  // for(int i=0;i<n;i++){
  //     ans = max(ans, (abs(vp[0].f-vp[i].f) + abs(vp[0].s-vp[i].s)));
  // }
  // ll ans = dist(v1, n) + dist(v2, n);
  // sort(v.begin(),v.end());
  ans = max(abs(a[n - 1] - a[0]), abs(b[n - 1] - b[0]));
  cout << ans;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back
int main() {
  ll n;
  cin >> n;
  ll mod = 1000000007;
  ll x, y;
  vector<pair<ll, ll>> vp;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    vp.push_back({x, y});
  }
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans = max(ans, (abs(vp[i].f - vp[j].f) + abs(vp[i].s - vp[j].s)));
    }
  }
  cout << ans;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <limits>

using namespace std;

const int INF = numeric_limits<int>::max();
const int NEGINF = numeric_limits<int>::min();

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

  int x, y;
  int maxPlusXY = NEGINF, minPlusXY = INF, maxMinusXY = NEGINF,
      minMinusXY = INF;
  for (int i = 0; i < N; ++i) {
    cin >> x >> y;
    maxPlusXY = max(maxPlusXY, x + y);
    minPlusXY = min(minPlusXY, x + y);
    maxMinusXY = max(maxMinusXY, x - y);
    minMinusXY = min(minMinusXY, x - y);
  }
  cout << max(maxPlusXY - minPlusXY, maxMinusXY - minMinusXY) << endl;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <limits>
#include <vector>

#define x first
#define y second

using namespace std;

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

  vector<pair<int, int>> points(N);
  for (int i = 0; i < N; ++i) {
    cin >> points[i].x >> points[i].y;
  }

  int maxDistance = numeric_limits<int>::min();
  for (int i = 0; i < N; ++i) {
    auto a = points[i];
    for (int j = i + 1; j < N; ++j) {
      auto b = points[j];
      maxDistance = max(maxDistance, abs(a.x - b.x) + abs(a.y - b.y));
    }
  }
  cout << maxDistance << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

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

ll solve(vector<int> x, vector<int> y) {
  int mn = INT_MAX, mx = INT_MIN;
  int mn2 = INT_MAX, mx2 = INT_MIN;
  int max_i = 0, min_i = 0;
  for (int i = 0; i < n; i++) {
    mn = min(mn, (x[i] + y[i]));
    mx = max(mx, (x[i] + y[i]));
    mn2 = min(mn2, (x[i] - y[i]));
    mx2 = max(mx2, (x[i] - y[i]));
  }
  // cout<<mn<<" "<<mx<<" "<<mn2<<" "<<mx2<<" ";
  return max(abs(mx2 - mn2), abs(mx - mn));
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  vector<int> x(n, 0), y(n, 0);
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i];
  cout << solve(x, y);
  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  ll x[n], y[n];
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i];
  ll max_val = INT_MIN;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ll dist = abs(x[i] - x[j]) + abs(y[i] - y[j]);
      max_val = max(dist, max_val);
    }
  }
  cout << max_val;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
long long a[N], b[N];
long long n, x, y;
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld%lld", &x, &y);
    a[i] = x + y;
    b[i] = x - y;
  }
  sort(a + 1, a + 1 + n);
  sort(b + 1, b + 1 + n);
  printf("%lld", max(a[n] - a[1], b[n] - b[1]));
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
struct node {
  long long x, y;
};
node a[N];
long long n, ans;
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++)
    scanf("%lld%lld", &a[i].x, &a[i].y);
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++)
      ans = max(ans, abs(a[i].x - a[j].x) + abs(a[i].y - a[j].y));
  printf("%lld", ans);
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main() {
  int N = 0;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  int m = 0;

  for (int i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i);
  }

  int zmax = x.at(0) + y.at(0);
  int zmin = x.at(0) + y.at(0);
  int wmax = x.at(0) - y.at(0);
  int wmin = x.at(0) - y.at(0);

  for (int i = 0; i < N; i++) {
    if (zmax < x.at(i) + y.at(i)) {
      zmax = x.at(i) + y.at(i);
    }

    if (zmin > x.at(i) + y.at(i)) {
      zmin = x.at(i) + y.at(i);
    }
  }

  for (int i = 0; i < N; i++) {
    if (wmax < x.at(i) - y.at(i)) {
      wmax = x.at(i) - y.at(i);
    }

    if (wmin > x.at(i) - y.at(i)) {
      wmin = x.at(i) - y.at(i);
    }
  }

  m = max(zmax - zmin, wmax - wmin);
  cout << m << endl;
}

Error: TLE

Fixed submission:

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

int main() {
  int N = 0;
  cin >> N;
  vector<int> x(N);
  vector<int> y(N);
  int m = 0;

  for (int i = 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i);
  }

  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (m < abs(x.at(i) - x.at(j)) + abs(y.at(i) - y.at(j))) {
        m = abs(x.at(i) - x.at(j)) + abs(y.at(i) - y.at(j));
      }
    }
  }
  cout << m << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
// #include<bits/stdc++.h>
#define PI 2 * acos(0.0)
#define pb push_back

using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  ll x[200005], y[200005];
  ll p[200005], m[200005];

  ll n;
  cin >> n;

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

    cin >> x[i] >> y[i];
    p[i] = x[i] + y[i];
    m[i] = y[i] - x[i];
  }
  ll mxp = 0, minp = 1e9 + 5, mxm = 0, minm = 1e9 + 5;
  for (int i = 0; i < n; i++) {
    if (mxp < p[i]) {
      mxp = p[i];
    }

    if (minp > p[i]) {
      minp = p[i];
    }

    if (mxm < m[i]) {
      mxm = m[i];
    }
    if (minm > m[i]) {
      minm = m[i];
    }
  }

  ll ans = max(mxp - minp, mxm - minm);

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

  return 0;

  /***Israil Hosen
       Computer Science & Engineering
    University Of Rajshahi.
    ***/
}

Error: 0

Fixed submission:

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
// #include<bits/stdc++.h>
#define PI 2 * acos(0.0)
#define pb push_back

using namespace std;
using ll = long long;
using lli = long long int;
using ld = long double;

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

  ll n;
  cin >> n;
  ll x, y;
  ll p[100000], m[100000];
  for (int i = 0; i < n; i++) {

    cin >> x >> y;
    p[i] = x + y;
    m[i] = y - x;
  }
  ll mxp = 0, minp = 1e9 + 5, mxm = 0, minm = 1e9 + 5;
  for (int i = 0; i < n; i++) {
    if (mxp < p[i]) {
      mxp = p[i];
    }

    if (minp > p[i]) {
      minp = p[i];
    }

    if (mxm < m[i]) {
      mxm = m[i];
    }
    if (minm > m[i]) {
      minm = m[i];
    }
  }

  ll ans = max(mxp - minp, mxm - minm);

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

  return 0;

  /***Israil Hosen
       Computer Science & Engineering
    University Of Rajshahi.
    ***/
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#define forn(i, n) for (int(i) = 0; i < (n); i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
const int MAXN = 100005;
const int INF = 2147483647;
const ll LINF = 9223372036854775807;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int n, x[200005], y[200005];
int mx1 = 0, mn1 = INF, mx2 = -INF, mn2 = INF, mx3 = -INF, mn3 = INF;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  forn(i, n) {
    cin >> x[i] >> y[i];
    mx1 = max(mx1, x[i] + y[i]);
    mn1 = min(mn1, x[i] + y[i]);
    mx2 = max(mx2, x[i] - y[i]);
    mn2 = min(mn2, x[i] - y[i]);
    mx3 = max(mx3, y[i] - x[i]);
    mn3 = min(mn3, y[i] - x[i]);
  }
  cout << max(max(mx1 - mn1, mx2 - mn2), mx3 - mn3);
  return 0;
}


Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#define forn(i, n) for (int(i) = 0; i < (n); i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
const int MAXN = 100005;
const int INF = 2147483647;
const ll LINF = 9223372036854775807;
const int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int n, x[100005], y[100005];
int mx1 = 0, mn1 = INF, mx2 = 0, mn2 = INF;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  forn(i, n) {
    cin >> x[i] >> y[i];
    mx1 = max(mx1, x[i] + y[i]);
    mn1 = min(mn1, x[i] + y[i]);
    mx2 = max(mx2, abs(x[i] - y[i]));
    mn2 = min(mn2, abs(x[i] - y[i]));
  }
  cout << max(mx1 - mn1, mx2 - mn2);
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<ll> a, b;
  for (int i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    a.push_back(x + y);
    b.push_back((x - y));
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ll maxip = (a[n - 1] - a[0]);
  ll maixn = (b[n - 1] - b[0]);
  ll ans = max(maxip, maixn);
  cout << ans;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll modu = 10e6 + 7;
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  vector<pair<ll, ll>> a;
  for (auto i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    a.push_back({x, y});
  }
  ll maxi = -1;
  for (auto i = 0; i < n; i++) {
    for (auto j = i + 1; j < n; j++) {
      ll diff = abs(a[j].first - a[i].first) + abs(a[j].second - a[i].second);
      maxi = max(diff, maxi);
    }
  }
  cout << maxi;
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
int WD;
struct Point {
  int x, y;
  bool operator<(const Point &tmp) const {
    return x == tmp.x ? y < tmp.y : x < tmp.x;
  }
};

const int maxn = 200000 + 10;

Point p[maxn];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d %d", &p[i].x, &p[i].y);
  sort(p + 1, p + 1 + n);
  int y1 = p[1].y, y2 = p[1].y, x = p[1].x, ans = 0;
  for (int i = 2, j; i <= n; i = j) {
    j = i;
    int dx = p[i].x - x, _y1 = y1 - dx, _y2 = y2 + dx;
    int __y1 = p[i].y, __y2 = p[i].y;
    while (j <= n && p[j].x == p[i].x) {
      ans = max(ans, max(abs(p[j].y - y1), abs(p[j].y - y2)) + dx);
      _y1 = min(p[j].y, _y1);
      __y1 = min(p[j].y, __y1);
      _y2 = max(p[j].y, _y2);
      __y2 = max(p[j].y, __y2);
      j++;
    }
    ans = max(ans, __y2 - __y1);
    x += dx;
    y1 = _y1;
    y2 = _y2;
  }
  cout << ans;
#ifndef ONLINE_JUDGE
  system("pause");
#endif
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int WD;
struct Point {
  int id;
  int x[2];
  bool operator<(const Point &tmp) const { return x[WD] < tmp.x[WD]; }
};
int sqr(int x) { return x * x; }
int _dis(Point a, Point b) {
  int res = 0;
  for (int i = 0; i < 2; i++) {
    res += abs(a.x[i] - b.x[i]);
  }
  return res;
}

const int maxn = 200000 + 10;
#define M ((L + R) >> 1)
Point p[maxn], pt[maxn];
int ls[maxn], rs[maxn], cnt;
int maxv[maxn][2], minv[maxn][2];
void Merge(int id) {
  for (int i = 0; i < 2; i++) {
    maxv[id][i] = minv[id][i] = pt[id].x[i];
    if (ls[id]) {
      maxv[id][i] = max(maxv[id][i], maxv[ls[id]][i]);
      minv[id][i] = min(minv[id][i], minv[ls[id]][i]);
    }
    if (rs[id]) {
      maxv[id][i] = max(maxv[id][i], maxv[rs[id]][i]);
      minv[id][i] = min(minv[id][i], minv[rs[id]][i]);
    }
  }
}
int Build(int L, int R, int wd) {
  if (L > R)
    return 0;
  int t = ++cnt;
  WD = wd;
  nth_element(p + L, p + M, p + R + 1);
  pt[t] = p[M];
  ls[t] = Build(L, M - 1, (wd + 1) % 2);
  rs[t] = Build(M + 1, R, (wd + 1) % 2);
  Merge(t);
  return t;
}
int GetMaxDis(Point a, int id) {
  int res = 0;
  for (int i = 0; i < 2; i++) {
    res += max(abs(a.x[i] - minv[id][i]), abs(a.x[i] - maxv[id][i]));
  }
  return res;
}
const int INF = INT_MIN;
int ans = INF;
void Query(Point a, int id) {
  int dis = _dis(a, pt[id]);
  ans = max(ans, dis);
  int disl = INF, disr = INF;
  if (ls[id])
    disl = GetMaxDis(a, ls[id]);
  if (rs[id])
    disr = GetMaxDis(a, rs[id]);
  if (disl > disr) {
    if (disl > ans)
      Query(a, ls[id]);
    if (disr > ans)
      Query(a, rs[id]);
  } else {
    if (disr > ans)
      Query(a, rs[id]);
    if (disl > ans)
      Query(a, ls[id]);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    p[i].id = i;
    for (int j = 0; j < 2; j++) {
      scanf("%d", &p[i].x[j]);
    }
  }
  int rt = Build(1, n, 1);
  for (int i = 1; i <= n; i++) {
    Query(p[i], rt);
  }
  printf("%d\\n", ans);
#ifndef ONLINE_JUDGE
  system("pause");
#endif
  return 0;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

/*
17/10/2017
*/
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> vc;
  int x, y;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    vc.push_back({x, y});
  }
  sort(vc.begin(), vc.end());
  int mx = vc[0].first + vc[0].second, mx2 = vc[0].first - vc[0].second;
  int ans = 0;
  for (int i = 1; i < n; i++) {
    ans = max(ans, vc[i].first + vc[i].second - mx);
    ans = max(ans, vc[i].first - vc[i].second - mx2);
    mx = min(mx, vc[i].first + vc[i].second);
    mx2 = min(mx2, vc[i].first - vc[i].second);
  }
  cout << ans << endl;
}

Error: WA

Fixed submission:

/*
17/10/2017
*/
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
vector<pair<int, int>> vc;
int ans = 0;
int n;
void upd(int x, int y) {
  for (int i = 0; i < n; i++) {
    ans = max(ans, abs(x - vc[i].first) + abs(y - vc[i].second));
  }
}
int main() {
  cin >> n;
  int x, y;
  int mx = 0;
  set<pair<int, int>> st;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (st.count({x, y})) {
      continue;
    }
    st.insert({x, y});
    vc.push_back({x, y});
    mx = max(mx, y);
  }
  sort(vc.begin(), vc.end());
  int mx2 = 0;
  for (int i = 0; i < n; i++) {
    if (vc[i].second == mx) {
      upd(vc[i].first, mx);
    }
    mx2 = max(mx2, vc[i].first);
  }
  int mn = mod, mn2 = mod;
  for (int i = 0; i < n; i++) {
    if (vc[i].first == mx2) {
      upd(mx2, vc[i].second);
    }
    mn = min(mn, vc[i].second);
    mn2 = min(mn2, vc[i].first);
  }

  for (int i = 0; i < n; i++) {
    if (vc[i].first == mn2) {
      upd(mn2, vc[i].second);
    }
  }
  for (int i = 0; i < n; i++) {
    if (vc[i].second == mn) {
      upd(vc[i].first, mn);
    }
  }
  cout << ans;
}
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;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T, typename cmp=less<T>> using oset =tree<T, null_type,
// cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long
#define mod 1000000007
#define MOD 998244353
#define inf 100000000000000000
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(), _x.end()
#define f first
#define s second
#define pb push_back
#define ar array
#define ld long double

void mahakal() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
#endif
}
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};
// char c[4]={'D' , 'R' , 'U' , 'L'};
const ll maxN = 3e5 + 5;
ll n;
bool cmp(pair<ll, ll> p1, pair<ll, ll> p2) {
  ll ans1 = p1.f + p1.s, ans2 = p2.f + p2.s;
  return ans1 < ans2;
}

bool cmp1(pair<ll, ll> p1, pair<ll, ll> p2) {
  ll ans1 = p1.f - p1.s, ans2 = p2.f - p2.s;
  return ans1 < ans2;
}

void solve() {
  cin >> n;
  vector<pair<ll, ll>> a(n), b(n);
  for (ll i = 0; i < n; i++) {
    cin >> a[i].f >> a[i].s;
    b[i].f = a[i].f, b[i].s = a[i].s;
  }
  sort(a.begin(), a.end(), cmp);
  sort(b.begin(), b.end(), cmp1);
  ll ans = max(abs(a[0].f - a[n - 1].f) + abs(a[0].s - a[n - 1].s),
               abs(b[0].f - b[n - 1].f) + abs(b[0].s - b[n - 1].s));

  cout << ans << endl;
}

int main() {
  // 	mahakal();
  fast;
  ll t = 1;
  // 	cin>> t ;
  while (t--)
    solve();
  // 	cerr << "\\ntime taken : " << (float)clock() / CLOCKS_PER_SEC << " secs"
  // << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <algorithm>
#include <bits/stdc++.h>
#include <cstring>
#include <iostream>
#define ios ios::sync_with_stdio(false)
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long ll;
const ll maxn = 2e5 + 10;
const ll mod = 1e9 + 7;
ll maxx = 0;
ll x[maxn], y[maxn], ans[maxn];
int main() {
  int n, k = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> x[i] >> y[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      ll ans = abs(x[i] - x[j]) + abs(y[i] - y[j]);
      if (ans > maxx)
        maxx = ans;
    }
  }
  //	cout<<ans[0];
  //	for(int i = 0;i < n; i++)
  //		cout<<ans[i]<<endl;
  cout << maxx << '\\n';
  return 0;
}