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 Rust (1.15.1) (judge verdict: Accepted)


#![allow(unused)]

use std::cmp;
use std::io::{self, BufRead};
use std::iter;

macro_rules! destruct_ {
  ($e: expr, ()) => (
    //assert!($e.next().is_none())
  );
  ($e: expr, ($arg: ident, $( $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args)*))
  );
  ($e: expr, ($arg: ident $( $args: ident )*)) => (
    $arg = $e.next().unwrap();
    destruct_!($e, ($($args)*))
  );
}

macro_rules! split {
  ($e: expr, ($($name: ident)*)) => {
    let mut iter = $e.into_iter();
    destruct_!(iter, ($($name)*));
  }
}

macro_rules! gets {
  ($id: ident) => (
    let stdin = io::stdin();
    $id = Vec::new();
    for line in stdin.lock().lines() {
      $id.push(
        line
          .unwrap()
          .split_whitespace()
          .map(|a| a.parse().unwrap())
          .collect()
      );
    }
  )
}

macro_rules! get {
  ($id: ident) => (
    let stdin = io::stdin();
    $id = Vec::new();
    for line in stdin.lock().lines() {
      $id.push(
        line
          .unwrap()
          .parse().unwrap()
      );
    }
  )
}

macro_rules! p {
  ($a: expr) => (
    println!("{}", $a);
  )
}

macro_rules! pp {
  ($a: expr) => (
    println!("{:?}", $a);
  )
}

fn main() {
  let mut args: Vec<String>;
  let mut s;
  get!(args);
  split!(args, (s));

  for i in (1 .. s.len() - 1).rev() {
    let (s1, _) = s.split_at(i);
    let l = s1.len() / 2;
    let (ss1, ss2) = s1.split_at(l);
    if ss1 == ss2 {
      p!(i);
      return;
    }
  }
}