Failure. It seems almost wrong that one word, a short, easily said one at that, incorporates so much pain. But such is life, and such is failure. Of course, failure is hard, but that's only because failure is always personal. Sure, you can blame that failure on any number of people, but the consequences of the failure will always be on you. You failed a test because you didn't study, that hurts. You failed a test because you didn't know there was one, that hurts too. And you can blame the teacher for not preparing you, but my guess? They won't care, and you'll still have failed.
So yeah failure hurts. And it hurts because no matter how far in advance you know it's coming, there is no way to prepare for the disappointment failure brings. You know you won't get that position you've been dying for because there are much more qualified people applying for it. It doesn't make failing to get it hurt any less. It doesn't make the rejection, and the failure, any easier to take.
So what can you do to avoid failure? Nothing. If you do anything at all in your whole life you will fail. If you try for anything, try at anything, you will fail. Not all the time, but sometime. And it will hurt. But what's important is that you continue to try, even if you know you'll fail again. All you can do, all you must do is keep going and keep pushing through, because the only thing worse than failure because you tried, is failure because you didn't do anything at all.
So maybe you won't get into that amazing program, or maybe you'll fail to get the A in that class no matter how hard you try, how many office hours you go to, no matter what, but you'll get back up and try again. And somewhere along the way you'll succeed. And you will feel so much more accomplished because you have failed in the past. The lows will make you appreciate the highs, and you'll look back and be so much stronger for that failure. Plus, you'll have another talking point for those interviews where you get asked about a failure in your life and how you dealt with it. So here's hoping that until you succeed, you fail beautifully, and that when you do succeed you can look back and say "I only wish I'd failed more often."