Number of ways to make a list for local elections Let's say a group of people consists of M male and F female candidates that should form a list of $n$ people for the upcoming elections. 
These rules apply:


*

*If the first person on the list is a man, than the second one should be a woman. (and vice versa)

*If the number of candidates n is even, then should the number of male candidates be equal to the number of female candidates on the list. 

*When $n$ is odd, the number of male and female candidates should only differ by one. 

*$n$ is between $1$ and $27$

*the position of the candidate on the list is important 


My first guess is/was this formula... $2\times M\times F$ ways to arrange a male and a female candidate on the first two places on the list. 
Two candidates are already chosen for the first two places so there are n-2 left. Half of them should be male and the other half of the group should be female candidates. From both groups, already one can't be chosen again, so for the male candidates we still should select $\tfrac{n-2}{2}$ for a place on our list out of $M-1$ men. (similar for the female candidates)...
$$
2\times M\times F\times{M-1\choose \tfrac{n-2}{2}}{F-1\choose \tfrac{n-2}{2}}
$$
Is this correct? I struggle to find a formula for n = odd, and if possible a formula where it doesn't matter if n is even or odd...
edit: m can be more or less than f and in such a situation, not all people can get a place on the list. For example let $f=10$ and $m=8$ and $n=17$
if $n=18$ and $f=10$ and $m=8$ then the result should be zero, cause it's against the law to form such a list. 
 A: To arrange such a list, it's enough to pick an ordered arrangement of the men, then an ordered arrangement of the women, then decide whether the first person in the combined list should be a man or a woman, then interleave the two lists accordingly.
Accordingly, if I understand your scenario:


*

*If $M=F$, then there are $2\cdot M! \cdot F!$ ways to arrange the candidates. 
($M!$ ways of arranging the men in order, $F!$ ways of arranging the women in order, 2 choices of which list to start with, and a deterministic interleaving process.)

*If $M$ and $F$ differ by 1, then there are just $M!\cdot F!$ ways to arrange the candidates, because the group with the greater numbers must be first.

*If they differ by a greater amount, then it is impossible to both interleave them and use all of the participants. Assuming the interleaved order is most important, we can derive the following formula:
When $M\neq F$, let $G\equiv \min(M,F)$ be the number of elements of the smaller group, and let $H\equiv \max(M,F)$ be the number of elements in the larger group. We can use exactly $G+1$ elements of the larger list. (Would you also want to count ways of making arrangements where you use only $G$ elements of the larger list? I wasn't sure) 
Hence there are $(G+1)! \cdot {H \choose (G+1)}$ ways of first picking and then arranging $G+1$ members of the larger group. There are then $G!$ ways of arranging the entirety of the smaller group. The two lists must be interleaved with the larger group being first. Overall, the number of ways of arranging them is:
$$\frac{G! \; H!}{(H-G-1)!}$$
when $M\neq F$.

*If $M\neq F$, suppose without loss of generality that $F>M$. Then we can make valid lists using $M+1$ elements from $F$, or we could alternatively make valid lists using just $M$ elements from $F$. If we want to count both ways of doing this, the formula is convenient:
$$\frac{G! \; H!}{(H-G-1)!} + \frac{2\;G! \; H!}{(H-G)!}$$
or better, through some rearrangement:
$$ \frac{G!\;H!\;(H-G+2)}{(H-G)!}$$
This formula itself seems to work for all cases of $M=F$ and $M\neq F$, provided you don't mind counting arrangements where you don't use as many of the larger group as possible.
