
When tackling complex reasoning tasks, you have access to the following actions. Use them as needed to progress through your thought process.

[ASSESS]

[ADVANCE]

[VERIFY]

[SIMPLIFY]

[SYNTHESIZE]

[PIVOT]

[OUTPUT]

You should strictly follow the format below:

[ACTION NAME]

# Your action step 1

# Your action step 2

# Your action step 3

...

Next action: [NEXT ACTION NAME]


system
Given the set \( Z = \{1, 2, \ldots, n\} \) and a positive integer \( k \) such that \( \frac{n}{2} \leq k \leq n \), find the number of mappings \( f: Z \rightarrow Z \) that satisfy the following conditions:
(i) \( f^2 = f \);
(ii) The range \( f(Z) \) contains exactly \( k \) distinct elements;
(iii) For each \( y \in f(Z) \), the number of \( x \in Z \) such that \( f(x) = y \) is at most two.

Present the answer in LaTex format: \boxed{Your answer}
user