/**
 * Given a dictionary 'data" containing information about the occurrence of animal species,
 * count the number of times each species appears in the dataset.
 *
 * @param data A dictionary where the keys are species names (strings) and the values are lists
 *             of locations (strings) where the species was observed.
 * @return A dictionary where the keys are species names (strings) and the values are
 *         the counts (integers) of occurrences of each species in the dataset.
 */
fun countSpeciesOccurrence(data: Map<String, List<String>>): Map<String, Int> {

    val count = mutableMapOf<String, Int>()
    for ((species, locations) in data) {
        if (species !in count) {
            count[species] = 0
        }
        for (location in locations) {
            count[species] = count.getOrDefault(species, 0) + 1
        }
    }
    return count
}
/**
 * Given a dictionary 'data" containing information about the occurrence of animal species,
 * count the number of times each species appears in the dataset.
 *
 * @param data A dictionary where the keys are species names (strings) and the values are lists
 *             of locations (strings) where the species was observed.
 * @return A dictionary where the keys are species names (strings) and the values are
 *         the counts (integers) of occurrences of each species in the dataset.
 */
fun countSpeciesOccurrence(data: Map<String, List<String>>): Map<String, Int> {
/**
 * Given a dictionary 'data" containing information about the occurrence of animal species,
 * count the number of times each species appears in the dataset.
 *
 * @param data A dictionary where the keys are species names (strings) and the values are lists
 *             of locations (strings) where the species was observed.
 * @return A dictionary where the keys are species names (strings) and the values are
 *         the counts (integers) of occurrences of each species in the dataset.
 */
fun countSpeciesOccurrence(data: Map<String, List<String>>): Map<String, Int> {

    val count = mutableMapOf<String, Int>()
    for ((species, locations) in data) {
        if (species !in count) {
            count[species] = 0
        }
        for (location in locations) {
            count[species] = count.getOrDefault(species, 0) + 1
        }
    }
    return count
}