Removing duplicates from a sorted vector with counting

C++ Medium vectors

Task «Removing duplicates from a sorted vector with counting»

Given a vector of integers sorted in ascending order. It is necessary to remove all duplicates, leaving only unique elements, but at the same time count how many times each number appeared in the original vector. Output the result as two vectors: the first contains the unique numbers, the second contains their count. Use std::vector and algorithms.

Input Format

In the first line, an integer N (1 ≤ N ≤ 1000) — the number of elements. In the second line, N integers sorted in ascending order, each not exceeding 10^9 in absolute value.

Output Format

In the first line, an integer K — the number of unique elements. In the second line, K integers — the unique elements in ascending order. In the third line, K integers — the number of repetitions of each element.

Examples

Example 1

INPUT
5 10 10 10 10 10
OUTPUT
1 10 5
main.cpp