def invertStereo(smifragment):
    """
    >>> invertStereo("C")
    'C'
    >>> invertStereo("[C@@]")
    '[C@]'
    >>> invertStereo("[C@]")
    '[C@@]'
    >>> invertStereo("[C@H]")
    '[C@@H]'
    >>> invertStereo("[C@@H]")
    '[C@H]'
    """
    ans = []
    i = 0
    while i < len(smifragment):
        x = smifragment[i]
        ans.append(x)
        if x == '@':
            if smifragment[i + 1] == '@':
                i += 1
            else:
                ans.append('@')
        i += 1
    return ''.join(ans)
