There's a myth about Max Martin's melodic
math that all phrase repetitions must be precise. That's not true--while
repetitions are very close, Max 'tolerates' two kinds of melodic
variations on the core motif: 1. Variations that allow lyrical
flexibility WITHOUT harming the integrity of the core motif. 2.
Variations that change the melodic function of the phrase and allow it
to fit into a melodic structure (e.g., ABAC). Those have more freedom to
tweak core notes but it still has to sound like a repetition. Here's an
example from Taylor Swift's "Shake It Off" (2014).