Solution 1:

Flat is used in British English, and apartment is used in North American English. The exact meaning of the word apartment depends on where you live.

In large parts of Canada and in or near New York City, it is used for a residence in a multi-unit building; this meaning is the one given by OALD, and is a synonym of the British word flat.

In most of the rest of the U.S. and on the West Coast of Canada, the word apartment is reserved for a rented residence in a multi-unit building; if the residences in the building are individually owned, they are called condos.

As Ben Hocking says in his comment, an apartment doesn't have to be on just one story (although the majority of them are). But if you live in a multistory residence which doesn't have anything either above or below your unit, even though there are residences attached on both sides, this is more commonly called a townhouse. If there are just two residences in the same building, you have a duplex.

See also this question.

Solution 2:

No, it's not that clear-cut.

Both words are used in the UK: a "flat" would generally be a fairly 'ordinary' residence that doesn't constitute the entire space within a building, whereas an "apartment" tends to imply a similar concept, but more luxurious. As I understand, "flat" is rarely used in the US.

Solution 3:

An answer based on British English:

There are several components to this: number of storeys; sole-use versus shared-use buildings; and the target market.

As the OALD says, flats tend to be flat - i.e. on just one floor of a building. And they imply that they don't have sole use of the building - that there are other units in the same building; either other dwellings, a shop, offices, whatever.

If it's got more than one storey, but does not have sole use of the building, then it's a maisonette.

If a flat or maisonette is being sold/rented to an international market, it tends to get called an apartment, as that's better understood in International English.

If it's the sole use of a one-storey building (i.e. if the dwelling occupies the entire building), it's not a flat, it's a bungalow.

If it's the sole use of a building with more than one storey, then it's not a maisonette, it's a house. Bungalows are sometimes considered to be a subset of houses.