Sort by

recency

|

1650 Discussions

|

  • + 0 comments
    # Enter your code here. Read input from STDIN. Print output to STDOUT
    from collections import Counter
    if __name__ == '__main__':
        n  = int(input())
        words = []
        for _ in range(n):
            s = input()
            words.append(s)
            
        total = 0
        count = Counter(words)
        print(len(count))
        for item in count:
            print(count[item], end=" ")
    
  • + 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()