#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)(x).size()
using namespace std;
const double pi = acos(-1);
const int mod = 1e9 + 7;
const int N = 1e3 + 5, M = 1e2 + 2, K = 5e2 + 5;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
void fast()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr), cout.tie(nullptr);
}
int id = 0;
string s, ans;
int dp[N][N], vis[N][N];
int lcs(int i, int j)
{
if (i > j)
return 0;
if (i == j)
return 1;
int &ret = dp[i][j];
if (vis[i][j] == id)
return ret;
if (s[i] == s[j])
return ret = 2 + lcs(i + 1, j - 1);
ret = 0, vis[i][j] = id;
ret = max(ret, lcs(i, j - 1));
ret = max(ret, lcs(i + 1, j));
return ret;
}
void build(int i, int j)
{
if (i > j)
return;
if (i == j)
{
ans += s[i];
return;
}
if (s[i] == s[j])
{
ans += s[i];
build(i + 1, j - 1);
return;
}
if (lcs(i, j - 1) >= lcs(i + 1, j))
build(i, j - 1);
else
build(i + 1, j);
}
int32_t main()
{
fast();
while (cin >> s)
{
id++;
ans = "";
int x = lcs(0, s.size() - 1);
build(0, s.size() - 1);
string temp = ans;
reverse(all(temp));
if (x % 2 == 1)
ans.pop_back();
cout << ans << temp << "\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIGFsbCh4KSB4LmJlZ2luKCksIHguZW5kKCkKI2RlZmluZSByYWxsKHgpIHgucmJlZ2luKCksIHgucmVuZCgpCiNkZWZpbmUgc3ooeCkgKGludCkoeCkuc2l6ZSgpCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBkb3VibGUgcGkgPSBhY29zKC0xKTsKY29uc3QgaW50IG1vZCA9IDFlOSArIDc7CmNvbnN0IGludCBOID0gMWUzICsgNSwgTSA9IDFlMiArIDIsIEsgPSA1ZTIgKyA1OwoKaW50IGR4W10gPSB7MCwgMCwgMSwgLTEsIDEsIDEsIC0xLCAtMX07CmludCBkeVtdID0gezEsIC0xLCAwLCAwLCAxLCAtMSwgMSwgLTF9OwoKdm9pZCBmYXN0KCkKewojaWZuZGVmIE9OTElORV9KVURHRQogICAgZnJlb3BlbigiaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CiAgICBmcmVvcGVuKCJvdXRwdXQudHh0IiwgInciLCBzdGRvdXQpOwojZW5kaWYKICAgIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsKICAgIGNpbi50aWUobnVsbHB0ciksIGNvdXQudGllKG51bGxwdHIpOwp9CgppbnQgaWQgPSAwOwpzdHJpbmcgcywgYW5zOwppbnQgZHBbTl1bTl0sIHZpc1tOXVtOXTsKCmludCBsY3MoaW50IGksIGludCBqKQp7CiAgICBpZiAoaSA+IGopCiAgICAgICAgcmV0dXJuIDA7CgogICAgaWYgKGkgPT0gaikKICAgICAgICByZXR1cm4gMTsKCiAgICBpbnQgJnJldCA9IGRwW2ldW2pdOwoKICAgIGlmICh2aXNbaV1bal0gPT0gaWQpCiAgICAgICAgcmV0dXJuIHJldDsKCiAgICBpZiAoc1tpXSA9PSBzW2pdKQogICAgICAgIHJldHVybiByZXQgPSAyICsgbGNzKGkgKyAxLCBqIC0gMSk7CgogICAgcmV0ID0gMCwgdmlzW2ldW2pdID0gaWQ7CiAgICByZXQgPSBtYXgocmV0LCBsY3MoaSwgaiAtIDEpKTsKICAgIHJldCA9IG1heChyZXQsIGxjcyhpICsgMSwgaikpOwogICAgcmV0dXJuIHJldDsKfQoKdm9pZCBidWlsZChpbnQgaSwgaW50IGopCnsKICAgIGlmIChpID4gaikKICAgICAgICByZXR1cm47CgogICAgaWYgKGkgPT0gaikKICAgIHsKICAgICAgICBhbnMgKz0gc1tpXTsKICAgICAgICByZXR1cm47CiAgICB9CiAgICBpZiAoc1tpXSA9PSBzW2pdKQogICAgewogICAgICAgIGFucyArPSBzW2ldOwogICAgICAgIGJ1aWxkKGkgKyAxLCBqIC0gMSk7CiAgICAgICAgcmV0dXJuOwogICAgfQoKICAgIGlmIChsY3MoaSwgaiAtIDEpID49IGxjcyhpICsgMSwgaikpCiAgICAgICAgYnVpbGQoaSwgaiAtIDEpOwogICAgZWxzZQogICAgICAgIGJ1aWxkKGkgKyAxLCBqKTsKfQoKaW50MzJfdCBtYWluKCkKewogICAgZmFzdCgpOwoKICAgIHdoaWxlIChjaW4gPj4gcykKICAgIHsKICAgICAgICBpZCsrOwogICAgICAgIGFucyA9ICIiOwogICAgICAgIGludCB4ID0gbGNzKDAsIHMuc2l6ZSgpIC0gMSk7CiAgICAgICAgYnVpbGQoMCwgcy5zaXplKCkgLSAxKTsKCiAgICAgICAgc3RyaW5nIHRlbXAgPSBhbnM7CiAgICAgICAgcmV2ZXJzZShhbGwodGVtcCkpOwoKICAgICAgICBpZiAoeCAlIDIgPT0gMSkKICAgICAgICAgICAgYW5zLnBvcF9iYWNrKCk7CgogICAgICAgIGNvdXQgPDwgYW5zIDw8IHRlbXAgPDwgIlxuIjsKICAgIH0KCiAgICByZXR1cm4gMDsKfQ==