# https://www.codechef.com/problems/PALIN

https://www.codechef.com/problems/PALIN

this is my code.actually i found after my solution that it can take 10^6 digits.For this i don’t know how to proceed.plz some1 solve this for me by modifying my code so that i can grab what’s going wrong with me.plz.

#include<bits/stdc++.h>
using namespace std;

string mid(string &x,int y)
{
int a=y/2;
if(y%2!=0)
while(a>0)
{
if(x[a]==9)
{
x[a]=0;

``````    }

else
{
x[a]+=1;
return(x);
}

a--;

}

else
while(a>0)
{
if(x[a]==9)
{
if(x[a]>x[a-1])
{
x[a]=0;
x[a-1]=0;

}

else if(x[a]==x[a-1])
{
x[a]=0;
x[a-1]=0;
}

else
{
x[a]=x[a-1];
}
}

else
{
if(x[a]>x[a-1])
{

x[a-1]+=1;

}

else if(x[a]==x[a-1])
{

x[a-1]+=1;
}

else
{
x[a]=x[a-1];
}
return(x);
}

a--;

}
``````

}

void change(string &x,int y)
{
int a=y/2-1;

``````while(a>=0)
{

x[y-1-a]=x[a];
a--;

}
cout<<x<<endl;
``````

}
int main()
{
int t;
cin>>t;
while(t–)
{
long long int n;
cin>>n;
n=n+1;

``````    ostringstream str1;

str1<<n;

string s;
s=str1.str();

int len;
len=s.length();
int flag=0;

if(n<=11)
cout<<"11"<<endl;
else

{
for(int i=len/2-1;i>=0;i--)
{
if(s[i]<s[len-1-i])
{
flag=1;
break;
}
else if(s[i]>s[len-1-i])
{
flag=2;
}

}

if(flag==0)
{
cout<<s<<endl;

}

else if(flag==2)
{
change(s,len);

}

else if(flag==1)
{

s=mid(s,len);
change(s,len);

}

}
``````

}

``````return 0;
``````

}