#C11210. Remove Duplicate Log Entries from Log File

    ID: 40502 Type: Default 1000ms 256MiB

Remove Duplicate Log Entries from Log File

Remove Duplicate Log Entries from Log File

You are given a log file containing multiple log entries. The first line of input contains an integer \( n \) which represents the number of log entries. The following \( n \) lines each contain a log entry. Some log entries may be duplicated. Your task is to remove duplicate log entries while preserving the order of their first occurrence.

Task: Given the log file as input from stdin, output the cleaned log file to stdout containing only the first occurrence of each log entry (duplicates removed). If \( n = 0 \), the output should be empty.

Note: The order of log entries in the output must match the order in which they first appear in the input.

inputFormat

The input is read from stdin and is formatted as follows:

  • The first line contains an integer \( n \), the number of log entries.
  • The next \( n \) lines each contain a single log entry.

outputFormat

Output the cleaned log file to stdout. Each unique log entry should be printed on its own line in the order of their first occurrence. If there are no entries (i.e. \( n = 0 \)), output nothing.

## sample
6
Started processing
Started processing
Completed processing
Database connection established
Started processing
Database connection closed
Started processing

Completed processing Database connection established Database connection closed

</p>