The students were not listening to the teacher then.
The students were not listening to the teacher then. の文で、the students の代わりに students と言えるか、という質問ですね。
この場合は、the students と言います。
もし students と言うと、学生一般を指します。
ここでは先生の言うことを聞いていなかった生徒のことを言っているので、the students と the をつけてあげる必要があります。
the students ということで、その先生の言うことを聞いていなかった生徒、例えばそのクラスにいた生徒を指すことになります。
ご参考まで!