Sort by

recency

|

1649 Discussions

|

  • + 0 comments

    n=int(input())

    k={} list1=[]

    for i in range(n): stri=input() list1.append(stri)

    for i in list1: k[i]=k.get(i,0)+1 print(len(k)) for i ,p in k.items(): print(p,end=" ")

  • + 0 comments
    n = int(input())
    word_count = {}
    order = []
    for _ in range(n):
        word = input().strip()
        if word not in word_count:
            word_count[word] = 0
            order.append(word)
        word_count[word] += 1
    print(len(order))
    print(' '.join(str(word_count[word]) for word in order))   
    
  • + 0 comments
    from collections import Counter,OrderedDict
    n=int(input())
    a=[input() for _ in range(n)]
    c=list(OrderedDict.fromkeys(a))
    d=Counter(a)
    b=[d[_] for _ in c]
    print(len(b))
    print(*b,end=" ")
    
  • + 0 comments

    from collections import Counter

    n = int(input().strip()) words = [input().strip() for _ in range(n)]

    words_count = Counter(words)

    distinct = [] for w in words: if w not in distinct: distinct.append(w)

    print(len(distinct))

    for d in distinct: print(words_count[d], end=" ") print()

  • + 0 comments
    from collections import Counter
    words = [input() for _ in range(int(input()))]
    print(len(Counter(words)))
    counts = [i  for i in Counter(words).values()]
    print(' '.join([str(i) for i in counts]))