/**
 * This function takes in two lists and returns a new list containing the common elements between them.
 *
 * Note: Short-circuiting with if-else is used to improve efficiency.
 */
fun copyCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val result = mutableListOf<Any>()
    
    // Iterate through the first list
    for (element in list1) {
        // Check if the element exists in the second list
        if (element in list2) {
            result.add(element)
        }
    }
    
    return result
}
/**
 * This function takes in two lists and returns a new list containing the common elements between them.
 *
 * Note: Short-circuiting with if-else is used to improve efficiency.
 */
fun copyCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {
/**
 * This function takes in two lists and returns a new list containing the common elements between them.
 *
 * Note: Short-circuiting with if-else is used to improve efficiency.
 */
fun copyCommonElements(list1: List<Any>, list2: List<Any>): List<Any> {

    val result = mutableListOf<Any>()
    
    // Iterate through the first list
    for (element in list1) {
        // Check if the element exists in the second list
        if (element in list2) {
            result.add(element)
        }
    }
    
    return result
}