What is DP_rarity ?
DP_rarity = 1 << (problem - 2 * kangoo_power) // 2 - 2
Is DP_rarity same DP method (distinguished point DP) right?
Yeah this is just a fancy way of making a DP mask.
if P.x % DP_rarity == 0:
What is code check ? Modulus to zero this mean collision ?
No it checks whether the point is a DP with its x-coordinate.
Where are people finding the compressed or uncompresssed public keys for the puzzle transactions?
Every fifth transaction starting at #65 also has a spending transaction that reveals the public key.