This is a bit complicated, but I'll do my best to cover everything. I'll start with 'can'.
'Can' essentially indicates ability. Usually it's used for general ability, although nowadays more and more people also use it to indicate permission. For example:
He can play piano.
I can drive a car.
Can you come to the party tomorrow?
The past tense of 'can' is 'could'. For example:
He could play piano when he was a child.
I could drive a car when I was 16 years old.
Here's where it gets tricky - 'could' is also used to indicate possibility or talk about options. It usually indicates about 50% certainty and means that something may or may not happen. For example:
I could go to the party tonight if I wanted to.
Where's John? I don't know, he could be upstairs.
Take an umbrella, it could rain later.
'Could' is also used to ask for permission or request favors politely. For example:
Could you get me a glass of water?
Could I use your pen?
The past tense of 'could' is 'could have' (often shortened to could've) and because of the 'have' it takes the participle form of the verb. When used in the past it has the connotation that there was the option to do something in the past, but that action was not taken. For example:
I could have gone to the party yesterday. (But I didn't)
He could have told her the secret. (But he didn't)
Lastly, 'managed to' has the very specific meaning that the subject was able to do something that was very difficult or unlikely. For example:
There was a fire in the building, but everyone managed to evacuate safely.
The police managed to catch the bank robbers yesterday.
I stayed up all night studying and managed to pass my history test.
Hope that was clear and not too overwhelming. If you need any clarifications let me know!