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

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