/**
 * Given a set of elements, this function calculates the intersection and complement of the set.
 *
 * @param elementsSet The set of elements.
 * @return A pair containing the intersection and complement sets respectively.
 */
fun calculateIntersectionComplement(elementsSet: Set<Int>): Pair<Set<Int>, Set<Int>> {

    val intersectionSet = mutableSetOf<Int>()
    val complementSet = mutableSetOf<Int>()

    for (element in elementsSet) {
        // Check if the element is present in intersectionSet and remove it if present
        if (element in intersectionSet) {
            intersectionSet.remove(element)
        } else {
            // If the element is not present in intersectionSet, add it
            intersectionSet.add(element)
        }

        // Check if the element is present in complementSet and remove it if present
        if (element in complementSet) {
            complementSet.remove(element)
        } else {
            // If the element is not present in complementSet, add it
            complementSet.add(element)
        }
    }

    return Pair(intersectionSet, complementSet)
}

// Example usage
/**
 * Given a set of elements, this function calculates the intersection and complement of the set.
 *
 * @param elementsSet The set of elements.
 * @return A pair containing the intersection and complement sets respectively.
 */
fun calculateIntersectionComplement(elementsSet: Set<Int>): Pair<Set<Int>, Set<Int>> {
/**
 * Given a set of elements, this function calculates the intersection and complement of the set.
 *
 * @param elementsSet The set of elements.
 * @return A pair containing the intersection and complement sets respectively.
 */
fun calculateIntersectionComplement(elementsSet: Set<Int>): Pair<Set<Int>, Set<Int>> {

    val intersectionSet = mutableSetOf<Int>()
    val complementSet = mutableSetOf<Int>()

    for (element in elementsSet) {
        // Check if the element is present in intersectionSet and remove it if present
        if (element in intersectionSet) {
            intersectionSet.remove(element)
        } else {
            // If the element is not present in intersectionSet, add it
            intersectionSet.add(element)
        }

        // Check if the element is present in complementSet and remove it if present
        if (element in complementSet) {
            complementSet.remove(element)
        } else {
            // If the element is not present in complementSet, add it
            complementSet.add(element)
        }
    }

    return Pair(intersectionSet, complementSet)
}

// Example usage