#K46992. Total Characters of Twice Occurrence
Total Characters of Twice Occurrence
Total Characters of Twice Occurrence
You are given a list of words. Your task is to compute the total number of characters in all the words that occur exactly twice in the list.
More formally, let \(w\) be any word in the list. If \(w\) appears exactly two times and its length is \(|w|\), then you should add \(|w|\) once to the answer. If no word appears exactly twice, the answer is 0.
Input Format: The input begins with an integer \(n\) representing the number of words, followed by \(n\) lines each containing a single word.
Output Format: Output a single integer representing the sum of the lengths of the words that occur exactly twice.
Example:
Input: 6 apple banana apple orange kiwi banana</p>Output: 11
In the above example, "apple" and "banana" appear exactly twice. The length of "apple" is 5 and the length of "banana" is 6, hence the result is \(5 + 6 = 11\).
inputFormat
The first line of input contains an integer \(n\), which is the number of words. The following \(n\) lines each contain a single word.
outputFormat
Output a single integer: the sum of the lengths of the words that appear exactly twice in the input list.
## sample6
apple
banana
apple
orange
kiwi
banana
11