Codeforces Round 561 (Div. 2)
A
Silent Classroom
Codeforces
900
原题
←B →
翻译中…

There are $n$ students in the first grade of Nlogonia high school. The principal wishes to split the students into two classrooms (each student must be in exactly one of the classrooms). Two distinct students whose name starts with the same letter will be chatty if they are put in the same classroom (because they must have a lot in common). Let $x$ be the number of such pairs of students in a split. Pairs $(a, b)$ and $(b, a)$ are the same and counted only once.

翻译中…

For example, if there are $6$ students: "olivia", "jacob", "tanya", "jack", "oliver" and "jessica", then:

翻译中…
  • splitting into two classrooms ("jack", "jacob", "jessica", "tanya") and ("olivia", "oliver") will give $x=4$ ($3$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom),
  • splitting into two classrooms ("jack", "tanya", "olivia") and ("jessica", "oliver", "jacob") will give $x=1$ ($0$ chatting pairs in the first classroom, $1$ chatting pair in the second classroom).
翻译中…

You are given the list of the $n$ names. What is the minimum $x$ we can obtain by splitting the students into classrooms?

翻译中…

Note that it is valid to place all of the students in one of the classrooms, leaving the other one empty.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1\leq n \leq 100$) — the number of students.

翻译中…

After this $n$ lines follow.

翻译中…

The $i$-th line contains the name of the $i$-th student.

翻译中…

It is guaranteed each name is a string of lowercase English letters of length at most $20$. Note that multiple students may share the same name.

翻译中…

Output

翻译中…

The output must consist of a single integer $x$ — the minimum possible number of chatty pairs.

翻译中…

Note

翻译中…

In the first sample the minimum number of pairs is $1$. This can be achieved, for example, by putting everyone except jose in one classroom, and jose in the other, so jorge and jerry form the only chatty pair.

翻译中…

In the second sample the minimum number of pairs is $2$. This can be achieved, for example, by putting kambei, gorobei, shichiroji and kyuzo in one room and putting heihachi, katsushiro and kikuchiyo in the other room. In this case the two pairs are kambei and kyuzo, and katsushiro and kikuchiyo.

翻译中…

In the third sample the minimum number of pairs is $4$. This can be achieved by placing three of the students named mike in one classroom and the other two students in another classroom. Thus there will be three chatty pairs in one classroom and one chatty pair in the other classroom.

翻译中…

样例

Input #1
4
jorge
jose
oscar
jerry
Output #1
1
InputCopy OutputCopy
Input #2
7
kambei
gorobei
shichiroji
kyuzo
heihachi
katsushiro
kikuchiyo
Output #2
2
InputCopy OutputCopy
Input #3
5
mike
mike
mike
mike
mike
Output #3
4
InputCopy OutputCopy
题目信息
题号
1166A
时间限制
1 s
内存限制
256 MB
标签
组合数学
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。