#C14140. Most Frequent Character

    ID: 43757 Type: Default 1000ms 256MiB

Most Frequent Character

Most Frequent Character

Problem Statement: Given a string s, determine the character that appears most frequently in the string. In the case where multiple characters share the highest frequency, return the lexicographically smallest one. If the input string is empty, output an empty string.

Input Format: The input consists of a single line containing the string s.

Output Format: Output a single character that is the most frequent in the string, or an empty string if no characters are provided.

Note: All comparisons among characters are based on their ASCII values, and ties are broken by choosing the smallest character in lexicographical order.

The frequency condition can be expressed mathematically as follows: For a character \(c\) in string \(s\), let \(f(c)\) denote its frequency. The answer is a character \(x\) such that \[ x = \min\{ c \;:\; f(c)=\max_{d \in s} f(d) \} \] in \(\text{lexicographical order}\).

inputFormat

A single line of input containing the string s. The string may consist of any visible characters and can be empty.

outputFormat

Output a single character: the one that appears most frequently in s. If more than one character has the highest frequency, output the lexicographically smallest one. If s is empty, output an empty string.## sample

a
a