You just have to hit all the checkboxes the residency program directors look for:
1. High Step 1 score: 240+ gets you in the door at the vast majority of top programs
2. 3rd year grades: the more Honors, the better. Especially in medicine and surgery
3. Research - More you publish, the better. Also acceptable: posters and presentations
4. Letters of Recommendation - make sure they're in the field you're applying to and from a big-wig in the field. Also, its best if they know you well and can write a more in-depth rather than superficial and generic letter. How do you do this? Identify a mentor as soon as possible and start shadowing them, volunteering at their clinic, and possibly doing research with them.
5. AOA - better hit the books, son
6. Go to a prestigious school. Look at the match lists thread. There is a world of difference between the UPenn list and the SUNY Downstate list. There is nary a single match on the Penn list that isnt at a top 20 institution. You think that every single person at Penn is that much better than an average student at Downstate? Prestige matters.
Obviously all the above works out best if you can identify what specialty you'd like to pursue early. It allows you to set up research, mentorships, and away rotations early and puts you in the best position to match at your ideal program.
Source: it worked for me!