Keep It Simple - Stick to simple past.
A: Before he came to the factory, Tom studied at the University of London.
Using past perfect (had come) places the narrative focus further back in time. Once you've started with that, you can't refer to anything earlier without also using past perfect, so OP's #1 is incorrect.
In this case, since studying predates coming to the factory, you could reasonably refer to the earlier action with past tense:
B: Before he came to the factory, Tom had studied at the university of London.
It would be (just about) possible to use had come in B. But it serves no purpose unless the narrative context primarily concerns other events in the past which are all later than both studying and coming to the factory. That's a complex literary context which probably isn't relevant here, so just forget about it.
If OP wants to use past continuous for the studying (I see no good reason for that here, and it seems "stilted" at best), I might prefer to see that same verb form reflected in the initial clause:
C: Before coming to the factory, Tom was studying at the university of London.
Note that A, B would be just as good with the "progressive/continuous" participle (coming), and C would be just as bad with simple past (he came). Although I must admit, "bad" is perhaps putting it too strongly; there are contexts where competent writers would use #3, but I don't think learners need concern themselves with this form until they've mastered the "standard" usages.
This is a tricky question. The native ear will immediately recognize that "had been remained" is not correct. The had should be followed by a past participle. Remained and been are both past participles; you can use one or the other, but not both.
So, either of these could be used to start the sentence:
- He had been president for 20 years...
- He had remained president for 20 years...
This issue gets tricky, however, when you switch to the passive voice. In that case, you can use he had been followed by a past participle, as in:
- He had been elected 20 years ago...
That's a valid formation, and it's listed as the past perfect passive verb form in this table1:
So, the question becomes, why can the verb elected be used in this way, but not the verb remained?
The key is that the sentence with elected is using the passive construction, but the sentence with remained has an active construction. As Dave Sperling says on his ESL website:
Because subjects of passive verbs receive the action, verbs that cannot have objects (intransitive verbs) do not have passive forms.
If you look up the words in a dictionary, you'll see that elect is transitive, and remain is intransitive, which is why had been remained sounds so awkward to the native ear, while had been elected sounds just fine – although many native speakers might have a hard time explaining why.
Now, you can explain it for them: "It's because remained is an intransitive verb, so it cannot be used in the passive voice."
Best Answer
In the first sentence you use a present participle: some people also call it an active participle. You use it to talking about something that you are doing.
The second sentence uses a past participle: some people call it a passive participle. You use it to talk about something that is being done to you.
This is probably not the meaning that you intend, so let's rule out sentence 2.
Sentence 1 is past perfect continuous: it says that you were doing something for a period of time (three years) before some event in the past (reaching level B).
Sentence 3 is past simple: you did something for an unspecified period of time, and you completed it three years before you reached level B.
Sentence 1 is closer to what you probably meant, but there is no real need to use past perfect continuous: you could just change sentence 3 from simple past to past continuous and add a for:
Note that the to after reached is not required.