Let x be the number of cupcakes and y be the number of cookies sold. We can write a system of equations:
total of 250 cupcakes and cookies ==> x + y = 250 . (1)
total cost was $506 ==> 3.5x + 1.25y = 506 . (2)
We can multiply equation (1) by 5 and equation (2) by -4:
5x + 5y = 1250
-14x - 5y = -2024
Adding, we get -9x = -774, so x = 86 and y = 164.
You baked 86 cupcakes and 164 cookies.