It works better if you assume birth cohorts were exceptionally small at the end of the war and extremely large afterwards. It is canon that there were over 100 students taking OWLs with Severus. So Harry's year and Ginny's year would have 40 students each, the next one, with the beginning of recovery at the tail end of the year, would have, say 50 students, followed by years of 150-200 students (post-war baby boom). The years above Harry's would have the usual 100 students per year. Using these numbers in OOTP there would have been 630-730 students at Hogwarts. (Don't ask how the teachers managed larger cohorts.)
Note that the oldest baby-boom students would be 4th years at the time of the battle, the same age Ginny and Luna were during the DOM battle. One could imagine any number of them sneaking back from the Hog's Head to participate in the battle to add to the number of defenders.
Note that the oldest baby-boom students would be 4th years at the time of the battle, the same age Ginny and Luna were during the DOM battle. One could imagine any number of them sneaking back from the Hog's Head to participate in the battle to add to the number of defenders.