<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def after(f, chain=False):
 """Runs f with the result of the decorated function."""

    def decorator(g):
        @wraps(g)
        def h(*args, **kargs):
            if chain:
                return f(g(*args, **kargs))
            else:
                r = g(*args, **kargs)
                f(*args, **kargs)
                return r
        return h
    return decorator