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

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

    tx = tx - sx
    ty = ty - sy

    def f1():
        s = ""
        s = s + "U" * ty
        s = s + "R" * tx
        return s

    def b1():
        s = ""
        s = s + "D" * ty
        s = s + "L" * tx
        return s

    def f2():
        s = ""
        s = s + "L" + "U" * (ty + 1)
        s = s + "R" * (tx + 1) + "D"
        return s

    def b2():
        s = ""
        s = s + "R" + "D" * (ty + 1)
        s = s + "L" * (tx + 1) + "U"
        return s

    print(f1() + b1() + f2() + b2())


if __name__ == "__main__":
    main()

Solution (Python):




def main():
    X, Y, TX, TY = map(int, input().split())
    DX = TX - X
    DY = TY - Y
    result = ''
    result += 'U' * DY + 'R' * DX
    result += 'D' * DY + 'L' * DX
    result += 'L' + 'U' * (DY + 1) + 'R' * (DX + 1) + 'D'
    result += 'R' + 'D' * (DY + 1) + 'L' * (DX + 1) + 'U'
    print(result)


if __name__ == "__main__":
    main()

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

mv_x = tx - sx
mv_y = ty - sy

ans = ''
ans += 'R' * mv_x + 'U' * mv_y
ans += 'L' * mv_x + 'D' * mv_y
ans += 'D' + 'R' * (mv_x+1) + 'U' * (mv_y+1) + 'L'
ans += 'U' + 'L' * (mv_x+1) + 'D' * (mv_y + 1) + 'R'

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline

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

mov_x = tx - sx
mov_y = ty - sy

ans = ''
ans += 'R' * mov_x
ans += 'U' * mov_y
ans += 'L' * mov_x
ans += 'D' * mov_y
ans += 'D'
ans += 'R' * (mov_x + 1)
ans += 'U' * (mov_y + 1)
ans += 'L'
ans += 'U'
ans += 'L' * (mov_x + 1)
ans += 'D' * (mov_y + 1)
ans += 'R'
print(ans)

Solution (Python):
sx, sy, tx, ty = list(map(int, input().split()))
ans = ''
x = tx-sx
y = ty-sy

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

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

ans=""
for i in range(tx-sx):
    ans+="R"
for i in range(ty-sy):
    ans+="U"
for i in range(tx-sx):
    ans+="L"
for i in range(ty-sy):
    ans+="D"
ans+="L"
for i in range(ty-sy+1):
    ans+="U"
for i in range(tx-sx+1):
    ans+="R"
ans+="D"
ans+="R"
for i in range(ty-sy+1):
    ans+="D"
for i in range(tx-sx+1):
    ans+="L"
ans+="U"
print(ans)

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

ans=""
y=ty-sy
x=tx-sx


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

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)

Solution (Python):
sx, sy, tx, ty = map(int, input().split())
ans = ""
for i in range(sx, tx): ans += 'R'
for i in range(sy, ty): ans += 'U'
for i in range(sx, tx): ans += 'L'
for i in range(sy, ty): ans += 'D'
ans += 'D'
for i in range(sx, tx + 1): ans += 'R'
for i in range(sy - 1, ty): ans += 'U'
ans += 'LU'
for i in range(sx - 1, tx): ans += 'L'
for i in range(sy, ty + 1): ans += 'D'
ans += 'R'
print(ans)

Solution (Python):
x0, y0, x1, y1 = map(int, input().split())
print(
    "R" * (x1 - x0)
    + "U" * (y1 - y0)
    + "L" * (x1 - x0)
    + "D" * (y1 - y0)
    + "D"
    + "R" * (x1 - x0)
    + "R"
    + "U"
    + "U" * (y1 - y0)
    + "L"
    + "U"
    + "L" * (x1 - x0)
    + "L"
    + "D"
    + "D" * (y1 - y0)
    + "R"
)

Solution (Python):
a,b,c,d = map(int, input().split())



s = (a, b)
g = (c, d)

route = []


route.append('R' * (g[0] - s[0]))
route.append('U' * (g[1] - s[1]))

route.append('L' * (g[0] - s[0]))
route.append('D' * (g[1] - s[1]))

route.append('D')
route.append('R' * (g[0] - s[0] + 1))
route.append('U' * (g[1] - s[1] + 1))
route.append('L')

route.append('U')
route.append('L' * (g[0] - s[0] + 1))
route.append('D' * (g[1] - s[1] + 1))
route.append('R')


route = "".join(route)
print(route)

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

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

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

Solution (Python):
sx, sy, tx, ty = [int(n) for n in input().split()]
dx = tx - sx
dy = ty - sy
print('U'*dy+'R'*dx, end="")
print('D'*dy+'L'*dx, end="")
print('L'+'U'*(dy+1)+'R'*(dx+1)+'D', end="")
print('R'+'D'*(dy+1)+'L'*(dx+1)+'U')

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

Solution (Python):
SX,SY,TX,TY=map(int,input().split())
NX=TX-SX
NY=TY-SY
ans=[]
for i in range(NX):
  ans.append('R')
for i in range(NY):
  ans.append('U')
for i in range(NX):
  ans.append('L')
for i in range(NY):
  ans.append('D')
ans.append('D')
for i in range(NX+1):
  ans.append('R')
for i in range(NY+1):
  ans.append('U')
ans.append('L')
ans.append('U')
for i in range(NX+1):
  ans.append('L')
for i in range(NY+1):
  ans.append('D')
ans.append('R')
print(''.join(ans))

Solution (Python):
a,b,c,d=map(int,input().split())
A=[]
if (d-b)>0:
  A.append('U'*(d-b))
else:
  A.append('D'*(b-d))

if (c-a)>0:
  A.append('R'*(c-a))
else:
  A.append('L'*(a-c))

if (d-b)>0:
  A.append('D'*(d-b))
else:
  A.append('U'*(b-d))

if (c-a)>0:
  A.append('L'*(c-a+1))
else:
  A.append('R'*(a-c+1))  

if (d-b)>0:
  A.append('U'*(d-b+1))
else:
  A.append('D'*(b-d+1))

if (c-a)>0:
  A.append('R'*(c-a+1))
else:
  A.append('L'*(a-c+1))  
  
if (d-b)>0:
  A.append('D')
else:
  A.append('U')

if (c-a)>0:
  A.append('R')
else:
  A.append('L')
  
if (d-b)>0:
  A.append('D'*(d-b+1))
else:
  A.append('U'*(b-d+1))  
  
if (c-a)>0:
  A.append('L'*(c-a+1))
else:
  A.append('R'*(a-c+1))  
  
if (d-b)>0:
  A.append('U')
else:
  A.append('D')
print(*A,sep='')

Solution (Python):
sx,sy,tx,ty=map(int,input().split())
x,y=tx-sx,ty-sy
Root=''

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

Root+='L'*x+'D'*y

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

Root+='D'*y+'L'*x
print(Root)

Solution (Python):
sx, sy, tx, ty = map(int, input().split())
X = ["L", "R"]
Y = ["D", "U"]
if sx == tx or sy == ty:
    if sy == ty:
        X, Y = Y, X
        sy, ty = sx, tx
    dy = abs(ty - sy)
    d = sy < ty
    nd = sy > ty
    ans = Y[d]*(dy+1)+X[0]*2+Y[nd]*(dy+2)+X[1]*2+Y[d]+X[0]+Y[d]*dy+X[1]*2+Y[nd]*dy+X[0]
else:
    dx = abs(tx-sx)
    dy = abs(ty-sy)
    xd = sx < tx
    yd = sy < ty
    ans = Y[yd]*dy+X[xd]*dx+Y[not yd]*dy+X[not xd]*(dx+1)+Y[yd]*(dy+1)+X[xd]*(dx+1)+Y[not yd]+X[xd]+Y[not yd]*(dy+1)+X[not xd]*(dx+1)+Y[yd]
print(ans)

Solution (Python):

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

ans = ""

y = (ty - sy) 
x = (tx - sx)


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


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)

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

tx-=sx
ty-=sy

res=[]

for i in range(ty):
    res.append("U")
for i in range(tx+1):
    res.append("R")
for i in range(ty+1):
    res.append("D")
for i in range(tx+1):
    res.append("L")
res.append("U")

res.append("L")
for i in range(ty+1):
    res.append("U")
for i in range(tx+1):
    res.append("R")
for i in range(ty+1):
    res.append("D")
for i in range(tx):
    res.append("L")

for i in res:
    print(i,end='')

Solution (Python):
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
u="U"
d="D"
r="R"
l="L"
print(u*dy+r*dx+d*dy+l*dx+l+u*(dy+1)+r*(dx+1)+d+r+d*(dy+1)+l*(dx+1)+u)

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

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

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

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

ans=[]

ans+='R'*(tx-sx)
ans+='U'*(ty-sy)


ans+='L'*(tx-sx)
ans+='D'*(ty-sy)


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


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


print(''.join(ans))

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

Solution (Python):
import sys
import math

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

dy=ty-sy
dx=tx-sx

a=""
a+="U"*dy
a+="R"*dx
a+="D"*dy
a+="L"*dx
a+="L"
a+="U"*(dy+1)
a+="R"*(dx+1)
a+="D"
a+="R"
a+="D"*(dy+1)
a+="L"*(dx+1)
a+="U"

print(a)

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

ans = ""
ans2 = ""

for u in range(ty - sy):
    ans += "U"
for r in range(tx - sx):
    ans += "R"

ans2 = "LU" + ans + "RD"

print(ans + ans.translate(str.maketrans('UR', 'DL')) + ans2 + ans2.translate(str.maketrans('URDL', 'DLUR')))

Solution (Python):
SX, SY, TX, TY = map(int, input().split())
way1 = 'U' * (TY - SY) + 'R' * (TX - SX)
way2 = 'D' * (TY - SY)+ 'L' * (TX - SX)
way3 = 'L' + 'U' * (TY - SY + 1) + 'R' * (TX - SX + 1) + 'D'
way4 = 'R' + 'D' * (TY - SY + 1) + 'L' * (TX - SX + 1) + 'U'
print(way1 + way2 + way3 + way4)

Solution (Python):
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="")

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

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

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

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

print("L",end="")
print("U",end="")

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

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

print("R",end="")

Solution (Python):


import sys
[a,b,c,d] = list(map(int,input().split()))




e=d-b

f=c-a

g=""

for i in range(e):
    g=g+"U"
for i in range(f):
    g=g+"R"

for i in range(e):
    g=g+"D"
for i in range(f):
    g=g+"L"

g=g+"L"
for i in range(e+1):
    g=g+"U"
for i in range(f+1):
    g=g+"R"
g=g+"D"

g=g+"R"
for i in range(e+1):
    g=g+"D"
for i in range(f+1):
    g=g+"L"
g=g+"U"

print(g)

Solution (Python):
sx, sy, tx, ty = map(int,input().split())
keiro = ""
for i in range(ty-sy):
    keiro += "U"
for i in range(tx-sx):
    keiro += "R"
keiro0 = keiro
keiro = ""
for i in range(ty-sy):
    keiro += "D"
for i in range(tx-sx):
    keiro += "L"
keiro1 = keiro

ans = keiro0+keiro1+"LU"+keiro0+"RDRD"+keiro1+"LU"

print(ans)

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    sx, sy, tx, ty = [int(x) for x in input().split()]

    print("R" * (tx - sx) + "U" * (ty - sy) + "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")


if __name__ == '__main__':
    main()

Solution (Python):

import sys
INF = float("inf")


def solve(sx: int, sy: int, tx: int, ty: int):

    dirc = ["U", "D", "L", "R"]
    ans = []
    
    if sx > tx:
        dirc[2] = "R"
        dirc[3] = "L"
    if sy > ty:
        dirc[0] = "D"
        dirc[1] = "U"

    ans += [dirc[3]]*(tx-sx)
    ans += [dirc[0]]*(ty-sy)

    ans += [dirc[2]]*(tx-sx)
    ans += [dirc[1]]*(ty-sy)

    ans += [dirc[1]]
    ans += [dirc[3]]*(tx-sx+1)
    ans += [dirc[0]]*(ty-sy+1)
    ans += [dirc[2]]

    ans += [dirc[0]]
    ans += [dirc[2]]*(tx-sx+1)
    ans += [dirc[1]]*(ty-sy+1)
    ans += [dirc[3]]

    print("".join(ans))

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    sx = int(next(tokens))  
    sy = int(next(tokens))  
    tx = int(next(tokens))  
    ty = int(next(tokens))  
    solve(sx, sy, tx, ty)


if __name__ == '__main__':
    main()

Solution (Python):
import sys


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

root = ""



root += "U" * (ty - sy)

root += "R" * (tx - sx)



root += "D" * (ty - sy)

root += "L" * (tx - sx)



root += "L"
root += "U" * ((ty + 1) - sy)

root += "R" * (tx - (sx - 1))
root += "D"



root += "R"
root += "D" * (ty - (sy - 1))

root += "L" * ((tx + 1)  - sx)
root += "U"

print(root)

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

Solution (Python):
if __name__ == '__main__':
	sx, sy, tx, ty = map(int, input().split())
	h = ty - sy
	w = tx - sx

	ans = ''

	for i in range(0,2):
		if i == 0:
			ans += 'LU'
		for j in range(0,h):
			ans += 'U'
		for j in range(0,w):
			ans += 'R'
		if i == 0:
			ans += 'RD'

		if i == 0:
			ans += 'RD'
		for j in range(0,h):
			ans += 'D'
		for j in range(0,w):
			ans += 'L'
		if i == 0:
			ans += 'LU'

	print(ans)

Solution (Python):
def main():
    sx, sy, tx, ty = map(int, input().split())
    vert = ty - sy
    hor = tx - sx
    ans = 'U'*vert + 'R'*hor + 'D'*vert + 'L'*hor
    ans += 'L' + 'U'*(vert+1) + 'R'*(hor+1) + 'D'
    ans += 'R' + 'D'*(vert+1) + 'L'*(hor+1) + 'U'
    print(ans)
main()

Solution (Python):


def main():
    sx ,sy, tx, ty = map(int ,input().split())
    for i in range(sx,tx):
        print('R',end="")
    for i in range(sy,ty):
        print('U',end="")
    for i in range(sx,tx):
        print('L',end="")
    for i in range(sy,ty + 1):
        print('D',end="")
    for i in range(sx,tx + 1):
        print('R',end="")
    for i in range(sy,ty + 1):
        print('U',end="")
    print('L',end="")
    print('U',end="")
    for i in range(sx,tx + 1):
        print('L',end="")
    for i in range(sy,ty + 1):
        print('D',end="")
    print('R')

if __name__ == '__main__':
    main()

Solution (Python):
a,b,c,d=map(int,input().split())
Str = ""
U_1st_num = d-b
for i in range(U_1st_num):
  Str = Str + "U"
R_1st_num = c-a
for i in range(R_1st_num):
  Str = Str + "R"
D_2nd_num = d-b
for i in range(D_2nd_num):
  Str = Str + "D"
L_2nd_num = c-a
for i in range(L_2nd_num):
  Str = Str + "L"
Str = Str + "L"
for i in range(U_1st_num+1):
  Str = Str + "U"
for i in range(R_1st_num+1):
  Str = Str + "R"
Str = Str + "D"
Str = Str + "R"
for i in range(D_2nd_num+1):
  Str = Str + "D"
for i in range(L_2nd_num+1):
  Str = Str + "L"
Str = Str + "U"
print(Str)

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

dx = tx - sx
dy = ty - sy

txt = ""

for i in range(dx):
    txt += "R"
for i in range(dy):
    txt += "U"
for i in range(dx):
    txt += "L"
for i in range(dy):
    txt += "D"

txt += "D"
for i in range(dx+1):
    txt += "R"
for i in range(dy+1):
    txt += "U"
txt += "L"

txt += "U"
for i in range(dx+1):
    txt += "L"
for i in range(dy+1):
    txt += "D"
txt += "R"

print(txt)

Solution (Python):
sx, sy, tx, ty = map(int, input().split())
ans = ""
gx, gy = (tx - sx, ty - sy)

ans += "R" * gx + "U" * gy
ans += "R" + "D" * (gy + 1) + "L" * (gx + 1) + "U"


ans += "U" * gy + "R" * gx
ans += "U" + "L" * (gx + 1) + "D" * (gy + 1) + "R"

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
sx, sy, tx, ty = [int(x) for x in input().split()]
dx = tx - sx
dy = ty - sy

lr = ["0", "R", "L"]
ud = ["0", "U", "D"]

lr_idx = 1 if dx > 0 else 2
ud_idx = 1 if dy > 0 else 2

first = lr[lr_idx] * abs(dx) + ud[ud_idx] * abs(dy)
second = lr[-lr_idx] * abs(dx) + ud[-ud_idx] * abs(dy)
third = ud[-ud_idx] + lr[lr_idx] + first + ud[ud_idx] + lr[-lr_idx]
fourth = ud[ud_idx] + lr[-lr_idx] + second + ud[-ud_idx] + lr[lr_idx]

print(first + second + third + fourth)

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

def main():
    sx, sy, tx, ty = LI()
    right = (tx - sx)
    up = (ty - sy)
    p1 = 'R' * right + 'U' * up
    p2 = 'L' * right + 'D' * up
    p3 = 'D' + 'R' * (right + 1) + 'U' * (up + 1) + 'L'
    p4 = 'U' + 'L' * (right + 1) + 'D' * (up + 1) + 'R'
    print(p1+p2+p3+p4)
main()

Solution (Python):
import sys
bbn=1000000007
	


		
def main():
	sx,sy,tx,ty = map(int, input().split())
	cx=tx-sx
	cy=ty-sy
	
	u='U'
	d='D'
	l='L'
	r='R'
	
	ret=''
	ret+=u*cy
	ret+=r*cx
	ret+=d*cy
	ret+=l*(cx+1)
	ret+=u*(cy+1)
	ret+=r*(cx+1)
	ret+=d
	ret+=r
	ret+=d*(cy+1)
	ret+=l*(cx+1)
	ret+=u
	
	
	print(ret)
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

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

dx, dy = tx-sx, ty-sy

path1 = 'U'*dy + 'R'*dx
path2 = 'D'*dy + 'L'*dx
path3 = 'L' + 'U'*(dy+1) + 'R'*(dx+1) + 'D'
paht4 = 'R' + 'D'*(dy+1) + 'L'*(dx+1) + 'U'

ans = path1 + path2 + path3 + paht4
print(ans)

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

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

print(ans)

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

Solution (Python):



sx, sy, tx, ty = map(int, input().split())
print('U'*abs(ty-sy),
        'R'*abs(tx-sx),
        'D'*abs(ty-sy),
        'L'*abs(tx-sx),
        'L',
        'U'*(abs(ty-sy)+1),
        'R'*(abs(tx-sx)+1),
        'DR',
        'D'*(abs(ty-sy)+1),
        'L'*(abs(tx-sx)+1),
        'U',
        sep='')

Solution (Python):
Sx, Sy, Tx, Ty = map(int,input().split())

X = int(Tx - Sx)
Y = int(Ty - Sy)


z = 'R'*X+'U'*Y+'L'*X+'D'*Y+'D'+'R'*(X+1)+'U'*(Y+1)+'L'+'U'+'L'*(X+1)+'D'*(Y+1)+'R'


print(z)

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

go = ""
back = ""

if sx <= tx:
    for i in range(tx-sx):
        go += "R"
        back += "L"
else:
    for i in range(sx-tx):
        go += "L"
        back += "R"
        
if sy <= ty:
    for i in range(ty-sy):
        go += "U"
        back += "D"
else:
    for i in range(ty-sy):
        go += "D"
        back += "U"

go_2nd = ""
back_2nd = ""

if sx <= tx:
    if sy <= ty:
        go_2nd += "D"
        go_2nd += "R"
        go_2nd += go
        go_2nd += "U"
        go_2nd += "L"
        back_2nd += "U"
        back_2nd += "L"
        back_2nd += back
        back_2nd += "D"
        back_2nd += "R"
    else:
        go_2nd += "U"
        go_2nd += "R"
        go_2nd += go
        go_2nd += "D"
        go_2nd += "L"
        back_2nd += "D"
        back_2nd += "L"
        back_2nd += back
        back_2nd += "U"
        back_2nd += "R"
else:
    if sy <= ty:
        go_2nd += "D"
        go_2nd += "L"
        go_2nd += go
        go_2nd += "U"
        go_2nd += "R"
        back_2nd += "U"
        back_2nd += "R"
        back_2nd += back
        back_2nd += "D"
        back_2nd += "L"
    else:
        go_2nd += "U"
        go_2nd += "L"
        go_2nd += go
        go_2nd += "D"
        go_2nd += "R"
        back_2nd += "D"
        back_2nd += "R"
        back_2nd += back
        back_2nd += "U"
        back_2nd += "L"


print(go + back + go_2nd + back_2nd)

Solution (Python):
a,b,c,d = map(int,input().split())
A = c - a 
B = d - b 

ans = ''

ans +='R'*A + 'U'*B
ans +='L'*A + 'D'*B
ans +='L'+'U'*B+'U'+'R'*A +'R'+'D'
ans +='R'+'D'*B+'D'+'L'*A +'L'+'U'
print(ans)

Solution (Python):
a,b,c,d = map(int,input().split())
A = c - a 
B = d - b 

ans = ''

ans +='R'*A + 'U'*B
ans +='L'*A + 'D'*B
ans +='L'+'U'*B+'U'+'R'*A +'R'+'D'
ans +='R'+'D'*B+'D'+'L'*A +'L'+'U'
print(ans)

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

def forward(x, y, tx, ty):
   while y < ty:
      print('U', end='')
      y += 1
   while x < tx:
      print('R', end='')
      x += 1
   return()

def backward(x, y, sx, sy):
   while y > sy:
      print('D', end='')
      y -= 1
   while x > sx:
      print('L', end='')
      x -= 1
   return()

forward(sx, sy, tx, ty)
backward(tx, ty, sx, sy)

print('L', end='')
forward(sx-1, sy, tx, ty+1)
print('DR', end='')
backward(tx+1, ty, sx, sy-1)
print('U')

Solution (Python):
sx,sy,tx,ty=map(int,input().split())
path1=(tx-sx)*"R"+(ty-sy)*"U"
path2=(tx-sx)*"L"+(ty-sy)*"D"
path3="D"+(tx-sx+1)*"R"+(ty-sy+1)*"U"+"L"
path4="U"+(tx-sx+1)*"L"+(ty-sy+1)*"D"+"R"
print(path1+path2+path3+path4)

Solution (Python):
import sys
input = sys.stdin.readline
sx,sy,tx,ty=map(int,input().split())
ans=""
for i in range(ty-sy):
    ans+="U"
for i in range(tx-sx):
    ans+="R"
for i in range(ty-sy):
    ans+="D"
for i in range(tx-sx):
    ans+="L"
ans+="L"
for i in range(ty-sy+1):
    ans+="U"
for i in range(tx-sx+1):
    ans+="R"
ans+="DR"
for i in range(ty-sy+1):
    ans+="D"
for i in range(tx-sx+1):
    ans+="L"
ans+="U"
print(ans)

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

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

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

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

s = ''

for i in range(ty - sy):
    s = s + 'U'
for i in range(tx - sx):
    s = s + 'R'
for i in range(ty - sy):
    s = s + 'D'
for i in range(tx - sx):
    s = s + 'L'

s = s + 'L'

for i in range(ty - sy + 1):
    s = s + 'U'
for i in range(tx - sx + 1):
    s = s + 'R'

s = s + 'DR'

for i in range(ty - sy + 1):
    s = s + 'D'
for i in range(tx - sx + 1):
    s = s + 'L'

s = s + 'U'

print(s)

Solution (Python):
sx, sy, tx, ty = map(int, input().split())
path = ''
for _ in range(tx - sx):
  path += 'R'
for _ in range(ty - sy):
  path += 'U'
for _ in range(tx - sx):
  path += 'L'
for _ in range(ty - sy):
  path += 'D'

  
path += 'D'
for _ in range(tx - sx + 1):
  path += 'R'
for _ in range(ty - sy + 1):
  path += 'U'
path += 'L'
path += 'U'
for _ in range(tx - sx + 1):
  path += 'L'
for _ in range(ty - sy + 1):
  path += 'D'
path += 'R'

print(path)

Solution (Python):

x1,y1,x2,y2=map(int,input().split())
for i in range(y2-y1):
    print("U",end="")
for i in range(x2-x1):
    print("R",end="")
for i in range(y2-y1):
    print("D",end="")
for i in range(x2-x1):
    print("L",end="")
print("L",end="")
for i in range(y2-y1):
    print("U",end="")
print("U",end="")
for i in range(x2-x1):
    print("R",end="")
print("RDR",end="")
for i in range(y2-y1):
    print("D",end="")
print("DL",end="")
for i in range(x2-x1):
    print("L",end="")
print("U",end="")

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

Solution (Python):
SX, SY, TX, TY = [int(n) for n in input().split()]

def main():
    xd = TX - SX
    yd = TY - SY
    first = ['R' * xd, 'U' * yd, 'L' * xd, 'D' * yd]
    second = ['D', 'R' * (xd + 1), 'U' * (yd + 1), 'L', 'U', 'L' * (xd + 1), 'D' * (yd + 1), 'R']

    ans = first + second
    print(''.join(ans))

if __name__ == '__main__':
    main()

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

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

print(ans)

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

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

x=tx-sx
y=ty-sy


n1="U"*y +"R"*x+"D"*y+"L"*x
n2="L"+"U"*(y+1)+"R"*(x+1)+"D"
n3="R"+"D"*(y+1)+"L"*(x+1)+"U"
print(n1+n2+n3)

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

v1 = tx - sx
if v1 >= 0:
	sv0 = "R"
	sv1 = "L"
	s1 = "R" * v1
	s3 = "L" * v1
else:
	sv0 = "L"
	sv1 = "R"
	s1 = "L" * v1
	s3 = "R" * v1

v2 = ty - sy

if v2 >= 0:
	sh0 = "U"
	sh1 = "D"
	s2 = "U" * v2
	s4 = "D" * v2
else:
	sh0 = "D"
	sh1 = "U"
	s2 = "D" * v2
	s4 = "U" * v2


print(s1 + s2 + s3 + s4 + sh1 + sv0 + s1 + s2 + sh0 + sv1 + sh0 + sv1 + s3 + s4 + sh1 + sv0)

Solution (Python):
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx-sx, ty-sy
ans = "UD"[dy<0]*dy + "RL"[dx<0]*dx + "UD"[dy>0]*dy
dx += 1;dy += 1
print(ans + "RL"[dx>0]*dx + "UD"[dy<0]*dy + "RL"[dx<0]*dx + "UD"[dy>0] + "RL"[dx<0] + "UD"[dy>0]*dy + "RL"[dx>0]*dx + "UD"[dy<0])

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

sx, sy, tx, ty = MAP()

x = tx - sx
y = ty - sy


ans = ''
if x >= 0:
    x1 = 'R'
    x2 = 'L'
else:
    x1 = 'L'
    x2 = 'R'
if y >= 0:
    y1 = 'U'
    y2 = 'D'
else:
    y1 = 'D'
    y2 = 'U'


ans += x1 * x
ans += y1 * y
ans += x2 * x
ans += y2 * y


ans += y2
ans += x1 * (x+1)
ans += y1 * (y+1)
ans += x2
ans += y1
ans += x2 * (x+1)
ans += y2 * (y+1)
ans += x1

print(ans)

Solution (Python):
a,b,c,d = map(int,input().split())

print((d-b)*"U"+(c-a)*"R"+(d-b)*"D"+(c-a+1)*"L"+(d-b+1)*"U"+(c-a+1)*"R"+"DR"+(d-b+1)*"D"+(c-a+1)*"L"+"U")

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

u = "U" * (ty - sy)
d = "D" * (ty - sy)
r = "R" * (tx - sx)
l = "L" * (tx - sx)

s1 = u + r 
s2 = d + l
s3 = "LU" + s1 + "RD"
s4 = "RD" + s2 + "LU"
print(s1 + s2 + s3 + s4)

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

Solution (Python):
sx, sy, tx, ty = map(lambda x: int(x), input().split())
keika = list()

lenx = tx - sx
leny = ty - sy

for i in range(leny):
  keika.append('U')
for i in range(lenx):
  keika.append('R')
for i in range(leny):
  keika.append('D')
for i in range(lenx):
  keika.append('L')

keika.append('L')
for i in range(leny+1):
  keika.append('U')
for i in range(lenx+1):
  keika.append('R')
keika.append('D')
keika.append('R')
for i in range(leny+1):
  keika.append('D')
for i in range(lenx+1):
  keika.append('L')
keika.append('U')
print(''.join(keika))

Solution (Python):
N = list(map(int,input().split()))
for i in range(len(N)):
	N[i]+=1000
direction = ["U","L","D","R"]
sub_ans1=[]
sub_ans2=[]
sub_ans1 += ["U"]*(N[3]-N[1])
sub_ans1 += ["R"]*(N[2]-N[0])


for i in range(len(sub_ans1)):
	sub_ans1 += direction[direction.index(sub_ans1[i])-2]


sub_ans2 += ["L"]*1
sub_ans2 += ["U"]*(N[3]-N[1]+1)
sub_ans2 += ["R"]*(N[2]-N[0]+1)
sub_ans2 += ["D"]*1

for i in range(len(sub_ans2)):
	sub_ans2 += direction[direction.index(sub_ans2[i])-2]


for i in range(len(sub_ans1)):
	print(sub_ans1[i],end="")
for i in range(len(sub_ans2)):
	print(sub_ans2[i],end="")

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

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

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

Solution (Python):
SX,SY,TX,TY=map(int,input().split())
NX=TX-SX
NY=TY-SY
ans=[]
for i in range(NX):
  ans.append('R')
for i in range(NY):
  ans.append('U')
for i in range(NX):
  ans.append('L')
for i in range(NY):
  ans.append('D')
ans.append('D')
for i in range(NX+1):
  ans.append('R')
for i in range(NY+1):
  ans.append('U')
ans.append('L')
ans.append('U')
for i in range(NX+1):
  ans.append('L')
for i in range(NY+1):
  ans.append('D')
ans.append('R')
print(''.join(ans))