Problem p02556 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl '\\n'
#define ll long long
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define For(i, s) for (auto i : s)
#define Forr(i, s) for (auto &i : s)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vll vector<pair<ll, ll>>
#define PI double PPPPPP = 3.14159265358979323846;
#define bit(mask, i) ((mask >> i) & 1)
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...)                                                             \\
  debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5 + 5, mod = 100000007, mod2 = 998244353, MAXN = 100000 + 29;
void files() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
int dist(ii a, ii b) {
  return abs(a.first - b.first) + abs(a.second - b.second);
}
bool cmp(ii a, ii b) {
  int d1 = abs(a.first) + abs(a.second);
  int d2 = abs(b.first) + abs(b.second);
  return d1 < d2;
}
bool cmp2(ii a, ii b) {
  int d1 = abs(a.first) - abs(a.second);
  int d2 = abs(b.first) - abs(b.second);
  return d1 < d2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  files();
  int n;
  cin >> n;
  vii v(n);
  Forr(i, v) cin >> i.first >> i.second;
  sort(all(v), cmp);
  int ans = dist(v.front(), v.back());
  sort(all(v), cmp2);
  ans = max(ans, dist(v.front(), v.back()));

  cout << ans;
}

Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
/*
 *  JUST KEEP GOING
 */
#define endl '\\n'
#define ll long long
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define sz(v) ((int)((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define rep(i, v) for (int i = 0; i < sz(v); ++i)
#define For(i, s) for (auto i : s)
#define Forr(i, s) for (auto &i : s)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define lpi(i, j, n) for (int i = (j); i < (int)(n); ++i)
#define lpd(i, j, n) for (int i = (j); i >= (int)(n); --i)
#define vi vector<int>
#define vl vector<ll>
#define ii pair<int, int>
#define vii vector<ii>
#define vll vector<pair<ll, ll>>
#define PI double PPPPPP = 3.14159265358979323846;
#define bit(mask, i) ((mask >> i) & 1)
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) int idx,
               __attribute__((unused)) int LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...)                                                             \\
  debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
void run() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
}
const int N = 2e5 + 5, mod = 100000007, mod2 = 998244353, MAXN = 100000 + 29;
void files() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}
bool cmp(ii a, ii b) {
  int d1 = abs(a.first) + abs(a.second);
  int d2 = abs(b.first) + abs(b.second);
  return d1 >= d2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  files();
  int n;
  cin >> n;
  vii v(n);
  Forr(i, v) cin >> i.first >> i.second;
  sort(all(v), cmp);
  cout << abs(v.front().first - v.back().first) +
              abs(v.front().second - v.back().second);
}