/**
 * This function takes a list of cities and a new city as input.
 * It replaces the largest city in the list with the new city and returns the modified list.
 *
 * @param cities List of cities
 * @param newCity Tuple representing the new city to be inserted
 * @return Modified list of cities with the largest city replaced by the new city
 */
fun replaceLargestCity(cities: MutableList<Pair<String, Int>>, newCity: Pair<String, Int>): MutableList<Pair<String, Int>> {

    var largestCityIndex = -1
    var largestArea = 0

    for (i in cities.indices) {
        val (name, area) = cities[i]
        if (area > largestArea) {
            largestArea = area
            largestCityIndex = i
        }
    }

    if (largestCityIndex != -1) {
        cities[largestCityIndex] = newCity
    }

    return cities
}
/**
 * This function takes a list of cities and a new city as input.
 * It replaces the largest city in the list with the new city and returns the modified list.
 *
 * @param cities List of cities
 * @param newCity Tuple representing the new city to be inserted
 * @return Modified list of cities with the largest city replaced by the new city
 */
fun replaceLargestCity(cities: MutableList<Pair<String, Int>>, newCity: Pair<String, Int>): MutableList<Pair<String, Int>> {
/**
 * This function takes a list of cities and a new city as input.
 * It replaces the largest city in the list with the new city and returns the modified list.
 *
 * @param cities List of cities
 * @param newCity Tuple representing the new city to be inserted
 * @return Modified list of cities with the largest city replaced by the new city
 */
fun replaceLargestCity(cities: MutableList<Pair<String, Int>>, newCity: Pair<String, Int>): MutableList<Pair<String, Int>> {

    var largestCityIndex = -1
    var largestArea = 0

    for (i in cities.indices) {
        val (name, area) = cities[i]
        if (area > largestArea) {
            largestArea = area
            largestCityIndex = i
        }
    }

    if (largestCityIndex != -1) {
        cities[largestCityIndex] = newCity
    }

    return cities
}