#K12276. Spaceship Return to Origin

    ID: 23655 Type: Default 1000ms 256MiB

Spaceship Return to Origin

Spaceship Return to Origin

You are given a string of commands that instruct a spaceship to move in a 2D plane. The spaceship starts at the origin \((0,0)\) and initially faces North. The commands are given as a sequence of characters where:

  • G means to move forward one unit in the direction it is currently facing.
  • L means to turn left (90 degrees counter-clockwise).
  • R means to turn right (90 degrees clockwise).

Your task is to determine whether the spaceship returns to the origin after executing the entire sequence of commands. If it returns to the origin, output Yes, otherwise output No.

Note: An empty command string means the spaceship stays at the origin.

inputFormat

The input consists of a single line containing a non-empty string of characters. Each character is either G, L, or R. The string may be empty, which indicates that there is no movement.

outputFormat

Output a single line with the string Yes if the spaceship returns to the origin \((0,0)\) after executing all commands, and No otherwise.

## sample
GLGLGLG
Yes