Problem:


Score : 300 points

Problem Statement

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

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

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

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

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

Under this condition, find a shortest path for him.  

Constraints

-1000 ≤ sx < tx ≤ 1000 

-1000 ≤ sy < ty ≤ 1000 

sx,sy,tx and ty are integers.

Input

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

sx sy tx ty

Output

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

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

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

U: Up

D: Down

L: Left

R: Right

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

Sample Input 1

0 0 1 2

Sample Output 1

UURDDLLUUURRDRDDDLLU

One possible shortest path is:

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

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

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

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

Sample Input 2

-2 -2 1 1

Sample Output 2

UURRURRDDDLLDLLULUUURRURRDDDLLDL



Sample input:
0 0 1 2


Sample output:
UURDDLLUUURRDRDDDLLU

Submission status: Accepted

Solution code:
sx, sy, tx, ty = [int(i) for i in input().split()]
dx, dy = tx - sx, ty - sy
p1 = "U" * dy + "R" * dx
p2 = "D" * dy + "L" * dx
p3 = "LU" + p1 + "RD"
p4 = "RD" + p2 + "LU"
print(p1 + p2 + p3 + p4)

Submission status: Accepted

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

res = ""

res += "R"*(tx-sx) + "U"*(ty-sy)
res += "L"*(tx-sx) + "D"*(ty-sy)

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

print(res)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter
#以下てんぷら
def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)

#n = ip()                                     #入力整数1つ
a,b,c,d= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#v=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
#こっから本文
for i in range(d-b):
    print("U", end='')
for i in range(c-a):
    print("R", end='')
for i in range(d-b):
    print("D", end='')
for i in range(c-a+1):
    print("L", end='')
for i in range(d-b+1):
    print("U", end='')
for i in range(c-a+1):
    print("R", end='')
print("D", end='')
print("R", end='')
for i in range(d-b+1):
    print("D", end='')
for i in range(c-a+1):
    print("L", end='')
print("U")

Submission status: Accepted

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

x = tx - sx
y = ty - sy

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
	sx, sy, tx, ty = map(int, input().split())
	dx = tx-sx
	dy = ty-sy
	ans = ""
	offset_x = ["", "R", "L"]
	offset_y = ["", "U", "D"]
	def move(x, y):
		res = ""
		if y != 0:
			res += offset_y[y//abs(y)]*abs(y)
		if x != 0:
			res += offset_x[x//abs(x)]*abs(x)
		return res

	ans += move(dx, dy)
	ans += move(-dx, -dy)
	ans += move(-dx//abs(dx), 0)
	ans += move((dx//abs(dx))*(abs(dx)+1), (dy//abs(dy))*(abs(dy)+1))
	ans += move(dx//abs(dx), -dy//abs(dy))
	ans += move((-dx//abs(dx))*(abs(dx)+1), (-dy//abs(dy))*(abs(dy)+1))
	ans += move(0, dy//abs(dy))

	print(ans)


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int,input().split())
ans = []
firstup = (ty-sy)*['U']
firstright = (tx-sx)*['R']
firstdown = (ty-sy)*['D']
firstleft = (tx-sx)*['L']
second_offset = ['L']
secoudup = firstup+['U']
secondright = firstright + ['R']
second_offset2 = ['D']
second_offset3 = ['R']
secounddown = firstdown +['D']
secondleft = firstleft + ['L']
second_offset4 = ['U']
ans = firstup+firstright+firstdown+firstleft+second_offset+secoudup+secondright+second_offset2+second_offset3+secounddown+secondleft+second_offset4
print(''.join(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

    return (sx, sy), (tx, ty)


def get_right(point):
    return (point[0] + 1, point[1])


def get_left(point):
    return (point[0] - 1, point[1])


def get_up(point):
    return (point[0], point[1] + 1)


def get_down(point):
    return (point[0], point[1] - 1)


def go_right_up(sp, ep):
    move = []
    curr = sp

    while curr[0] < ep[0]:
        move.append('R')
        curr = get_right(curr)

    while curr[1] < ep[1]:
        move.append('U')
        curr = get_up(curr)

    return move


def go_left_down(sp, ep):
    move = []
    curr = sp

    while ep[0] < curr[0]:
        move.append('L')
        curr = get_left(curr)

    while ep[1] < curr[1]:
        move.append('D')
        curr = get_down(curr)

    return move


def submit():
    start, end = read_input()

    start1 = get_right(start)
    end1 = get_down(end)

    start2 = get_left(end)
    end2 = get_up(start)

    start3 = get_down(start)
    end3 = get_right(end)

    start4 = get_up(end)
    end4 = get_left(start)


    move = ['R']
    move += go_right_up(start1, end1)
    move += ['U']

    move += ['L']
    move += go_left_down(start2, end2)
    move += ['D']

    move += ['D']
    move += go_right_up(start3, end3)
    move += ['L']

    move += ['U']
    move += go_left_down(start4, end4)
    move += ['R']

    print(''.join(move))


if __name__ == '__main__':
    submit()

Submission status: Accepted

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

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)

Submission status: Accepted

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

def path(sx, sy, tx, ty):
  res = ''
  y = ty - sy
  res += abs(y) * ('U' if y > 0 else 'D')
  x = tx - sx
  res += abs(x) * ('R' if x > 0 else 'L')
  return res

ans = ''
ans += path(sx, sy ,tx ,ty)
ans += path(tx, ty, sx, sy)
ans += 'L'
ans += path(sx - 1, sy, tx, ty + 1)
ans += 'DR'
ans += path(tx + 1, ty, sx, sy - 1)
ans += 'U'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def path(x, y, gx, gy):
  u = gy - y
  if u > 0:
    for i in range(u):
      print('U', end='')
  elif u < 0:
    for i in range(-u):
      print('D', end='')
  r = gx - x
  if r > 0:
    for i in range(r):
      print('R', end='')
  elif r < 0:
    for i in range(-r):
      print('L', end='')

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

Submission status: Accepted

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

ans = 'U' * ty + 'R' * tx + 'D' * ty + 'L' * tx
ans += 'L' + 'U' * (ty+1) + 'R' * (tx+1) + 'DR' + 'D' * (ty+1) + 'L' * (tx+1) + 'U'

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
input=stdin.readline().rstrip().split()

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

first=tx-sx
second=ty-sy

output=first*"R"+second*"U"+first*"L"+second*"D"+"D"+(first+1)*"R"+(second+1)*"U"+"L"+"U"+(first+1)*"L"+(second+1)*"D"+"R"
"""
output=None
output+=first*"R"
output+=second*"U"

output+=first*"L"
output+=second*"D"

output+="D"
output+=(first+1)*"R"
output+=(second+1)*"U"
output+="L"

output+="U"
output+=(first+1)*"L"
output+=(second+1)*"D"
output+="R"
"""
print(output)

Submission status: Accepted

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

Submission status: Accepted

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

h = ty - sy
w = tx - sx

ans = 'U'*h + 'R'*w + 'D'*h + 'L'*w + 'L' + 'U'*(h+1) + 'R'*(w+1) + 'D' + 'R' + 'D'*(h+1) + 'L'*(w+1) + 'U'

print(ans)

Submission status: Accepted

Solution code:
s1,s2,t1,t2 = map(int,input().split())
a = ""
a += "U"*(t2-s2)
a += "R"*(t1-s1)
a += "D"*(t2-s2)
a += "L"*(t1-s1)
a += "L"
a += "U"*(t2-s2+1)
a += "R"*(t1-s1+1)
a += "D"
a += "R"
a += "D"*(t2-s2+1)
a += "L"*(t1-s1+1)
a += "U"
print(a)

Submission status: Accepted

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

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

print(round1 + round2)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x1, y1, x2, y2 = map(int, input().split())
x = abs(x2 - x1)
y = abs(y2 - y1)
for _ in range(y):
    print("U", end="")
for _ in range(x):
    print("R", end="")
for _ in range(y):
    print("D", end="")
for _ in range(x):
    print("L", end="")
print("L", end="")
for _ in range(y + 1):
    print("U", end="")
for _ in range(x + 1):
    print("R", end="")
print("D", end="")
print("R", end="")
for _ in range(y + 1):
    print("D", end="")
for _ in range(x + 1):
    print("L", end="")
print("U")

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-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 pf(s): return print(s, flush=True, end="")

sx,sy,tx,ty=LI()

for i in range(abs(ty-sy)):
	pf("U")

for i in range(abs(sx-tx)):
	pf("R")

for i in range(abs(ty-sy)):
	pf("D")
	
for i in range(abs(sx-tx)):
	pf("L")

pf("L")

for i in range(abs(ty-sy)):
	pf("U")
pf("U")
pf("R")

for i in range(abs(sx-tx)):
	pf("R")
	
pf("D")

pf("R")

for i in range(abs(ty-sy)):
	pf("D")
pf("D")
pf("L")
for i in range(abs(tx-sx)):
	pf("L")
pf("U")

Submission status: Accepted

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

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

dif_x = abs(tx - sx)
dif_y = abs(ty - sy)


for i in range(dif_x):
    print("R" , end="")

for i in range(dif_y):
    print("U", end="")

for i in range(dif_x):
    print("L", end="")

for i in range(dif_y):
    print("D", end="")

#２周目

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

for i in range(dif_y+1):
    print("U", end="")

print("L", end="")

print("U", end="")

for i in range(dif_x+1):
    print("L", end="")

for i in range(dif_y+1):
    print("D", end="")

print("R", end="")

Submission status: Accepted

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

route = ''

# 1周目
route += 'U' * (ty - sy)
route += 'R' * (tx - sx)

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

# 2週目
route += 'L'
route += 'U' * (ty - sy + 1)
route += 'R' * (tx - sx + 1)
route += 'D'

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

print(route)

Submission status: Accepted

Solution code:
sx, sy, tx, ty = map(int, input().split())
first_step = ""
second_step = ""
third_step = "L"
fourth_step = ""

if ty-sy > 0:
  first_step += 'U'*(ty-sy)
elif ty-sy < 0:
  first_step += 'D'*(sy-ty)
if tx-sx > 0:
  first_step += "R"*(tx-sx)
elif tx-sx < 0:
  first_step += "L"+(sx-tx)

for c in list(first_step):
  if c == 'U':
    second_step += 'D'
  elif c == 'D':
    second_step += 'U'
  elif c == 'R':
    second_step += 'L'
  elif c == 'L':
    second_step += 'R'

sx -= 1
ty += 1


if ty-sy > 0:
  third_step += 'U'*(ty-sy)
elif ty-sy < 0:
  third_step += 'D'*(sy-ty)
if tx-sx > 0:
  third_step += "R"*(tx-sx)
elif tx-sx < 0:
  third_step += "L"+(sx-tx)

third_step += 'D'
sy -= 1
tx += 1
for c in list(third_step):
  if c == 'U':
    fourth_step += 'D'
  elif c == 'D':
    fourth_step += 'U'
  elif c == 'R':
    fourth_step += 'L'
  elif c == 'L':
    fourth_step += 'R'

print(first_step+second_step+third_step+fourth_step)

Submission status: Accepted

Solution code:
a,b,c,d=map(int,input().split())
dic={"U":"D","D":"U","L":"R","R":"L"}

x=c-a
y=d-b

ans=""
if y>0:
    ans+="U"*y
else:
    ans+="D"*y
if x>0:
    ans+="R"*x
else:
    ans+="L"*x
for i in ans:
    ans+=dic[i]
ans2=""
if x>0:
    ans2+="L"
else:
    ans2+="R"
if y>0:
    ans2+="U"*(y+1)
else:
    ans2+="D"*(y+1)
if x>0:
    ans2+="R"*(x+1)
else:
    ans2+="L"*(x+1)
if y>0:
    ans2+="D"
else:
    ans2+="U"
for i in ans2:
    ans2+=dic[i]
print(ans+ans2)

Submission status: Accepted

Solution code:
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = s_inpl()   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

import math
import copy
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

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

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

#############################################

sx, sy, tx, ty = s_inpl()

ans = ""

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

print(ans)

Submission status: Accepted

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

#内廻り(S->T)
ans += 'U'
ans += 'U'*(ty-sy-1)
ans += 'R'*(tx-sx-1)
ans += 'R'
#内廻り(T->S)
ans += 'D'
ans += 'D'*(ty-sy-1)
ans += 'L'*(tx-sx-1)
ans += 'L'
#外廻り(S->T)
ans += 'L'
ans += 'U'*(ty-sy+1)
ans += 'R'*(tx-sx+1)
ans += 'D'
#外廻り(T->S)
ans += 'R'
ans += 'D'*(ty-sy+1)
ans += 'L'*(tx-sx+1)
ans += 'U'

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

sx, sy, tx, ty = MAP()

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

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

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

Submission status: Accepted

Solution code:
a, b, c, d = [int(item) for item in input().split()]
path = ""
path += "R" * (c-a) + "U" * (d-b) + "L" * (c-a) + "D" * (d-b)
path += "D" + "R" * (c-a+1) + "U" * (d-b+1) + "L"
path += "U" + "L" * (c-a+1) + "D" * (d-b+1) + "R"
print(path)

Submission status: Accepted

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

print("U" * dy + "R" * (dx + 1) + "D" * (dy + 1) + "L" * (dx + 1) + 
      "UL" + "U" * (dy + 1) + "R" * (dx + 1) + "D" * (dy + 1) + "L" * dx)

Submission status: Accepted

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

print (ans)

Submission status: Accepted

Solution code:
import sys

def main():
    input = sys.stdin.readline
    X = list(map(int, input().split()))

    diffx = X[2] - X[0]
    diffy = X[3] - X[1]

    f1 = 'U' * diffy + 'R' * diffx 
    b1 = 'D' * diffy + 'L' * diffx
    f2 = 'L' + 'U' * (diffy + 1) + 'R' * (diffx + 1) + 'D'
    b2 = 'R' + 'D' * (diffy + 1) + 'L' * (diffx + 1) + 'U'

    return f1 + b1 + f2 + b2


if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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+1)
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)

Submission status: Accepted

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

w = tx-sx
h = ty-sy


ans = ""
ans+="R"*w
ans+="U"*h
ans+="L"*w
ans+="D"*h

ans+="D"
ans+="R"*(w+1)
ans+="U"*(h+1)
ans+="L"

ans+="U"
ans+="L"*(w+1)
ans+="D"*(h+1)
ans+="R"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

S=''
S+='R'*x
S+='U'*y
S+='L'*x
S+='D'*y

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

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

print(S)

Submission status: Accepted

Solution code:
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

sx, sy, tx, ty = nm()

ans = ''

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

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    sx, sy, tx, ty = (int(_) for _ in input().split())
    tx = tx - sx
    ty = ty - sy
    print('R'*tx+'U'*ty + 'L'*tx+'D'*ty + 'L'+'U'*(ty+1)+'R'*(tx+1)+'D' + 'R'+'D'*(ty+1)+'L'*(tx+1)+'U')
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
xs, ys, xt, yt = map(int, input().split())
p1 = 'R' * (xt - xs) + 'U' * (yt - ys)
p2 = 'L' * (xt - xs) + 'D' * (yt - ys)
p3 = 'D' + 'R' * (xt - xs + 1) + 'U' * (yt - ys + 1) + 'L'
p4 = 'U' + 'L' * (xt - xs + 1) + 'D' * (yt - ys + 1) + 'R'
print(p1 + p2 + p3 + p4)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#n=int(input())
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#import math
#li=input().split()
#S=input()

lis=list(map(int,input().split()))
S=""
x=lis[2]-lis[0]
y=lis[3]-lis[1]
S+="U"*y
S+="R"*x
S+="D"*y
S+="L"*(x+1)
S+="U"*(y+1)
S+="R"*(x+1)
S+="D"
S+="R"
S+="D"*(y+1)
S+="L"*(x+1)
S+="U"
print(S)

Submission status: Accepted

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

Submission status: Accepted

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

dx = tx - sx
dy = ty - sy

p1 = dy * 'U' + dx * 'R'
p2 = dy * 'D' + dx * 'L'
p3 = 'D' + (dx + 1) * 'R' + \
	(dy + 1) * 'U' + 'L'
p4 = 'U' + (dx + 1) * 'L' + \
	(dy + 1) * 'D' + 'R'
  
print(p1 + p2 + p3 + p4)

Submission status: Accepted

Solution code:
def back_and_forth(sx: int, sy: int, tx: int, ty: int)->int:
    dx, dy = tx - sx, ty - sy
    forth = ('U' * dy) + ('R' * dx)
    back = ('D' * dy) + ('L' * dx)
    first = forth + back
    second = 'LU' + forth + 'RD' + 'RD' + back + 'LU'

    return first + second


if __name__ == "__main__":
    sx, sy, tx, ty = map(int, input().split())
    ans = back_and_forth(sx, sy, tx, ty)
    print(ans)

Submission status: Accepted

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

ans = 'R'
x = tx - sx
y = ty - sy
for _ in range(x-1):
    ans += 'R'
for _ in range(y):
    ans += 'U'
for _ in range(x):
    ans += 'L'
for _ in range(y):
    ans += 'D'
ans += 'LU'
for _ in range(y):
    ans += 'U'
for _ in range(x):
    ans += 'R'
ans += 'RD'
ans += 'RD'
for _ in range(y):
    ans += 'D'
for _ in range(x):
    ans += 'L'
ans += 'LU'

print(ans)

Submission status: Accepted

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

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

route = []

y = ty - sy
x = tx - sx

route += ["U"] * y
route += ["R"] * x
route += ["D"] * y
route += ["L"] * x
route += ["L"]
route += ["U"] * (y + 1)
route += ["R"] * (x + 1)
route += ["D","R"]
route += ["D"] * (y + 1)
route += ["L"] * (x + 1)
route += ["U"]

print("".join(route))

Submission status: Accepted

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

s = ''
dx = tx - sx
dy = ty - sy

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

print(s)

Submission status: Accepted

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

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

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

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

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

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

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

s += 'LU'

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

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

s += 'R'

print(s)

Submission status: Accepted

Solution code:
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+='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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=list(map(int, input().split()))
a = ""
for i in range(n[2]-n[0]):
        a += "R"
for i in range(n[3]-n[1]):
        a += "U"
for i in range(n[2]-n[0]):
        a += "L"
for i in range(n[3]-n[1]):
        a += "D"
a += "D"
for i in range(n[2]-n[0]+1):
        a += "R"
for i in range(n[3]-n[1]+1):
        a += "U"
a += "LU"
for i in range(n[2]-n[0]+1):
        a += "L"
for i in range(n[3]-n[1]+1):
        a += "D"
a += "R"
print(a)

Submission status: Accepted

Solution code:
x1, y1, x2, y2 = map(int, input().split())
ans = ('U'*(y2-y1),'R'*(x2-x1+1),'D'*(y2-y1+1),
      'L'*(x2-x1+1),'U','L','U'*(y2-y1+1),
      'R'*(x2-x1+1),'D'*(y2-y1+1),'L'*(x2-x1))
print(''.join(ans))

Submission status: Accepted

Solution code:
x, y, p, q = map(int, input().split())

p -= x
q -= y

# s -> t
r1 = 'R' * p + 'U' * q

# t -> s
r2 = 'L' + 'D' * (q-1) + 'L' * (p-1) + 'D'

# s -> t
r3 = 'L' + 'U' * (q + 1) + 'R' * (p + 1) + 'D'

# t -> s
r4 = 'R' + 'D' * (q + 1) + 'L' * (p + 1) + 'U'


print(r1 + r2 + r3 + r4)

Submission status: Accepted

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

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

print(result)