Keeping Score

No attempts yetTime limit1sMemory limit128 MB

Problem

In a card game, each player's hand is made up of $13$ cards. A hand's value is the sum of two kinds of points: high-card points and distribution points.

Four ranks carry high-card points: Ace ($4$ points), King ($3$ points), Queen ($2$ points), and Jack ($1$ point). Every other rank — 2, 3, 4, 5, 6, 7, 8, 9, 10 — is worth nothing.

There are four suits — clubs (C), diamonds (D), hearts (H), and spades (S) — with one card of each rank in every suit. Distribution points reward short suits: a void (no cards in the suit) is worth $3$ points, a singleton (exactly one card) is worth $2$ points, and a doubleton (exactly two cards) is worth $1$ point. A suit's score is its high-card points plus its distribution points, and the hand's total is the sum over all four suits.

Input. One line containing a single string that describes one hand of thirteen cards. The cards are grouped by suit, each group introduced by its suit letter, and the suits appear in increasing alphabetical order: clubs (C), diamonds (D), hearts (H), then spades (S). Every suit letter is present even when that suit is void. Within a suit there are no duplicate cards, and the rank 10 is written as the single character T.

Output. Print the scored hand as a table. The first line is the header Cards Dealt with Points right-aligned to column $31$. Then print one line for each suit, in the order Clubs, Diamonds, Hearts, Spades: the suit name, then its cards separated by single spaces in the same order as the input, then the suit's point value right-aligned so it ends at column $31$ (always separated from the cards by at least one space). A void suit shows only its name and its points. The last line prints Total followed by the hand's total, right-aligned to column $31$. Write 10 as T in the output as well.

Note

The suit names printed in the output are Clubs, Diamonds, Hearts, and Spades. Match the layout of the sample output exactly, including the spacing that right-aligns every point value.