Fix copy_n to increment only n-1 times for an input iterator.  This works much better with std::istream_iterator<int>(std::cin).  Credit: Matan Nassau.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@126581 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/algorithm b/include/algorithm
index d91c57c..4909221 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -1559,8 +1559,17 @@
 >::type
 copy_n(_InputIterator __first, _Size __n, _OutputIterator __result)
 {
-    for (; __n > 0; --__n, ++__first, ++__result)
+    if (__n > 0)
+    {
         *__result = *__first;
+        ++__result;
+        for (--__n; __n > 0; --__n)
+        {
+            ++__first;
+            *__result = *__first;
+            ++__result;
+        }
+    }
     return __result;
 }