LogiQuest

203. Simplify Unix Path

MediumStack

Simplify an absolute Unix path: resolve . and .., collapse multiple slashes and remove a trailing slash.

Input format

A single path starting with /.

Output format

The canonical path.

Example 1

Input

/home/

Output

/home

Example 2

Input

/../

Output

/

Constraints

1 ≤ length ≤ 3000

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…