#292. 字符串前缀重复
字符串前缀重复
Prefix Repetition
Background
Congcong is learning string manipulation. He encountered an interesting task that requires extracting a part of a string and repeating it.
Problem Description
Given a string, return a new string made of 3 copies of the first 2 characters of the original string. The string may be any length. If there are fewer than 2 characters, use whatever is there.
Input Format
Input is given from standard input in the following format.
A string .
Output Format
Output is printed to standard output in the following format.
A new string, consisting of the first two characters of (or all characters if less than two) repeated 3 times.
Sample
Hello
HeHeHe
ab
ababab
H
HHH
Sample Explanation
Sample 1: The first two characters of "Hello" are "He". Repeating them 3 times gives "HeHeHe". Sample 2: The first two characters of "ab" are "ab". Repeating them 3 times gives "ababab". Sample 3: The length of "H" is less than 2, so all characters "H" are used. Repeating them 3 times gives "HHH".
Constraints
Time limit: 1s, Memory limit: 1024KiB for each test case.