#C13107. Longest Palindromic Substring

    ID: 42609 Type: Default 1000ms 256MiB

Longest Palindromic Substring

Longest Palindromic Substring

Given a string \( s \), find the longest palindromic substring contained in \( s \). A palindrome is a string that reads the same backward as forward. If there are multiple palindromic substrings of maximum length, return the one that appears first in the string.

Example:

  • Input: "babad"
  • Output: "bab"
  • Note: "aba" is also a valid answer, but since the problem requires the first occurrence, the answer is "bab".

You are expected to read the input from standard input and print the result to standard output.

inputFormat

The input consists of a single line containing the string \( s \) (with length at least 1 and up to a reasonable limit).

outputFormat

Output the longest palindromic substring of \( s \) on a single line.

## sample
a
a