So I am a final year math student and there are two questions here, 1) I am a math student but all of my research has been in CS. If I do pursue a CS degree it will be in something mathematical like cryptography, but I really have no clue. Should I be applying to Math or CS departments? Does it matter in the long run? 2) How do you know what range of schools is appropriate to be applying to? I have 4.0 gpa, REUs at Cornell and UCLA, 1 publication from other research at home institution, top percentile on GRE, but I come from a poor undergrad school. That is, given say 10 applications, how would you distribute them between top 20 schools, top 20-50 schools, etc? I know rank-centric sorting may not be most accurate measure, but I don't see another easy way to partition good vs not-as-good.