After baking cookies, Lucy had 500 – 240 = <<500-240=260>>260g of flour left.
She accidentally spilled half of this, which means she had 260 * 0.5 = <<260*0.5=130>>130g of flour left.
She therefore needs 500 – 130 = <<500-130=370>>370g of flour.
#### 370