We know that in a collision the momentum of the system is conserved, that is:

In this case, since the railroad cars coupled together and have the same mass we have:

Now, we know the initial velocity of the cars, one is traveling at 5 m/s and the other is at rest; plugging the values and solving for the final velocity we have:

Therefore, the velocity of the combined cars is 2.5 m/s