/**
 * Given a list of tuples and a divisor, return a new list of tuples satisfying the following conditions:
 * 1. The sum of all elements in the tuples is divisible by the divisor.
 * 2. The first element in each tuple is divisible by the second element.
 * 3. The second element in each tuple is not equal to zero.
 *
 * @param tuples List of tuples containing integer elements.
 * @param divisor An integer used as the divisor.
 * @return List of tuples satisfying the given conditions.
 */
fun getFilteredTuples(tuples: List<Pair<Int, Int>>, divisor: Int): List<Pair<Int, Int>> {

    val filteredTuples = mutableListOf<Pair<Int, Int>>()
    for (tpl in tuples) {
        val (first, second) = tpl
        if (tpl.first + tpl.second % divisor == 0 && first % second == 0 && second != 0) {
            filteredTuples.add(tpl)
        }
    }
    return filteredTuples
}

// Example usage
/**
 * Given a list of tuples and a divisor, return a new list of tuples satisfying the following conditions:
 * 1. The sum of all elements in the tuples is divisible by the divisor.
 * 2. The first element in each tuple is divisible by the second element.
 * 3. The second element in each tuple is not equal to zero.
 *
 * @param tuples List of tuples containing integer elements.
 * @param divisor An integer used as the divisor.
 * @return List of tuples satisfying the given conditions.
 */
fun getFilteredTuples(tuples: List<Pair<Int, Int>>, divisor: Int): List<Pair<Int, Int>> {
/**
 * Given a list of tuples and a divisor, return a new list of tuples satisfying the following conditions:
 * 1. The sum of all elements in the tuples is divisible by the divisor.
 * 2. The first element in each tuple is divisible by the second element.
 * 3. The second element in each tuple is not equal to zero.
 *
 * @param tuples List of tuples containing integer elements.
 * @param divisor An integer used as the divisor.
 * @return List of tuples satisfying the given conditions.
 */
fun getFilteredTuples(tuples: List<Pair<Int, Int>>, divisor: Int): List<Pair<Int, Int>> {

    val filteredTuples = mutableListOf<Pair<Int, Int>>()
    for (tpl in tuples) {
        val (first, second) = tpl
        if (tpl.first + tpl.second % divisor == 0 && first % second == 0 && second != 0) {
            filteredTuples.add(tpl)
        }
    }
    return filteredTuples
}

// Example usage