Problem:


Score : 300 points

Problem Statement

Dolphin resides in two-dimensional Cartesian plane, with the positive x-axis pointing right and the positive y-axis pointing up.

Currently, he is located at the point (sx,sy). In each second, he can move up, down, left or right by a distance of 1.

Here, both the x- and y-coordinates before and after each movement must be integers.

He will first visit the point (tx,ty) where sx < tx and sy < ty, then go back to the point (sx,sy), then visit the point (tx,ty) again, and lastly go back to the point (sx,sy).

Here, during the whole travel, he is not allowed to pass through the same point more than once, except the points (sx,sy) and (tx,ty).

Under this condition, find a shortest path for him.  

Constraints

-1000 ≤ sx < tx ≤ 1000 

-1000 ≤ sy < ty ≤ 1000 

sx,sy,tx and ty are integers.

Input

The input is given from Standard Input in the following format:

sx sy tx ty

Output

Print a string S that represents a shortest path for Dolphin.

The i-th character in S should correspond to his i-th movement.

The directions of the movements should be indicated by the following characters:  

U: Up

D: Down

L: Left

R: Right

If there exist multiple shortest paths under the condition, print any of them.

Sample Input 1

0 0 1 2

Sample Output 1

UURDDLLUUURRDRDDDLLU

One possible shortest path is:

Going from (sx,sy) to (tx,ty) for the first time: (0,0) → (0,1) → (0,2) → (1,2)

Going from (tx,ty) to (sx,sy) for the first time: (1,2) → (1,1) → (1,0) → (0,0)

Going from (sx,sy) to (tx,ty) for the second time: (0,0) → (-1,0) → (-1,1) → (-1,2) → (-1,3) → (0,3) → (1,3) → (1,2)

Going from (tx,ty) to (sx,sy) for the second time: (1,2) → (2,2) → (2,1) → (2,0) → (2,-1) → (1,-1) → (0,-1) → (0,0)

Sample Input 2

-2 -2 1 1

Sample Output 2

UURRURRDDDLLDLLULUUURRURRDDDLLDL



Sample input:
0 0 1 2


Sample output:
UURDDLLUUURRDRDDDLLU

Submission status: Accepted

Solution code:
a, b, c, d = map(int, input().split())
ans = ""
ans += "U" * (d-b) + "R" * (c-a) + "D" * \
    (d-b) + "L" * (c-a+1) + "U"*(d-b+1) + \
    "R"*(c-a+1)+"DR"+"D"*(d-b+1)+"L"*(c-a+1)+"U"
print(ans)

Submission status: Accepted

Solution code:

def main():
    buf = input()
    buflist = buf.split()
    sx = int(buflist[0])
    sy = int(buflist[1])
    tx = int(buflist[2])
    ty = int(buflist[3])
    xdiff = tx - sx
    ydiff = ty - sy
    movement = ""
    movement += "R" * xdiff
    movement += "U" * ydiff
    movement += "L" * xdiff
    movement += "D" * ydiff
    movement += "D"
    movement += "R" * (xdiff+1)
    movement += "U" * (ydiff+1)
    movement += "L"
    movement += "U"
    movement += "L" * (xdiff+1)
    movement += "D" * (ydiff+1)
    movement += "R"
    print(movement)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

sx, sy, tx, ty = map(int, raw_input().split())

S = ''
S += 'R' * (tx - sx)
S += 'U' * (ty - sy)
S += 'L' * (tx - sx)
S += 'D' * (ty - sy)
S += 'D'
S += 'R' * (tx - sx + 1)
S += 'U' * (ty - sy + 1)
S += 'L'
S += 'U'
S += 'L' * (tx - sx + 1)
S += 'D' * (ty - sy + 1)
S += 'R'

print S

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
ans1 = "R"*(tx-sx) + "U"*(ty-sy)
ans2 = "L"*(tx-sx) + "D"*(ty-sy)
ans3 = "D" + "R"*(tx-sx+1) + "U"*(ty-sy+1) + "L"
ans4 = "U" + "L"*(tx-sx+1) + "D"*(ty-sy+1) + "R"

print(ans1+ans2+ans3+ans4)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

dx, dy = tx - sx, ty - sy
print('U' * dy + 'R' * (dx + 1) + 'D' * (dy + 1) + 'L' * (dx + 1) + 'U' + \
      'R' * dx + 'U' * (dy + 1) + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R')

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]

sx,sy,tx,ty = inpl()

uplen = ty - sy
rightlen = tx - sx

print('U' * uplen + 'R' * rightlen +
      'D' * uplen + 'L' * (rightlen + 1) +
      'U' * (uplen + 1) + 'R' * (rightlen + 1) + 'D' +
      'R' + 'D' * (uplen + 1) + 'L' * (rightlen + 1) + 'U' )

Submission status: Accepted

Solution code:
a,b,c,d = map(int, input().split())
x,y = c-a,d-b
s = "U"*y+"R"*x+"D"*y+"L"*x
s += "L"+"U"*(y+1)+"R"*(x+1)+"DR"+"D"*(y+1)+"L"*(x+1)+"U"
print(s)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans = ''
# s to t
ans += 'U' * dy
ans += 'R' * dx
# t to s
ans += 'D' * dy
ans += 'L' * (dx+1)
# s tp t part2
ans += 'U' * (dy+1)
ans += 'R' * (dx+1)
ans += 'D'
# t to s part2
ans += 'R' 
ans += 'D' * (dy+1)
ans += 'L' * (dx+1)
ans += 'U'

print(ans)

Submission status: Accepted

Solution code:
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

sx, sy, tx,ty = getList()
xdis = tx-sx
ydis = ty-sy

move = []
move = move + ["R"] * xdis
move = move + ["U"] * ydis
move = move + ["L"] * xdis
move = move + ["D"] * ydis
move = move + ["D"]
move = move + ["R"] * (xdis+1)
move = move + ["U"] * (ydis+1)
move = move + ["L"]
move = move + ["U"]
move = move + ["L"] * (xdis+1)
move = move + ["D"] * (ydis+1)
move = move + ["R"]

print("".join(move))

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())

x = tx-sx
y = ty-sy

ans = ''
ans += 'U'*y
ans += 'R'*x
ans += 'D'*y
ans += 'L'*(x+1)
ans += 'U'*(y+1)
ans += 'R'*(x+1)
ans += 'D'
ans += 'R'
ans += 'D'*(y+1)
ans += 'L'*(x+1)
ans += 'U'

print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(i) for i in input().split()]

dx = tx - sx
dy = ty - sy

ans = 'U' * dy + 'R' * dx
ans += 'D' * dy + 'L' * dx
ans += 'L' + 'U' * (dy+1) + 'R' * (dx+1) + 'D'
ans += 'R' + 'D' * (dy+1) + 'L' * (dx+1) + 'U'

print(ans)

Submission status: Accepted

Solution code:
S = [0,0]
T = [0,0]

S[0],S[1],T[0],T[1]= map(int,input().split())

del_x = T[0] - S[0]
del_y = T[1] - S[1]

ans = ''

ans = 'R'*del_x + 'U'*del_y + 'L'*del_x + 'D'*del_y

ans = ans + 'D' + 'R'*(del_x+1) + 'U'*(del_y+1) + 'L'

ans = ans + 'U' + 'L'*(del_x+1) + 'D'*(del_y+1) + 'R'
print(ans)

Submission status: Accepted

Solution code:
S = list(map(int,input().split()))
sx = S[0]
sy = S[1]
tx = S[2]
ty = S[3]

dx = tx - sx
dy = ty - sy
path = ''
path += 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
path += 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
path += 'U'*dy + 'R'*dx
path += 'D'*dy + 'L'*dx

print(path)

Submission status: Accepted

Solution code:
#! /usr/bin/python
# Back and Forth

"""
    −1000≦sx<tx≦1000
    −1000≦sy<ty≦1000
    sx,sy,tx,ty
    は整数である。
"""

test_mode = False

sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
abs_dx = abs(dx)
abs_dy = abs(dy)

if test_mode:
    print('dx = {}'.format(dx))
    print('dy = {}'.format(dy))
    print('abs_dx = {}'.format(abs_dx))
    print('abs_dy = {}'.format(abs_dy))


def course_type(x, y):
    """
    x, y について
        0: x,y 両方が でない
        1: x   だけが 0
        2: y   だけが 0
        3: x,y 両方が 0
    を返す。入力は絶対値でよろしく。
    """
    if x != 0 and y != 0:
        return 0
    if x == 0 and y != 0:
        return 1
    if x != 0 and y == 0:
        return 2
    return 3


def course_temp(x, y):
    """
    とりあえず (0, 0)→(x, y) の2往復のしかたを返す関数。
    x,y >= 0 とすること。※第1象限で考えるため
    """

    s = ''
    flag = course_type(x, y)

    if flag == 0: # 2点が線分上にない場合
        # ここから 1往復目
        for _ in range(x):
            s += 'R'
        for _ in range(y+1):
            s += 'U'
        for _ in range(x+1):
            s += 'L'
        for _ in range(y+1):
            s += 'D'
        s += 'R'
        # ここまで 1往復目
        # ここから 2往復目
        s += 'D'
        for _ in range(x+1):
            s += 'R'
        for _ in range(y+1):
            s += 'U'
        for _ in range(x+1):
            s += 'L'
        for _ in range(y):
            s += 'D'
        # ここまで 2往復目

    elif flag == 1:
        # ここから 1往復目
        for _ in range(y+1):
            s += 'U'
        s += 'L'
        s += 'L'
        for _ in range(y+2):
            s += 'D'
        s += 'R'
        s += 'R'
        s += 'U'
        # ここまで 1往復目
        # ここから 2往復目
        s += 'R'
        for _ in range(y):
            s += 'U'
        s += 'L'
        s += 'L'
        for _ in range(y):
            s += 'D'
        s += 'R'
        # ここまで 2往復目

    elif flag == 2:
        # ここから 1往復目
        for _ in range(y+1):
            s += 'R'
        s += 'U'
        s += 'U'
        for _ in range(y+2):
            s += 'L'
        s += 'D'
        s += 'D'
        s += 'R'
        # ここまで 1往復目
        # ここから 2往復目
        s += 'D'
        for _ in range(y):
            s += 'R'
        s += 'U'
        s += 'U'
        for _ in range(y):
            s += 'L'
        s += 'D'
        # ここまで 2往復目

    else:
        pass

    return s


def convert(s):
    """
    dx, dy の符号に応じて 文字列s を変換して返す関数
    """
    if dx >= 0:
        pass
    else:
        s.translate(str.maketrans('RL', 'LR', )) # x方向の移動を反転
    if dy >= 0:
        pass
    else:
        s.translate(str.maketrans('UD', 'DU', )) # y方向の移動を反転

    return s


def main():
    """
    全体の処理を実行する関数
    """
    course = course_temp(abs_dx, abs_dy)
    if test_mode:
        print('course:', course)

    course = convert(course)
    if test_mode:
        print('course:', course)
    print(course)


if __name__ == '__main__':
    main()


"""
参考
    Pythonで文字列を置換（replace, translate, re.sub, re.subn）
    https://note.nkmk.me/python-str-replace-translate-re-sub/
"""

Submission status: Accepted

Solution code:
x1, y1, x2, y2 = map(int, input().split())
x = x2-x1
y = y2-y1
s = "R"*x + "U"*y + "L"*x + "D"*(y+1) + "R"*(x+1) + "U"*(y+1) + "LU" + "L"*(x+1) + "D"*(y+1) + "R"
print(s)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
ans_list = []
for i in range(tx - sx):
    ans_list.append("R")
for j in range(ty-sy):
    ans_list.append("U")
for i in range(tx - sx):
    ans_list.append("L")
for j in range(ty-sy):
    ans_list.append("D")
ans_list.append("D")
for i in range(tx - sx + 1):
    ans_list.append("R")
for j in range(ty-sy + 1):
    ans_list.append("U")
ans_list.append("L")
ans_list.append("U")
for i in range(tx - sx + 1):
    ans_list.append("L")
for j in range(ty-sy + 1):
    ans_list.append("D")
ans_list.append("R")
print("".join(ans_list))

Submission status: Accepted

Solution code:
sx, sy , tx, ty = map(int, input().split())
x = tx - sx
y = ty - sy
ans = "U" * y + "R" * x + "D" * y + "L" * x
ans += "L" + "U" * (y + 1) + "R" * (x + 1) + "D"
ans += "R" + "D" * (y + 1) + "L" * (x + 1) + "U"
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

xmove, ymove = tx - sx, ty- sy
move = "U"*ymove + "R" * xmove + "D" * ymove + "L" * xmove
move += "L" + "U" * (ymove+1) + "R" * (xmove+1) + "DR" + "D" * (ymove+1) + "L" * (xmove+1) + "U"
print(move)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,raw_input().split())

x =tx-sx
y =ty-sy

ans=""
ans+=x*"R"
ans+=y*"U"
ans+=x*"L"
ans+=y*"D"

ans+="L"
ans+="U"*(y+1)
ans+="R"*(x+1)
ans+="D"
ans+="R"
ans+="D"*(y+1)
ans+="L"*(x+1)
ans+="U"

print ans

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
for i in range(tx - sx):
    print("R", end = "")

for i in range(ty - sy):
    print("U", end = "")

print("R", end = "")

for i in range(ty - sy + 1):
    print("D", end = "")

for i in range(tx - sx + 1):
    print("L", end = "")

print("UU", end = "")

for i in range(tx - sx - 1):
    print("R", end = "")

for i in range(ty - sy - 1):
    print("U", end = "")

print("RU", end = "")

for i in range(tx - sx + 1):
    print("L", end = "")

for i in range(ty - sy + 1):
    print("D", end = "")

print("R", end = "")
print()

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-

sx, sy, tx, ty = [int(i) for i in input().split()]
dx, dy = tx - sx, ty - sy
path = []

# 1
path += ['R'] * dx
path += ['U'] * dy
path += ['L'] * dx
path += ['D'] * dy

# 2
path += ['D']
path += ['R'] * (dx + 1)
path += ['U'] * (dy + 1)
path += ['L', 'U']
path += ['L'] * (dx + 1)
path += ['D'] * (dy + 1)
path += ['R']

print(''.join(path))

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    sx, sy, tx, ty = map(int, input().split())

    dy, dx = ty - sy, tx - sx
    ans = ""
    ans += dx * "R" + dy * "U"
    ans += "R" + (1 + dy) * "D" + (1 + dx) * "L" + "U"
    ans += dy * "U" + dx * "R"
    ans += "U" + (1 + dx) * "L" + (1 + dy) * "D" + "R"
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
print('U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx)+'LU'+'U'*(ty-sy)+'R'*(tx-sx)+'RDRD'+'D'*(ty-sy)+'L'*(tx-sx)+'LU')

Submission status: Accepted

Solution code:
ai = lambda: list(map(int, input().split()))

sx, sy, tx, ty = ai()
dx,dy = tx-sx, ty-sy

ans = ''
ans += 'R'*dx; ans += 'U'*dy
ans += 'L'*dx; ans += 'D'*(dy+1)

ans += 'R'*(dx+1); ans += 'U'*(dy+1); ans += 'L'
ans += 'U'
ans += 'L'*(dx+1); ans += 'D'*(dy+1); ans += 'R'
print(ans)

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split());l="URDL";e,f=d-b,c-a;print("".join([l[i]*e+l[i+1]*(f) for i in[0,2]]+[l[(j+3)%4]+l[j]*(e+1)+l[j+1]*(f+1)+l[(j+2)%4] for j in[0,2]]))

Submission status: Accepted

Solution code:
p=lambda x:print(x,end="");a,b,c,d=map(int,input().split());l="URDL";e,f=d-b,c-a;
for i in[0,2]:p(l[i]*e+l[i+1]*(f))
for i in[0,2]:p(l[(i+3)%4]+l[i]*(e+1)+l[i+1]*(f+1)+l[(i+2)%4])

Submission status: Accepted

Solution code:
p=lambda x:print(x,end="")
a,b,c,d=map(int,input().split())
l="URDL"
e,f=d-b,c-a
for i in[0,2]:p(l[i]*e+l[i+1]*(f))
for i in[0,2]:p(l[(i+3)%4]+l[i]*(e+1)+l[i+1]*(f+1)+l[(i+2)%4])

Submission status: Accepted

Solution code:
a=lambda x:print(x,end="")
sx,sy,tx,ty=map(int,input().split())
l=["U","R","D","L"]
for i in[0,2]:
 a(l[i]*(ty-sy))
 a(l[i+1]*(tx-sx))
for i in[0,2]:
 a(l[(i+3)%4])
 a(l[i]*(ty-sy+1))
 a(l[i+1]*(tx-sx+1))
 a(l[(i+2)%4])

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
a=["U","R","D","L"]
for i in[0,2]:
 print(a[i]*(ty-sy),end="")
 print(a[i+1]*(tx-sx),end="")
for i in[0,2]:
 print(a[(i+3)%4],end="")
 print(a[i]*(ty-sy+1),end="")
 print(a[i+1]*(tx-sx+1),end="")
 print(a[(i+2)%4],end="")

Submission status: Accepted

Solution code:
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

sx, sy, tx, ty = il()
a = ["U", "R", "D", "L"]
for i in [0, 2]:
    print(a[i] * (ty-sy), end="")
    print(a[i+1] * (tx-sx), end="")
for i in [0, 2]:
    print(a[(i+3)%4], end="")
    print(a[i] * (ty-sy+1), end="")
    print(a[i+1] * (tx-sx+1), end="")
    print(a[(i+2)%4], end="")

Submission status: Accepted

Solution code:
xy = list(map(int, input().split()))

x = xy[2]-xy[0]
y = xy[3]-xy[1]

print("R"*x+"U"*y, end="")
print("L"*x+"D"*y, end="")
print("D"+"R"*(x+1)+"U"*(y+1)+"L",end="")
print("U"+"L"*(x+1)+"D"*(y+1)+"R",end="")

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split())

print("R" * (tx-sx) + "U" * (ty-sy), end="")
print("L" * (tx-sx) + "D" * (ty-sy), end="")
print("D" + "R" * (tx-sx+1) + "U" * (ty-sy+1) + "L", end="")
print("U" + "L" * (tx-sx+1) + "D" * (ty-sy+1) + "R", end="")

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
a=(tx-sx)*"R"+(ty-sy)*"U"
a=a+a.replace("R","L").replace("U","D")
b="D"+(tx-sx+1)*"R"+(ty-sy+1)*"U"+"L"
b=b+b.translate(str.maketrans({"D":"U","U":"D","R":"L","L":"R"}))
print(a+b)

Submission status: Accepted

Solution code:
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys

LEFT = "L"
RIGHT = "R"
UP = "U"
DOWN = "D"

def move(x,y):
    xs = RIGHT*x if x > 0 else LEFT*(-x)
    ys = UP*y if y > 0 else DOWN*(-y)
    return ys + xs

def main():
    sx, sy, tx, ty = map(int,sys.stdin.read().split())

    x = tx - sx
    y = ty - sy

    ans = ""
    ans += move(x,y)
    ans += move(-x,-y)
    ans += LEFT + move(x+1,y+1) + DOWN
    ans += RIGHT + move(-(x+1),-(y+1)) + UP

    sys.stdout.write(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def move(x,y):
    xs = "R"*x if x > 0 else "L"*(-x)
    ys = "U"*y if y > 0 else "D"*(-y)
    return (xs, ys)

def main():
    sx, sy, tx, ty = map(int,sys.stdin.read().split())
    x = tx - sx
    y = ty - sy

    xs, ys = move(x,y)
    ans = ys + xs

    xs, ys = move(-x,-y)
    ans += ys + xs

    xs, ys = move(x+1,y+1)
    ans += "L" + ys + xs + "D" 

    xs, ys = move(-(x+1),-(y+1))
    ans += "R" + ys + xs + "U" 

    sys.stdout.write(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
 
a="U"*dy+"R"*dx
b="D"*dy+"L"*dx
c="L"+"U"*(dy+1)+"R"*(dx+1)+"D"
d="R"+"D"*(dy+1)+"L"*(dx+1)+"U"
print(a+b+c+d)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int,input().split())
dx,dy = abs(sx-tx), abs(sy-ty)
fx,bx = 'RL' if sx < tx else 'LR'
fy,by = 'UD' if sy < ty else 'DU'
ans = ''
ans += fy*dy + fx*dx
ans += by*dy + bx*(dx+1)
ans += fy*(dy+1) + fx*(dx+1) + by
ans += fx + by*(dy+1) + bx*(dx+1) + fy
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

ans = "U"*dy + "R"*dx + "D"*dy + "L"*(dx+1) + "U"*(dy+1) \
        + "R"*(dx+1) + "D" + "R" + "D"*(dy+1) + "L"*(dx+1) + "U"
        
print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int, input().split())
h=ty-sy
w=tx-sx
print("L"+"U"*(h+1)+"R"*(w+1)+"DR"+"D"*(h+1)+"L"*(w+1)+
      "U"*(h+1)+"R"*w+"D"*h+"L"*w)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int ,input().split(" "))
reco = []
reco.append((ty-sy)*"U"+(tx-sx)*"R")
reco.append((ty-sy)*"D"+(tx-sx)*"L")
reco.append("L"+(ty-sy+1)*"U"+(tx-sx+1)*"R"+"D")
reco.append("R"+(ty-sy+1)*"D"+(tx-sx+1)*"L"+"U")
print("".join(reco))

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
x=tx-sx
y=ty-sy
for i in range(x):
    print('R',end='')
for i in range(y):
    print('U',end='') 
for i in range(x):
    print('L',end='') 
for i in range(y):
    print('D',end='')
print('D',end='')
for i in range(x+1):
    print('R',end='')
for i in range(y+1):
    print('U',end='')
print('L',end='')
print('U',end='')
for i in range(x+1):
    print('L',end='')
for i in range(y+1):
    print('D',end='')
print('R',end='')

Submission status: Accepted

Solution code:
sx, sy, tx, ty = list(map(int, input().split()))
s = []
s.append('R'*(tx-sx)+'U'*(ty-sy))
s.append('L'*(tx-sx)+'D'*(ty-sy))
s.append('D'+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L')
s.append('U'+'L'*(tx-sx+1)+'D'*(ty-sy+1)+'R')
ans = ''.join(s)
print(ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty=map(int,input().split())
ux=tx-sx
uy=ty-sy
S_ans=str('')
S_forw_x=str('')
S_forw_y=str('')
S_back_x=str('')
S_back_y=str('')
for i in range(ux):
    S_forw_x=S_forw_x+'R'
    S_back_x=S_back_x+'L'
for i in range(uy):
    S_forw_y=S_forw_y+'U'
    S_back_y=S_back_y+'D'
S_ans=S_forw_x+S_forw_y+S_back_x+S_back_y+'D'+S_forw_x+'RU'+S_forw_y+'LU'+S_back_x+'LD'+S_back_y+'R'
print(S_ans)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

yu = "U" * (ty - sy)
xr = "R" * (tx - sx)
yd = "D" * (ty - sy)
xl = "L" * (tx - sx)

print(yu + xr + yd + xl + "L" + yu + "U" + xr + "R" + "D" + "R" + yd + "D" + xl + "L" + "U")

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int ,input().split())
rec = []
rec.append((tx - sx) * "R" + (ty - sy) * "U")
rec.append((tx - sx) * "L" + (ty - sy) * "D")
rec.append("D" + (tx - sx + 1) * "R" + (ty - sy + 1) * "U" + "L")
rec.append("U" + (tx - sx + 1) * "L" + (ty - sy + 1) * "D" + "R")

print("".join(map(str, rec)))

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split());w=c-a;h=d-b;print(h*'U'+w*'R'+h*'D'+(w+1)*'L'+(h+1)*'U'+(w+1)*'R'+'D'+'R'+(h+1)*'D'+(w+1)*'L'+'U')

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
X = tx - sx
Y = ty - sy
S = ''
S += 'R' * X
S += 'U' * Y
S += 'L' * X
S += 'D' * (Y + 1)
S += 'R' * (X + 1)
S += 'U' * (Y + 1)
S += 'LU'
S += 'L' * (X + 1)
S += 'D' * (Y + 1)
S += 'R'
print(S)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

print(
      'U' * (ty - sy) + 'R' * (tx - sx) +
      'D' * (ty - sy) + 'L' * (tx - sx) +
      'L' + 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1) + 'D' +
      'R' + 'D' * (ty - sy + 1) + 'L' * (tx - sx + 1) + 'U'
     )

Submission status: Accepted

Solution code:

def main():
    sx, sy, tx, ty = map(int,input().split())

    x = tx -sx
    y = ty -sy

    ans = "U"*y + "R"*x + "D"*y + "L"*(x+1) + "U"*(y+1)+ "R"*(x+1)+"D"+"R"+"D"*(y+1)+"L"*(x+1)+"U"
    print(ans)

if __name__ == "__main__":
        main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
tx -= sx
ty -= sy

r = 'U' * ty + 'R' * tx + 'D' * ty + 'L' * (tx+1) + \
    'U' * (ty+1) + 'R' * (tx+1) + 'DR' + 'D' * (ty+1) + 'L' * (tx+1) + 'U'
print(r)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

dx = abs(tx - sx)
dy = abs(ty - sy)

ans = ''

ans += 'R' * dx
ans += 'U' * dy

ans += 'L' * dx
ans += 'D' * dy

ans += 'D'
ans += 'R' * (dx + 1)
ans += 'U' * (dy + 1)
ans += 'L'

ans += 'U'
ans += 'L' * (dx + 1)
ans += 'D' * (dy + 1)
ans += 'R'

print(ans)

Submission status: Accepted

Solution code:
sx,sy,tx,ty = map(int, raw_input().split())
r = ""
r += "L"+"U"*(ty-sy+1)+"R"*(tx-sx+1)+"D"
r += "R"+"D"*(ty-sy+1)+"L"*(tx-sx+1)+"U"
r += "U"*(ty-sy)+"R"*(tx-sx)
r += "D"*(ty-sy)+"L"*(tx-sx)
print r

Submission status: Accepted

Solution code:
sx, sy, tx, ty = list(map(int, input().split()))

x_diff = tx - sx
y_diff = ty - sy

S = []
for i in range(x_diff):
    S.append("R")
for i in range(y_diff):
    S.append("U")
for i in range(x_diff):
    S.append("L")
for i in range(y_diff):
    S.append("D")
S.append("L")
for i in range(y_diff + 1):
    S.append("U")
for i in range(x_diff + 1):
    S.append("R")
S.append("D")
S.append("R")
for i in range(y_diff + 1):
    S.append("D")
for i in range(x_diff + 1):
    S.append("L")
S.append("U")
print(''.join(S))

Submission status: Accepted

Solution code:
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy

a="U"*dy+"R"*dx
b="D"*dy+"L"*dx
c="L"+"U"*(dy+1)+"R"*(dx+1)+"D"
d="R"+"D"*(dy+1)+"L"*(dx+1)+"U"
print(a+b+c+d)

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-

def main():
    sx, sy, tx, ty = map(int, input().split())

    diff = [tx - sx, ty - sy]
    for i in range(diff[1]):
        print('U', end='')
    for i in range(diff[0]):
        print('R', end='')
    for i in range(diff[1]):
        print('D', end='')
    for i in range(diff[0]):
        print('L', end='')
    
    print('L', end='')

    for i in range(diff[1] + 1):
        print('U', end='')
    for i in range(diff[0] + 1):
        print('R', end='')
    
    print('D', end='')

    print('R', end='')

    for i in range(diff[1] + 1):
        print('D', end='')
    for i in range(diff[0] + 1):
        print('L', end='')

    print('U', end='')
    print('')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    sx, sy, tx, ty = map(int, input().split())
    result = "U" * (ty - sy)
    result += "R" * (tx - sx)
    result += "D" * (ty - sy)
    result += "L" * (tx - sx)

    result += "L"
    result += "U" * (ty - sy + 1)
    result += "R" * (tx - sx + 1)
    result += "D"
    result += "R"
    result += "D" * (ty - sy + 1)
    result += "L" * (tx - sx + 1)
    result += "U"
    print(result)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
print('U' * (ty - sy) + 'R' * (tx - sx), end='')
print('D' * (ty - sy) + 'L' * (tx - sx), end='')
print('D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L', end='')
print('U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R')

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

yoko = tx - sx
tate = ty - sy

ans1 = ""
ans2 = ""

ans2 += "LU"

for i in range(tate):
    ans1 += "U"
    ans2 += "U"
for i in range(yoko):
    ans1 += "R"
    ans2 += "R"

ans2 +="RDRD"

for i in range(tate):
    ans1 += "D"
    ans2 += "D"
for i in range(yoko):
    ans1 += "L"
    ans2 += "L"

ans2 += "LU"

print(ans1 + ans2)

Submission status: Accepted

Solution code:
def main():
    sx, sy, tx, ty = map(int, raw_input().split())

    dy = ty-sy
    dx = tx-sx
    result = ''
    for i in range(dy):
        result += 'U'
    for i in range(dx):
        result += 'R'
    for i in range(dy):
        result += 'D'
    for i in range(dx):
        result += 'L'
    result += 'L'
    for i in range(dy+1):
        result += 'U'
    for i in range(dx+1):
        result += 'R'
    result += 'D'
    result += 'R'
    for i in range(dy+1):
        result += 'D'
    for i in range(dx+1):
        result += 'L'
    result += 'U'
    print result

main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

dx = tx - sx
dy = ty - sy

if dx > 0 and dy > 0:
    ptn = ['U', 'R', 'D', 'L', 0]
elif dx < 0 and dy > 0:
    ptn = ['U', 'L', 'D', 'R', 0]
elif dx > 0 and dy < 0:
    ptn = ['D', 'R', 'U', 'L', 0]
elif dx < 0 and dy < 0:
    ptn = ['D', 'L', 'U', 'R', 0]
elif dx == 0 and dy > 0:
    ptn = ['U', 'R', 'D', 'L', 1]
elif dx == 0 and dy < 0:
    ptn = ['D', 'R', 'U', 'L', 1]
elif dx > 0 and dy == 0:
    ptn = ['U', 'R', 'D', 'L', 2]
elif dx < 0 and dy == 0:
    ptn = ['D', 'R', 'U', 'L', 2]

ans = ''
if ptn[4] == 0:
    ans += ptn[0] * dy
    ans += ptn[1] * dx

    ans += ptn[2] * dy
    ans += ptn[3] * dx

    ans += ptn[3]
    ans += ptn[0] * (dy + 1)
    ans += ptn[1] * (dx + 1)
    ans += ptn[2]

    ans += ptn[1]
    ans += ptn[2] * (dy + 1)
    ans += ptn[3] * (dx + 1)
    ans += ptn[0]
elif ptn[4] == 1:
    ans += ptn[0] * dy

    ans += ptn[1]
    ans += ptn[2] * dy
    ans += ptn[3]

    ans += ptn[4]
    ans += ptn[0]
    ans += ptn[1]

    ans += ptn[0]
    ans += ptn[1] * 2
    ans += ptn[2] * (dy + 2)
    ans += ptn[3] * 2
    ans += ptn[0]
else:
    ans += ptn[1] * dx

    ans += ptn[0]
    ans += ptn[3] * dx
    ans += ptn[2]

    ans += ptn[2]
    ans += ptn[1] * dx
    ans += ptn[0]

    ans += ptn[1]
    ans += ptn[0] * 2
    ans += ptn[3] * (dy + 2)
    ans += ptn[2] * 2
    ans += ptn[1]
print(ans)

Submission status: Accepted

Solution code:

def main():
    sx, sy, tx, ty = map(int,input().split())

    x = tx - sx
    y = ty - sy

    ans = "U" * y + "R"*x + "D"*y + "L"*x + "L" + "U" * (y+1) + "R"*(x+1) + "D"+"R"+ "D"*(y+1) + "L"*(x+1) + "U"
    print(ans)

if __name__ == "__main__":
        main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split(" "))

x1 = tx - sx
y1 = ty - sy

l1 = ["U"] * y1 + ["R"] * x1 + ["D"] * y1 + ["L"] * x1
l2 = ["L"] * 1 + ["U"] * (y1 + 1) + ["R"] * (x1 + 1) + ["D"] * 1 + \
     ["R"] * 1 + ["D"] * (y1 + 1) + ["L"] * (x1 + 1) + ["U"] * 1

print("".join(l1 + l2))

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
print(
       'L' + 'U' * (ty - sy + 1) + 'R' * (tx - sx + 1) + 'D' +
             'L' * (tx - sx    ) + 'D' * (ty - sy    )       +
       'D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L' +
             'D' * (ty - sy    ) + 'L' * (tx - sx    )
      )

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())

w = tx - sx
h = ty - sy
S = ''
S += 'U' * h
S += 'R' * w
S += 'D' * h
S += 'L' * w
S += 'L'
S += 'U' * (h + 1)
S += 'R' * (w + 1)
S += 'D'
S += 'R'
S += 'D' * (h + 1)
S += 'L' * (w + 1)
S += 'U'
print(S)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, raw_input().split())
dx = tx-sx
dy = ty-sy
s = ""
s += "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
s += "R" + "D"*(dy+1) + "L"*(dx+1) + "U"
s += "U"*dy + "R"*dx
s += "D"*dy + "L"*dx
print s

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
tx = tx - sx
ty = ty - sy
sx, sy = 0, 0

def move(x, y):
    if x == 1:
        print('R', end='')
    elif x == -1:
        print('L', end='')
    elif y == 1:
        print('U', end='')
    elif y == -1:
        print('D', end='')
    else:
        print('Something wrong')

# first loop
for i in range(tx):
    move(1, 0)      # right
for i in range(ty):
    move(0, 1)      # up
for i in range(tx):
    move(-1, 0)     # left
for i in range(ty):
    move(0, -1)     # down

# second loop
move(-1, 0)
for i in range(ty + 1):
    move(0, 1)
for i in range(tx + 1):
    move(1, 0)
move(0, -1)
move(1, 0)
for i in range(ty + 1):
    move(0, -1)
for i in range(tx + 1):
    move(-1, 0)
move(0, 1)
print()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = (int(x) for x in raw_input().split())
first = "R" * (tx-sx) + "U" * (ty - sy)
second = "L" * (tx-sx) + "D" * (ty - sy)
third = "D" + "R" * (tx-sx+1) + "U" * (ty-sy+1) + "L"
fourth = "U" + "L" * (tx-sx+1) + "D" * (ty-sy+1) + "R"
print first + second + third + fourth

Submission status: Accepted

Solution code:
sx, sy, tx, ty = list(map(int, input().split()))

# 上右下左
S = [[sx, sy+1], [sx+1, sy], [sx, sy-1], [sx-1, sy]]
T = [[tx, ty+1], [tx+1, ty], [tx, ty-1], [tx-1, ty]]

diff_x = abs(sx - tx) #差分計算
diff_y = abs(sy - ty)

re = ''
# 1回目の行き
re += 'U' * diff_y + 'R' * diff_x

# 1回目の帰り
re += 'D' * diff_y + 'L' * diff_x

# 2回目の行き
re += 'L' + 'U' * (diff_y + 1) + 'R' * (diff_x + 1) + 'D'


# 2回目の帰り
re += 'R' + 'D' * (diff_y + 1) + 'L' * (diff_x + 1) + 'U'

print(re)

Submission status: Accepted

Solution code:
# input
sx, sy, tx, ty = map(int, input().split())

for i in range(ty - sy):
    print('U', end = "")

for i in range(tx - sx):
    print('R', end = "")

for i in range(ty - sy):
    print('D', end = "")

for i in range(tx - sx):
    print('L', end = "")

print('L', end = "")

for i in range(ty - sy + 1):
    print('U', end = "")

for i in range(tx - sx + 1):
    print('R', end = "")

print('D', end = "")

print('R', end = "")

for i in range(ty - sy + 1):
    print('D', end = "")

for i in range(tx - sx + 1):
    print('L', end = "")

print('U')

Submission status: Accepted

Solution code:
def sign(n):
    if 0 <= n:
        return 0
    return -1

sx, sy, tx, ty = map(int, input().split(" "))

w, h = tx-sx, ty-sy

text = ""
text += "UD"[sign(h)] * abs(h)
text += "RL"[sign(w)] * abs(w)
text += "DU"[sign(h)] * abs(h)
text += "LR"[sign(w)] * (abs(w)+1)
text += "UD"[sign(h)] * (abs(h)+1)
text += "RL"[sign(w)] * (abs(w)+1)
text += "DU"[sign(h)]
text += "RL"[sign(w)]
text += "DU"[sign(h)] * (abs(h)+1)
text += "LR"[sign(w)] * (abs(w)+1)
text += "UD"[sign(h)]
print(text)