einfallen
to occur to
An idea or memory suddenly comes to mind. The verb is often used with a dative object.
Mir ist gerade eingefallen, dass ich noch meine Mutter anrufen wollte.
It just occurred to me that I still wanted to call my mother.

to occur to / collapse / invade
Loading your saved state.
to occur to
An idea or memory suddenly comes to mind. The verb is often used with a dative object.
Mir ist gerade eingefallen, dass ich noch meine Mutter anrufen wollte.
It just occurred to me that I still wanted to call my mother.

'Einfallen' (to occur to / collapse / invade) is a separable verb. The prefix 'ein-' comes at the end of the main clause, while in a subordinate clause it remains attached to the verb.
Plötzlich fällt mir die Lösung ein.
Suddenly the solution occurs to me.
The perfect tense of 'einfallen' (to occur to / collapse / invade) is always formed with the auxiliary verb 'sein' for all meanings. This is because the base verb 'fallen' (to fall) describes a change of state or movement.
Mir ist eine gute Idee eingefallen.
A good idea occurred to me.
You can recognize the very different meanings from the subject and the sentence structure. A person in the dative points to an idea. A building as the subject points to collapse, and troops as the subject point to an invasion.
Dem Autor ist ein besserer Titel für sein Buch eingefallen.
The author thought of a better title for his book.
When an idea or memory comes to mind, the person who has the idea is in the dative. The thing that occurs to someone is the subject in the nominative.
Was fällt dir zu diesem Thema ein?
What occurs to you on this topic?
In the meaning 'eindringen' (to enter / penetrate), 'einfallen' is almost always used with the preposition 'in' and the accusative to name the target of the invasion.
Historische Berichte beschreiben, wie die Wikinger in England eingefallen sind.
Historical accounts describe how the Vikings invaded England.
The past participle 'eingefallen' (sunken) is often used as an adjective to describe a thin, hollow face or cheeks. It then comes directly before the noun.
Nach seiner langen Krankheit hatte er ein schmales, eingefallenes Gesicht.
After his long illness, he had a narrow, sunken face.
to come
'kommen' and 'einfallen' can both have to do with ideas or memories. With 'auf etwas kommen', you are often looking for an idea, solution, or answer and then find it. With 'einfallen', an idea or memory suddenly comes into your head, often without much thought. Learners confuse the words because both talk about thoughts. The grammar is important: you say 'ich komme auf eine Idee' (I think of an idea), but 'mir fällt eine Idee ein' (an idea occurs to me). So 'einfallen' often uses the dative for the person.

Mir fällt im Bus plötzlich der Name des Restaurants ein.
On the bus, the name of the restaurant suddenly occurs to me.
Nach langem Überlegen kommt Maria auf eine einfache Lösung.
After thinking for a long time, Maria comes up with a simple solution.