/**
 * Given two lists, return a new list containing common elements.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing common elements between list1 and list2.
 *
 * Examples:
 * copyCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * copyCommonElements(listOf("a", "b", "c"), listOf("c", "d", "e")) // ["c"]
 * copyCommonElements(listOf(1, 2, 3), listOf(4, 5, 6)) // []
 */
fun copyCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()
    for (element in list1) {
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)
        }
    }
    return commonElements
}
/**
 * Given two lists, return a new list containing common elements.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing common elements between list1 and list2.
 *
 * Examples:
 * copyCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * copyCommonElements(listOf("a", "b", "c"), listOf("c", "d", "e")) // ["c"]
 * copyCommonElements(listOf(1, 2, 3), listOf(4, 5, 6)) // []
 */
fun copyCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * Given two lists, return a new list containing common elements.
 *
 * @param list1 The first list.
 * @param list2 The second list.
 * @return A new list containing common elements between list1 and list2.
 *
 * Examples:
 * copyCommonElements(listOf(1, 2, 3, 4, 5), listOf(4, 5, 6, 7, 8)) // [4, 5]
 * copyCommonElements(listOf("a", "b", "c"), listOf("c", "d", "e")) // ["c"]
 * copyCommonElements(listOf(1, 2, 3), listOf(4, 5, 6)) // []
 */
fun copyCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val commonElements = mutableListOf<Any>()
    for (element in list1) {
        if (element in list2 && element !in commonElements) {
            commonElements.add(element)
        }
    }
    return commonElements
}