USACO 2016 December Contest, Silver
Problem 2. Cities and States
Contest has ended.
Let us say that two cities are a "special pair" if they satisfy this property and come from different states. The cows are wondering how many special pairs of cities exist. Please help them solve this amusing geographical puzzle!
INPUT FORMAT (file citystate.in):The first line of input contains $N$ ($1 \leq N \leq 200,000$), the number of cities on the map.
The next $N$ lines each contain two strings: the name of a city (a string of at least 2 and at most 10 uppercase letters), and its two-letter state code (a string of 2 uppercase letters). Note that the state code may be something like ZQ, which is not an actual USA state. Multiple cities with the same name can exist, but they will be in different states.
OUTPUT FORMAT (file citystate.out):Please output the number of special pairs of cities.
6 MIAMI FL DALLAS TX FLINT MI CLEMSON SC BOSTON MA ORLANDO FL
Problem credits: Brian Dean