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

#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

namespace FastIO {
struct Strs {
  char strs[10000 * 4];
  constexpr Strs() : strs() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      for (int t = 3; t >= 0; --t) {
        strs[i * 4 + t] = j % 10 + '0';
        j /= 10;
      }
    }
  }
} constexpr strs;
static constexpr size_t buf_size = 1 << 18;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e9)
    return 10;
  if (x >= (long long)1e8)
    return 9;
  if (x >= (long long)1e7)
    return 8;
  if (x >= (long long)1e6)
    return 7;
  if (x >= (long long)1e5)
    return 6;
  if (x >= (long long)1e4)
    return 5;
  if (x >= (long long)1e3)
    return 4;
  if (x >= (long long)1e2)
    return 3;
  if (x >= (long long)1e1)
    return 2;
  return 1;
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char &c) { c = buf_in[pt_in++]; }
template <class T> inline void scan(T &x) {
  if (pt_in + 32 > tail_in)
    load();
  char c;
  bool minus = 0;
  x = 0;
  scan(c);
  while (c >= '0') {
    x = x * 10 + (c & 15);
    scan(c);
  }
  if (minus)
    x = -x;
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T> inline void print(T x) {
  if (pt_out > buf_size - 32)
    flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, strs.strs + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, strs.strs + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
inline void print(const char *s) {
  if (pt_out > buf_size - 32)
    flush();
  for (int i = 0; s[i] != 0; ++i)
    print(s[i]);
}
template <class T> inline void println(T x) {
  print(x);
  print('\\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
} // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N;
  scan(N);
  int mn1 = INF, mx1 = -INF, mn2 = INF, mx2 = -INF;
  REP(i, N) {
    int x, y;
    scan(x);
    scan(y);
    int a = x + y, b = x - y;
    mn1 = min(mn1, a);
    mx1 = max(mx1, a);
    mn2 = min(mn2, b);
    mx2 = max(mx2, b);
  }
  println(max(mx1 - mn1, mx2 - mn2));
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

namespace FastIO {
struct Strs {
  char strs[10000 * 4];
  constexpr Strs() : strs() {
    for (int i = 0; i < 10000; ++i) {
      int j = i;
      for (int t = 3; t >= 0; --t) {
        strs[i * 4 + t] = j % 10 + '0';
        j /= 10;
      }
    }
  }
} constexpr strs;
static constexpr size_t buf_size = 1 << 17;
char buf_in[buf_size], buf_out[buf_size];
size_t pt_in = 0, pt_out = 0, tail_in = 0;
inline size_t num_digits(long long x) {
  if (x >= (long long)1e5)
    return 6;
  if (x >= (long long)1e4)
    return 5;
  if (x >= (long long)1e3)
    return 4;
  if (x >= (long long)1e2)
    return 3;
  if (x >= (long long)1e1)
    return 2;
  return 1;
}
inline void load() {
  memcpy(buf_in, buf_in + pt_in, tail_in - pt_in);
  size_t width = tail_in - pt_in;
  tail_in = width + fread(buf_in + width, 1, buf_size - width, stdin);
  pt_in = 0;
}
inline void flush() {
  fwrite(buf_out, 1, pt_out, stdout);
  pt_out = 0;
}
inline void scan(char &c) { c = buf_in[pt_in++]; }
template <class T> inline void scan(T &x) {
  if (pt_in + 32 > tail_in)
    load();
  char c;
  bool minus = 0;
  x = 0;
  scan(c);
  while (c >= '0') {
    x = x * 10 + (c & 15);
    scan(c);
  }
  if (minus)
    x = -x;
}
inline void print(char c) { buf_out[pt_out++] = c; }
template <class T> inline void print(T x) {
  if (pt_out > buf_size - 32)
    flush();
  if (x < 0) {
    print('-');
    x = -x;
  }
  size_t digits = num_digits(x);
  int i;
  for (i = pt_out + digits - 4; i > (int)pt_out; i -= 4) {
    memcpy(buf_out + i, strs.strs + (x % 10000) * 4, 4);
    x /= 10000;
  }
  memcpy(buf_out + pt_out, strs.strs + x * 4 + (pt_out - i), 4 + i - pt_out);
  pt_out += digits;
}
inline void print(const char *s) {
  if (pt_out > buf_size - 32)
    flush();
  for (int i = 0; s[i] != 0; ++i)
    print(s[i]);
}
template <class T> inline void println(T x) {
  print(x);
  print('\\n');
}
struct SetUp {
  SetUp() { load(); }
  ~SetUp() { flush(); }
} setup;
} // namespace FastIO

using FastIO::print;
using FastIO::println;
using FastIO::scan;

int main() {
  int N;
  scan(N);
  int mn1 = INF, mx1 = -INF, mn2 = INF, mx2 = -INF;
  REP(i, N) {
    int x, y;
    scan(x);
    scan(y);
    int a = x + y, b = x - y;
    mn1 = min(mn1, a);
    mx1 = max(mx1, a);
    mn2 = min(mn2, b);
    mx2 = max(mx2, b);
  }
  println(max(mx1 - mn1, mx2 - mn2));
  return 0;
}