Russian skater Kamila Valieva, who had tested positive for a banned drug, finished fourth in the women’s free skate in a stunning upset.