The term schadenfreude literally means damage-joy. When one enjoys the news that a rival is encountering trouble, one is experiencing a sense of schadenfreude. Most of us have experienced this feeling at some point in our lives, but most of us also have been jerks at some point in our lives, and the two sometimes come at the same time.
There is no real-world term for its opposite, so some people have begun to use a made-up word, freudenschade, to describe the distress one feels when a friend or rival is doing well or has had a success.
And then there are some people, I am thinking of the late Gore Vidal here, who appear to take pleasure at others’ distress at one’s success. Vidal confessed to feelings of schadenfreude over other writers’ freudenschade. (That is as hard to type as it is to say.)