App registered to wrong account; how to fix this?
I tried various actions, including clearing all data, and uninstalling and reinstalling the app. None of them worked.

Eventually, I removed accounts B and C, uninstalled the app again, restarted the phone, and reinstalled the app.

This worked. The licence was automatically restored.

What's more, Google restored the app's data — admittedly, from a couple of weeks back before the upgrade to 5.0, but still it meant that I lost little.

I'm going to leave accounts B and C off the phone for a while to see what happens.

I think that I should report this fault to Google.