def shifted_data_covariance(dataX, dataY):
    """Fixes catastrophic cancellation probelem"""
    n = len(dataX)
    if n < 2:
        return 0
    Kx = dataX[0]
    Ky = dataY[0]
    Ex = Ey = Exy = 0
    for iX, iY in zip(dataX, dataY):
        Ex += iX - Kx
        Ey += iY - Ky
        Exy += (iX - Kx) * (iY - Ky)
    return (Exy - Ex * Ey / n) / n
