#K76547. Robot Return to Origin
Robot Return to Origin
Robot Return to Origin
The robot starts at the origin point \( (0, 0) \). It follows a series of commands represented as a string, where each character instructs the robot to move one unit in one of the four cardinal directions: 'U' for up, 'D' for down, 'L' for left, and 'R' for right.
After executing all the commands, determine whether the robot returns to its starting point. In other words, if we let the net horizontal displacement be \( x \) and the net vertical displacement be \( y \), the robot is back at the origin if and only if \( x = 0 \) and \( y = 0 \).
inputFormat
The input consists of a single line containing a string of characters, each of which is one of 'U', 'D', 'L', or 'R', representing the robot's moves.
outputFormat
Output a single line: print "Yes" if the robot returns to the origin after executing all the commands, or "No" if it does not.
## sampleUDLR
Yes