Molecular dynamics investigation of the structural flexibility of H2O2 and H2S2 in response to medium polarity