<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def titlefy(subject):
 """\ Titlecases the provided subject but respects common abbreviations. This function returns ``None`` if the provided `subject` is ``None``. It returns an empty string if the provided subject is empty. `subject A cable's subject. """

    def clean_word(word):
        return _APOS_PATTERN.sub(lambda m: u'%s%s%s' % (m.group(1), m.group(2) if not m.group(2) == ',' else u"'", m.group(3).lower()), word)
    def titlefy_word(word):
        if _is_number(word):
            return word.lower()
        if _TITLEFY_BIG_PATTERN.match(word):
            return clean_word(word.upper())
        return clean_word(_SPECIAL_WORDS.get(word, word.title()))
    if not subject:
        return None if subject is None else u''
    res = []
    append = res.append
    wl = subject.strip().split()
    append(titlefy_word(wl[0]))
    for word in wl[1:]:
        if _TITLEFY_SMALL_PATTERN.match(word):
            if res[-1][-1] not in ':-':
                if word == u'A' and res[-1] == u'and' and res[-2] == 'Q':
                    # Q and A
                    append(word.upper())
                else:
                    append(word.lower())
            else:
                append(titlefy_word(word))
        else:
            append(titlefy_word(word))
    return u' '.join(res)