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: Wrong Answer

Solution code:
def main():
    sx, sy, tx, ty = map(int, input().split())
    x = tx - sx
    y = ty - sy
    s = ""
    for i in range(2):
        tmp = ""
        if i:
            tmp += "D"
            tmp += "R"*(x+1)
            tmp += "U"*(y+1)
            tmp += "L"

        else:
            tmp += "R"*x
            s += "U"*y
        s += tmp + tmp.translate(str.maketrans({"U": "D",
                                                "D": "U", "L": "R", "R": "L"}))
    print(s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    sx, sy, tx, ty = map(int, input().split())
    x = tx - sx
    y = ty - sy
    s = ""
    for i in range(2):
        if i:
            s += "D"
            s += "R"*(x+1)
            s += "U"*(y+1)
            s += "L"

        else:
            s += "R"*x
            s += "U"*y
        s += s.translate(str.maketrans({"U": "D",
                                        "D": "U", "L": "R", "R": "L"}))
    print(s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    sx, sy, tx, ty = map(int, input().split())
    x = tx - sx
    y = ty - sy
    s = ""
    for i in range(2):
        if i:
            s += "D"
            s += "R"*x
            s += "U"*y
            s += "L"

        else:
            s += "R"*x
            s += "U"*y

        s += s.translate(str.maketrans({"U": "D",
                                        "D": "U", "L": "R", "R": "L"}))
    print(s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    sx, sy, tx, ty = map(int, input().split())
    x = tx - sx
    y = ty - sy
    s = ""
    for i in range(2):
        if i:
            s += "D"
            s += "R"*x
            s += "U"*x
            s += "L"

        else:
            s += "R"*x
            s += "U"*x

        s += s.translate(str.maketrans({"U": "D",
                                        "D": "U", "L": "R", "R": "L"}))
    print(s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(ty-sy):
    ans.append('U')
for i in range(tx-sx):
    ans.append('R')
for i in range(abs(sy-ty)):
    ans.append('D')
for i in range(abs(sx-tx)):
    ans.append('L')

ans.append('L')
for i in range(ty+1-sy):
    ans.append('U')
for i in range(tx-sx+1):
    ans.append('R')
ans.append('D')
ans.append('R')
for i in range(abs(sx-tx)+1):
    ans.append('L')
ans.append('U')
print(*ans, sep='')

Submission status: Wrong Answer

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

ans = ""

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    sx, sy, tx, ty = LI()

    dx = tx - sx
    dy = ty - sy
    ans_f0 = 'U' * dy + 'R' * dx
    ans_b0 = 'U' + 'L' * (dx + 1) + 'D' * (dy + 1) + 'R'
    ans_f1 = 'R' * dx + 'U' * dy
    ans_b1 = 'R' + 'D' * (dx + 1) + 'L' * (dy + 1) + 'U'

    print(ans_f0 + ans_b0 + ans_f1 + ans_b1)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ABC 051: C – Back and Forth
sx, sy, tx, ty = [int(i) for i in input().split()]

dx = tx - sx
dy = ty - sy

# r1
r1 = 'U' * (dy + 1) + 'R' * (dx + 1)

# r2
r2 = 'D' * (dy + 1) + 'L' * (dx + 1)

# r3
r3 = 'L' + 'U' * (dy + 2) + 'R' * (dx + 2) + 'D'

# r4
r4 = 'R' + 'D' * (dy + 2) + 'L' * (dx + 2) + 'U'

print(r1 + r2 + r3 + r4)

Submission status: Wrong Answer

Solution code:
def addRoute(i, c):
  t = ''
  for _ in range(i):
    t += c
  return t

pos=list(map(int, input().split()))
ud = pos[3] - pos[1]
rl = pos[2] - pos[0]
s = ''

s += addRoute(ud, 'U')
s += addRoute(rl, 'R')
s += addRoute(ud, 'D')
s += addRoute(rl, 'L')
s += 'L'
s += addRoute(ud+1, 'U')
s += addRoute(rl+1, 'R')
s += 'RR'
s += addRoute(ud+1, 'D')
s += addRoute(rl+1, 'L')
s += 'U'
print(s)

Submission status: Wrong Answer

Solution code:
def addRoute(i, c):
  t = ''
  for _ in range(i):
    t += c
  return t

pos=list(map(int, input().split()))
ud = pos[2] - pos[0]
rl = pos[3] - pos[1]
s = ''

s += addRoute(ud, 'U')
s += addRoute(rl, 'R')
s += addRoute(ud, 'D')
s += addRoute(rl, 'L')
s += 'L'
s += addRoute(ud+1, 'U')
s += addRoute(rl+1, 'R')
s += 'RR'
s += addRoute(ud+1, 'D')
s += addRoute(rl+1, 'L')
s += 'U'
print(s)

Submission status: Wrong Answer

Solution code:
def search_route(f, t):
    route = ''
    y = t[1] - f[1]
    tmp_y = 'U'*y if y >= 0 else 'D'*(y*-1)
    x = t[0] - f[0]
    tmp_x = 'R'*x if x >= 0 else 'L'*(x*-1)
    route = tmp_y + tmp_x
    return route


def main():
    t = list(map(int, input().split()))
    route = search_route(t[:2], t[2:]) + search_route(t[2:], t[:2])
    t[0] -= 1
    t[3] += 1
    route_2 = 'L' + search_route(t[:2], t[2:]) + 'D'
    t[2] += 1
    t[1] -= 1
    route_2 = route + 'R' + search_route(t[2:], t[:2]) + 'U'
    print(route+route_2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
sx, sy, tx, ty = map(int, input().split())
vertical = ty - sy
side =  tx - sx
cycle1 = "U" * vertical + "R" * side + "D" * vertical + "L" * side
cycle2 = "L" + "U" * (vertical + 1) + "R" * (side + 2) + "D" * (vertical + 2) + "L" * (side + 1) + "U"
print(cycle1 + cycle2)

Submission status: Wrong Answer

Solution code:
sx, sy, tx, ty = map(int, input().split())
vertical = ty - sy
side =  tx - sx
cycle1 = "U" * vertical + "R" * side + "D" * vertical + "L" * side
print(cycle1)
cycle2 = "L" + "U" * (vertical + 1) + "R" * (side + 2) + "D" * (vertical + 2) + "L" * (side + 1) + "U"
print(cycle1 + cycle2)

Submission status: Wrong Answer

Solution code:
SX,SY,TX,TY=map(int,input().split())
vx=TX-SX
vy=TY-SY
print('U'*vy+'R'*vx+'L'*vx+'D'*vy+'L'+'U'*(vy+1)+'R'*(vx+1)+'D'+ 'R'+'D'*(vy+1)+'L'*(vx+1)+'U')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    sx, sy, tx, ty = i_map()

    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+1):
        print('L', end='')

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

    for _ in range(tx-sx+2):
        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()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def dol1(sx, sy, gx, gy):
  s = ''
  x = sx - gx
  y = sy - gy
  if x >= 0:
    s += 'R' * x
  else:
    s += 'L' * abs(x)
  if y >= 0:
    s += 'U' * y
  else:
    s += 'D' * abs(y)
  return s

sx, sy, tx, ty = map(int, input().split())
ans = ''
ans += dol1(sx,sy,tx,ty)
print(ans)
ans += dol1(tx,ty,sx,sy)
print(ans)

if sx <= tx:
  if sy <= ty:
    ans += 'D'
    ans += dol1(sx, sy-1, tx+1, ty)
    ans += 'L'
    ans += 'U'
    ans += dol1(tx, ty+1, sx-1, sy)
    ans += 'R'
  else:
    ans += 'U'
    ans += dol1(sx, sy+1, tx+1, ty)
    ans += 'L'
    ans += 'D'
    ans += dol1(tx, ty-1, sx-1, sy)
    ans += 'R'
else:
  if sy <= ty:
    ans += 'D'
    ans += dol1(sx, sy-1, tx-1, ty)
    ans += 'R'
    ans += 'U'
    ans += dol1(tx, ty+1, sx+1, sy)
    ans += 'L'
  else:
    ans += 'U'
    ans += dol1(sx, sy+1, tx-1, ty)
    ans += 'R'
    ans += 'D'
    ans += dol1(tx, ty-1, sx+1, sy)
    ans += 'L'
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


def main():
    sx, sy, tx, ty = map(int, input().split())
    dx, dy = tx - sx, ty - sy
    ans = ""
    for _ in range(dx): ans += "R"
    for _ in range(dy): ans += "U"
    for _ in range(dx): ans += "L"
    for _ in range(dy): ans += "D"
    ans += "D"
    for _ in range(dx + 1): ans += "R"
    for _ in range(dy + 1): ans += "U"
    ans += "L"
    ans += "U"
    for _ in range(dx + 1): ans += "L"
    for _ in range(dy + 1): ans += "D"
    ans += "L"
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

dx = tx - sx
dy = ty - sy

res = ""

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

print(res)

Submission status: Wrong Answer

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

# input = stdin.readline

def solve(sx,sy,tx,ty):
  res = []
  dx = tx - sx
  dy = ty - sy
  
  assert dx > 0 and dy > 0
  # 1回目
  res.extend(['R']*dx)
  res.extend(['U']*dy)
  res.extend(['L']*dx)
  res.extend(['D']*dy)

  # 2回目
  res.append('D')
  res.extend(['R']*(dx+1))
  res.extend(['U']*(dy+2))
  res.extend(['L']*(dx+2))
  res.extend(['D']*(dy+1))
  res.append('R')
  return ''.join(res)


def main():
  sx,sy,tx,ty = map(int,input().split())
  print('{}'.format(solve(sx,sy,tx,ty)))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

# input = stdin.readline

def solve(sx,sy,tx,ty):
  res = []
  dx = tx - sx
  dy = ty - sy
  # 1回目
  res.extend(['R']*dx)
  res.extend(['U']*dy)
  res.extend(['L']*dx)
  res.extend(['D']*dy)

  # 2回目
  res.append('D')
  res.extend(['R']*(dx+2))
  res.extend(['U']*(dy+2))
  res.extend(['L']*(dx+1))
  res.extend(['D']*(dy+1))
  res.append('R')
  return ''.join(res)


def main():
  sx,sy,tx,ty = map(int,input().split())
  print('{}'.format(solve(sx,sy,tx,ty)))

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

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

dx = tx -sx
dy = ty -sy

if dx >= 0:
    mx = ["R", "L"]
else:
    mx = ["L", "R"]
    dx = -dx

if dy >= 0:
    my = ["U", "D"]
else:
    mx = ["D", "U"]
    dy = -dy

ans = mx[0]*dx + my[0]*dy
ans = ans + mx[1]*dx + my[1]*dy
ans = ans + my[1] + mx[0]*(dx + 1) + my[0]*(dy + 1) + mx[1]
ans = ans + my[0] + mx[1]*(dx + 1) + my[1]*(dx + 1) + mx[0]

print(ans)

Submission status: Wrong Answer

Solution code:

sx,sy, tx,ty = map(int, raw_input().split())
print sx,sy, tx,ty
def f(sx,sy,tx,ty):
	path = ['D']
	path += ['R'] * (abs(tx - sx) + 1)
	path += ['U'] * (abs(ty - sy) + 1)
	path += ['L'] * (abs(tx - sx) + 1)
	path += ['D'] * (abs(ty - sy))
	return path

	
def g(sx,sy,tx,ty):
	path = []
	path += ['R'] * (abs(tx - sx))
	path += ['U'] * (abs(ty - sy) + 1)
	path += ['L'] * (abs(tx - sx)+1)
	path += ['D'] * (abs(ty - sy)+1) 
	return path + ['R']



print ''.join(f(sx,sy, tx,ty) + g(sx,sy,tx,ty))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())
def NIJIGEN(H): return [list(input()) for i in range(H)]
a,b,c,d=MAP()
x=c-a
y=d-b
ans=str()
ans+="R"*x+"U"*y
ans+="L"*x+"R"*y
ans+="L"+"U"*(y+1)+"R"*(x+1)+"D"
ans+="D"+"R"*(x+1)+"U"*(y+1)+"L"
print(ans)

Submission status: Wrong Answer

Solution code:
SX,SY,TX,TY = (int(T) for T in input().split())
print('L'*(2*(1+TX-SX))+'R'*(2*(1+TX-SX))+'U'*(2*(1+TY-SY))+'D'*(2*(1+TY-SY)))

Submission status: Wrong Answer

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

dx = tx - sx
dy = ty - sy

ans = ''

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

print(ans)

Submission status: Wrong Answer

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

s = ["L"]+["U"]*dy+["R"]*dx+["D"] + ["R"]+["D"]*dy+["L"]*dx+["U"] + ["U"]*dy+["R"]*dx + ["D"]*dy+["L"]*dx
print("".join(s))

Submission status: Wrong Answer

Solution code:
# C - Back and Forth
def main():
    sx, sy, tx, ty = map(int, input().split())

    rx = tx - sx
    ry = ty - sy

    ans = []

    # path1
    for _ in range(rx):
        ans.append('R')
    for _ in range(ry):
        ans.append('U')

    # path2
    for _ in range(rx):
        ans.append('L')
    for _ in range(ry):
        ans.append('D')

    # path3
    ans.append('L')
    for _ in range(ry+1):
        ans.append('U')
    for _ in range(rx+1):
        ans.append('R')
    
    # path4
    ans.append('R')
    for _ in range(ry+1):
        ans.append('D')
    for _ in range(rx+1):
        ans.append('L')
    
    print(''.join(ans))


if __name__ ==  "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

short_outward = []
short_return = []
long_outward = ["L"]
long_return = ["R"]

for i in range((ty-sy)):
    short_outward.append("U")

for i in range((tx-sx)):
    short_outward.append("R")


print(short_outward)

for i in range((ty-sy)):
    short_return.append("D")

for i in range((tx-sx)):
    short_return.append("L")



print(short_return)

for i in range((ty-sy)+1):
    long_outward.append("U")

for i in range((tx-sx)+1):
    long_outward.append("R")

long_outward.append("D")

print(long_outward)

for i in range((ty-sy)+1):
    long_return.append("D")

for i in range((tx-sx)+1):
    long_return.append("L")

long_return.append("U")

print(long_return)

list = short_outward+short_return+long_outward+long_return
# print(list)

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

Submission status: Wrong Answer

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

short_outward = []
short_return = []
long_outward = ["L"]
long_return = ["R"]

for i in range((ty-sy)):
    short_outward.append("U")

for i in range((tx-sx)):
    short_outward.append("R")


print(short_outward)

for i in range((ty-sy)):
    short_return.append("D")

for i in range((tx-sx)):
    short_return.append("L")



print(short_return)

for i in range((ty-sy)+1):
    long_outward.append("U")

for i in range((tx-sx)+1):
    long_outward.append("R")

long_outward.append("D")

print(long_outward)

for i in range((ty-sy)+1):
    long_return.append("D")

for i in range((tx-sx)+1):
    long_return.append("L")



long_return.append("U")

print(long_return)

list = short_outward+short_return+long_outward+long_return
# print(list)

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

Submission status: Wrong Answer

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

short_outward = []
short_return = []
long_outward = ["D"]
long_return = ["U"]

for i in range((tx-sx)):
    short_outward.append("R")

for i in range((ty-sy)):
    short_outward.append("U")

print(short_outward)

for i in range((tx-sx)):
    short_return.append("L")

for i in range((ty-sy)):
    short_return.append("D")

print(short_return)

for i in range((tx-sx)+1):
    long_outward.append("R")

for i in range((ty-sy)+1):
    long_outward.append("U")

long_outward.append("L")

print(long_outward)

for i in range((tx-sx)+1):
    long_return.append("L")

for i in range((ty-sy)+1):
    long_return.append("D")

long_return.append("R")

print(long_return)

list = short_outward+short_return+long_outward+long_return

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[17]:


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


# In[19]:


X = sx; Y = sy
for x in range(sx+1,tx+1):
    print("R")
X = x
for y in range(sy+1,ty+1):
    print("U")
Y = y
for x in reversed(range(sx,tx)):
    print("L")
X = x
for y in reversed(range(sy,ty)):
    print("D")
Y = y
Y -= 1
print("D")
for x in range(sx+1,tx+2):
    print("R")
X = x
for y in range(sy,ty+1):
    print("U")
Y = y
X -= 1
print("L")
Y += 1
print("U")
for x in reversed(range(sx-1,tx)):
    print("L")
X = x
for y in reversed(range(sy,ty+1)):
    print("D")
Y = y
X += 1
print("R")


# In[ ]:

Submission status: Wrong Answer

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

x_diff = tx-sx
y_diff = ty-sy

up = 'U'*abs(y_diff)
down = 'D'*abs(y_diff)
left = 'L'*abs(y_diff)
right = 'R'*abs(y_diff)

ans = down+left+up+right
ans = 'RD'+down+left+'LU'+'LU'+up+right+'RD'+ans

print(ans)

Submission status: Wrong Answer

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

dx=tx-sx
dy=ty-sy
d={0:'R', 1:'U', 2:'L', 3:'D'}
dirc=[dx,dy,dx,dy]

def path(sign,x,y,z,w):
  return d[sign+1]*abs(z-x) + d[sign+2]*abs(y-w)

s=''
s+='R'
s+=path(-1, sx+1, sy, tx, ty-1)
s+='UU'
s+=path(1, tx,ty+1,sx-1,sy)
s+='RU'
s+=path(-1, sx,sy-1,tx+1,ty)
s+='LL'
s+=path(1, tx-1,ty,sx,sy+1)
s+='D'
print(s)

Submission status: Wrong Answer

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

dx=tx-sx
dy=ty-sy
d={0:'R', 1:'U', 2:'L', 3:'D'}
dirc=[dx,dy,dx,dy]

def path(sign,x,y,z,w):
  return d[sign+1]*abs(z-x) + d[sign+2]*abs(y-w)

s=''
s+='R'
s+=path(-1, sx+1, sy, tx, ty-1)
s+='UU'
s+=path(1, tx,ty+1,sx-1,sy)
s+='RU'
s+=path(-1, sx,sy-1,tx+1,ty)
s+='LL'
s+=path(1, tx-1,ty,sx,sy+1)
s+='U'
print(s)

Submission status: Wrong Answer

Solution code:
s = input().split()

sx = int(s[0])
sy = int(s[1])
tx = int(s[2])
ty = int(s[3])

answer = []

for num in range(ty - sy):
    answer.append('U')

for num in range(tx - sx):
    answer.append('R')

for num in range(ty - sy):
    answer.append('D')

for num in range(tx - sx):
    answer.append('L')

answer.append('L')

for num in range(ty - sy + 1):
    answer.append('U')

for num in range(ty - sx + 1):
    answer.append('R')

answer.append('D')

answer.append('R')

for num in range(ty - sy + 1):
    answer.append('D')

for num in range(tx - sx + 1):
    answer.append('L')

answer.append('U')

for num in range(len(answer)):
    print(answer[num], end='')
    
print('')

Submission status: Wrong Answer

Solution code:
s = input().split()

sx = int(s[0])
sy = int(s[1])
tx = int(s[2])
ty = int(s[3])

answer = []

for num in range(ty - sy):
    answer.append('U')

for num in range(tx - sx):
    answer.append('R')

for num in range(ty - sy):
    answer.append('D')

for num in range(tx - sx):
    answer.append('L')

answer.append('L')

for num in range(ty - sy + 1):
    answer.append('U')

for num in range(ty - sx + 1):
    answer.append('R')

answer.append('D')

answer.append('R')

for num in range(ty - sy + 1):
    answer.append('D')

for num in range(tx - sx + 1):
    answer.append('L')

answer.append('U')

for num in range(len(answer)):
    print(answer[num],end='')

Submission status: Wrong Answer

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

dx = tx - sx
dy = ty - sy
d1 = ['L'] + ['U']*(dy+1) + ['R']*(dx+1) + ['D']*1
d2 = ['L']*dx + ['D']*dy
d3 = ['D']*1 + ['R']*(dx+1) + ['U']*(dy+1) + ['L']*1
d4 = ['U']*dy + ['R']*dx

print(''.join(d1+d2+d3+d4))

Submission status: Wrong Answer

Solution code:
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)+"L"+"U"+"L"*(tx-sx+1)+"D"*(ty-sx+1)+"R")

Submission status: Wrong Answer

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

if dx == 0:
    if dy > 0:
        d1 = "U"
        d2 = "D"
    else:
        d1 = "D"
        d2 = "U"
    dy = abs(dy)
    ans = d1 * dy
    ans += "R" + d2 * dy + "L"
    ans += "L" + d1 * dy + "R"
    ans += d1 + "RR" + d2 * (dy + 2) + "LL" + d1
    print(ans)
    
elif dy == 0:
    if dx > 0:
        d1 = "R"
        d2 = "L"
    else:
        d1 = "L"
        d2 = "R"
    dx = abs(dx)
    ans = d1 * dx
    ans += "U" + d2 * dx + "D"
    ans += "D" + d1 * dx + "U"
    ans += d1 + "UU" + d2 * (dx + 2) + "DD" + d1
    print(ans)

else:
    if dy > 0:
        d1 = "U"
        d2 = "D"
    else:
        d1 = "D"
        d2 = "U"
    if dx > 0:
        d3 = "R"
        d4 = "L"
    else:
        d3 = "L"
        d4 = "R"
    dx = abs(dx)
    dy = abs(dy)
    ans = d1 * dy + d3 * dx
    ans += d4 * dx + d2 * dy
    ans += d4 + d1 * (dy + 1) + d3 * (dx + 1) + d2
    ans += d1 + d4 * (dx + 1) + d2 * (dy + 1) + d3
    print(ans)

Submission status: Wrong Answer

Solution code:
sx,sy,gx,gy=map(int,input().split())
s=''
t=''
for i in range(gx-sx):
  s+='R'
  t+='L'
for i in range(gy-sy):
  s+='U'
  t+='D'
s+=t
s+='D'
t='U'
for i in range(gx-sx+1):
  s+='R'
  t+='L'
for i in range(gy-sy+1):
  s+='U'
  t+='D'
s+='L'+t+'R'
print(len(s))

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def calcTwoPointDistance(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5


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

    sx, sy, tx, ty = il()

    move = []
    for _ in range(sy, ty):
        move.append('U')
    for _ in range(sx, tx):
        move.append('R')
    move.append('U')
    for _ in range(sx, tx + 1):
        move.append('L')
    for _ in range(sy, ty):
        move.append('D')
    move.append('R')

    for _ in range(sx, tx):
        move.append('R')
    for _ in range(sy, ty):
        move.append('U')
    move.append('R')
    for _ in range(sy, ty+1):
        move.append('D')
    for _ in range(sx, tx+1):
        move.append('L')
    move.append('U')

    print(*move,sep='')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def calcTwoPointDistance(x1, y1, x2, y2):
    return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5


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

    sx, sy, tx, ty = il()

    move = []
    for _ in range(sy, ty+1):
        move.append('U')
    for _ in range(sx, tx+1):
        move.append('R')
    move.append('U')
    for _ in range(sx, tx + 2):
        move.append('L')
    for _ in range(sy, ty+1):
        move.append('D')
    move.append('R')

    for _ in range(sx, tx+1):
        move.append('R')
    for _ in range(sy, ty+1):
        move.append('U')
    move.append('R')
    for _ in range(sy, ty+2):
        move.append('D')
    for _ in range(sx, tx+2):
        move.append('L')
    move.append('U')

    print(*move,sep='')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys; input = lambda: sys.stdin.readline()
def calc(dx,dy):
    f = ""
    if dx >= 0:
        f += "R" * dx
    if dx < 0:
        f += "L" * dx
    if dy >= 0:
        f += "U" * dy
    if dy < 0:
        f += "D" * dy
    for i in f:
        if i == "U":
            f += "D"
        if i == "D":
            f += "U"
        if i == "R":
            f += "L"
        if i == "L":
            f += 'R'
    return f
sx, sy, tx, ty = map(int, input().split())
a, b, c, d = calc(tx - (sx + 1), ty - sy), calc(tx - (sx - 1), ty - sy), calc(tx - sx, ty - (sy + 1)), calc(tx - sx, ty - (sy - 1))
print(calc(tx - sx, ty - sy) + max(a, b, c, d, key=lambda i: len(i)))

Submission status: Wrong Answer

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

dx=tx-sx
dy=ty-sy

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

print(s)

Submission status: Wrong Answer

Solution code:
x,y,X,Y=map(int,input().split())
a=X-x
b=Y-y
cnt=0
new_cnt=0
l=[]
L=[]
for i in range(a):
  l.append('R')
  cnt+=1

for i in range(b):
  l.append('U')
  new_cnt+=1

for i in l:
  if i=='R':
    l.append('L')
  elif i=='U':
    l.append('D')

l.append('D')
L.append('D')

for i in range(cnt+2):
  l.append('R')
  L.append('R')
  
for i in range(new_cnt+2):
  l.append('U')
  L.append('U')
l.append('L')
L.append('L')
l.append('U')
for i in L:
  if i=='R':
    l.append('L')
  elif i=='U':
    l.append('D')
l.append('R')

print(('').join(l))

Submission status: Wrong Answer

Solution code:
sx,sy,tx,ty=map(int,input().split())
ans=""
d=(tx-sx)+(ty-sy)#sとtの距離
#1週目　最短距離
for i in range(2*d):
    if i<=(tx-sx)-1:
        ans+="R"
    elif i<=d-1:
        ans+="U"
    elif i<=(d-1)+(tx-sx):
        ans+="L"
    else:
        ans+="D"
#print(ans)
#2週目 外周
for j in range(2*(d+4)):
    if j==0:
        ans+="D"
    elif j<=(tx-sx)+2-1:
        ans+="R"
    elif j<=(d+4)-1-1:
        ans+="U"
    elif j<=(d+4)-1:
        ans+="L"
    elif j<=(d+4)-1+1:
        ans+="U"
    elif j<=(d+4)-1-1+(tx-sx+1):
        ans+="L"
    elif j<=2*(d+4)-1-1:
        ans+="D"
    else:
        ans+="R"
print(ans)

Submission status: Wrong Answer

Solution code:
x,y,X,Y=map(int,input().split())
a=X-x
b=Y-y
cnt=0
new_cnt=0
l=[]
L=[]
for i in range(a):
  l.append('R')
  cnt+=1

for i in range(b):
  l.append('U')
  new_cnt+=1

for i in l:
  if i=='R':
    l.append('L')
  elif i=='U':
    l.append('D')

l.append('U')
L.append('U')
for i in range(cnt+2):
  l.append('R')
  L.append('R')
for i in range(new_cnt+2):
  l.append('U')
  L.append('U')
l.append('L')
L.append('L')
l.append('U')
for i in L:
  if i=='R':
    l.append('L')
  elif i=='U':
    l.append('D')

print(('').join(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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