fork download
  1. n = int(input())
  2.  
  3. k={}
  4. for _ in range(n):
  5. y = int(input())
  6. k[y]= k.get(y,0)+1
  7. minfreq = float('inf')
  8. maxfreq= 0
  9. minelem=-1
  10. maxelem=-1
  11.  
  12. for number , count in k.items():
  13. if count > maxfreq:
  14. maxfreq=count
  15. maxelem= number
  16. if count <minfreq:
  17. minfreq = count
  18. minelem= number
  19. print(maxelem , maxfreq)
  20. print(minelem , minfreq)
Success #stdin #stdout 0.07s 14144KB
stdin
5
1 
1 
2 
2 
3 
stdout
1 2
3 1