from typing import List
from typing import Tuple
from typing import Union


def wilcoxon_w(pairs: List[Tuple[Union[float, int], int]]) -> float:
    """
    Returns the Wilcoxon "W" value, with rank smoothing; see Wikipedia article.
    """
    i = 0
    w = 0.0
    while i < len(pairs):
        absi = pairs[i][0]
        sum_sgn = pairs[i][1]
        j = i + 1
        while j < len(pairs) and pairs[j][0] == absi:
            sum_sgn += pairs[j][1]
            j += 1
        r = 1 + 0.5 * (i + j - 1)  # smoothed rank
        w += r * sum_sgn
        i = j
    return w