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

#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

bool prime[(1 << 15) + 50];
// bool used[(1<<15) + 50][(1<<15) + 50];

void mp(void) {
  fill(prime, prime + (1 << 15) + 50, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i < (1 << 15) + 50; i++) {
    if (prime[i]) {
      for (int j = i * 2; j < (1 << 15) + 50; j += i) {
        prime[j] = false;
      }
    }
  }

  return;
}

int main(void) {
  int n;

  mp();
  while (cin >> n, n) {
    // memset(used, false, sizeof(used));
    int ret = 0;

    for (int i = 0; i <= n / 2; i++) {
      if (prime[i] && prime[n - i]) {
        // cout << i << " " << n - i << endl;
        // if (!used[i][n - i]){
        ret++;
        // }
      }
    }
    cout << ret << endl;
  }

  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

bool prime[(1 << 15) + 50];
bool used[(1 << 15) + 50][(1 << 15) + 50];

void mp(void) {
  fill(prime, prime + (1 << 15) + 50, true);
  prime[0] = prime[1] = false;
  for (int i = 2; i < (1 << 15) + 50; i++) {
    if (prime[i]) {
      for (int j = i * 2; j < (1 << 15) + 50; j += i) {
        prime[j] = false;
      }
    }
  }

  return;
}

int main(void) {
  int n;

  mp();
  while (cin >> n, n) {
    memset(used, false, sizeof(used));
    int ret = 0;

    for (int i = 0; i <= n; i++) {
      if (prime[i] && prime[n - i]) {
        // cout << i << " " << n - i << endl;
        if (!used[i][n - i]) {
          ret++;
          used[i][n - i] = true;
          used[n - i][i] = true;
        }
      }
    }
    cout << ret << endl;
  }

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

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define f first
#define s second
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, c)                                                              \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

template <int m> class Prime {
  std::vector<bool> p;
  std::vector<int> ps;

public:
  Prime() {
    p = std::vector<bool>(m, true);
    assert(m > 1);
    p[0] = p[1] = false;
    for (int i = 4; i < m; i += 2)
      p[i] = false;
    ps.push_back(2);
    for (int i = 3; i < m; i += 2) {
      if (p[i]) {
        ps.push_back(i);
        for (int j = i + i; j < m; j += i)
          p[j] = false;
      }
    }
  }

  bool isPrime(int n) {
    assert(m > n);
    return p[n];
  }

  int operator[](int n) {
    if (n < ps.size())
      return ps[n];
    else
      return 0;
  }

  int size() { return ps.size(); }
};

int main() {
  Prime<(1 << 15) + 100> p;
  int n;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; p[i] + p[i] <= n; i++) {
      if (p.isPrime(n - p[i]))
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define f first
#define s second
#define mp make_pair

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, c)                                                              \\
  for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

template <int m> class Prime {
  std::vector<bool> p;
  std::vector<int> ps;

public:
  Prime() {
    p = std::vector<bool>(m, true);
    assert(m > 1);
    p[0] = p[1] = false;
    for (int i = 4; i < m; i += 2)
      p[i] = false;
    ps.push_back(2);
    for (int i = 3; i < m; i += 2) {
      if (p[i]) {
        ps.push_back(i);
        for (int j = i + i; j < m; j += i)
          p[j] = false;
      }
    }
  }

  bool isPrime(int n) {
    assert(m > n);
    return p[n];
  }

  int operator[](int n) {
    if (n < ps.size())
      return ps[n];
    else
      return 0;
  }

  int size() { return ps.size(); }
};

int main() {
  Prime<(1 << 14) + 100> p;
  int n;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; p[i] + p[i] <= n; i++) {
      if (p.isPrime(n - p[i]))
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}
Problem p00780 (C++) — buggy submission, verdict: Runtime Error

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

const int MAX = 10000001;
char p[MAX];
vector<char> P;

void f() {
  for (int i = 2; i < MAX; i++)
    p[i] = 1;
  for (int i = 2; i + i < MAX; i++) {
    if (p[i]) {
      for (int j = i + i; j < MAX; j += i) {
        p[j] = 0;
      }
    }
  }
  for (int i = 2; i < MAX; i++) {
    if (p[i])
      P.push_back(i);
  }
}

int main() {
  int n;
  f();
  while (cin >> n, n) {
    int ans = 0;
    for (int a = 2; a < n; a++) {
      if (p[a]) {
        int b = n - a;
        if (a > b)
          break;
        if (p[b])
          ans++;
      }
    }
    cout << ans << endl;
  }
}

Error: 0

Fixed submission:

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

const int MAX = 1000001;
char p[MAX];
vector<char> P;

void f() {
  for (int i = 2; i < MAX; i++)
    p[i] = 1;
  for (int i = 2; i + i < MAX; i++) {
    if (p[i]) {
      for (int j = i + i; j < MAX; j += i) {
        p[j] = 0;
      }
    }
  }
  for (int i = 2; i < MAX; i++) {
    if (p[i])
      P.push_back(i);
  }
}

int main() {
  int n;
  f();
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 0; P[i] < n; i++) {
      int a = P[i];
      int b = n - a;
      if (a > b)
        break;
      if (p[b])
        ans++;
    }
    cout << ans << endl;
  }
}
Problem p00780 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(t, i, c) for (t::iterator i = (c).begin(); i != (c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
  bool prime[1 << 14 + 1] = {0};
  FOR(i, 0, 1 << 14 + 1) { prime[i] = true; }
  prime[0] = false;
  prime[1] = false;
  for (int i = 0; i * i < 1 << 14 + 1; i++) {
    if (prime[i]) {
      for (int j = i + i; j < 1 << 14 + 1; j += i) {
        prime[j] = false;
      }
    }
  }

  int n;
  while (cin >> n, n) {
    int cnt = 0;
    FOR(i, 2, n / 2 + 1) {
      if (prime[i] && prime[n - i]) {
        ++cnt;
      }
    }
    cout << cnt << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(t, i, c) for (t::iterator i = (c).begin(); i != (c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
  bool prime[1 << 14] = {0};
  FOR(i, 0, 1 << 14) { prime[i] = true; }
  prime[0] = false;
  prime[1] = false;
  for (int i = 0; i * i < 1 << 14; i++) {
    if (prime[i]) {
      for (int j = i + i; j < 1 << 14; j += i) {
        prime[j] = false;
      }
    }
  }

  int n;
  while (cin >> n, n) {
    int cnt = 0;
    FOR(i, 2, n / 2 + 1) {
      if (prime[i] && prime[n - i]) {
        ++cnt;
      }
    }
    cout << cnt << endl;
  }
}
Problem p00780 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
bool b[33000];
int main() {
  fill(b, b + 33000, true);
  b[0] = false;
  b[1] = false;
  for (int i = 2; i < 33000; i++) {
    if (b[i]) {
      int j = 2;
      while (i * j < 33000) {
        b[i * j] = false;
        j++;
      }
    }
  }
  int n;
  while (cin >> n && n != 0) {
    int sum = 0;
    for (int i = 0; i <= n / 2; i++) {
      if (b[i] && b[n - i]) {
        sum++;
      }
    }
    cout << sum << endl;
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
bool b[33000];
int main() {
  fill(b, b + 33000, true);
  b[0] = false;
  b[1] = false;
  for (int i = 2; i < 33000; i++) {
    if (b[i]) {
      int j = 2;
      while (i * j < 33000) {
        b[i * j] = false;
      }
    }
  }
  int n;
  while (cin >> n && n != 0) {
    int sum = 0;
    for (int i = 0; i < n / 2; i++) {
      if (b[i] && b[n - i]) {
        sum++;
      }
    }
    cout << sum << endl;
  }
}
Problem p00780 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i, n) for (i = 0; i < n; i++)
#define loop(i, a, n) for (i = a; i < n; i++)
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)

typedef vector<int> vi;
typedef pair<int, int> pii;

int main(void) {
  int i, j;
  int n;
  vector<bool> prime(40000, true);

  for (i = 2; i < 40000; i++)
    if (prime[i])
      for (j = 2; i * j < 40000; j++)
        prime[i * j] = false;

  vi ans(40000, 0);

  for (i = 2; i < 40000; i++)
    if (prime[i])
      for (j = i; j < 40000; j++)
        if (prime[j] && i + j < 40000)
          ans[i + j]++;

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    cout << ans[n] << endl;
  }
}

Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i, n) for (i = 0; i < n; i++)
#define loop(i, a, n) for (i = a; i < n; i++)
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)

typedef vector<int> vi;
typedef pair<int, int> pii;

int main(void) {
  int i, j;
  int n;
  vector<bool> prime(40000, true);

  for (i = 2; i < 4000; i++)
    if (prime[i])
      for (j = 2; i * j < 4000; j++)
        prime[i * j] = false;

  vi ans(4000, 0);

  for (i = 2; i < 4000; i++)
    if (prime[i])
      for (j = i; j < 4000; j++)
        if (prime[j] && i + j < 4000)
          ans[i + j]++;

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    cout << ans[n] << endl;
  }
}
Problem p00780 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
bool primes[1000000];

void Sieve() {
  for (int i = 2; i < 1000000; i++) {
    primes[i] = true;
  }
  primes[1] = false;

  for (int i = 2; i <= 1000; i++) {
    if (primes[i] == true)
      for (int j = i; j * i <= 1000000; j++) {
        primes[j * i] = false;
      }
  }
}

bool IsPrime(int x) { return primes[x]; }

int main(void) {
  int k;
  for (k = 1; k > 0; k++) {
    Sieve();
    int n, c = 0;
    cin >> n;
    if (n == 0)
      break;
    else {
      for (int i = 0; i <= n / 2; i++) {
        if (IsPrime(i) == true) {
          if (IsPrime(n - i) == true)
            c++;
        }
      }
      cout << c << endl;
    }
  }

  return 0;
}


Error: -11

Fixed submission:

#include <iostream>
using namespace std;
bool primes[100000];

void Sieve() {
  for (int i = 2; i < 1000000; i++) {
    primes[i] = true;
  }
  primes[1] = false;

  for (int i = 2; i <= 1000; i++) {
    if (primes[i] == true)
      for (int j = i; j * i <= 1000000; j++) {
        primes[j * i] = false;
      }
  }
}

bool IsPrime(int x) { return primes[x]; }

int main(void) {
  int k;
  for (k = 1; k > 0; k++) {
    Sieve();
    int n, c = 0;
    cin >> n;
    if (n == 0)
      break;
    else {
      for (int i = 0; i <= n / 2; i++) {
        if (IsPrime(i) == true) {
          if (IsPrime(n - i) == true)
            c++;
        }
      }
      cout << c << endl;
    }
  }

  return 0;
}
Problem p00781 (C++) — buggy submission, verdict: Time Limit Exceeded

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

string data[10];

void revstr(string &str, string *target) {
  *target = "";

  for (int i = 1; i <= str.length(); i++) {
    *target += str[str.length() - i];
  }
}

string str[10];
bool flag[10];
int cnt;

bool isFix(int level) {
  for (int j = 0; j < 5; j++) {
    if (str[level][j] == str[j][level - 5])
      return false;
  }
  return true;
}

void rec(int level) {
  if (level == 0) {
    for (int i = 0; i < 10; i++)
      flag[i] = false;
  }
  if (level == 10) {
    cnt++;
    return;
  }

  for (int i = 0; i < 10; i++) {
    if (!flag[i]) {
      flag[i] = true;
      str[level] = data[i];
      if (level < 5) {
        rec(level + 1);
      } else if (level >= 5 && isFix(level)) {
        rec(level + 1);
        flag[i] = false;
        return;
      }
      revstr(data[i], &str[level]);
      if (str[level] != data[i]) {
        if (level < 5) {
          rec(level + 1);
        } else if (level >= 5 && isFix(level)) {
          rec(level + 1);
          flag[i] = false;
          return;
        }
      }
      flag[i] = false;
    }
  }
}

int main() {
  while (1) {
    for (int i = 0; i < 10; i++) {
      cin >> data[i];
      if (data[i] == "END")
        return 0;
    }
    cnt = 0;
    rec(0);
    cout << cnt / 8 << endl;
  }
}

Error: TLE

Fixed submission:

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

string data[10];
string sp[5];
int cnt;

string strrev(string *str) {
  string s = "";
  for (int i = 0; i < str->length(); i++) {
    s += (*str)[str->length() - 1 - i];
  }
  return s;
}

void rec(int flag, int step) {
  if (step == 10) {
    cnt++;
  } else if (step >= 5) {
    for (int i = 0; i < 10; i++) {
      if ((flag & (1 << i)) == 0) {
        for (int t = 0; t < 2; t++) {
          string tmp;
          if (t == 0)
            tmp = data[i];
          else
            tmp = strrev(&data[i]);

          for (int j = 0; j < 5; j++) {
            if (tmp[j] == sp[j][step - 5])
              break;
            if (j + 1 == 5)
              rec(flag | (1 << i), step + 1);
          }
        }
      }
    }
  } else {
    for (int i = 0; i < 10; i++) {
      if ((flag & (1 << i)) == 0) {
        sp[step] = data[i];
        rec(flag | (1 << i), step + 1);
        sp[step] = strrev(&data[i]);
        rec(flag | (1 << i), step + 1);
      }
    }
  }
}

void solve() {
  cnt = 0;
  rec(0, 0);
  cout << cnt / 64 << endl;
}

int main() {
  while (1) {
    cin >> data[0];
    if (data[0] == "END")
      break;

    for (int i = 1; i < 10; i++) {
      cin >> data[i];
    }

    solve();
  }
}
Problem p00782 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
double unit = 0.001;
typedef complex<double> P;
#define rep(i, n) for (int i = 0; i < n; i++)

bool cmp(const pair<P, P> &a, const pair<P, P> &b) {
  return a.first.imag() < b.first.imag();
}
int main() {
  int n, N = 0;
  while (cin >> n, n) {
    vector<pair<P, P>> data;
    double ans = 0;
    rep(i, n) {
      double a, b, r;
      cin >> a >> b >> r;
      data.push_back(make_pair(P(a - r, b - r), P(a + r, b + r)));
    }
    sort(data.begin(), data.end(), cmp);
    for (double x = -200; x <= 400; x += unit) {
      vector<pair<double, double>> L;
      rep(i, n) {
        if (data[i].first.real() <= x && x <= data[i].second.real()) {
          L.push_back(make_pair(data[i].first.imag(), data[i].second.imag()));
        }
      }
      if (L.size() == 0)
        continue;
      double sz = 0;
      double cs = L[0].first, ce = L[0].second;
      for (int i = 1; i < L.size(); i++) {
        if (L[i].first <= ce)
          ce = max(ce, L[i].second);
        else
          sz += ce - cs, cs = L[i].first, ce = L[i].second;
      }
      sz += ce - cs;
      ans += sz * unit;
    }
    printf("%d %.2lf\\n", ++N, ans);
  }
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <complex>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
double unit = 1.0 / (1 << 15);
typedef complex<double> P;
#define rep(i, n) for (int i = 0; i < n; i++)

bool cmp(const pair<P, P> &a, const pair<P, P> &b) {
  return a.first.imag() < b.first.imag();
}
int main() {
  int n, N = 0;
  while (cin >> n, n) {
    vector<pair<P, P>> data;
    double ans = 0;
    rep(i, n) {
      double a, b, r;
      cin >> a >> b >> r;
      data.push_back(make_pair(P(a - r, b - r), P(a + r, b + r)));
    }
    sort(data.begin(), data.end(), cmp);
    for (double x = -200; x <= 200; x += unit) {
      vector<pair<double, double>> L;
      rep(i, n) {
        if (data[i].first.real() <= x && x <= data[i].second.real()) {
          L.push_back(make_pair(data[i].first.imag(), data[i].second.imag()));
        }
      }
      if (L.size() == 0)
        continue;
      double sz = 0;
      double cs = L[0].first, ce = L[0].second;
      for (int i = 1; i < L.size(); i++) {
        if (L[i].first <= ce)
          ce = max(ce, L[i].second);
        else
          sz += ce - cs, cs = L[i].first, ce = L[i].second;
      }
      sz += ce - cs;
      ans += sz * unit;
    }
    printf("%d %.2lf\\n", ++N, ans);
  }
}
Problem p00783 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string prepare(string a) {
  string res;
  for (int i = 0; i < a.size(); i++) {
    if ('a' <= a[i] && a[i] <= 'z')
      res += a[i] - 32;
    if ('A' <= a[i] && a[i] <= 'Z')
      res += a[i];
  }
  return res;
}

bool pal(string a) {
  int l = a.size();
  for (int i = 0; i < l / 2; i++) {
    if (a[i] != a[l - 1 - i])
      return false;
  }
  return true;
}

string x, tmp;

int main() {
  while (getline(cin, x)) {
    x = prepare(x);
    vector<string> v;
    for (int i = 0; i < x.size(); i++) {
      for (int j = 3; j + i <= x.size(); j++) {
        tmp = x.substr(i, j);
        if (pal(tmp))
          v.push_back(tmp);
      }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    for (int i = 0; i < v.size(); i++) {
      for (int j = 0; j < v.size(); j++) {
        if (i != j) {
          if (v[i].size() <= v[j].size() + 1)
            continue;
          int a = v[i].size();
          a -= v[j].size();
          if (a & 1)
            continue;
          a >>= 1;
          if (v[j] == v[i].substr(a, v[j].size())) {
            v.erase(v.begin() + j);
            if (j < i)
              i--;
            j--;
          }
        }
      }
    }

    for (int i = 0; i < v.size(); i++) {
      cout << v[i] << ((i + 1 == v.size()) ? "\\n" : " ");
    }
    if (v.empty())
      cout << endl;
  }
}

Error: WA

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string prepare(string a) {
  string res;
  for (int i = 0; i < a.size(); i++) {
    if ('a' <= a[i] && a[i] <= 'z')
      res += a[i] - 32;
    if ('A' <= a[i] && a[i] <= 'Z')
      res += a[i];
  }
  return res;
}

bool pal(string a) {
  int l = a.size();
  for (int i = 0; i < l / 2; i++) {
    if (a[i] != a[l - 1 - i])
      return false;
  }
  return true;
}

string x, tmp;

int main() {
  while (getline(cin, x)) {
    x = prepare(x);
    vector<string> v;
    for (int i = 0; i < x.size(); i++) {
      for (int j = 3; j + i <= x.size(); j++) {
        tmp = x.substr(i, j);
        if (pal(tmp))
          v.push_back(tmp);
      }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());

    for (int i = 0; i < v.size(); i++) {
      for (int j = 0; j < v.size(); j++) {
        if (i != j) {
          if (v[i].size() <= v[j].size() + 1)
            continue;
          int a = v[i].size();
          a -= v[j].size();
          if (a & 1)
            continue;
          a >>= 1;
          if (v[j] == v[i].substr(a, v[j].size())) {
            v.erase(v.begin() + j);
            if (i < j)
              i--;
            j--;
          }
        }
      }
    }

    for (int i = 0; i < v.size(); i++) {
      cout << v[i] << ((i + 1 == v.size()) ? "\\n" : " ");
    }
  }
}