Let cupcakes = c and muffins = m.
c + m = 270
After 1/3 of cupcakes are sold (leaving 2c/3) and 18 more muffins are baked (m + 18), there are twice as many cupcakes as muffins:
2c/3 = 2(m + 18)
2c/3 = 2m + 36
c = 3m + 54
Substituting into the original equation:
3m + 54 + m = 270
4m = 216
m = 54 muffins
c = 3(54) + 54 = 216 cupcakes