def replace_repeated_characters(text):
  """Replaces every 3+ repetition of a character with a 2-repetition."""
  if not text:
    return text
  res = text[0]
  c_prev = text[0]
  n_reps = 0
  for c in text[1:]:
    if c == c_prev:
      n_reps += 1
      if n_reps < 2:
        res += c
    else:
      n_reps = 0
      res += c
    c_prev = c
  return res