#C1385. Robot Return to Origin

    ID: 43433 Type: Default 1000ms 256MiB

Robot Return to Origin

Robot Return to Origin

Given a sequence of moves represented by the characters 'U', 'D', 'L', and 'R', determine whether a robot starting from the origin \((0,0)\) will return to the origin after completing its moves. Each move updates the robot's position as follows:

  • 'U': Increment the y-coordinate by 1.
  • 'D': Decrement the y-coordinate by 1.
  • 'L': Decrement the x-coordinate by 1.
  • 'R': Increment the x-coordinate by 1.

The robot returns to the origin if its final position \((x,y)\) satisfies \(x=0 \text{ and } y=0\).

inputFormat

The input is provided via standard input (stdin) as a single line string. This string represents the sequence of moves, where each character is one of 'U', 'D', 'L', or 'R'.

outputFormat

Output a single line to standard output (stdout). Print "True" if the robot returns to the origin after executing the provided moves; otherwise, output "False".

## sample
UD
True