Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import collections
- n = int(input())
- m = int(input())
- k = int(input())
- s = []
- ans = set()
- if(m >= n):
- for i in range(n):
- s.append(input())
- cnt = collections.Counter(s)
- for i in set(s):
- if(cnt[i] >= k):
- print(i)
- else:
- for i in range(m):
- s.append(input())
- ipst = collections.Counter(s)
- ans.update(set([i for i in ipst.keys() if ipst[i] >= k]))
- for i in range(n - m):
- s.append(input())
- ipst += collections.Counter([s[-1]])
- ipst[s[0]] -= 1
- if (ipst[s[-1]] >= k):
- ans.add(s[-1])
- s.pop(0)
- for i in sorted(list(ans), key=str.lower):
- print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement