#K38672. Return to Origin

    ID: 26251 Type: Default 1000ms 256MiB

Return to Origin

Return to Origin

A robot is located at the origin (0, 0) on an infinite 2D grid. The robot receives a sequence of instructions, where each instruction is one of the following characters:

  • U: move up (increase y coordinate)
  • D: move down (decrease y coordinate)
  • L: move left (decrease x coordinate)
  • R: move right (increase x coordinate)

The task is to determine whether the robot returns to the origin after executing all moves.

Formally, if the initial position of the robot is \( (0, 0) \) and after executing the moves the position becomes \( (x, y) \), then the answer is "YES" if \( x = 0 \) and \( y = 0 \); otherwise, the answer is "NO".

Read the input from stdin and output the result to stdout.

inputFormat

The input is a single line containing a string of characters ('U', 'D', 'L', and 'R') with no spaces. Each character represents a move by the robot.

Example: UDLR

outputFormat

Output a single line: "YES" if the robot returns to the origin after all moves, or "NO" otherwise.

Example: For input UD, the output should be YES.

## sample
UD
YES

</p>