#C77. Count Distinct Programming Language Preferences
Count Distinct Programming Language Preferences
Count Distinct Programming Language Preferences
In this problem, you are given survey responses from several individuals. Each survey response is a comma-separated list of programming languages that a person prefers. A single person might list the same language more than once, but it should only be counted once per person. Your task is to compute, for each programming language, how many distinct people mentioned it. Finally, output the count for each language, with the languages sorted in alphabetical order.
Formally, let \(n\) be the number of survey responses. For each survey response \(i\) (where \(1 \le i \le n\)), we are given a string \(S_i\) of comma-separated programming language names. For each language, count the number of responses in which it appears at least once.
Example:
Input: 6 Python,Java,C++ Python,C++ Java,Python C++ Java C++,Python,Java</p>Output: C++ 4 Java 4 Python 4
inputFormat
The first line of the input contains an integer \(n\) denoting the number of survey responses. The following \(n\) lines each contain a non-empty string which is a comma-separated list of programming languages.
outputFormat
For each distinct programming language that appears in the input, output a line containing the language name and the number of distinct people (survey responses) that mentioned it, separated by a space. The output should be sorted in alphabetical order of the language names.
## sample1
Python,Java,C++
C++ 1
Java 1
Python 1
</p>