import collections


def top_k(signal, k):
  """Computes the top_k cut of a {'string': frequency} dict."""
  counter = collections.Counter(signal)
  ranks = collections.defaultdict(list)
  for key, value in counter.most_common():
    ranks[value].append(key)
  results = {}
  counter = 0
  for freq, values in ranks.items():
    for v in values:
      results[v] = freq
      counter += 1
    if counter >= k:
      break
  return results