Boulderfall deals 5 damage divided as you choose among any number of targets.
If an effect creates a copy of Boulderfall, the division of damage and number of targets can't be changed. The effect that creates the copy may allow you to change targets, however.
If some but not all of Boulderfall's targets become illegal, you can't change the division of damage. Damage that would have been dealt to illegal targets simply isn't dealt.
You divide the damage as you cast the spell, not as it resolves. Each target must be assigned at least 1 damage.