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 Kotlin (1.0.0) (judge verdict: Accepted)

import java.io.BufferedReader
import java.io.PrintWriter
import java.lang.StrictMath.*
import kotlin.comparisons.compareBy

var out: PrintWriter = PrintWriter(System.out)  // これを使って出力すると早い
fun main(args: Array<String>) {
    try {
        val s = ReadLib.readString()
        for (i in 1..s.length){
            val w = s.take(s.length - i)
            if(w.length % 2 > 0){
                continue
            }
            
            if(w.take(w.length / 2) == w.drop(w.length / 2)){
                out.println(w.length)
                return
            }
        }

    } finally {
        out.flush()   // 消さない
    }
}

/**
 * 読み取り
 */
class ReadLib {
    companion object {
        private var reader: BufferedReader = System.`in`.bufferedReader()

        fun reset() {
            reader = System.`in`.bufferedReader()
        }

        fun readInt(): Int {
            return Integer.parseInt(reader.readLine())
        }

        // Int
        fun readIntArray(delimiters: String = " "): IntArray {
            return reader
                .readLine()
                .split(delimiters)
                .map { s -> Integer.parseInt(s) }
                .toIntArray()
        }

        fun readNTimesInt(n: Int): IntArray {
            return (1..n).map { readInt() }.toIntArray()
        }

        fun readNTimesIntArray(n: Int): Array<IntArray> {
            return (1..n).map { readIntArray() }.toTypedArray()
        }

        // long
        // TODO 別の方法を考える
        fun readLong(): Long {
            return reader.readLine().toLong()
        }

        fun readLongArray(delimiters: String = " "): LongArray {
            return reader.readLine()
                .split(delimiters)
                .map { s -> s.toLong() }
                .toLongArray()
        }

        fun readNTimesLong(n: Int): LongArray {
            return (1..n).map { readLong() }.toLongArray()
        }

        fun readString(): String {
            return reader.readLine()
        }

        fun readStringArray(delimiters: String = " "): Array<String> {
            return readString().split(delimiters).toTypedArray()
        }

        fun readNTimesCharArray(n: Int): Array<CharArray> {
            return (1..n).map { readString().toCharArray() }.toTypedArray()
        }

        fun readNTimesString(n: Int): Array<String> {
            return (1..n).map { readString() }.toTypedArray()
        }

    }
}

/**
 * 要素とその個数を出力
 */
fun <T> Array<T>.ofCountMap(): Map<T, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

/**
 * 文字とその個数を出力
 */
fun String.ofCountMap(): Map<Char, Int> {
    return this.toCharArray().ofCountMap()
}

/**
 * 文字とその個数を出力
 */
fun CharArray.ofCountMap(): Map<Char, Int> {
    return this.groupBy { it }.mapValues { it.value.count() }
}

/**
 * Combination, nCk mod p を求める
 * https://ja.wikipedia.org/wiki/%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%A9%E9%80%86%E6%95%B0
 * http://drken1215.hatenablog.com/entry/2018/06/08/210000
 * @param maxN 最大のn
 * @param mod 素数p
 */
class ModCombination(private val maxN: Int, private val mod: Int = 1000000007) {
    private val fac: IntArray = IntArray(maxN)
    private val finv: IntArray = IntArray(maxN)

    init {
        val inv: IntArray = IntArray(maxN)
        fac[0] = 1
        fac[1] = 1

        inv[0] = 1
        inv[1] = 1
        for (i in 2..maxN) {
            fac[i] = fac[i - 1] * i % mod   // 累積
            // mod % i < i
            inv[i] = mod - ((inv[mod % i].toLong()) * (mod / i) % mod).toInt()
            finv[i] = finv[i - 1] * inv[i] % mod
        }
    }

    /**
     * nCk mod p
     */
    fun Calc(n: Int, k: Int): Int {
        if (n < k || n < 0 || k < 0) {
            return 0
        }

        return ((fac[n].toLong() * finv[k] % mod) * finv[n - k] % mod).toInt()
    }
}

class MyMath {
    companion object {
        // 最大公約数
        fun gcd(m: Long, n: Long): Long {
            var M = m
            var N = n
            while (M % N > 0) {
                val pN = N
                N = M % N
                M = pN
            }

            return N
        }

        // 素因数分解（試し割り）
        // http://sucrose.hatenablog.com/entry/2014/10/10/235805
        fun primeFactorization(n: Long): Map<Long, Long> {
            val primes = enumeratePrime(ceil(sqrt(n.toDouble())).toInt())
                .map { it.toLong() }
                .toLongArray()
            primes.sort()

            val counter = mutableMapOf<Long, Long>()
            var cn = n
            for (p in primes) {
                if (cn < p) {
                    break
                }

                while (cn % p == 0L) {
                    counter[p] = counter.getOrElse(p, { 0 }) + 1
                    cn /= p
                }
            }

            if (cn > 1) {
                counter[cn] = 1
            }

            return counter
        }

        // Nまでの素数列挙
        fun enumeratePrime(n: Int): IntArray {
            val isPrime = BooleanArray(n + 1) { true }
            val primes = mutableListOf<Int>()
            for (i in 2..n) {
                if (!isPrime[i]) {
                    continue
                }

                primes.add(i)
                for (j in i..n step i) {
                    isPrime[i] = false
                }
            }

            return primes.toIntArray()
        }
    }
}