def argmin(pairs):
    """
    Given an iterable of pairs (key, value), return the key corresponding to the smallest value.
    Raises `ValueError` on empty sequence.

    >>> argmin(zip(range(20), range(20, 0, -1)))
    19
    """
    return min(pairs, key=lambda x: x[1])[0]