#K9846. Find the Middle Character(s)

    ID: 39120 Type: Default 1000ms 256MiB

Find the Middle Character(s)

Find the Middle Character(s)

You are given a string s. Your task is to find the middle character(s) of the given string. If the length of s is odd, output the middle character. If the length is even, output the two middle characters.

For example, if s = "testing" (length 7, odd), the middle character is 't', and if s = "middle" (length 6, even), the middle two characters are 'dd'.

Please note: The input is provided via standard input (stdin) and the result should be output to standard output (stdout).

Matrix formulation:

Let \( n = |s| \) be the length of the string. Define the middle index \( m = \lfloor n/2 \rfloor \).

  • If \( n \) is odd, output \( s[m] \).
  • If \( n \) is even, output \( s[m-1]s[m] \).

inputFormat

The input consists of a single line that contains the string s. The string will only contain printable characters without any additional spaces.

outputFormat

Output the middle character(s) of the string s according to the rules defined.

## sample
testing
t