Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. import collections
  2. n = int(input())
  3. m = int(input())
  4. k = int(input())
  5. s = []
  6. ans = set()
  7. if(m >= n):
  8.     for i in range(n):
  9.         s.append(input())
  10.     cnt = collections.Counter(s)
  11.     for i in set(s):
  12.         if(cnt[i] >= k):
  13.             print(i)
  14. else:
  15.     for i in range(m):
  16.         s.append(input())
  17.     ipst = collections.Counter(s)
  18.     ans.update(set([i for i in ipst.keys() if ipst[i] >= k]))
  19.     for i in range(n - m):
  20.         s.append(input())
  21.         ipst += collections.Counter([s[-1]])
  22.         ipst[s[0]] -= 1
  23.         if (ipst[s[-1]] >= k):
  24.             ans.add(s[-1])
  25.         s.pop(0)
  26.     for i in sorted(list(ans), key=str.lower):
  27.             print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement