/**
 * Modifies the elements of a list at the specified index with a new value.
 *
 * @param elements The list of elements.
 * @param index The index at which the elements need to be modified.
 * @param newValue The new value to replace the element at the specified index.
 * @return The modified list with the new value at the specified index.
 */
fun modifyListElements(elements: MutableList<Int>, index: Int, newValue: Int): List<Int> {

    // Check if the index is within the bounds of the list
    if (index in elements.indices) {
        elements[index] = newValue
    }
    return elements
}

// Example usage
/**
 * Modifies the elements of a list at the specified index with a new value.
 *
 * @param elements The list of elements.
 * @param index The index at which the elements need to be modified.
 * @param newValue The new value to replace the element at the specified index.
 * @return The modified list with the new value at the specified index.
 */
fun modifyListElements(elements: MutableList<Int>, index: Int, newValue: Int): List<Int> {
/**
 * Modifies the elements of a list at the specified index with a new value.
 *
 * @param elements The list of elements.
 * @param index The index at which the elements need to be modified.
 * @param newValue The new value to replace the element at the specified index.
 * @return The modified list with the new value at the specified index.
 */
fun modifyListElements(elements: MutableList<Int>, index: Int, newValue: Int): List<Int> {

    // Check if the index is within the bounds of the list
    if (index in elements.indices) {
        elements[index] = newValue
    }
    return elements
}

// Example usage