dont be too hard on urself, sometimes things just doesnt turn out the way we want it to be lol... i do get ur frustration, been there done that but theres no point worrying about it. Though if you didn't try at all and somehow got a really high mark, I congratulate you, not many people can do that and I can tell u right now a lot of people wished they could get a good mark without having to dedicate time to study.
The real question is to ask yourself, why and how. Why did u not study a lot? Was it because of lack of motivation? And how? How was it possible that you got a higher mark. It might be because it takes time to process things, and if you cram a lot, it will overload ur brain and on the day of the exam you actually might do worse due to the stress that you get.
Like, as in if you know u tried so hard, the pressure on you to do well increases BECAUSE your expectations increase too. Maybe when you weren't trying, there wasn't much to loose, and thus less pressure was on you to do well. Any maybe because of that lack of stress and lowered expectations caused youacutally do better in an exam.
again, idk just a thought
not much advice here but this is what i persoanlly thought when i was in ur situation