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