Problem:
Score : 200 points

Problem Statement

We will call a string that can be obtained by concatenating two equal strings an even string.
For example, xyzxyz and aaaaaa are even, while ababab and xyzxy are not.

You are given an even string S consisting of lowercase English letters.
Find the length of the longest even string that can be obtained by deleting one or more characters from the end of S.
It is guaranteed that such a non-empty string exists for a given input.

Constraints

2 \leq |S| \leq 200

S is an even string consisting of lowercase English letters.

There exists a non-empty even string that can be obtained by deleting one or more characters from the end of S.

Input

Input is given from Standard Input in the following format:

S

Output

Print the length of the longest even string that can be obtained.

Sample Input 1

abaababaab

Sample Output 1

6

abaababaab itself is even, but we need to delete at least one character.

abaababaa is not even.

abaababa is not even.

abaabab is not even.

abaaba is even. Thus, we should print its length, 6.

Sample Input 2

xxxx

Sample Output 2

2

xxx is not even.

xx is even.

Sample Input 3

abcabcabcabc

Sample Output 3

6

The longest even string that can be obtained is abcabc, whose length is 6.

Sample Input 4

akasakaakasakasakaakas

Sample Output 4

14

The longest even string that can be obtained is akasakaakasaka, whose length is 14.

Solution in C++14 (GCC 5.4.1) (judge verdict: Accepted)


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

#define FOR(i,f,t) for(int i=(int)f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=(int)f; i>(int)t; i--)
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define pb push_back
#define SYNC ios_base::sync_with_stdio(false)
#define inf 100248012
#define mp make_pair
#define F first
#define S second
#define ri(x) scanf("%d",&x)
#define rii(x,y) scanf("%d %d",&x,&y)
#define riii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define lri(x) scanf("%lld",&x)
#define lrii(x,y) scanf("%lld %lld",&x,&y)
#define lriii(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)


typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> ii;
double X0;
double Y0;
const int MAXN = 5e3+3;

struct Point{
  double x;
  double y;
  Point(double a = 0, double b = 0){
    x = a,y = b;
  }
  bool operator==(const Point p)const {
    return p.x == x && p.y == y;
  }
  bool operator<(const Point &p) const{
    return y<p.y || (y == p.y && x<p.x);
  }
  bool operator<=(const Point &p) const{
    return y<p.y || (y == p.y && x<=p.x);
  }
  Point operator+( Point p){
    return Point(x+p.x,y+p.y);
  }
  Point operator-( Point p){
    return Point(x-p.x,y-p.y);
  }
  Point operator*( double a){
	  return Point(a*x,a*y);
  }
  double operator*( Point p){
    return x*p.x + y*p.y;
  }
  double operator^( Point p){
    return x*p.y - y*p.x;
  }
  double norma2(){
    return x*x + y*y;
  }
  double norma(){
    return sqrt(this->norma2());
  }
};
struct Recta{
	Point P;
	Point V;
	Recta(Point p=Point(0,0),Point q=Point(0,0)){
		P=p;
		V=q;
		}
	Point operator *(Recta M){
		if(((M.V)^V) == 0){
			return Point(inf,inf);
			}
		else{
			double alpha;
			alpha=((M.P-P)^M.V)/(V^M.V);
			return P+V*alpha;
			}
		}
	};
struct Segmento{
	Point P;
	Point V;
	Segmento(Point p=Point(0,0),Point q=Point(0,0)){
		P=p;
		V=q;
		}
	Point operator *(Recta M){
		if(((M.V)^V) == 0){
			return Point(inf,inf);
			}
		else{
			double alpha;
			alpha=((M.P-P)^M.V)/(V^M.V);
			if((alpha<=1)&&(alpha>=0))
			{return P+V*alpha;}
			else
			{return Point(inf,inf);}
			}
		}
	};




int main(){
	string S;
	cin >> S;
	int n=S.length();
	int iseven=0,i,j;
	if(n%2==0){i=n-2;}
	else{i=n-1;}
	while(iseven==0){
		iseven=1;
		for(j=0;j<i/2;j++){
			if(S[j]!=S[j+(i/2)]){iseven=0;j=i/2;}
			}
		i=i-2;
		}
	i=i+2;
		printf("%d",i);
	printf("\n");
	return 0;
	}