This is taken from a practice quiz by my university.
I ruled out that aabbbaab is not part of the grammar:
S → aSb → aaSbb... This shows that I can't make this word because it would have to have atleast two b's at the end in order for me to add more letters
Then I tried to see if abbaabb can be derived from the grammar and I experienced the same thing:
S → aSb → aaSbb... This shows that I can't make a word with two b's at the end without having at least two a's in the beginning
Finally, I tried to do aabaabbb:
S → aSb → aaSbb → aaSSbb → aaSaSbbb... I decided it can't be this one because even if I make aaSaSbbb into ϵ, I still need to find a way to make aaSaSbbb into ba so I can derive the word. It doesn't seem like I can do that.
So by elimination I thought the correct answer was aabaabb but I was wrong.
Please show me how to work out whether a word can be derived from a grammar.