#C13561. Longest Substring with At Most Two Distinct Characters
Longest Substring with At Most Two Distinct Characters
Longest Substring with At Most Two Distinct Characters
Given a string s, find the longest substring that contains at most two distinct characters. If there are multiple substrings with the maximum length, return the one that appears first. Additionally, your program should print the length of the longest substring on the first line, followed by the substring itself on the second line.
Note: You need to read the input from standard input (stdin) and print the output to standard output (stdout).
For example:
Input: abcbbbbcccbdddadacb Output: 10 bcbbbbcccb
inputFormat
The input consists of a single line containing the string s. The string may be empty.
outputFormat
The output consists of two lines. The first line is an integer representing the length of the longest substring that contains at most two distinct characters. The second line contains the substring itself.
## sampleabcbbbbcccbdddadacb
10
bcbbbbcccb
</p>