/**
 * Write a function that takes a dictionary as input and counts the total number of elements in it.
 *
 * @param dictionary A dictionary containing various elements.
 * @return The total number of elements in the dictionary.
 * @throws IllegalArgumentException If the input is not a dictionary.
 */
fun countElements(dictionary: Map<*, *>): Int {

    if (dictionary !is Map<*, *>) {
        throw IllegalArgumentException("Input must be a dictionary.")
    }

    var count = 0
    for ((key, value) in dictionary) {
        if (value is Map<*, *>) {
            count += countElements(value)
        } else {
            count += 1
        }
    }
    return count
}
/**
 * Write a function that takes a dictionary as input and counts the total number of elements in it.
 *
 * @param dictionary A dictionary containing various elements.
 * @return The total number of elements in the dictionary.
 * @throws IllegalArgumentException If the input is not a dictionary.
 */
fun countElements(dictionary: Map<*, *>): Int {
/**
 * Write a function that takes a dictionary as input and counts the total number of elements in it.
 *
 * @param dictionary A dictionary containing various elements.
 * @return The total number of elements in the dictionary.
 * @throws IllegalArgumentException If the input is not a dictionary.
 */
fun countElements(dictionary: Map<*, *>): Int {

    if (dictionary !is Map<*, *>) {
        throw IllegalArgumentException("Input must be a dictionary.")
    }

    var count = 0
    for ((key, value) in dictionary) {
        if (value is Map<*, *>) {
            count += countElements(value)
        } else {
            count += 1
        }
    }
    return count
}