← Home
```go
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	const maxCapacity = 60000
	buf := make([]byte, maxCapacity)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(buf, maxCapacity)

	if scanner.Scan() {
		s := scanner.Text()
		n := len(s)

		// Count character frequencies
		counts := make([]int, 26)
		for i := 0; i < n; i++ {
			counts[s[i]-'a']++
		}

		// If any character appears >= 100 times, print it 100 times
		for i := 0; i < 26; i++ {
			if counts[i] >= 100 {
				ans := make([]byte, 100)
				char := byte('a' + i)
				for k := 0; k < 100; k++ {
					ans[k] = char
				}
				fmt.Println(string(ans))
				return
			}
		}

		// If no character appears >= 100 times, then n < 2600.
		// We can solve using O(n^2) Dynamic Programming.
		dp := make([][]int16, n)
		for i := range dp {
			dp[i] = make([]int16, n)
		}

		// Fill DP table for Longest Palindromic Subsequence
		for length := 1; length <= n; length++ {
			for i := 0; i <= n-length; i++ {
				j := i + length - 1
				if s[i] == s[j] {
					if length == 1 {
						dp[i][j] = 1
					} else if length == 2 {
						dp[i][j] = 2
					} else {
						dp[i][j] = 2 + dp[i+1][j-1]
					}
				} else {
					v1 := dp[i+1][j]
					v2 := dp[i][j-1]
					if v1 > v2 {
						dp[i][j] = v1
					} else {
						dp[i][j] = v2
					}
				}
			}
		}

		// Reconstruct the palindrome
		lpsLen := int(dp[0][n-1])
		res := make([]byte, lpsLen)
		i, j := 0, n-1
		p, q := 0, lpsLen-1

		for p <= q {
			if s[i] == s[j] {
				res[p] = s[i]
				res[q] = s[i]
				p++
				q--
				i++
				j--
			} else {
				if dp[i+1][j] >= dp[i][j-1] {
					i++
				} else {
					j--
				}
			}
		}

		// If LPS length >= 100, print a palindrome of length exactly 100
		if lpsLen >= 100 {
			fmt.Print(string(res[:50]))
			fmt.Println(string(res[lpsLen-50:]))
		} else {
			// Otherwise print the longest palindrome found
			fmt.Println(string(res))
		}
	}
}
```