Sort by

recency

|

1594 Discussions

|

  • + 0 comments

    Python3

    from collections import OrderedDict
    
    ordered_dict = OrderedDict()
    
    n = int(input())
    
    for _ in range(n):
        myinput = input()
        try:
            if ordered_dict[myinput]:
                ordered_dict[myinput] += 1
        except KeyError:
            ordered_dict[myinput] = 1
            
    print(len(ordered_dict.items()))
    for x,y in ordered_dict.items():
        print(y, end=" ")
    
  • + 0 comments

    ` import sys

    from collections import Counter

    words = sys.stdin.read().splitlines()[1:]

    counter = Counter(words)

    print(len(counter))

    print( *counter.values())

    `

  • + 0 comments
    from collections import Counter
    
    if __name__ == "__main__":
        n = int(input())
        words = Counter(input() for i in range(n))
        print(len(set(words)))
        [print(count,end=' ') for word,count in words.items()]
    
  • + 0 comments
    from collections import defaultdict
    
    d = defaultdict(int)
    n = int(input())
    
    for _ in range(n):
        d[input()] += 1
    
    print(len(d))
    print(*d.values())
    
  • + 0 comments
    from collections import Counter
    
    instances = int(input())
    words = []
    
    for i in range(instances):
        words.append(input())
        
    ocurrencies = Counter(words)
    
    print(len(ocurrencies))
    print(" ".join(map(str, ocurrencies.values())))