eolymp
bolt
Try our new interface for solving problems
Problems

base64

base64

Required to write the converter in \textbf{base64} format and from \textbf{base64}. Encoding in \textbf{base64} is as follows: 1. If the length of the source text, in bytes is not divisible by \textbf{3}, then it is supplemented by a minimum of zero bytes so that the length was divided by \textbf{3}, the number of bytes added remembered. 2. The text is divided into groups of \textbf{3} bytes. Each group is coded separately. 3. Of the three bytes get \textbf{24}-bit number. The first byte of the troika is a senior, the third - the youngest. 4. \textbf{24}-bit number is divided into four \textbf{6}-bit groups. Senior \textbf{6} bit character encoding specifies the first four, the lower \textbf{6} bits - the latter etc. 5. Six bits of coded symbols next set: \textbf{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/} Number \textbf{0} is encoded by the letter '\textbf{A}', number \textbf{1} by the letter '\textbf{B}', number \textbf{63} with '\textbf{/}'. 6. These four characters are written one after another in the same order in which were three of which they were received. 7. I remember how many null characters were added to the end of the source text in step \textbf{1}, and so the last character encoded text changed to '\textbf{=}'. 8. The text is divided into groups of \textbf{76} characters (the latter may be less) and each group is recorded in a separate line. Every non-empty line must end with a linefeed (the characters \textbf{13} \textbf{10}). \InputFile The first line contains the type of information in the input file, the second line is blank, followed by the information that you want to encode or decode. If you want to encode the text, the file begins with a '\textbf{Content-Transfer-Encoding: 8bit}', followed by \textbf{4}characters \textbf{13} \textbf{10} \textbf{13} \textbf{10} --- and the rest of the file - a set of bytes to be coding. The volume of the encoded text ( "text" can be binary data) does not exceed \textbf{100 000} bytes. If you want to decode the text, the file begins with a 'Content-Transfer-Encoding '\textbf{Content-Transfer-Encoding: base64}', followed by \textbf{4} characters \textbf{13} \textbf{10} \textbf{13} \textbf{10} --- and the rest of the file - text encoded base64. The coded text was obtained from a source that does not exceed \textbf{100 000} bytes. \OutputFile Remove the string with the opposite type of information, then an empty string, then the result of encoding or decoding. If required to encode the text, the output should start characters '\textbf{Content-Transfer-Encoding: base64}', followed by the \textbf{4} symbols \textbf{13} \textbf{10} \textbf{13} \textbf{10} --- continue until the end of the file should contain text encoded in \textbf{base64}. If required to decode the text, the output should start characters'\textbf{Content-Transfer-Encoding: 8bit}', followed by the \textbf{4} symbols \textbf{13} \textbf{10} \textbf{13} \textbf{10} --- continue until the end of the file should contain the decoded text.
Time limit 1 second
Memory limit 64 MiB
Input example #1
Content-Transfer-Encoding: 8bit

Vologda SPU
Output example #1
Content-Transfer-Encoding: base64

Vm9sb2dkYSBTUFU=
Author Vladimir Pinaev, Fedor Menschiko