This algorithm fails in the case that the duplicated number appears more than twice in the list, which is explicitly allowed by the problem statement.
The actual sum is 8, and the 4th triangular number is 10, so the duplicated number according to your algorithm must be -2 (or some fraction thereof, depending on how you calculate m).