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

#include <iostream>
#include <set>

using namespace std;
typedef pair<int, int> P;

void solve() {
  int n;
  while (cin >> n, n) {
    set<P> Set;
    for (int i = 0; i < n; ++i) {
      int x, y;
      cin >> x >> y;
      Set.insert(P(x, y));
    }
    int ans = 0;
    for (set<P>::iterator It = Set.begin(); It != Set.end(); ++It) {
      for (set<P>::iterator It2 = Set.begin(); It2 != Set.end(); ++It2) {
        int tx = It->first - It2->first;
        int ty = It->second - It2->second;
        if (tx * tx + ty * ty <= ans) {
          continue;
        }
        if (Set.count(P(It->first - ty, It->second + tx)) &&
            Set.count(P(It2->first - ty, It2->second + tx))) {
          ans = tx * tx + ty * ty;
        }
      }
    }
    cout << ans << endl;
  }
}

int main() {
  solve();
  return (0);
}

Error: TLE

Fixed submission:

#include <complex>
#include <iostream>
#include <vector>

using namespace std;
typedef complex<double> P;
static const double eps = 1e-9;

double dot(P p1, P p2) {
  return (p1.real() * p2.real() + p1.imag() * p2.imag());
}

void solve() {
  int n;
  while (cin >> n, n) {
    vector<P> Vec(n);
    for (int i = 0; i < n; ++i) {
      double a, b;
      cin >> a >> b;
      P p(a, b);
      Vec[i] = p;
    }
    double Max = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        P temp2 = Vec[j] - Vec[i];
        for (int k = j + 1; k < n; ++k) {
          P temp1 = Vec[k] - Vec[i];
          if (dot(temp1, temp2) < eps && abs(abs(temp1) - abs(temp2)) < eps) {
            for (int l = 0; l < n; ++l) {
              if (l == i || l == j || l == k) {
                continue;
              }
              P temp3 = Vec[l] - Vec[k];
              P temp4 = Vec[l] - Vec[j];
              if (dot(temp3, temp4) < eps &&
                  abs(abs(temp3) - abs(temp4)) < eps) {
                double square = abs(temp1) * abs(temp1);
                if (Max < square) {
                  Max = square;
                }
              }
            }
          }
        }
      }
    }
    cout << Max << endl;
  }
}

int main() {
  solve();
  return (0);
}
Problem p00441 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

// #define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

bool p[5010][5010];

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  auto inrange = [&](int i, int j) {
    return i >= 0 && i < 5010 && j >= 0 && j < 5010;
  };
  for (int N; cin >> N && N;) {
    vector<int> x(N), y(N);
    rep(i, 0, N) {
      cin >> x[i] >> y[i];
      p[x[i]][y[i]] = true;
    }
    int ans = 0;
    rep(i, 0, N) rep(j, i + 1, N) {
      int dx = x[i] - x[j], dy = y[i] - y[j];
      if (inrange(x[i] - dy, y[i] + dx) && p[x[i] - dy][y[i] + dx] &&
          inrange(x[j] - dy, y[j] + dx) && p[x[j] - dy][y[j] + dx]) {
        chmax(ans, dx * dx + dy * dy);
      }
      if (inrange(x[i] + dy, y[i] - dx) && p[x[i] + dy][y[i] - dx] &&
          inrange(x[j] + dy, y[j] - dx) && p[x[j] + dy][y[j] - dx]) {
        chmax(ans, dx * dx + dy * dy);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

// #define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}

bool p[5010][5010];

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  for (int N; cin >> N && N;) {
    vector<int> x(N), y(N);
    rep(i, 0, N) {
      cin >> x[i] >> y[i];
      p[x[i]][y[i]] = true;
    }
    int ans = 0;
    rep(i, 0, N) rep(j, i + 1, N) {
      int dx = x[i] - x[j], dy = y[i] - y[j];
      if (p[x[i] + dy][y[i] + dx] && p[x[j] + dy][y[i] + dx]) {
        chmax(ans, dx * dx + dy * dy);
      } else if (p[x[i] - dy][y[i] - dx] && p[x[j] - dy][y[i] - dx]) {
        chmax(ans, dx * dx + dy * dy);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00441 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
#define X first
#define Y second
int N;
P p[3002];
// map<int,map<int,int> > M;
set<P> S;
int area(int mx, int my) {
  //  printf("%d %d\\n",mx,my);
  double line = sqrt(mx * mx + my * my);
  line *= line;
  line *= 10;
  int ret = (int)line;
  ret += 5;
  ret /= 10;
  return ret;
}
int main() {
  while (1) {
    scanf("%d", &N);
    if (!N)
      break;
    //    M.clear();
    for (int i = 0; i < N; i++) {
      scanf("%d %d", &p[i].X, &p[i].Y);
      //      M[p[i].X][p[i].Y]=1;
      S.insert(p[i]);
    }
    int res = 0;
    sort(p, p + N);
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        int x = p[i].X, y = p[i].Y;
        int mx = p[j].X - x;
        int my = p[j].Y - y;
        if (S.find(P(x - my, y + mx)) != S.end()) {
          if (S.find(P(x - my + mx, y + mx + my)) != S.end())
            res = max(res, area(mx, my));
        }
        if (S.find(P(x + my, y - mx)) != S.end()) {
          if (S.find(P(x + my + mx, y - mx + my)) != S.end())
            res = max(res, area(mx, my));
        }

        /*
          if(M[x+my][y+mx]){
          if(M[x+my+mx][y+mx+my])
          res = max(res,area(mx,my));
          }
          if(M[x-my][y+mx]){
          if(M[x-my+mx][y+mx+my])
          res = max(res,area(mx,my));
          }
        */
      }
    }
    printf("%d\\n", res);
    S.clear();
  }
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
typedef pair<int, int> P;
#define X first
#define Y second
int N;
P p[3002];
map<P, int> M;
int area(int mx, int my) {
  int line = (int)sqrt(mx * mx + my * my);
  line *= 2;
  return line;
}
int main() {
  while (1) {
    scanf("%d", &N);
    if (!N)
      break;
    M.clear();
    for (int i = 0; i < N; i++) {
      scanf("%d %d", &p[i].X, &p[i].Y);
      M[p[i]] = 1;
    }
    int res = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i + 1; j < N; j++) {
        int x = p[i].X, y = p[i].Y;
        int mx = x - p[j].X;
        int my = y - p[j].Y;
        if (M[P(x + my, y + mx)]) {
          if (M[P(x + my + mx, y + mx + my)])
            res = max(res, area(mx, my));
        }
        if (M[P(x - my, y + mx)]) {
          if (M[P(x - my + mx, y + mx + my)])
            res = max(res, area(mx, my));
        }
      }
    }
    printf("%d\\n", res);
  }
}
Problem p00441 (C++) — buggy submission, verdict: Runtime Error

#include <cstring>
#include <iostream>

using namespace std;
bool map[5001][5001];

int main(void) {
  int a, b;
  int n;
  int ans = 0;
  int x[3000], y[3000];
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    ans = 0;
    memset(map, 0, sizeof(map));
    for (a = 0; a < n; a++) {
      int xx, yy;
      cin >> xx >> yy;
      x[a] = xx, y[a] = yy;
      map[x[a]][y[a]] = 1;
    }
    for (a = 0; a < n - 1; a++) {
      for (b = a + 1; b < n; b++) {
        int h = x[a] - x[b];
        int w = y[a] - y[b];
        if (x[a] - w >= 0 && x[a] - w <= 5000 && y[a] + h >= 0 &&
            y[a] + h <= 5000 && x[b] - w >= 0 && x[b] - w <= 5000 &&
            y[b] + h >= 0 && y[b] + h <= 5000)
          if (map[x[a] - w][y[a] + h] == 1 && map[x[b] - w][y[b] + h] == 1)
            ans = max(ans, h * h + w * w);
        if (x[a] + w >= 0 && x[a] + w <= 5000 && y[a] - h >= 0 &&
            y[a] - h <= 5000 && x[b] + w >= 0 && x[b] + w <= 5000 &&
            y[b] - h >= 0 && y[b] - h <= 5000)
          if (map[x[a] + w][y[a] - h] == 1 && map[x[b] + w][y[b] - h] == 1)
            ans = max(ans, h * h + w * w);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cstring>
#include <iostream>

using namespace std;

int main(void) {
  int a, b;
  int n;
  int ans = 0;
  bool map[1001][1001];
  int x[3000], y[3000];
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    ans = 0;
    memset(map, 0, sizeof(map));
    for (a = 0; a < n; a++) {
      int xx, yy;
      cin >> xx >> yy;
      x[a] = xx, y[a] = yy;
      map[xx][yy] = 1;
    }
    for (a = 0; a < n - 1; a++) {
      for (b = a; b < n; b++) {
        int h = x[a] - x[b];
        int w = y[a] - y[b];
        if (x[a] - w >= 0 && x[a] - w <= 5000 && y[a] + h >= 0 &&
            y[a] + h <= 5000 && x[b] - w >= 0 && x[b] - w <= 5000 &&
            y[b] + h >= 0 && y[b] + h <= 5000)
          if (map[x[a] - w][y[a] + h] == 1 && map[x[b] - w][y[b] + h] == 1)
            ans = max(ans, h * h + w * w);
        if (x[a] + w >= 0 && x[a] + w <= 5000 && y[a] - h >= 0 &&
            y[a] - h <= 5000 && x[b] + w >= 0 && x[b] + w <= 5000 &&
            y[b] - h >= 0 && y[b] - h <= 5000)
          if (map[x[a] + w][y[a] - h] == 1 && map[x[b] + w][y[b] - h] == 1)
            ans = max(ans, h * h + w * w);
      }
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00441 (C++) — buggy submission, verdict: Memory Limit Exceeded

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

pair<int, int> p[3004];
bool a[MAX][MAX];

bool s(int n) {
  if (0 <= n && n <= 5000)
    return 1;
  return 0;
}

int main() {
  int n, t1, t2;
  while (cin >> n, n) {
    fill((int *)a, (int *)(a + MAX), 0);
    for (int i = 0; i < n; i++) {
      cin >> t1 >> t2;
      p[i].first = t1;
      p[i].second = t2;
      a[t2][t1] = 1;
    }

    int ans = 0;
    int p1[4][2], f1, f2;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        f1 = f2 = 0;
        t1 = p[i].first - p[j].first;
        t2 = p[i].second - p[j].second;
        if (!t1 && !t2)
          continue;
        int x1 = p[i].first - t2, y1 = p[i].second + t1, x2 = p[j].first - t2,
            y2 = p[j].second + t1;
        int x3 = p[i].first - t2, y3 = p[i].second + t1, x4 = p[j].first + t2,
            y4 = p[j].second - t1;
        if (s(x1) && s(y1) && a[y1][x1] && s(x2) && s(y2) && a[y2][x2])
          ans = max(ans, t1 * t1 + t2 * t2);
        if (s(y3) && s(x3) && a[y3][x3] && s(y4) && s(x4) && a[y4][x4])
          ans = max(ans, t1 * t1 + t2 * t2);
      }
    }
    // cout << endl;
    // for(int i = 0;i < 4;i++)cout << (i>>1&1) << " " << (i&1) << endl;
    cout << ans << endl;
  }
  return 0;
}

Error: MLE

Fixed submission:

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

pair<int, int> p[3004];
int a[MAX][MAX];

int s(int n) {
  if (0 <= n && n <= 5000)
    return 1;
  return 0;
}

int main() {
  int n, t1, t2;
  while (cin >> n, n) {
    fill((int *)a, (int *)(a + MAX), 0);
    for (int i = 0; i < n; i++) {
      cin >> t1 >> t2;
      p[i].first = t1;
      p[i].second = t2;
      a[t2][t1] = 1;
    }

    int ans = 0;
    int p1[4][2], f1, f2;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        f1 = f2 = 0;
        t1 = p[i].first - p[j].first;
        t2 = p[i].second - p[j].second;
        if (!t1 && !t2)
          continue;
        int x1 = p[i].first - t2, y1 = p[i].second + t1, x2 = p[j].first - t2,
            y2 = p[j].second + t1;
        int x3 = p[i].first - t2, y3 = p[i].second + t1, x4 = p[j].first + t2,
            y4 = p[j].second - t1;
        if (s(x1) && s(y1) && a[y1][x1] && s(x2) && s(y2) && a[y2][x2])
          ans = max(ans, t1 * t1 + t2 * t2);
        if (s(y3) && s(x3) && a[y3][x3] && s(y4) && s(x4) && a[y4][x4])
          ans = max(ans, t1 * t1 + t2 * t2);
      }
    }
    // cout << endl;
    // for(int i = 0;i < 4;i++)cout << (i>>1&1) << " " << (i&1) << endl;
    cout << ans << endl;
  }
  return 0;
}
Problem p00441 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int x[5001], y[5001], an = 0;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i], p[x[i]][y[i]] = 1;
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++) {
        int dx = x[i] - x[j];
        int dy = y[i] - y[j];
        int x1 = x[i] - dy;
        int x2 = x[j] - dy;
        int y1 = y[i] + dx;
        int y2 = y[j] + dx;
        int x3 = x[i] - dy, y3 = y[i] + dx, x4 = x[j] + dy, y4 = y[j] - dx;
        if (c(x1) && c(y1) && p[x1][y1] && c(x2) && c(y2) && p[x2][y2])
          an = max(an, dx * dx + dy * dy);
        if (c(x3) && c(y3) && p[x3][y3] && c(x4) && c(y4) && p[x4][y4])
          an = max(an, dx * dx + dy * dy);
      }
    cout << an << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int x[5001], y[5001], an = 0;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i], p[x[i]][y[i]] = 1;
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++) {
        int dx = x[i] - x[j];
        int dy = y[i] - y[j];
        int x1 = x[i] - dy;
        int x2 = x[j] - dy;
        int y1 = y[i] + dx;
        int y2 = y[j] + dx;
        int x3 = x[i] - dy, y3 = y[i] + dx, x4 = x[j] + dy, y4 = y[j] - dx;
        if (c(x1) && c(y1) && p[x1][y1] && c(x2) && c(y2) && p[x2][y2])
          an = max(an, dx * dx + dy * dy);
        if (p[x3][y3] && p[x4][y4] && c(x3) && c(y3) && c(x4) && c(y4))
          an = max(an, dx * dx + dy * dy);
      }
    cout << an << endl;
  }
  return 0;
}
Problem p00441 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int x[5000], y[5001], an = 0;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i], p[x[i]][y[i]] = 1;
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++) {
        int dx = x[i] - x[j];
        int dy = y[i] - y[j];
        int x1 = x[i] - dy;
        int x2 = x[j] - dy;
        int y1 = y[i] + dx;
        int y2 = y[j] + dx;
        int x3 = x[i] - dy, y3 = y[i] + dx, x4 = x[j] + dy, y4 = y[j] - dx;
        if (c(x1) && c(y1) && p[x1][y1] && c(x2) && c(y2) && p[x2][y2])
          an = max(an, dx * dx + dy * dy);
        if (c(x3) && c(y3) && p[x3][y3] && c(x4) && c(y4) && p[x4][y4])
          an = max(an, dx * dx + dy * dy);
      }
    cout << an << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int x[5001], y[5001], an = 0;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i], p[x[i]][y[i]] = 1;
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++) {
        int dx = x[i] - x[j];
        int dy = y[i] - y[j];
        int x1 = x[i] - dy;
        int x2 = x[j] - dy;
        int y1 = y[i] + dx;
        int y2 = y[j] + dx;
        int x3 = x[i] - dy, y3 = y[i] + dx, x4 = x[j] + dy, y4 = y[j] - dx;
        if (p[x1][y1] && p[x2][y2] && c(x1) && c(y1) && c(x2) && c(y2))
          an = max(an, dx * dx + dy * dy);
        if (p[x3][y3] && p[x4][y4] && c(x3) && c(y3) && c(x4) && c(y4))
          an = max(an, dx * dx + dy * dy);
      }
    cout << an << endl;
  }
  return 0;
}
Problem p00441 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int x[5000], y[5001], an = 0;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i], p[x[i]][y[i]] = 1;
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++) {
        int dx = x[i] - x[j];
        int dy = y[i] - y[j];
        int x1 = x[i] - dy;
        int x2 = x[j] - dy;
        int y1 = y[i] + dx;
        int y2 = y[j] + dx;
        int x3 = x[i] - dy, y3 = y[i] + dx, x4 = x[j] + dy, y4 = y[j] - dx;
        if (c(x1) && c(y1) && p[x1][y1] && c(x2) && c(y2) && p[x2][y2])
          an = max(an, dx * dx + dy * dy);
        if (c(x3) && c(y3) && p[x3][y3] && c(x4) && c(y4) && p[x4][y4])
          an = max(an, dx * dx + dy * dy);
      }
    cout << an << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;
int n;
bool exi[5001][5001];
bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int x[5001], y[5001], an = 0;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i], exi[x[i]][y[i]] = 1;
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++) {
        int dx = x[i] - y[j];
        int dy = x[i] - y[j];
        int x1 = x[i] - dy;
        int x2 = x[j] - dy;
        int y1 = y[i] + dx;
        int y2 = y[j] + dx;
        int x3 = x[i] - dy, y3 = y[i] + dx, x4 = x[j] + dy, y4 = y[j] - dx;
        if (exi[x1][y1] && exi[x2][y2] && c(x1) && c(y1) && c(x2) && c(y2))
          an = max(an, dx * dx + dy * dy);
        if (exi[x3][y3] && exi[x4][y4] && c(x3) && c(y3) && c(x4) && c(y4))
          an = max(an, dx * dx + dy * dy);
      }
    cout << an << endl;
  }
  return 0;
}
Problem p00441 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int x[5000], y[5001], an = 0;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i], p[x[i]][y[i]] = 1;
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++) {
        int dx = x[i] - x[j], dy = y[i] - y[j];
        int x1 = x[i] - dy, y1 = y[i] + dx, x2 = x[j] - dy, y2 = y[j] + dx;
        int x3 = x[i] - dy, y3 = y[i] + dx, x4 = x[j] + dy, y4 = y[j] - dx;
        if (c(x1) && c(y1) && p[x1][y1] && c(x2) && c(y2) && p[x2][y2])
          an = max(an, dx * dx + dy * dy);
        if (c(x3) && c(y3) && p[x3][y3] && c(x4) && c(y4) && p[x4][y4])
          an = max(an, dx * dx + dy * dy);
      }
    cout << an << endl;
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
using namespace std;

int n;
bool exi[5005][5005];

bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int X[5005], Y[5005];
    int au = 0;
    for (int i = 0; i < n; i++) {
      cin >> X[i] >> Y[i];
      exi[X[i]][Y[i]] = true;
    }
    for (int i = 0; i < n; i++) {
      for (int j = i; j < n; j++) {
        int dx = X[i] - X[j];
        int dy = Y[i] - Y[j];
        int x1 = X[i] - dy;
        int x2 = X[j] - dy;
        int y1 = Y[i] + dx;
        int y2 = Y[j] + dx;
        int x3 = X[i] - dy, y3 = Y[i] + dx, x4 = X[j] + dy, y4 = Y[j] - dx;
        if (exi[x1][y1] && exi[x2][y2] && c(x1) && c(y1) && c(x2) && c(y2))
          au = max(au, dx * dx + dy * dy);
        if (exi[x3][y3] && exi[x4][y4] && c(x3) && c(y3) && c(x4) && c(y4))
          au = max(au, dx * dx + dy * dy);
      }
    }
    cout << au << endl;
  }
  return 0;
}
Problem p00441 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int x[5000], y[5001], an = 0;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i], p[x[i]][y[i]] = 1;
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++) {
        int dx = x[i] - x[j], dy = y[i] - y[j];
        int x1 = x[i] - dy, y1 = y[i] + dx, x2 = x[j] - dy, y2 = y[j] + dx;
        int x3 = x[i] - dy, y3 = y[i] + dx, x4 = x[j] + dy, y4 = y[j] - dx;
        if (c(x1) && c(y1) && p[x1][y1] && c(x2) && c(y2) && p[x2][y2])
          an = max(an, dx * dx + dy * dy);
        if (c(x3) && c(y3) && p[x3][y3] && c(x4) && c(y4) && p[x4][y4])
          an = max(an, dx * dx + dy * dy);
      }
    cout << an << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
using namespace std;

int X[5001], Y[5001];
bool exi[5001][5001];

bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 1; i <= n; i++) {
      cin >> X[i] >> Y[i];
      exi[X[i]][Y[i]] = true;
    }
    //  bool sik=false;
    // priority_queue<int> PQ;
    int au = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i; j <= n; j++) {
        int dx = X[j] - X[i];
        int dy = Y[j] - Y[i];
        int x1 = X[i] + dy;
        int x2 = X[j] - dy;
        int y1 = Y[i] - dx;
        int y2 = Y[j] + dx;
        if (exi[X[i] + dy][Y[i] - dx] && exi[X[j] + dy][Y[j] - dx] && c(x1) &&
            c(y1)) {
          /*PQ.push(dx*dx + dy*dy);
          sik = true;*/
          au = max(au, dx * dx + dy * dy);
        }
        if (exi[X[i] - dy][Y[i] + dx] && exi[X[j] - dy][Y[j] + dx] && c(x2) &&
            c(y2)) {
          /*PQ.push(dx*dx + dy*dy);
          sik = true;*/
          au = max(au, dx * dx + dy * dy);
        }
      }
    }
    /*if(sik) cout << PQ.top() << endl;
    else cout << 0 << endl;*/
    cout << au << endl;
  }
  return 0;
}
Problem p00441 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int n;
bool p[5001][5001];
bool c(int a) { return 0 <= a && a <= 5000; }
int main() {
  while (cin >> n && n) {
    int x[5000], y[5001], an = 0;
    for (int i = 0; i < n; i++)
      cin >> x[i] >> y[i], p[x[i]][y[i]] = 1;
    for (int i = 0; i < n; i++)
      for (int j = i; j < n; j++) {
        int dx = x[i] - x[j], dy = y[i] - y[j];
        int x1 = x[i] - dy, y1 = y[i] + dx, x2 = x[j] - dy, y2 = y[j] + dx;
        int x3 = x[i] - dy, y3 = y[i] + dx, x4 = x[j] + dy, y4 = y[j] - dx;
        if (c(x1) && c(y1) && p[x1][y1] && c(x2) && c(y2) && p[x2][y2])
          an = max(an, dx * dx + dy * dy);
        if (c(x3) && c(y3) && p[x3][y3] && c(x4) && c(y4) && p[x4][y4])
          an = max(an, dx * dx + dy * dy);
      }
    cout << an << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <queue>
using namespace std;

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    int X[1001], Y[1001];
    bool exi[1001][1001];
    for (int i = 1; i <= n; i++) {
      cin >> X[i] >> Y[i];
      exi[X[i]][Y[i]] = true;
    }
    bool sik = false;
    priority_queue<int> PQ;
    for (int i = 1; i < n; i++) {
      for (int j = 2; j <= n; j++) {
        int dx = X[j] - X[i];
        int dy = Y[j] - Y[i];
        if (exi[X[i] + dy][Y[i] - dx] == true &&
            exi[X[j] + dy][Y[j] - dx] == true) {
          PQ.push(dx * dx + dy * dy);
          sik = true;
        }
        if (exi[X[i] - dy][Y[i] + dx] == true &&
            exi[X[j] - dy][Y[j] + dx] == true) {
          PQ.push(dx * dx + dy * dy);
          sik = true;
        }
      }
    }
    if (sik)
      cout << PQ.top() << endl;
    else
      cout << 0 << endl;
  }
  return 0;
}