Measurement of long-range multiparticle azimuthal correlations with the subevent cumulant method in pp and p plus Pb collisions with the ATLAS detector at the CERN Large Hadron Collider