#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1218
Task: ,

Write a Python function that converts a given nested dictionary into a flat dictionary with keys joined by a hyphen, preserving the original values in a list if multiple entries share the same flat
Generated: 2026-02-13T00:36:14.271985
"""

def flatten_dict(nested_dict, parent_key="", flat_dict=None):
    if flat_dict is None:
        flat_dict = {}
    for key, value in nested_dict.items():
        new_key = f"{parent_key}-{key}" if parent_key else key
        if isinstance(value, dict):
            flatten_dict(value, new_key, flat_dict)
        else:
            if new_key in flat_dict:
                if isinstance(flat_dict[new_key], list):
                    flat_dict[new_key].append(value)
                else:
                    flat_dict[new_key] = [flat_dict[new_key], value]
            else:
                flat_dict[new_key] = value
    return flat_dict


if __name__ == "__main__":
    test_data = {
        "a": {
            "b": 1,
            "c": {
                "d": 2,
                "e": 3
            }
        },
        "a": {
            "f": 4
        }
    }
    result = flatten_dict(test_data)
    for key, value in result.items():
        print(f"{key}: {value}")