UCI rule 2.6.026. This states that ‘In the case of a duly noted fall, puncture or mechanical incident in the last three kilometres of a road race stage, the rider or riders involved shall be credited with the time of the rider or riders in whose company they were riding at the moment of the accident. His or their placing shall be determined by the order in which he or they actually cross the finishing line.’
UCI rule 2.6.026. This states that ‘In the case of a duly noted fall, puncture or mechanical incident in the last three kilometres of a road race stage, the rider or riders involved shall be credited with the time of the rider or riders in whose company they were riding at the moment of the accident. His or their placing shall be determined by the order in which he or they actually cross the finishing line.’
There doesn't have to be anyone else involved.