/**
 * This function takes a city and its population as arguments and divides the population by a given factor.
 *
 * @param city The name of the city.
 * @param population A list with the population of each neighborhood in the city.
 * @return The updated population list after dividing each element by a given factor.
 */
fun changePopulation(city: String, population: MutableList<Int>): MutableList<Int> {

    // Create a copy of the population list to avoid modifying the original list
    val updatedPopulation = population.toMutableList()
    
    // Define the division factor
    print("Enter the division factor: ")
    val factor = readLine()!!.toInt()
    
    // Iterate over each element in the population list
    for (i in updatedPopulation.indices) {
        // Check if the element is divisible by the factor without remainder
        if (updatedPopulation[i] % factor == 0) {
            // Divide the element by the factor
            updatedPopulation[i] /= factor
        } else {
            // Round the division result of non-divisible elements to the nearest integer
            updatedPopulation[i] = Math.round(updatedPopulation[i] / factor.toFloat()).toInt()
        }
    }
    
    return updatedPopulation
}
/**
 * This function takes a city and its population as arguments and divides the population by a given factor.
 *
 * @param city The name of the city.
 * @param population A list with the population of each neighborhood in the city.
 * @return The updated population list after dividing each element by a given factor.
 */
fun changePopulation(city: String, population: MutableList<Int>): MutableList<Int> {
/**
 * This function takes a city and its population as arguments and divides the population by a given factor.
 *
 * @param city The name of the city.
 * @param population A list with the population of each neighborhood in the city.
 * @return The updated population list after dividing each element by a given factor.
 */
fun changePopulation(city: String, population: MutableList<Int>): MutableList<Int> {

    // Create a copy of the population list to avoid modifying the original list
    val updatedPopulation = population.toMutableList()
    
    // Define the division factor
    print("Enter the division factor: ")
    val factor = readLine()!!.toInt()
    
    // Iterate over each element in the population list
    for (i in updatedPopulation.indices) {
        // Check if the element is divisible by the factor without remainder
        if (updatedPopulation[i] % factor == 0) {
            // Divide the element by the factor
            updatedPopulation[i] /= factor
        } else {
            // Round the division result of non-divisible elements to the nearest integer
            updatedPopulation[i] = Math.round(updatedPopulation[i] / factor.toFloat()).toInt()
        }
    }
    
    return updatedPopulation
}