Traveler’s diarrhea pills. Picked up some from a travel clinic before I came to Mexico and did not regret it.
The ones I have are 3 pills per occurrence, take one pill every day, and I have enough for three “episodes,” (so 9 pills total).
I’ve been here nearly three months, eat a TON of street food and have only needed them once. Can you get them here? Probably. But they’re cheap, don’t take up much space in your bag, and when you need them you’re not really going to be in the mood to go to the pharmacy and explain in a language you don’t understand what you need.
Also, make sure you get all of your vaccines. If you find a travel clinic and tell them the places you’ll be going, they’ll tell you what you need. The major cities in Central America tend to be fine, but you’ll find a lot more disease in the rural areas.
I don’t know much about Costa Rica, but having spent some time in El Salvador I know that there are a lot of stray dogs pretty much everywhere so rabies is something you’ll also want to think about. Rabies shots are EXPENSIVE, though, in the states, and you need three injections over 28 days, so you may want to think about doing this once you get to Costa Rica instead. Will you need it? Probably not, but it is something that you’ll want to think about now rather than after you’ve been bitten by something!