Let

be the chocolate chip cookies, so the peanut butter treats will be

.
We know that the cookies and the treats are in a ratio of 5:3, so:

Now we can solve for

:






We now know Lydia has 90 chocolate chip cookies, and

peanut butter treats.
Then, Lydia's friend ate

of her cookies, so her friend ate

cookies. Therefore, Lydia has

cookies left.
Now we can calculate the total amount of baked goods after her friend ate the cookies:

Therefore, our remainder treats will be:

We also now that after her friend ate 54 cookies and some treats, the new ratio is 6:1, and that's all we need to set up our new equation and solve it to find how many treats she ate:






Finally, if she ate 81 out 90 treats, we can conclude the Lydia has left with 9 peanut butter treats.