They are pretty much the same. A key difference between the -hat/-het suffix and a tud construction is that the former only refers to the ability, while tud can also refer to the knowledge about an action:
- Nem táncolhatok. - I cannot dance. For some reason I'm unable to dance, either physically, mentally, or I am not allowed.
- Nem tudok táncolni. - I am either unable to dance or I don't know how to dance.
Since "I do not know how to stay here" would require a rather uncommon situation, though, both your sentences are pretty equivalent.
I think it's more like possibility (-hat/-het) and ability (tud). If you aren't allowed to stay here or something explicitly rules out the possibility of you staying here, you will aim for the first one. If you simply aren't able to do it because of lack of skill or something keeps you from it, you may go for the second one.
They are forms of the same verb, yes. Tud is a very flexible word that can mean "know" or "know how to do something" or "be able to do something" among other things.
Nem tudok itt maradni uses the (1st person singular) indefinite form because tud does not have any definite object here.
Nem tudom use the 1st person singular definite form. Even though there's no object visible in the sentence, the definite form of the verb implies one. The sentence is saying "I don't know (it)" or "I don't know (the answer to the question)" or "I don't know (that)."
I think that's a common myth about "know how to" being an accurate translation of "tud csinálni". "know how to do something" would actually be "tudja, hogy kell valamit csinálni", about theoretical knowledge rather than ability. This myth will be really hard to destroy, apparently people have a hard time accepting that "tud" simply has two meanings in English that really depend on the arguments in use - with an infinitive, it's always can.