Count and Say
mediumStrings II+20 XPTime limit 2s
The count-and-say sequence starts with 1. Each next term is made by reading the previous term aloud, group by group: 1 is "one 1" → 11; 11 is "two 1s" → 21; 21 is "one 2, one 1" → 1211; then 111221, 312211, …
Print the n-th term.
Input: one integer n.
Output: the n-th term of the sequence.
Constraints: 1 ≤ n ≤ 30 (the 30th term has 4462 digits).
Think about it: build the terms one by one. To describe a term, walk through it and split it into blocks of equal digits; each block becomes its length followed by the digit.
Sample input 1
4
Sample output 1
1211
Sample input 2
1
Sample output 2
1
Read input from standard input and print the answer to standard output. Your code runs in a secure sandbox against the samples (Run) and hidden tests (Submit).