class ShoppingList(dict):
    def __init__(self, data):
        return super().__init__(data)

    def multiply(self, k: float):
        new_ingredients = self.copy()
        for key,value in new_ingredients.items():
            new_ingredients[key] = value * k
        return new_ingredients

    def add(self, ingredients: dict):
        new_ingredients = self.copy()
        for key1,value1 in self.items():
            for key2,value2 in ingredients.items():
                if key1 == key2:
                    new_ingredients[key1] = value1 + value2
                elif key2 not in new_ingredients:
                    new_ingredients.update({key2: value2})
        return new_ingredients

    def __add__(self, other):
        new_list = self.copy()
        for key1,value1 in self.items():
            for key2,value2 in other.items():
                if key1 == key2:
                    new_list[key1] = value1 + value2
                    break
                elif key2 not in new_list:
                    new_list.update({key2: value2})
        return new_list

    def __mul__(self, other):
        new_list = self.copy()
        for key1,value1 in self.items():
            for key2,value2 in other.items():
                if key1 == key2:
                    new_list[key1] = value1 * value2
                    break
                elif key2 not in new_list:
                    new_list.update({key2: value2})
        return new_list

def multiply_ingredients(ingredients: dict, k: float) -> dict:
    new_ingredients = ingredients.copy()
    for key,value in new_ingredients.items():
        new_ingredients[key] = value * k
    return new_ingredients


def add_ingredients(ingredients1: dict, ingredients2: dict) -> dict:
    new_ingredients = ingredients1.copy()
    for key1,value1 in ingredients1.items():
        for key2,value2 in ingredients2.items():
            if key1 == key2:
                new_ingredients[key1] = value1 + value2
            elif key2 not in new_ingredients:
                new_ingredients.update({key2: value2})
    return new_ingredients


soup = {'onion': 1, 'potato': 2, 'water': 2.5, 'meat': 0.5}
salad = {'potato': 2, 'meat': 0.3, 'mayonaise': 0.1, 'peas': 200}
#soup + 2 * salad  # словари так не умеют :(

new_soup = ShoppingList(soup)
new_salad = ShoppingList(salad)

print(new_soup + new_salad)
print(new_soup * new_salad)
print(new_soup.add(new_salad))
print(add_ingredients(soup, salad))
