If you force me to give one definite answer, I would say:
Women are slightly more important to preserving a nation as a cultural community; men have historically been more important to preserving the machinery of the state.
And in the exact scenario you gave—one sex largely disappears and the survivors reproduce with foreigners—I would expect a country that retains most of its native women to preserve its original culture more successfully across the next generation than one that retains most of its native men.
The reason is that cultural transmission happens very heavily in childhood. The people who shape a child's first language, everyday customs, food, stories, religion, manners, family identity, and sense of "who we are" tend historically to be mothers and the maternal household. That does not mean fathers are unimportant; it means that, on average, maternal influence on early socialization is unusually strong.
So imagine two extreme cases.
In Country A, most native men die, but native women remain and marry foreign men. If the women stay embedded in their own villages, extended families, schools, churches, and language environment, their children can very easily grow up thinking of themselves as members of the mother's nation. The foreign fathers can assimilate into the majority culture around them.
In Country B, most native women disappear, and native men marry large numbers of foreign women. The native men may retain political power, surnames, property, military institutions, and national mythology, but now a large share of children are being raised from infancy by mothers who may speak another language and carry another set of domestic traditions. Assimilation can still happen, but the state has to work harder through schools, religion, military service, and public institutions to reproduce the old culture.
So for cultural continuity, I'd give the edge to women.
Where men historically had the stronger role was in state continuity. For most of recorded history, men disproportionately controlled armies, police, political offices, taxation, landholding, diplomacy, and elite administration. If a medieval kingdom suddenly lost 80–90% of its adult men, the immediate survival of its government and military could be in much greater danger than if it lost the same percentage of women.
But that is primarily an institutional/historical fact, not something inherent to male biology. In a modern state, women can obviously operate ministries, armed forces, courts, businesses, police, and infrastructure, so that difference becomes much smaller.
There is also an important distinction between nation and state.
A state can survive even while the population's culture changes dramatically. Empires did this constantly.
A nation can also survive without its own state if language, religion, historical memory, and community institutions continue.
If you made me compress the answer into one sentence:
Men historically carried more of the formal machinery of state power, but women have probably been slightly more important for reproducing the nation's culture from one generation to the next.
And therefore, in your hypothetical, I would expect native women + foreign men to preserve the original national identity somewhat more successfully than native men + foreign women, assuming all other conditions were equal.