<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _add_resources(data, runtime):
 """Merge input resources with current CWL runtime parameters. """

    if "config" not in data:
        data["config"] = {}
    # Convert input resources, which may be a JSON string
    resources = data.get("resources", {}) or {}
    if isinstance(resources, six.string_types) and resources.startswith(("{", "[")):
        resources = json.loads(resources)
        data["resources"] = resources
    assert isinstance(resources, dict), (resources, data)
    data["config"]["resources"] = resources
    # Add in memory and core usage from CWL
    memory = int(float(runtime["ram"]) / float(runtime["cores"]))
    data["config"]["resources"].update({"default": {"cores": int(runtime["cores"]),
                                                    "memory": "%sM" % memory,
                                                    "jvm_opts": ["-Xms%sm" % min(1000, memory // 2),
                                                                    "-Xmx%sm" % memory]}})
    data["config"]["algorithm"]["num_cores"] = int(runtime["cores"])
    return data