To solve this optimization problem, we first need to define the decision variables and the objective function. Let's denote:

- $x_1$ as the number of hours the mall kiosk operates,
- $x_2$ as the number of hours the flagship store operates.

The objective is to minimize the total cost of operating both locations. The costs are $150 per hour for the mall kiosk and $500 per hour for the flagship store. Thus, the objective function can be written as:

Minimize: $150x_1 + 500x_2$

We have constraints based on the production capacity and demand requirements:

- For small gift boxes: $5x_1 + 10x_2 \geq 80$
- For medium gift boxes: $6x_1 + 15x_2 \geq 100$
- For large gift boxes: $2x_1 + 9x_2 \geq 50$

Additionally, $x_1$ and $x_2$ must be non-negative since they represent hours of operation.

Now, let's translate this into Gurobi code in Python:

```python
from gurobipy import *

# Create a model
m = Model("Candy_Gift_Boxes")

# Define decision variables
x1 = m.addVar(lb=0, vtype=GRB.CONTINUOUS, name="mall_kiosk_hours")
x2 = m.addVar(lb=0, vtype=GRB.CONTINUOUS, name="flagship_store_hours")

# Objective function: Minimize cost
m.setObjective(150*x1 + 500*x2, GRB.MINIMIZE)

# Constraints
m.addConstr(5*x1 + 10*x2 >= 80, "small_gift_boxes")
m.addConstr(6*x1 + 15*x2 >= 100, "medium_gift_boxes")
m.addConstr(2*x1 + 9*x2 >= 50, "large_gift_boxes")

# Optimize the model
m.optimize()

# Print results
if m.status == GRB.OPTIMAL:
    print("Optimal solution found:")
    print(f"Mall kiosk hours: {x1.x}")
    print(f"Flagship store hours: {x2.x}")
    print(f"Total cost: {m.objVal}")
else:
    print("No optimal solution found")

```