Giving a bad exam is not causing ur depression mate but what u are telling youself about it. I can show u so many students who give very bad exams still they are happy. Why? because they dont do their self-downing because of it. U need to know the reality that giving a bad exam or not being in top 50 has got nothing to do with ur worth. It doesnt make u inferior or less of a person but its your own thought process about it. U feel nervous because u demand good score as if not getting it would be the end of the world for u. Making urself depressed by ur crooked thought process wont help. Accept urself with the bad score and do something to improve it next time not to feel good about urself but just to get a good score.