Print max no of recent duplicate words
You loop from the first element to the last, and in each iteration you check if a next element exists or not. This check will only be false on the last element, it will be true for all elements before that. In other words, most of the time the check is unnecessary. 

To get rid of this redundancy, you could start the iteration from the second element, and make comparisons with the previous one, which always exists. No more redundant checks.

More importantly, keep in mind that you don't need to read the entire input into memory to find the most frequent repetition. You don't need a vector. You could just parse the input word by word, always keeping only the last word in memory for comparisons. That way you will drastically reduce the memory footprint of the program.