Patterned cell death sculpts functional and adaptive neural networks in flies