fork(1) download
  1. n = int(input())
  2. lista = list()
  3. counts = {}
  4.  
  5. for _ in range(n):
  6. napis = input()
  7. lista.append(napis)
  8.  
  9. for element in lista:
  10. if element in counts:
  11. counts[element] += 1
  12. else:
  13. counts[element] = 1
  14.  
  15. if counts:
  16. najczestszy_element = max(counts, key=counts.get)
  17. liczba_wystapien = counts[najczestszy_element]
  18. print(f"{najczestszy_element} {liczba_wystapien}")
Success #stdin #stdout 0.07s 14132KB
stdin
3
code
code
ia
stdout
code 2