Dry hamster food is very cheap, with prices starting around $2 for a decent-sized bag. When choosing, check the labelling and ingredients. If you want a mix that supplies all the hamster's daily nutritional requirements, make sure the food you buy does just that. It's also best to avoid anything with added colorings, if possible.
Hamster food is pretty inexpensive, and your pet only needs a small amount at each feed
Be careful if buying loose foods. Although most of these are fine, you will need to check that the hopper the food is kept in looks clean, as any moisture or dirt can contaminate the food with bacteria and mould, both of which can harm your hamster. If the store keeps the loose food in airtight containers, that's a good start.