Optimal resource allocation for competing epidemics over arbitrary networks