/**
 * Calculate the total profit of all accounts.
 * @param accounts a list of account dictionaries, each containing the 'name' and 'profit' keys
 * @return the total profit
 */
fun totalProfit(accounts: List<Map<String, Any>>): Int {

    var total = 0  // Variable to store the total profit
    
    for (account in accounts) {
        if (!account.containsKey("profit")) {
            // Complete the code to raise an exception if 'profit' key is missing in any account dictionary
            throw IllegalArgumentException("Missing 'profit' key in account dictionary!")
        }
        
        // Complete the code to check if the 'profit' is a positive number
        if (account["profit"] is Int && account["profit"] as Int > 0) {
            // Update the total profit
            total += account["profit"] as Int
        }
    }

    return total
}
/**
 * Calculate the total profit of all accounts.
 * @param accounts a list of account dictionaries, each containing the 'name' and 'profit' keys
 * @return the total profit
 */
fun totalProfit(accounts: List<Map<String, Any>>): Int {
/**
 * Calculate the total profit of all accounts.
 * @param accounts a list of account dictionaries, each containing the 'name' and 'profit' keys
 * @return the total profit
 */
fun totalProfit(accounts: List<Map<String, Any>>): Int {

    var total = 0  // Variable to store the total profit
    
    for (account in accounts) {
        if (!account.containsKey("profit")) {
            // Complete the code to raise an exception if 'profit' key is missing in any account dictionary
            throw IllegalArgumentException("Missing 'profit' key in account dictionary!")
        }
        
        // Complete the code to check if the 'profit' is a positive number
        if (account["profit"] is Int && account["profit"] as Int > 0) {
            // Update the total profit
            total += account["profit"] as Int
        }
    }

    return total
}