I'm feeling demotivated in my undergraduate course
Solution 1:
Who cares about your batchmates and what they can do? Stop comparing yourself to them and focus on the material.
You don't have to compete with anybody but yourself! I encourage you to make mathematics personal. Internalize mathematics in your own way, and continue with math because it gives you joy!
Soon enough, you'll be able to recite proofs orally.
Also, try to avoid looking up answers if you can. Study for $45-60$ minutes and then, if you can't figure something out, read a book or watch netflix and come back to it. You have to give your subconscious a chance to suss stuff out.
Right now, you're in a competitive environment. It can feel frustrating when others understand something a lot faster than you do. Try to remind yourself what the frustration can do to you though--it can disrupt the way you perceive your own abilities! Additionally, this frustration can turn into anxiety which can actually inhibit your learning to an uncomfortable degree.
Focus on your basic needs: sleep, diet, exercise, and meditation. You're already on the right track by asking for feedback here. I'm sure you'll make for a wonderful mathematician.
Solution 2:
Only one thing will decide how far you go in mathematics, which is how long you stick with it.
Everybody has their blind spots. Everybody has great strengths and greater weaknesses. Everybody knows so little about mathematics, that if they ever fully admitted it they would be humiliated.
There is also not one cause nor one cure for frustration, though it is often a sign that it is time for a break. To take an extreme example: Steve Vai, a virtuoso guitar player, has stressed the importance of taking breaks from the guitar of a year or more.
You don't necessarily need something so extreme, but the point remains: it's okay to get sick of something you love, and it might even be better to see what life is like without it than it is to keep pushing yourself until you hate it.
At the very least, try to look at some of your struggles as opportunities for growth. Everybody, without exception, eventually runs up against their own limitations, and situations where they are no longer the best. Those limitations are not the end of one's career. On the contrary, success comes from reckoning with those limitations.