Add to this if you know any others: this information is stupidly hard to find, and it saves buying expensive pre-cut Brompton cable sets.
The exact measurements are on the instructions that come with each cable, or you could measure one that is definitely known to be correct.
M-type, SWB rear brake cable: 1303mm
M-type, SWB rear hub gear cable: 1288mm
The LWB M-type rear cables are approximately 8mm longer (although the wheelbase is more like an inch longer).