For this Question: Given a string S.
Let string A be it's longest palindromic suffix and string B be the longest palindromic prefix of string S.
String C = A + B 
Print the string C.The first line and the only line of the input contains a string S.

Constraints
1<=|S|<=100000Print the required answer.Sample Input 
aabb

Sample Output
bbaa

Explanation
longest prefix -> aa longest suffix ->bb

Sample Input 
aaaa

Sample Output
aaaaaaaa, I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pu push_back
#define ll long long 
#define fi first
#define se second
#define sz 4000000
string text,pat;
int lcs[sz];
int mcs[sz];
int sum=0;
int Z[sz];
void Zarr(string s)

{	

	int n=s.size();
	
		
		if(n>0)Z[0]=0;
	int L=0,R=0;
	for(int i=1;i<n;i++)
	{
		if(R<i)
		{
			
			L=i;R=i;
			
			while(R<n && s[R-L]==s[R])
			R++;
			
			Z[i]=R-L;
			R--;
		}else
		{
			
			
			if(Z[i-L]<R-i+1)
			{
				Z[i]=Z[i-L];
			}else
			
			{
				L=i;
				while(R<n && s[R-L]==s[R])
				R++;
				Z[i]=R-L;
				R--;
			}
		}
		
		
	}
}
void complcs(string pat)
{
	int m=pat.size();
	int i=1;
	int len=0;
	while(i<m)
	{
		if(pat[i]==pat[len])
		{
			len++;
			lcs[i]=len;
			i++;
		}else {
			
			if(len==0)
			{
				lcs[i]=0;
				i++;
			}else
			{
				len=lcs[len-1];
			}
		}
		
	}
}

void kmp(string text,string pat)
{
	int n=text.size();
	int m=pat.size();
	int i=0,j=0;
	
	while(i<n)
	{
		if(text[i]==pat[j])
		{
			j++;
			mcs[n-1-i]=j;
			i++;
		}else
		{
			if(j==0)
			{
				mcs[n-1-i]=j;
				i++;
			}else
			{
				j=lcs[j-1];
			}
		}
	}
}
int dp[sz];
int kmp2(string s)
{
	int n=s.size();
	int i=1;
	int len=0;
	for(int i=0;i<=n;i++)
	{
		lcs[i]=0;
	}
	while(i<n)
	{
		if(s[i]==s[len])
		{  len++;
		lcs[i]=len;
			i++;
		}else
		{
			if(len==0)
			{
				lcs[i]=0;
			i++;	
			}else
			{
				cout<<i<<" "<<len<<" f "<<endl;
				dp[len]++;
				len=lcs[len-1];
				
			}
		}
	}
	dp[n]=1;
	for(int i=n;i>1;i--)
	{    dp[i]+=dp[i+1];
		dp[lcs[i-1]]+=dp[i];
	}
	
	//dp[n]=1;
	/*int sum=0;
	for(int i=n;i>0;i--)
	{   int pp=dp[i];
	if(i>1)	dp[i]+=dp[i+1]+sum;
	else dp[i]+=dp[i+1];
		sum+=pp;
	}*/
	
}
int print(string s)
{
	string p="";
	int n=s.size();
	for(int i=n-1;i>=0;i--)
	{
		p+=s[i];
	}
	for(int i=0;i<=n;i++)
	{
		lcs[i]=0;
		mcs[i]=0;
	}
	complcs(s);
	//cout<<"gg";
	kmp(p,s);
	//cout<<"check";
	int sum=1;
	for(int i=0;i<n;i++)
	{ // cout<<i<<" "<<mcs[i]<<endl;
		if(mcs[i]==i)
		{
		 sum=max(sum,i*2);	
		}else if(mcs[i]>i)
		{
			sum=max(sum,i*2+1);	
		}
	}
	return sum;
}
int main()
{
	
	string s;
	cin>>s;
	string p="";
	int n=s.size();
	for(int i=n-1;i>=0;i--)
	{
		p+=s[i];
	}
	int nn=print(s);
	int mm=print(p);
//	cout<<nn<<"   "<<mm<<endl;
	string ss=p.substr(0,mm);
	ss=ss+s.substr(0,nn);
	int nm=ss.size();
	for(int i=0;i<=nm;i++)
	{
		lcs[i]=0;
	}
	cout<<ss<<endl;
	Zarr(ss);
	int an=ss.size();
	for(int i=0;i<an;i++)
	{  //cout<<Z[i]<<" ";
		dp[Z[i]]++;
	}
	dp[an]++;
	for(int i=an-1;i>=0;i--)
	{
		dp[i]+=dp[i+1];
	}
	
	
	
	
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?