n | n, w = eval(input()) | n | a1, a2 = eval(input()) |
| d = dict() | | d = dict() |
| text = input() | | text = input() |
n | | n | |
| while text: | | while text: |
| text = text.split() | | text = text.split() |
n | for words in text: | n | for slova in text: |
| if "'" in words: | | if "'" in slova: |
| words = words[0:words.find("'")] | | slova = slova[0:slova.find("'")] |
| if ";" in words: | | if ";" in slova: |
| words = words[0:words.find(";")] | | slova = slova[0:slova.find(";")] |
| if "-" in words: | | if "-" in slova: |
| words = words.replace((words[0:words.find("-")] + "-"), "") | | slova = slova.replace((slova[0:slova.find("-")]+"-"), "") |
| while len(words) > 1 and not words[-1].isalpha(): | | while len(slova) > 1 and not slova[-1].isalpha(): |
| words = words[0:-1] | | slova = slova[0:-1] |
| while len(words) > 1 and not words[0].isalpha(): | | while len(slova) > 1 and not slova[0].isalpha(): |
| words = words[1:] | | slova = slova[1:] |
| words = words.lower() | | slova = slova.lower() |
| if words.isalpha() and len(words) >= w: | | if slova.isalpha() and len(slova) >= a2: |
| if words in d: | | if slova in d: |
| d[words] += 1 | | d[slova] += 1 |
| else: | | else: |
n | d[words] = 1 | n | d[slova] = 1 |
| | | |
| text = input() | | text = input() |
t | | t | |
| wordsCount = set(d.values()) | | kol_sl = set(d.values()) |
| wordsCount = list(wordsCount) | | kol_sl = list(kol_sl) |
| wordsCount.sort(reverse=True) | | kol_sl.sort(reverse=True) |
| wordsCount = wordsCount[0:n] | | kol_sl = kol_sl[0:a1] |
| l = [(v, k) for k, v in d.items() if v in wordsCount] | | l = [(v, k) for k, v in d.items() if v in kol_sl] |
| l.sort() | | l.sort() |
| for x in l: | | for x in l: |
| print(x[0], ': ', x[1], sep='') | | print(x[0], ': ', x[1], sep='') |
| | | |