def equalspairs(X, Y):
    T = Y.copy()
    R = (T[1:] != T[:-1]).nonzero()[0]
    R = np.append(R,np.array([len(T)-1]))
    M = R[R.searchsorted(range(len(T)))]
    D = T.searchsorted(X)
    T = np.append(T,np.array([0]))
    M = np.append(M,np.array([0]))
    A = (T[D] == X) * D
    B = (T[D] == X) * (M[D] + 1)
    return [A,B]