How does summation over time samples influences DFT?
If the length of your data is $NM$ long (regardless of $N$), your DFT should be $NM$ long, so the correct equation is (1).

The explanation is simple: how long is your data? Use that length for the DFT.

You may want to define:
$$
y'_n = \left \{ \begin{array}{cl}
y_n, &amp;  0 \le n \le N-1\\
0, &amp;  n \ge N\\
\end{array}
\right .
$$
and operate on that because $y_n$ for $n\ge N$ is not defined.