#K73402. Trending Hashtags

    ID: 33967 Type: Default 1000ms 256MiB

Trending Hashtags

Joe is performing a survey on social media platforms and gathers posts containing hashtags from the past week. He wants to determine which hashtags are trending. A hashtag is considered trending if it appears in at least half of all posts.

Given an integer M (the number of posts) and M subsequent lines where each line contains space-separated hashtags (each hashtag begins with a '#' symbol), your task is to print all the trending hashtags in lexicographical (alphabetical) order. If no hashtag meets the criteria, output exactly No trending hashtags.

The threshold for a hashtag to be trending is given by the inequality \[ \text{count} \geq \frac{M}{2} \] where \( \text{count} \) is the number of posts in which a particular hashtag appears.

inputFormat

The input is read from stdin and is structured as follows:

  • The first line contains an integer M representing the number of posts.
  • The next M lines each contain a post represented by a space-separated list of hashtags. Each hashtag begins with the '#' symbol.

outputFormat

Output the trending hashtags to stdout in lexicographical order, printing each hashtag on a separate line. If no trending hashtag exists, output exactly No trending hashtags.

## sample
5
#fun #summer #vacation
#vacation #travel #fun
#fun #foodblogger
#travel #photography #fun
#summer #fun #travel
#fun

#travel

</p>