def decompress_amount(x):
    """    Undo the value compression performed by x=compress_amount(n). The input
    x matches one of the following patterns:
        x = n = 0
        x = 1+10*(9*n + d - 1) + e
        x = 1+10*(n - 1) + 9"""
    if not x:
        return 0
    x = x - 1
    x, e = divmod(x, 10)
    n = 0
    if e < 9:
        x, d = divmod(x, 9)
        d = d + 1
        n = x * 10 + d
    else:
        n = x + 1
    return n * 10 ** e
