Problem:
Problem D:
Napoleon's Grumble
Legend has it that, after being defeated in Waterloo, Napoleon Bonaparte, in retrospect of his days of glory, talked to himself "Able was I ere I saw Elba." Although, it is quite doubtful that he should have said this in English, this phrase is widely known as a typical
palindrome
.
A palindrome is a symmetric character sequence that looks the same when read backwards, right to left. In the above Napoleon's grumble, white spaces appear at the same positions when read backwards. This is not a required condition for a palindrome. The following, ignoring spaces and punctuation marks, are known as the first conversation and the first palindromes by human beings.
"Madam, I'm Adam."
"Eve."
(by Mark Twain)
Write a program that finds palindromes in input lines.
Input
A multi-line text is given as the input. The input ends at the end of the file.
There are at most 100 lines in the input. Each line has less than 1,024 Roman alphabet characters.
Output
Corresponding to each input line, a line consisting of
all
the character sequences that are palindromes in the input line should be output. However, trivial palindromes consisting of only one or two characters should not be reported.
On finding palindromes, any characters in the input except Roman alphabets, such as punctuation characters, digits, space, and tabs, should be ignored. Characters that differ only in their cases should be looked upon as the same character. Whether or not the character sequences represent a proper English word or sentence does not matter.
Palindromes should be reported all in uppercase characters. When two or more palindromes are reported, they should be separated by a space character. You may report palindromes in any order.
If two or more occurrences of the same palindromes are found in the same input line, report only once. When a palindrome overlaps with another, even when one is completely included in the other, both should be reported. However, palindromes appearing in the center of another palindrome, whether or not they also appear elsewhere, should not be reported. For example, for an input line of "AAAAAA", two palindromes "AAAAAA" and "AAAAA" should be output, but not "AAAA" nor "AAA". For "AABCAAAAAA", the output remains the same.
One line should be output corresponding to one input line. If an input line does not contain any palindromes, an empty line should be output.
Sample Input
As the first man said to the
first woman:
"Madam, I'm Adam."
She responded:
"Eve."
Output for the Sample Input
TOT

MADAMIMADAM MADAM
ERE DED
EVE
Note that the second line in the output is empty, corresponding to the second input line containing no palindromes. Also note that some of the palindromes in the third input line, namely "ADA", "MIM", "AMIMA", "DAMIMAD", and "ADAMIMADA", are not reported because they appear at the center of reported ones. "MADAM"
is
reported, as it does not appear in the center, but only once, disregarding its second occurrence.

Submitted solutions:

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	while(getline(cin,s)){
		string t="";
		set<string>out,no;
		rep(i,s.size())if(isalpha(s[i]))t+=toupper(s[i]);
		rep(i,t.size())loop(j,3,t.size()+1)if(i+j<=t.size()){
			string a=t.substr(i,j),b=a;
			reverse(all(b));
			if(a==b){
				out.insert(a);
				no.insert(t.substr(i+1,j-2));
			}
		}
		vector<string>ans;
		for(set<string>::iterator it=out.begin();it!=out.end();it++)
			if(no.find(*it)==no.end())
				ans.pb(*it);
		reverse(all(ans));
		rep(i,ans.size()){
			if(i)cout<<" ";
			cout<<ans[i];
		}
		cout<<endl;
	}
}
accuracy: 1
time_ms: 20
memory_kb: 1260
final_rank: 6

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	string s;
	while(getline(cin,s)){
		string t="";
		set<string>out,no;
		rep(i,s.size())if(isalpha(s[i]))t+=toupper(s[i]);
		rep(i,t.size())loop(j,3,t.size()+1)if(i+j<=t.size()){
			string a=t.substr(i,j),b=a;
			reverse(all(b));
			if(a==b){
				out.insert(a);
				no.insert(t.substr(i+1,j-2));
			}
		}
		vector<string>ans;
		for(set<string>::iterator it=out.begin();it!=out.end();it++)
			if(no.find(*it)==no.end())
				ans.pb(*it);
		rep(i,ans.size()){
			if(i)cout<<" ";
			cout<<ans[i];
		}
		cout<<endl;
	}
}
accuracy: 1
time_ms: 20
memory_kb: 1256
final_rank: 5

code_snippet: #include <bits/stdc++.h>
 
using namespace std;
 
string s;
typedef pair<int,string> P;
 
bool is_palindrome(const string &str){
    int size = str.size();
    for(int i = 0 ; i < size/2 ; i++){
	if(str[i] != str[size-i-1]) return false;
    }
    return true;
}
 
bool check(string a,string b){
    int alen = a.size(),blen = b.size();
    if(alen % 2 && blen % 2 == 0) return true;
    if(alen % 2 == 0 && blen % 2) return true;
    if(alen == blen) return true;
    if(alen > blen) swap(a,b),swap(alen,blen);
    int p = 0;
    while(true){
	if(p*2+alen == blen) break;
	p++;
    }
    for(int i = p ; i < p+alen ; i++){
	if(a[i-p] != b[i]) return true;
    }
    return false;
}
 
int main(){
    string in;
    while(getline(cin,in)){
	int size;
	set<P> st;
	set<string> ans;
	s.clear();
     
	for(int i = 0 ; i < (int)in.size() ; i++){
	    if(isalpha(in[i])){
		s += toupper(in[i]);
	    }
	}
	size = s.size();
	for(int i = 0 ; i < size ; i++){
	    for(int j = size ; j > i ; j--){
		string str = s.substr(i,j-i);
		if(is_palindrome(str) && j-i >= 3){
		    st.insert(P(str.size(),str));
		}
	    }
	}
	bool ok[1145] = {false};
	int ii,jj;
	set<P>::iterator i,j;
	for(ii = 0,i = st.begin() ; i != st.end() ; ++i,++ii){
	    for(jj = 0,j = st.begin() ; j != st.end() ; ++j,++jj){
		if(i == j) continue;
		if(!check(i->second,j->second)){
		    if(i->first > j->first){
			ok[jj] = true;
		    }else{
			ok[ii] = true;
		    }
		}
	    }
	}
	for(ii = 0,i = st.begin() ; i != st.end() ; ++i,++ii){
	    if(ok[ii]) continue;
	    ans.insert(i->second);
	}
	bool flg = false;
	set<string>::iterator k;
	for(k = ans.begin() ; k != ans.end() ; ++k){
	    if(flg) cout << " ";
	    flg = true;
	    cout << *k;
	}
	cout << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3212
final_rank: 7

code_snippet: #include <iostream>
#include <vector>
#include <string>
#include <set>
#include <queue>

using namespace std;

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

void solve()
{
	string temp;
	while (getline(cin, temp))
	{
		string str;
		for (int i = 0; i < temp.size(); ++i)
		{
			if ('a' <= temp[i] && temp[i] <= 'z')
			{
				str += temp[i] - 'a' + 'A';
			}
			if ('A' <= temp[i] && temp[i] <= 'Z')
			{
				str += temp[i];
			}
		}
		int n = str.size();
		vector<string> palindrome;
		set<string> bad;
		deque< deque<bool> > flag(n, deque<bool>(n));
		for (int i = n; i >= 3; --i)
		{
			for (int j = 0; j <= n - i; ++j)
			{
				if (flag[j][j + i - 1])
				{
					continue;
				}
				string sub;
				for (int k = j; k < j + i; ++k)
				{
					sub += str[k];
				}
				if (isPalindrome(sub) && bad.find(sub) == bad.end())
				{
					palindrome.push_back(sub);
					for (int k = 0; k < i / 2; ++k)
					{
						flag[j + k][j + i - k - 1] = true;
						string tmp;
						for (int l = k; l < i - k; ++l)
						{
							tmp += sub[l];
						}
						bad.insert(tmp);
					}
				}
			}
		}
		bool isFirst = true;
		for (int i = 0; i < palindrome.size(); ++i)
		{
			if (!isFirst)
			{
				cout << " ";
			}
			cout << palindrome[i];
			isFirst = false;
		}
		cout << endl;
	}
}

int main()
{
	solve();
	return(0);
}
accuracy: 1
time_ms: 50
memory_kb: 1324
final_rank: 14

code_snippet: #include<bits/stdc++.h>
using namespace std;
string buf;

bool check( string &s){
  int st = 0, ed = s.size()-1;
  while( st<ed && s[st] == s[ed] ){ st++; ed--;}
  return  st >= ed;
}

int main(){
  while( getline(cin,buf) ){
    string s;
    for(int i=0;i<(int)buf.size();i++){
      if( 'a' <= buf[i] && buf[i] <= 'z' ) s += (buf[i]+'A'-'a');
      else if( 'A' <= buf[i] && buf[i] <= 'Z' ) s+= buf[i];
    }

    vector<string> ans;
    for(int i=1;i<(int)s.size();i++){
      int range = min( i, (int)s.size() - i - 1 );
      for(int j=range;j>0;j--){
	string r = s.substr(i-j,2*j+1);
	//	cout << r << endl;
	if( check(r) ) {
	  ans.push_back(r);
	  break;
	}
      }
    }

    for(int i=0;i<(int)s.size();i++){
      int range = s.size()-i;
      if( range & 1 ) range--;
      for(int j=0;range-j*2>2;j++){
	string r = s.substr(i+j,range-2*j);
	//	cout << r << endl;
	if( check(r) ) {
	  ans.push_back(r);
	  break;
	}
      }
    }
    sort(ans.begin(),ans.end());
    ans.erase(unique(ans.begin(),ans.end()),ans.end());
    

    set<string> M;
    for(int i=0;i<(int)ans.size();i++){
      //cout << ans[i] << endl;
      //cout << M.count( ans[i] ) << endl;
      if( M.count(ans[i]) != 0 ) continue;
      int range = ans[i].size();
      //     cout << range << endl;
      for(int j=1;range-2*j>2;j++){
	//	cout << ans[i].substr(j,range-2*j) << endl;
	M.insert(ans[i].substr(j,range-2*j));
      }
    }
    vector<string> res;
    for(int i=0;i<(int)ans.size();i++){
      //cout << M.count(ans[i]) << endl;
      //cout << ans[i] << endl;
      if( M.count(ans[i]) == 0 )
	res.push_back(ans[i]);
    }


    for(int i=0;i<(int)res.size();i++){
      if( i ) cout << " ";
      cout << res[i];
    }
    cout << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 1224
final_rank: 3

code_snippet: #include <bits/stdc++.h>

using namespace std;

string s;
typedef pair<int,string> P;

bool is_palindrome(const string &str){
  int size = str.size();
  for(int i = 0 ; i < size/2 ; i++){
    if(str[i] != str[size-i-1]) return false;
  }
  return true;
}

bool check(string a,string b){
  int alen = a.size(),blen = b.size();
  if(alen % 2 && blen % 2 == 0) return true;
  if(alen % 2 == 0 && blen % 2) return true;
  if(alen == blen) return true;
  if(alen > blen) swap(a,b),swap(alen,blen);
  int p = 0;
  while(true){
    if(p*2+alen == blen) break;
    p++;
  }
  for(int i = p ; i < p+alen ; i++){
    if(a[i-p] != b[i]) return true;
  }
  return false;
}

int main(){
  string in;
  while(getline(cin,in)){
    int size;
    set<P> st;
    set<string> ans;
    s.clear();
    
    for(int i = 0 ; i < (int)in.size() ; i++){
      if(isalpha(in[i])){
        s += toupper(in[i]);
      }
    }
    size = s.size();
    for(int i = 0 ; i < size ; i++){
      for(int j = size ; j > i ; j--){
        string str = s.substr(i,j-i);
        if(is_palindrome(str) && j-i >= 3){
          st.insert(P(str.size(),str));
        }
      }
    }
    bool ok[1145] = {false};
    int ii,jj;
    set<P>::iterator i,j;
    for(ii = 0,i = st.begin() ; i != st.end() ; ++i,++ii){
      for(jj = 0,j = st.begin() ; j != st.end() ; ++j,++jj){
        if(i == j) continue;
        if(!check(i->second,j->second)){
          if(i->first > j->first){
            ok[jj] = true;
          }else{
            ok[ii] = true;
          }
        }
      }
    }
    for(ii = 0,i = st.begin() ; i != st.end() ; ++i,++ii){
      if(ok[ii]) continue;
      ans.insert(i->second);
    }
    bool flg = false;
    set<string>::iterator k;
    for(k = ans.begin() ; k != ans.end() ; ++k){
      if(flg) cout << " ";
      flg = true;
      cout << *k;
    }
    cout << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1228
final_rank: 4

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

int memo[1200][1200];

int center[1200];
int center2[1200][1200];

typedef pair<int, int> Pii;
map<int, Pii> mp1;
map<Pii, Pii> mp2;

int N;
string line;

bool is_palindrome(int L, int R) {
  if(L >= R) return 1;

  if(memo[L][R] != -1) {
    return memo[L][R];
  }
  
  int SIZE = R-L;
  
  if(line[L] == line[R-1]) {
    memo[L][R] = is_palindrome(L+1, R-1);

    if(memo[L][R] == 1) {
      if(R-L > 2) {
	if(SIZE % 2 == 0) {
	  int l = (L+R)/2, r = (L+R)/2+1;
	  if(center2[l][r] < R-L) {
	    mp2[Pii(l, r)] = Pii(L, R);
	    center2[l][r] = R-L;
	  }
	}
	else {
	  int m = (L+R)/2;
	  if(center[m] < R-L) {
	    mp1[m] = Pii(L, R);
	    center[m] = R-L;
	  }
	}
      }
      return 1;
    }
    else if(memo[L][R] == 0) return 0;
    else assert(false);
  }
  memo[L][R] = 0; return 0;
}

void kirei() {
  string ret;
  int const N = line.size();
  rep(i, N) {
    if(isalpha(line[i])) { ret += toupper(line[i]); }
  }
  line = ret;
}

bool cmp(string const& a, string const& b) {
  return a.size() < b.size();
}

vector<string> contains_remove(vector<string>& vec) {
  
  vector<bool> retbool(vec.size());
  vector<string> ret;
  sort(vec.begin(), vec.end(), cmp);
  
  rep(i, vec.size()) {
    int ISize = vec[i].size();
    REP(j, i+1, vec.size()) {
      int JSize = vec[j].size();
      if(ISize % 2 != JSize % 2) continue;
      if(ISize % 2 == 0) {
	if(vec[i] == string(vec[j].begin()+(JSize/2-ISize/2), vec[j].begin()+(JSize/2+ISize/2))) {
	  retbool[i] = 1;
	}
      }
      else {
	if(vec[i] == string(vec[j].begin()+(JSize/2-ISize/2), vec[j].begin()+(JSize/2+ISize/2+1))) {
	  retbool[i] = 1;
	}
      }
    }
  }
  
  for(int i=0; i<(int)vec.size(); i++) {
    if(!retbool[i]) {
      ret.push_back(vec[i]);
    }
  }
  
  return ret;
}


int main() {
  
  while(getline(cin, line)) {
    rep(i, 1200) {
      rep(j, 1200) {
	memo[i][j] = -1;
	center2[i][j] = -1;
      }
      center[i] = -1;
    }
    mp1.clear(), mp2.clear();
    
    kirei();
    N = line.size();
    
    rep(i, N) REP(j, i+1, N+1) {
      memo[i][j] = is_palindrome(i, j);
    }
    
    vector<string> vec;
    {
      map<int, Pii>::iterator it = mp1.begin();
      for(; it!=mp1.end(); it++) {
	int L = it->second.first;
	int R = it->second.second;
	vec.push_back(string(line.begin()+L, line.begin()+R));
      }
    }
    {
      map<Pii, Pii>::iterator it = mp2.begin();
      for(; it!=mp2.end(); it++) {
	int L = it->second.first;
	int R = it->second.second;
	vec.push_back(string(line.begin()+L, line.begin()+R));
      }
    }
    
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    vec = contains_remove(vec);

    for(int i=0; i<(int)vec.size(); i++) {
      if(i) cout << " ";
      cout << vec[i];
    }
    cout << endl;
  }
  
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 12476
final_rank: 16

code_snippet: #include <algorithm>
#include <set>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

typedef long long Long;
#define whole(xs) xs.begin(), xs.end()

string L;
bool input() {
    string _;
    getline(cin, _);
    if (cin.eof()) return false;
    L.clear();
    for (int i = 0; i < _.size(); i++) {
        if (isalpha(_[i])) {
            L.push_back(toupper(_[i]));
        }
    }
    return true;
}

#define ML 1024
int dp[ML][ML];

bool isPalindrome(int from, int to) {
    if (dp[from][to] >= 0) return dp[from][to];
    if (from >= to) return 1;
    if (L[from] == L[to]) {
        return dp[from][to] = isPalindrome(from + 1, to - 1);
    }
    return dp[from][to] = 0;
}

set<string> Ans;
set<string> Dup;

void AddDup(int from, int to) {
    if (to - from <= 1) return;
    Dup.insert(L.substr(from, to - from + 1));
    AddDup(from + 1, to - 1);
}

bool used[ML][ML];
void dfs(int from, int to) {
    if (to - from <= 1) return;
    if (used[from][to]) return;
    //cerr << "(" << from << ", " << to << ")" << endl;
    string X = L.substr(from, to - from + 1);
    if (isPalindrome(from, to) && !Dup.count(X)) {
        //cerr << from << " " << to << endl;
        Ans.insert(X);
        AddDup(from + 1, to - 1);
    }
    dfs(from + 1, to);
    dfs(from, to - 1);
    used[from][to] = true;
}

void solve() {
    Ans.clear();
    Dup.clear();
    memset(dp, -1, sizeof(dp));
    memset(used, 0, sizeof(used));
    dfs(0, int(L.size()) - 1);
    if (Ans.empty()) {
        cout << endl;
        return;
    }
    set<string> RealAns;
    set<string>::iterator it = Ans.begin();
    for (; it != Ans.end(); it++) {
        if (!Dup.count(*it)) RealAns.insert(*it);
    }
    it = RealAns.begin();
    cout << *it;
    for (it++; it != RealAns.end(); it++) {
        cout << " " << *it;
    }
    cout << endl;
}

int main() {
    while (input()) solve();
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 6424
final_rank: 13

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
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;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 1216
final_rank: 2

code_snippet: #include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
//C++11
#if __cplusplus == 201103L
#include <tuple>
#endif

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  for(string s; getline(cin, s);){
    string t;
    REP(i, s.size())if(isalpha(s[i])) t += toupper(s[i]);
    vector<string> candy;
    REP(i, t.size()){
      for(int l = 3; i + l - 1 < t.size(); l++){
        string sub = t.substr(i, l);
        string rev = sub;
        reverse(rev.begin(), rev.end());
        if(sub == rev) candy.push_back(sub);
      }
    }
    sort(candy.begin(), candy.end());
    candy.erase(unique(candy.begin(), candy.end()), candy.end());
    REP(i, candy.size()){
      bool ok = true;
      REP(j, candy.size()){
        if(candy[i] == candy[j].substr(1, candy[j].size() - 2)){
          ok = false;
        }
      }
      if(ok) cout<<candy[i]<<" ";
    }
    cout<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 940
final_rank: 10

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <cstring>

using namespace std;

bool used[2000];
bool check(string s){
    for(int i = 0; i < s.size()/2; i++){
        if(s[i]==s[s.size()-1-i])
            continue;
        else
            return false;
    }
    return true;
}

int main(){

    string str;
    while(getline(cin,str)){

        memset(used,0,sizeof(used));
        string s;
        for(int i = 0; i < str.size(); i++){
            if((str[i]>='a'&&str[i]<='z')||(str[i]>='A'&&str[i]<='Z')){
                s+=toupper(str[i]);
            }
        }
        set<string> ss;
        for(int i = s.size(); i >= 3; i--){
            for(int j = 0; j + i -1 < s.size(); j++){
                if(check(s.substr(j,i))){
                    ss.insert(s.substr(j,i));
                }
            }
        }
        vector<string> tmps=vector<string>(ss.begin(),ss.end());
        for(int i = 0; i < tmps.size(); i++){
            for(int j = i+1; j < tmps.size(); j++){
                if(tmps[i].size()<tmps[j].size()){
                    int diff=tmps[j].size()-tmps[i].size();
                    diff/=2;
                    if(tmps[j].substr(diff,tmps[i].size())==tmps[i]){
                        used[i]=true;
                    }
                }
                else{
                    int diff=tmps[i].size()-tmps[j].size();
                    diff/=2;
                    if(tmps[i].substr(diff,tmps[j].size())==tmps[j]){
                        used[j]=true;
                    }
                }
            }
        }
        ss.clear();
        for(int i = 0; i < tmps.size(); i++){
            if(!used[i])
                ss.insert(tmps[i]);
        }
        for(set<string>::iterator it=ss.begin();it!=ss.end();it++){
            cout<<*it;
            set<string>::iterator iit=it;
            iit++;
            if(iit==ss.end()){
                cout<<endl;
            }
            else
                cout<<" ";
        }
        if(ss.size()==0)cout<<endl;
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1

code_snippet: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <set>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
using namespace std;

#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()
const int INF = 1<<29;

int main() {
  string line;
  while(getline(cin,line)) {
    string str;
    FOR(it,line)
      if (isalpha(*it))
        str += toupper(*it);
    set<string> res;
    set<string> ignore;
    for (int len = str.size(); len >= 3; --len) {
      for (int pos = 0; pos < str.size()-len+1; ++pos) {
        string s = str.substr(pos, len);
        if (ignore.count(s)) continue;
        string t = s;
        reverse(ALL(t));
        if (s == t) {
          res.insert(s);
          for (int i=0; i<(len-1)/2; ++i) {
            ignore.insert(s.substr(i, len-i*2));
          }
        }
      }
    }
    bool f = 0;
    FOR (it, res) {
      if (f) cout << " ";
      else f = 1;
      cout << *it;
    }
    cout << endl;
  }
}
accuracy: 1
time_ms: 40
memory_kb: 0
final_rank: 12

code_snippet: #include<set>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  string s;
  while(getline(cin,s)){
    int ln=s.length();
    for(i=0;i<ln;i++){
      if(0){
      }else if(s[i]>='a'&&s[i]<='z'){
	s[i]+='A'-'a';
      }else if(s[i]>='A'&&s[i]<='Z'){
      }else{
	s.erase(i,1);
	i--;
	ln--;
      }
    }
    set<string,greater<string> > a;
    set<string> b;
    for(i=ln;i>2;i--){
      for(j=0;j<ln-i+1;j++){
	if(b.find(s.substr(j,i))==b.end()){
	  for(k=0;k<i/2;k++){
	    if(s[j+k]!=s[j+i-1-k])
	      break;
	  }
	  if(k==i/2){
	    a.insert(s.substr(j,i));
	    for(k=1;i-k*2>1;k++)
	      b.insert(s.substr(j+k,i-k*2));
	  }
	}
      }
    }
    if(a.empty()==0){
      set<string>::iterator it;
      cout<<*a.begin();
      for(it=a.begin(),it++;it!=a.end();it++)
	cout<<" "<<*it;
    }
    cout<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 932
final_rank: 9

code_snippet: #include<iostream>
#include<string>
#include<set>
#include<cctype>
#include<algorithm>
using namespace std;
typedef set<string>T;
int main()
{
	int i,j,len,x,c;
	string s,t,u,v;
	T S;
	T::iterator p,q;
	while(getline(cin,s))
	{
		for(c=i=0;i<s.size();)
			if(isalpha(s[i]))s[i]=toupper(s[i]),++i;
			else s.erase(i,1);
		len=s.size();
		for(x=0;x<2;++x)
		{
			S.clear();
			for(i=1;i<len-1-x;++i)
			{
				for(j=min(i,len-i-1-x);j>0;--j)
				{
					u=t=s.substr(i-j,2*j+1+x);
					reverse(u.begin(),u.end());
					if(t==u)
					{
						S.insert(t);
						break;
					}
				}
			}
			for(p=S.begin();p!=S.end();)
			{
				for(q=p,++q;q!=S.end();)
				{
					t=*p;
					u=*q;
					i=t.size();
					j=u.size();
					if(i<j)
					{v=u.substr((j+1)/2-(i+1)/2,i);
						if(v==t)
						{	S.erase(p++);
							goto E;
						}
					}
					else if(i>j)
					{
						v=t.substr((i+1)/2-(j+1)/2,j);
						if(v==u)
						{
							S.erase(q++);
							continue;
						}
					}
					++q;
				}
				++p;
E:;
			}
			for(p=S.begin();p!=S.end();++p)
			{
				if(c++)cout<<' ';
				cout<<*p;
			}
		}
		cout<<endl;
	}
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 912
final_rank: 8

code_snippet: #include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <set>
using namespace std;

string str;


bool isSymmetry(string &s) {
  string s2 = "";
  for(int i = s.length()-1; i >= 0; --i) {
    s2 += s[i];
  }
  return s2 == s;
}

void solve() {
  set<string> vis;

  for(int j = str.length(); j > 2; --j) {
    for(int i = 0; i+j <= str.length(); ++i) {
      string s = str.substr(i, j);
      if(isSymmetry(s) && vis.find(s) == vis.end()) {
	if(vis.size() != 0) cout << " ";
	vis.insert(s);
	cout << s;
	while(1) {
	  s = s.substr(1, s.length()-2);
	  vis.insert(s);
	  if(s.length() < 3) break;
	}
      }
    }
  }
  cout << endl;
}

main() {
  char c;
  str = "";
  while(scanf("%c", &c) != EOF) {
    if(c == '\n') {
      solve();
      str = "";
    } else if(!isalpha(c)) {
      continue;
    } else {
      str += toupper(c);
    }
  }
}
accuracy: 1
time_ms: 90
memory_kb: 960
final_rank: 15

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define pb         push_back


bool isinclude(string tar,vector<string>  a){
  rep(i,a.size()){
    string tmp = a[i].substr(1,(int)a[i].size()-2);
    if (tmp == tar)return true;
    /*
      if (search(tmp.begin(),tmp.end(),tar.begin(),tar.end()) != 
      tmp.end())return true;
    */
  }
  return false;
}


vector<string> makeans(vector<string> a){
  vector<string> ret; 
  rep(i,a.size()){
    if (!isinclude(a[i],a))ret.pb(a[i]);
  }
  return ret;
}

void solve(string in){
  vector<string> ver1,ans;
  rep(i,in.size()){
    string now="";
    REP(j,i,in.size()){
      now=now+in[j];
      if (now.size() > 2){
	string tmp=now;
	reverse(ALL(tmp));
	if (tmp == now)ver1.pb(now);
      }
    }
  }

  sort(ALL(ver1));
  ver1.erase(unique(ALL(ver1)),ver1.end());

  ans =makeans(ver1);
  sort(ALL(ans));
  rep(i,ans.size()){
    if (i)cout <<' ';
    cout << ans[i];
  }
  cout << endl;
}

main(){
  string in;
  while(getline(cin,in)){
    string tar="";
    rep(i,in.size()){
      if (isalpha(in[i]))tar+=toupper(in[i]);
    }
    solve(tar);
  }
}
accuracy: 1
time_ms: 30
memory_kb: 952
final_rank: 11