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):
sx,sy,tx,ty = map(int,input().split())

X = tx - sx
Y = ty - sy
go1 = ''
back1 = ''

for i in range(abs(X)):
  go1 += 'R'
  back1 += 'L'
for i in range(abs(Y)):
  go1 += 'U'
  back1 += 'D'

go2 = 'D'
back2 = 'U'

for i in range(go1.count('R')+1):
  go2 += 'R'
  back2 += 'L'
for i in range(go1.count('U')+1):
  go2 += 'U'
  back2 += 'D'

go2 += 'L'
back2 += 'R'

print(go1+back1+go2+back2)

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+="D"
for i in range(tx-sx+1):
    ans+="R"
for i in range(ty-sy+1):
    ans+="U"
ans+="L"
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):

def main():
    sx, sy, tx, ty = list(map(int, input().rstrip().split()))
    X, Y = abs(sx - tx), abs(sy - ty)
    move = ""
    move += "U" * Y + "R" * X + "D" * Y + "L" * X
    move += "L" + "U" * (Y + 1) + "R" * (X + 1) + "D"
    move += "R" + "D" * (Y + 1) + "L" * (X + 1) + "U"
    print(move)


if __name__ == "__main__":
    main()

Solution (Python):
x1,y1,x2,y2=map(int,input().split())
W,H=x2-x1,y2-y1
print(("R"*W)+("U"*H)+("L"*W)+("D"*H)+"D"+("R"*(W+1))+("U"*(H+1))+"LU"+("L"*(W+1))+("D"*(H+1))+"R")

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

y = ty - sy
x = tx - sx

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

Solution (Python):
sx,sy,tx,ty = map(int,input().split())
dx = tx-sx
dy = ty-sy
w = []
for i in range(dy):
    w.append('U')
for i in range(dx):
    w.append('R')
for i in range(dy):
    w.append('D')
for i in range(dx):
    w.append('L')
w.append('L')
for i in range(dy+1):
    w.append('U')
for i in range(dx+1):
    w.append('R')
w.append('D')
w.append('R')
for i in range(dy+1):
    w.append('D')
for i in range(dx+1):
    w.append('L')
w.append('U')
print(''.join(w))

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

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

path1 = "U" * (ty - sy) + "R" * (tx - sx)
path2 = "D" * (ty - sy) + "L" * (tx - sx)
path3 = "L" + "U" * (ty - sy + 1) + "R" * (tx - sx + 1) + "D"
path4 = "R" + "D" * (ty - sy + 1) + "L" * (tx - sx + 1) + "U"

print(path1 + path2 + path3 + path4)

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

dy = ty - sy
dx = tx - sx

print('U' * dy + 'R' * dx +
      'D' * dy + 'L' * dx +
      'LU' + 'U' * dy + 'R' * dx + 'RD' +
      'RD' + 'D' * dy + 'L' * dx + 'LU')

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


def get_route(start_x, start_y, end_x, end_y):
    route = ''
    d_y = end_y - start_y
    dir = ''
    if d_y < 0:
        dir = 'D'
    else:
        dir = 'U'
    for i in range(abs(d_y)):
        route += dir

    d_x = end_x - start_x
    dir = ''
    if d_x < 0:
        dir = 'L'
    else:
        dir = 'R'
    for i in range(abs(d_x)):
        route += dir

    return route


ans = get_route(sx, sy, tx, ty)
ans += get_route(tx, ty, sx, sy)
ans += 'LU' + get_route(sx, sy, tx, ty) + 'RD'
ans += 'RD' + get_route(tx, ty, sx, sy) + 'LU'

print(ans)

Solution (Python):
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

sx, sy, tx, ty = list(map(int, sys.stdin.readline().split()))

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

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

Solution (Python):

import re
import bisect
from datetime import datetime as dt
import math

def gcd(a, b):
    return math.gcd(a, b)

def lcm(a, b):
    return a * b // gcd(a, b)

if __name__ == '__main__':
    a, b, c, d = map(int, input().split())
    ans = ''
    ans += 'R'*(c-a)
    ans += 'U'*(d-b)
    ans += 'L'*(c-a)
    ans += 'D'*(d-b)
    ans += 'D'
    ans += 'R'*(c-a+1)
    ans += 'U'*(d-b+1)
    ans += 'L'
    ans += 'U'
    ans += 'L'*(c-a+1)
    ans += 'D'*(d-b+1)
    ans += 'R' 
    print(ans)

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


for _ in range(ty-sy):
    print("U",end='')
for _ in range(tx-sx):
    print("R",end='')
for _ in range(ty-sy):
    print("D",end='')
for _ in range(tx-sx):
    print("L",end='')


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

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

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

Solution (Python):
sx,sy,tx,ty=map(int,input().split())
print('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')

Solution (Python):
import numpy as np


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

    w = tx - sx
    h = ty - sy

    out = ''
    
    for _ in range(h):
        out += 'U'
    for _ in range(w):
        out += 'R'
    
    for _ in range(h):
        out += 'D'
    for _ in range(w):
        out += 'L'
    
    out += 'L'
    for _ in range(h+1):
        out += 'U'
    for _ in range(w+1):
        out += 'R'
    out += 'D'
    
    out += 'R'
    for _ in range(h+1):
        out += 'D'
    for _ in range(w+1):
        out += 'L'
    out += 'U'

    print(out)
 



if __name__ == '__main__':
    main()

Solution (Python):
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

sx, sy, tx, ty = nl()

path = ''

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

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

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

ans = ""
X = tx - sx
Y = ty - sy

for i in range(Y):
    ans += "U"
for i in range(X):
    ans += "R"
for i in range(Y):
    ans += "D"
for i in range(X):
    ans += "L"
ans += "L"

for i in range(Y+1):
    ans += "U"
for i in range(X+1):
    ans += "R"
ans += "D"
ans += "R"

for i in range(Y+1):
    ans += "D"
for i in range(X+1):
    ans += "L"
ans += "U"

print(ans)

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

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

dif_x=tx-sx
dif_y=ty-sy

cmd1 = 'R'*(dif_x) + 'U'*(dif_y)
cmd2 = 'L'*(dif_x) + 'D'*(dif_y)
cmd3 = 'D' + 'R'*(dif_x + 1) + 'U'*(dif_y+1) + 'L'
cmd4 = 'U' + 'L'*(dif_x + 1) + 'D'*(dif_y+1) + 'R'

ans = cmd1 + cmd2 + cmd3 + cmd4
print(ans)

Solution (Python):
import sys

sx, sy, tx, ty = map(int, sys.stdin.readline().split())


dif_x = tx - sx
dif_y = ty - sy


ans_s = ''
route_1 = 'RU'
route_2 = 'LD'
route_3 = 'DRUL'
route_4 = 'ULDR'

for i in range(dif_x):
    ans_s += 'R'
for i in range(dif_y):
    ans_s += 'U'
for i in range(dif_x):
    ans_s += 'L'
for i in range(dif_y):
    ans_s += 'D'

ans_s += 'D'
for i in range(dif_x + 1):
    ans_s += 'R'

for i in range(dif_y + 1):
    ans_s += 'U'
ans_s += 'L'

ans_s += 'U'
for i in range(dif_x + 1):
    ans_s += 'L'
for i in range(dif_y + 1):
    ans_s += 'D'
ans_s += 'R'


print(ans_s)

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

cmd1 = 'R' * dx + 'U' * dy
cmd2 = 'L' * dx + 'D' * dy
cmd3 = 'D' + 'R' * (dx+1) + 'U' * (dy+1) + 'L'
cmd4 = 'U' + 'L' * (dx+1) + 'D' * (dy+1) + 'R'

answer = cmd1 + cmd2 + cmd3 + cmd4
print(answer)

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

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

print(ans)

Solution (Python):

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

lst_A = []

if (sx < tx) and (sy < ty):
    for i in range(tx - sx):
        lst_A.append("R")
    for i in range(ty - sy):
        lst_A.append("U")
    for i in range(tx - sx):
        lst_A.append("L")
    for i in range(ty - sy):
        lst_A.append("D")
    lst_A.append("D")
    for i in range(tx - sx + 1):
        lst_A.append("R")
    for i in range(ty - sy + 1):
        lst_A.append("U")
    lst_A.append("L")
    lst_A.append("U")
    for i in range(tx - sx + 1):
        lst_A.append("L")
    for i in range(ty - sy + 1):
        lst_A.append("D")
    lst_A.append("R")


print("".join(lst_A))

Solution (Python):
sx, sy, tx, ty = map(int, input().split())
dire = ["", "U", "L", "R", "D"]
dire_f = []
dire_s = [2]
a = []
b = []
c = []
d = []
for i in range(abs(ty-sy)):
    dire_f.append((ty-sy)//abs(ty-sy))
for i in range(abs(sx-tx)):
    dire_f.append(((sx-tx)//abs(sx-tx))*2)
for i in range(abs(ty-sy)+1):
    dire_s.append((ty-sy)//abs(ty-sy))
for i in range(abs(sx-tx)+1):
    dire_s.append(((sx-tx)//abs(sx-tx))*2)
dire_s.append(-1)
for i in range(len(dire_f)):
    a.append(dire[dire_f[i]])
    b.append(dire[dire_f[i]*(-1)])
for i in range(len(dire_s)):
    c.append(dire[dire_s[i]])
    d.append(dire[dire_s[i]*(-1)])
print("".join(a+b+c+d))

Solution (Python):
def change_U_D_R_L(changelst):
    changelst = changelst.replace("U", "上")
    changelst = changelst.replace("D", "下")
    changelst = changelst.replace("R", "右")
    changelst = changelst.replace("L", "左")
    re_lst = changelst.replace("上", "D").replace("下", "U").replace("右", "L").replace("左", "L")
    return re_lst


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

for i in range(abs(ty - sy)):
    go1.append("U")
for i in range(abs(tx - sx)):
    go1.append("R")
go1 = "".join(go1)
back1 = change_U_D_R_L(go1)

print(go1 + back1 + "LU" + go1 + "RDRD" + back1 + "LU")

Solution (Python):




sx, sy, tx, ty = map(int, input().split())
difx, dify = abs(tx - sx), abs(ty - sy)
ans = "R" * difx + "U" * dify + "R" + "D" * (dify + 1) + "L" * (difx + 1) + "U"
ans += "U" * dify + "R" * difx + "U" + \
    "L" * (difx + 1) + "D" * (dify + 1) + "R"
print(ans)

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


diff_x = tx - sx
diff_y = ty - sy

if diff_y > 0:
    base_v = [abs(diff_y) * 'U', abs(diff_y) * 'D']
    add_v = ['U', 'D']
else:
    base_v = [abs(diff_y) * 'D', abs(diff_y) * 'U']
    add_v = ['D', 'U']
if diff_x > 0:
    base_h = [abs(diff_x) * 'R', abs(diff_x) * 'L']
    add_h = ['L', 'R']
else:
    base_h = [abs(diff_x) * 'L', abs(diff_x) * 'R']
    add_h = ['R', 'L']

ans = []
for i in range(2):
    if i == 1:
        ans.append(add_h[0])
    ans.append(base_v[0])
    if i == 1:
        ans.append(add_v[0])
    ans.append(base_h[0])
    if i == 1:
        ans.append(add_h[1])
        ans.append(add_v[1])
        ans.append(add_h[1])
    ans.append(base_v[1])
    if i == 1:
        ans.append(add_v[1])
        ans.append(add_h[0])
    ans.append(base_h[1])
    if i == 1:
        ans.append(add_v[0])

print(''.join(ans))

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

Solution (Python):
a=list(map(int, input().split()))

dx=-(a[0]-a[2])
dy=-(a[1]-a[3])

result=''
x=[]
y=[]
for i in range(dx):
    result=result+'R'

for i in range(dy):
    result=result+'U'

for i in range(dx):
    result=result+'L'

for i in range(dy):
    result=result+'D'

result=result+'D'

for i in range(dx+1):
    result=result+'R'

for i in range(dy+1):
    result=result+'U'

result=result+'L'

result=result+'U'

for i in range(dx+1):
    result=result+'L'

for i in range(dy+1):
    result=result+'D'

result=result+'R'

print(result)

Solution (Python):



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

solver = []
solver.append('U'*(ty-sy))
solver.append('R'*(tx-sx))
solver.append('D'*(ty-sy))
solver.append('L'*(tx-sx))
solver.append('L')
solver.append('U'*(ty-sy+1))
solver.append('R'*(tx-sx+1))
solver.append('D')
solver.append('R')
solver.append('D'*(ty-sy+1))
solver.append('L'*(tx-sx+1))
solver.append('U')

ans = ''.join(solver)
print(ans)

Solution (Python):
sx, sy, tx, ty = map(int, input().split())
nx = ny = 0
dx = tx - sx
dy = ty - sy

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

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

Solution (Python):
sx,sy,tx,ty = map(int,input().split())
x=tx-sx
y=ty-sy
ans = "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(ans)

Solution (Python):
def vertical_move(move):
    if move >= 0:
        return "U" * move
    return "D" * (-move)

def horizontal_move(move):
    if move >= 0:
        return "R" * move
    return "L" * (- move)

def opposite_horizontal_to_vertical(sx, sy, tx, ty):
    ans = ""
    first_opposite = ""
    vertical = ""
    horizontal = ""
    last_opposite = ""
    if sx <= tx:
        first_opposite = "L"
        horizontal = horizontal_move(tx - sx + 1)
    else:
        first_opposite = "R"
        horizontal = horizontal_move(tx - sx - 1)
        
    if sy <= ty:
        last_opposite = "D"
        vertical = vertical_move(ty + 1 - sy)
    else:
        last_opposite = "U"
        vertical = vertical_move(ty - 1 - sy)
        
    return first_opposite + vertical + horizontal + last_opposite

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

ans = ""
ans += vertical_move(ty - sy)
ans += horizontal_move(tx - sx)
ans += vertical_move(sy - ty)
ans += horizontal_move(sx - tx)

ans += opposite_horizontal_to_vertical(sx, sy, tx, ty)
ans += opposite_horizontal_to_vertical(tx, ty, sx, sy)

print(ans)

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

dx = tx - sx
dy = ty - sy

for _ in range(dx):
    print('R', end='')
for _ in range(dy):
    print('U', end='')
for _ in range(dx):
    print('L', end='')
for _ in range(dy):
    print('D', end='')

print('L', end='')
for _ in range(dy+1):
    print('U', end='')
for _ in range(dx+1):
    print('R', end='')
print('DR', end='')
for _ in range(dy+1):
    print('D', end='')
for _ in range(dx+1):
    print('L', end='')
print('U', end='')

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

sx_list = [sx, sx+1, sx, sx-1]
sy_list = [sy+1, sy, sy-1, sy]
tx_list = [tx-1, tx, tx+1, tx]
ty_list = [ty, ty-1, ty, ty+1]


U1 = ty_list[0]-sy_list[0]+1
R1 = tx_list[0]-sx_list[0]+1
D1 = ty_list[1]-sy_list[1]+1
L1 = tx_list[1]-sx_list[1]+1

D2 = 1
R2 = tx_list[2]-sx_list[2]
U2 = ty_list[2]-sy_list[2]
L2 = 1

U3 = 1
L3 = tx_list[3]-sx_list[3]
D3 = ty_list[3]-sy_list[3]
R3 = 1

ans = str()

for i in range(U1):
    ans += 'U'
for i in range(R1):
    ans += 'R'
for i in range(D1):
    ans += 'D'
for i in range(L1):
    ans += 'L'
    
for i in range(D2):
    ans += 'D'
for i in range(R2):
    ans += 'R'
for i in range(U2):
    ans += 'U'
for i in range(L2):
    ans += 'L'
    
for i in range(U3):
    ans += 'U'
for i in range(L3):
    ans += 'L'
for i in range(D3):
    ans += 'D'
for i in range(R3):
    ans += 'R'

print(ans)

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

ans+="R"
ans+=(diffY+1)*"D"
ans+=(diffX+1)*"L"
ans+="U"
print(ans)

Solution (Python):

"""考え方
1回目のt行きは、右行ったあと上
1回目のs行きは、左行ったあと下
2回目のt行きは、一回下行って、右行ったあと上、その後左
2回目のs行きは、一回上行って、左行ったあと下、その後右
"""
def solve():
    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(ans)

if __name__ == "__main__":
    solve()

Solution (Python):

sx,sy,tx,ty = list(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)+"L"+"U"+"L"*(tx-sx+1)+"D"*(ty-sy+1)+"R")

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

Solution (Python):
import itertools
sx,sy,tx,ty = map(int,input().split())
f = ""
f += abs(tx-sx)*"R" + abs(ty-sy)*"U"
f += abs(tx-sx)*"L" + abs(ty-sy)*"D"

f += "D"

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

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

distx = tx - sx
disty = ty - sy

for k in range(2):
    if k:
        distx += 1
        disty += 1
        print('D',end='')
    for i in range(distx):
        print('R',end='')
    for i in range(disty):
        print('U',end='')
    if k:
        print('L',end='')
        print('U',end='')
    for i in range(distx):
        print('L',end='')
    for i in range(disty):
        print('D',end='')
    if k:
        print('R')

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

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

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

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  a,b,c,d=LI()

  s=''
  for i in range(c-a):
    s+='R'
  for i in range(d-b):
    s+='U'

  for i in range(c-a):
    s+='L'
  for i in range(d-b):
    s+='D'

  s+='D'
  for i in range(c-a):
    s+='R'
  s+='R'
  for i in range(d-b):
    s+='U'
  s+='UL'

  s+='U'
  for i in range(c-a):
    s+='L'
  s+='L'
  for i in range(d-b):
    s+='D'
  s+='DR'

  return s

print(main())

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

Solution (Python):
l = input().split()
sx = int(l[0])
sy = int(l[1])
tx = int(l[2])
ty = int(l[3])



ans = ''

dx = tx - sx
dy = ty - sy


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


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


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


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

print(ans)

Solution (Python):





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

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

ans = r+u
ans += 'R'+d+'D'+l+'LU'
ans += u+r
ans += 'U'+l+'L'+d+'DR'
print(ans)

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

dx = tx - sx
dy = ty - sy
n = dx + dy
memo = ['' for i in range(n)]
memo2 = ['' for i in range(n)]
lmemo = ['' for i in range(n+2)]
lmemo2 = ['' for i in range(n+2)]

ans = ''

for i in range(dy):
    ans += 'U'

for i in range(dx):
    ans += 'R'

for i in range(dy):
    ans += 'D'

for i in range(dx):
    ans += 'L'


ans += 'L'
for i in range(dy+1):
    ans += 'U'

for i in range(dx+1):
    ans += 'R'

ans += 'D'
ans += 'R'
for i in range(dy+1):
    ans += 'D'

for i in range(dx+1):
    ans += 'L'

ans += 'U'

print(ans)

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

print("R"*dx, end="")
print("U"*dy, end="")
print("L"*dx, end="")
print("D"*dy, end="")
print("D", end="")
print("R"*(dx + 1), end="")
print("U"*(dy + 1), end="")
print("L", end="")
print("U", end="")
print("L"*(dx + 1), end="")
print("D"*(dy + 1), end="")
print("R", end="")

Solution (Python):

"""
C - Back and Forth
https://atcoder.jp/contests/abc051/tasks/abc051_c

"""
import sys


def solve(sx, sy, tx, ty):
    used = set()
    ans = []
    x, y = sx, sy
    gx, gy = tx, ty
    px, py = sx, sy
    while True:
        path = []
        for nx, ny, d in ((x, y+1, 'U'), (x, y-1, 'D'), (x-1, y, 'L'), (x+1, y, 'R')):
            if not (nx, ny) in used and (nx, ny) != (px, py):
                path.append([abs(nx-gx) + abs(ny-gy), d, (nx, ny)])
        if path == []:
            break
        o = ''
        if  x == gx or y == gy:
            if x == gx:
                o = 'RLUD'
            else:
                o = 'UDRL'
        elif x > gx:
            if y > gy:
                o = 'DLUR'
            else:
                o = 'ULDR'
        else:
            if y > gy:
                o = 'DRUL'
            else:
                o = 'URDL'
        path.sort(key=lambda x: [x[0], o.index(x[1])])
        ans.append(path[0][1])
        x, y = path[0][2]
        used.add((x, y))
        if x == gx and y == gy:
            used.discard((x, y))
            if gx == sx and gy == sy:
                gx, gy = tx, ty
                px, py = sx, sy
            else:
                gx, gy = sx, sy
                px, py = tx, ty
    return ans


def main(args):
    sx, sy, tx, ty = map(int, input().split())
    ans = solve(sx, sy, tx, ty)
    print(*ans, sep='')


if __name__ == '__main__':
    main(sys.argv[1:])

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

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

sx,sy,gx,gy = map(int,input().split())

ans = []

way1 = ["U"] * (gy-sy) + ["R"] * (gx-sx)

way2 = ["D"] * (gy-sy) + ["L"] * (gx-sx)

way3 = ["L"] + ["U"] * (gy-sy+1) + ["R"] * (gx-sx+1) + ["D"]
way4 = ["R"] + ["D"] * (gy-sy+1) + ["L"] * (gx-sx+1) + ["U"]
ans += way1 + way2 + way3 + way4

print("".join(ans))

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

if dx != 0 and dy != 0:
    d = ['R','U','L','D']
    root = [d[0]]*dx + [d[1]]*dy + [d[2]]*dx + [d[3]]*dy
    root += [d[3]] + [d[0]]*(dx+1) + [d[1]]*(dy+1) + [d[2]]
    root += [d[1]] + [d[2]]*(dx+1) + [d[3]]*(dy+1) + [d[0]]

print(''.join(root))

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

Solution (Python):
sx, sy, tx, ty = 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(ans)

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    sx, sy, tx, ty = f()

    xdiff = tx - sx
    ydiff = ty - sy

    for _ in range(xdiff):
        print('R', end = '')
    for _ in range(ydiff):
        print('U', end = '')

    for _ in range(xdiff):
        print('L', end = '')
    for _ in range(ydiff):
        print('D', end = '')

    print('L', end = '')
    for _ in range(ydiff+1):
        print('U', end = '')
    
    for _ in range(xdiff+1):
        print('R', end = '')
    
    print('D', end = '')

    print('R', end = '')

    for _ in range(ydiff+1):
        print('D', end = '')

    for _ in range(xdiff+1):
        print('L', end = '')
    
    print('U')
    

solve()

Solution (Python):
def solve(dx, dy):
    route = 'U'*dy + 'R'*dx + 'D'*dy + 'L'*(dx+1) \
        + 'U'*(dy+1) + 'R'*(dx+1) + 'DR' \
        + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
    print(route)

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

main()

Solution (Python):
a,b,x,y=map(int,input().split());r,c=y-b,x-a;R,L,U,D='RLUD';print(R*c+U*r+L*c+D*-~r+R*-~c+U*-~r+L+U+L*-~c+D*-~r+R)

Solution (Python):
a,b,x,y=map(int,input().split());r,c=y-b,x-a;print('R'*c+'U'*r+'L'*c+'D'*-~r+'R'*-~c+'U'*-~r+'LU'+'L'*-~c+'D'*-~r+'R')

Solution (Python):
a,b,x,y=map(int,input().split());r,c=y-b,x-a;print('R'*c+'U'*r+'L'*c+'D'*-~r+'R'*-~c+'U'*-~r+'LU'+'L'*-~c+'D'*-~r+'R')

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

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

ans="U"*b+"R"*a
ans+="D"*b+"L"*a

ans+="D"+"R"*(a+1)+"U"*(b+1)+"L"
ans+="U"+"L"*(a+1)+"D"*(b+1)+"R"

print(ans)

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

dx = tx - sx
dy = ty - sy

ans = ""

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

print(ans)

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

Solution (Python):
sx,sy,tx,ty = map(int, input().split())
u = 'U'
d = 'D'
l = 'L'
r = 'R'
ans = ''



for i in range(1,abs(tx-sx)+1):
    if tx > sx:
        ans += r
    else:
        ans += l

for i in range(1,abs(ty-sy)+1):
    if ty > sy:
        ans += u
    else:
        ans += d



if tx > sx:
    ans += r
else:
    ans += l

for i in range(1,abs(ty-sy)+2):
    if ty < sy:
        ans += u
    else:
        ans += d

for i in range(1,abs(tx-sx)+2):
    if tx < sx:
        ans += r
    else:
        ans += l

if ty > sy:
    ans += u
else:
    ans += d



for i in range(1,abs(ty-sy)+1):
    if ty > sy:
        ans += u
    else:
        ans += d

for i in range(1,abs(tx-sx)+1):
    if tx > sx:
        ans += r
    else:
        ans += l



if ty > sy:
    ans += u
else:
    ans += d

for i in range(1,abs(tx-sx)+2):
    if tx < sx:
        ans += r
    else:
        ans += l

for i in range(1,abs(ty-sy)+2):
    if ty < sy:
        ans += u
    else:
        ans += d
        
if tx > sx:
    ans += r
else:
    ans += l

print(ans)

Solution (Python):
a,b,c,d = map(int,input().split())
dx = c-a
dy = d-b
print('U'*dy+'R'*dx+'D'*dy+'L'*(dx+1)+'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())
dx = tx - sx
dy = ty - sy

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

print(s)

Solution (Python):
a, b, c, d = (int(i) for i in input().split())  
x = c - a
y = d - b
ans = ""
ans += "R"*x + "U"*y + "L"*x + "D"*y
ans += "D" + "R"*(x+1) + "U"*(y+1) + "L"
ans += "U" + "L"*(x+1) + "D"*(y+1) + "R"
print(ans)

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

dx = tx - sx
dy = ty - sy

result = ""
def move(r, u, l, d):
    return r * abs(dx) + u * abs(dy) + l * abs(dx) + d * abs(dy) + d + r * (abs(dx)+1) + u * (abs(dy)+1) + l + u + l * (abs(dx)+1) + d *(abs(dy)+1) + r

def horizen_move(r, u, l, d):
    return r * abs(dx+dy) + u + l * abs(dx+dy) + d * 2 + r * abs(dx+dy) + u + r + u * 2 + l * (abs(dx+dy) + 2) + d*2 + r

if dx > 0:
    if dy > 0:
        result = move("R", "U", "L", "D")
        
    elif dy < 0:
        result = move("R", "D", "L", "U")
    elif dy == 0:
        result = horizen_move("R", "U", "L", "D")
        
elif dx < 0:
    if dy > 0:
        result = move("L", "U", "R", "D")
    elif dy < 0:
        result = move("L", "D", "R", "U")
    elif dy == 0:
        result = horizen_move("L", "U", "R", "D")

else:
    if dy > 0:
        result = horizen_move("U", "R", "D", "L")
    elif dy < 0:
        result = horizen_move("D", "R", "U", "L")
        
print(result)