It depends on the specialty and the residency program. For most programs, leadership positions such as class president, group presidents, important committees (eg academic committee, admissions committee) etc are looked upon favorably by most residency programs. However, they should not be done at the cost of studying and getting good grades and getting a good USMLE score. Teaching and research opportunities are good too, because those show a dedication towards academics and academic programs are the ones that are competetive. For certain primary care programs such as ones in family practice, they will look upon things like community service favorably, but you should realize that most family practice and primary care (internal medicine primary care and pediatrics primary care/ community) programs are very aggressively trying to recruit students right now because most aren't filling, so you shouldn't worry too much about matching into those specialties. I don't think that most surgical or specialty programs care very much if you do a lot of community service, but I haven't heard this from any authorative source, this is just what my classmates who are applying for these specialties tell me. For those programs, in general, the order of importance is AOA/grades, LOR's, USMLE, research, and then leadership positions (which can actually factor into your election into AOA).