def remove_comments(text: str) ->str:
    """
    Удаление комментариев из кода.

    :param text: Код для очистки
    :return: Очищенный код
    """
    if '/*' not in text:
        return text
    result = []
    state = ''
    index = 0
    length = len(text)
    while index < length:
        char = text[index]
        if state in ("'", '"', '|'):
            if char == state:
                state = ''
            result.append(char)
        elif char == '/':
            if index + 1 < length and text[index + 1] == '*':
                while index < length:
                    char = text[index]
                    if char in ('\r', '\n'):
                        result.append(char)
                        break
                    index = index + 1
            else:
                result.append(char)
        elif char in ("'", '"', '|'):
            state = char
            result.append(char)
        else:
            result.append(char)
        index = index + 1
    return ''.join(result)
