Under construction

Still being built. Things may change

Remove Duplicates

Time limit5sMemory limit8 MB

Summary
Read a space-separated list whose length is not given, keep each value only at its first occurrence, and print the surviving values in order.
Level

Medium4 of 10

Topics
Hash map, Array, Implementation, Bit manipulation
Solved
No attempts yet

Problem

You are given NN integers A1,A2,…,ANA_1, A_2, \ldots, A_N. Remove every number that has already appeared earlier, and print the remaining N′N' numbers B1,B2,…,BN′B_1, B_2, \ldots, B_{N'} in input order. In other words, each value is printed once, at the position where it first appears.

  1. 0≤Ai<225=335544320 \le A_i < 2^{25} = 33554432 for i=1,2,…,Ni = 1, 2, \ldots, N.
  2. The count NN is between 1 and 5,000,000 inclusive.

Input

The first line contains A1,A2,…,ANA_1, A_2, \ldots, A_N separated by spaces. NN itself is not given.

Output

Print B1,B2,…,BN′B_1, B_2, \ldots, B_{N'} on one line, separated by spaces.

Hint

Watch the memory limit.

Examples2

  1. Example 1

    Input
    12 1 449 12 555 1201 912 555 19372
    
    Expected output
    12 1 449 555 1201 912 19372
    
  2. Example 2

    Input
    21003957 20891590 11382885 18340118 11354168 5461061 12693617 2552341 14639514 25224366 19239852 136782 17206566 18675414 9536557 24961835 2507460 32083310 4485200 19506627 21087117 9270314 12953612 10216350 8170712 20436397 11382885 29305594 27169105
    
    Expected output
    21003957 20891590 11382885 18340118 11354168 5461061 12693617 2552341 14639514 25224366 19239852 136782 17206566 18675414 9536557 24961835 2507460 32083310 4485200 19506627 21087117 9270314 12953612 10216350 8170712 20436397 29305594 27169105