/**
 * Given a list of nested tuples, where each tuple contains two values (a key and a value),
 * create and return a dictionary where the key-value pairs are merged based on the intersection
 * of their keys.
 *
 * @param tuples A list of nested tuples, where each tuple contains a key-value pair.
 * @return A dictionary containing the merged key-value pairs from the nested tuples.
 */
fun mergeNestedTuples(tuples: List<Pair<String, Int>>): Map<String, Int> {

    val dictionary = mutableMapOf<String, Int>()
    for (nestedTuple in tuples) {
        val (key, value) = nestedTuple
        if (dictionary.containsKey(key)) {
            dictionary[key] = dictionary[key]!! + value
        } else {
            dictionary[key] = value
        }
    }
    return dictionary
}
/**
 * Given a list of nested tuples, where each tuple contains two values (a key and a value),
 * create and return a dictionary where the key-value pairs are merged based on the intersection
 * of their keys.
 *
 * @param tuples A list of nested tuples, where each tuple contains a key-value pair.
 * @return A dictionary containing the merged key-value pairs from the nested tuples.
 */
fun mergeNestedTuples(tuples: List<Pair<String, Int>>): Map<String, Int> {
/**
 * Given a list of nested tuples, where each tuple contains two values (a key and a value),
 * create and return a dictionary where the key-value pairs are merged based on the intersection
 * of their keys.
 *
 * @param tuples A list of nested tuples, where each tuple contains a key-value pair.
 * @return A dictionary containing the merged key-value pairs from the nested tuples.
 */
fun mergeNestedTuples(tuples: List<Pair<String, Int>>): Map<String, Int> {

    val dictionary = mutableMapOf<String, Int>()
    for (nestedTuple in tuples) {
        val (key, value) = nestedTuple
        if (dictionary.containsKey(key)) {
            dictionary[key] = dictionary[key]!! + value
        } else {
            dictionary[key] = value
        }
    }
    return dictionary
}