n | p, l = eval(input()) | n | a, b = eval(input()) |
| m = dict() | | d = dict() |
| n = input() | | text = input() |
| while n: | | while text: |
| n = n.split() | | text = text.split() |
| for z in n: | | for word in text: |
| if "'" in z: | | if "'" in word: |
| z = z[0:z.find("'")] | | word = word[0:word.find("'")] |
| if ";" in z: | | if ";" in word: |
| z = z[0:z.find(";")] | | word = word[0:word.find(";")] |
| if "-" in z: | | if "-" in word: |
| z = z.replace((z[0:z.find("-")]+"-"), "") | | word = word.replace((word[0:word.find("-")]+"-"), "") |
| if len(z) > 1 and not z[-1].isalpha(): | | if len(word) > 1 and not word[-1].isalpha(): |
| z = z[0:-1] | | word = word[0:-1] |
| if len(z) > 1 and not z[0].isalpha(): | | if len(word) > 1 and not word[0].isalpha(): |
| z = z[1:] | | word = word[1:] |
| z = z.lower() | | word = word.lower() |
| if z.isalpha() and len(z) >= l: | | if word.isalpha() and len(word) >= b: |
| if z in m: | | if word in d: |
| m[z] += 1 | | d[word] += 1 |
| else: | | else: |
n | m[z] = 1 | n | d[word] = 1 |
| | | |
n | n = input() | n | text = input() |
| | | |
t | w_p = set(m.values()) | t | w_a = set(d.values()) |
| w_p = list(w_p) | | w_a = list(w_a) |
| w_p.sort(reverse=True) | | w_a.sort(reverse=True) |
| w_p = w_p[0:p] | | w_a = w_a[0:a] |
| w = [(v, k) for k, v in m.items() if v in w_p] | | w = [(v, k) for k, v in d.items() if v in w_a] |
| w.sort() | | w.sort() |
| for x in w: | | for x in w: |
| print(x[0], ': ', x[1], sep='') | | print(x[0], ': ', x[1], sep='') |
| | | |