Square Digit Chains

A number chain is created by continuously adding the square of the
digits in a number to form a new number until it has been seen before.
For example, 44 → 32 → 13 → 10 → 1 → 1 and 85 → 89 → 145 → 42 → 20 → 4
→ 16 → 37 → 58 → 89. Therefore any chain that arrives at 1 or 89 will
become stuck in an endless loop. What is most amazing is that EVERY
starting number will eventually arrive at 1 or 89. How many starting
numbers below ten million will arrive at 89?
Roman Numerals

The rules for writing Roman numerals allow for many ways of writing
each number. However, there is always a "best" way of writing a
particular number.

For example, the following represent all of the legitimate ways of
writing the number sixteen:

IIIIIIIIIIIIIIII
VIIIIIIIIIII
VVIIIIII
XIIIIII
VVVI
XVI

The last example being considered the most efficient, as it uses the
least number of numerals.

The 11K text file, roman.txt, contains one thousand numbers written in
valid, but not necessarily minimal, Roman numerals; that is, they are
arranged in descending units and obey the subtractive pair rule.

Find the number of characters saved by writing each of these in their
minimal form.

Note: You can assume that all the Roman numerals in the file contain no
more than four consecutive identical units.
Square Digit Chains

A number chain is created by continuously adding the square of the
digits in a number to form a new number until it has been seen before.
For example, 44 → 32 → 13 → 10 → 1 → 1 and 85 → 89 → 145 → 42 → 20 → 4
→ 16 → 37 → 58 → 89. Therefore any chain that arrives at 1 or 89 will
become stuck in an endless loop. What is most amazing is that EVERY
starting number will eventually arrive at 1 or 89. How many starting
numbers below ten million will arrive at 89?