Harryxun/stf_run huggingface dataset:
def dfs(v, d, path):
    # 頂点(0, N - 1)間の最短距離を求める
    # m_dist[v]:=頂点0からの最短距離
    res = []
    if m_dist[v] < float('inf'):
        return
    m_dist[v] = min(m_dist[v], d)
    if v == N - 1:
        return path
    for nv in e[v]:
        ret = dfs(nv, d + 1, path + [nv])
        if ret:
            res = ret
            break
    return res


def dfs_to_color(v, my_color):
    # 着色可能な範囲を着色する
    # 自分の色（黒、白）の幹から出ている未着色のマスが着色可能
    if m_bl[v]: return
    m_bl[v] = True
    if m[v] == my_color or m[v] == None:
        m[v] = my_color
        for nv in e[v]:
            dfs_to_color(nv, my_color)


N = int(input())
m = [None for _ in range(N)]
m[0] = True
m[N - 1] = False
# 色, 0-indexed
# True == 黒 == Fennec
# False == 白 == Snuke
m_dist = [float('inf') for _ in range(N)]
# 頂点0からの距離
m_bl = [False for _ in range(N)]
# 着色作業が完了したか

e = [[] for _ in range(N)]
# 道, 隣接リスト, 0-indexed

for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    # 0-indexed
    e[a].append(b)
    e[b].append(a)

path = dfs(0, 0, [0])
# 頂点(0, N - 1)間の最短距離をm_dist[N-1]に代入
# 最短パスを返す

for p in path:
    if m_dist[p] <= abs(m_dist[N - 1] - m_dist[p]):
        # 頂点0から近い場合
        # 等距離なら先に塗れる黒になる
        m[p] = True
        # 黒
    else:
        # 頂点N-1から近い場合
        m[p] = False
        # 白
# 最短経路を先に着色する

dfs_to_color(0, True)
# Fennec

dfs_to_color(N - 1, False)
# Snuke

print('Fennec' if m.count(True) > m.count(False) else 'Snuke')


### FIXED CODE ###

# https://atcoder.jp/contests/abc067/submissions/2975640

from collections import deque

INF = 10 ** 5 + 10

N = int(input())
f = [INF for _ in range(N)]
# f[v]:=頂点0からの最短距離
s = [INF for _ in range(N)]
# s[v]:=頂点N-1からの最短距離

e = [[] for _ in range(N)]
# 道, 隣接リスト, 0-indexed

for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    # 0-indexed
    e[a].append(b)
    e[b].append(a)

q = deque()
q.append((0, 0))

while q:
    v, d = q.popleft()
    f[v] = d
    for nv in e[v]:
        if f[nv] <= d + 1: continue
        q.append((nv, d + 1))

q = deque()
q.append((N - 1, 0))

while q:
    v, d = q.popleft()
    s[v] = d
    for nv in e[v]:
        if s[nv] <= d + 1: continue
        q.append((nv, d + 1))

Fennec_count = 0
for v in range(N):
    if f[v] <= s[v]:
        # 頂点0から近い場合
        # 等距離なら先に塗れる黒になる
        Fennec_count += 1
        # 黒

print('Fennec' if Fennec_count > N - Fennec_count else 'Snuke')
N,M,K=map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
sum_A=0
sum_B=0
for i in range(min(N,M)):
    sum_A +=A[i]
    sum_B +=B[i]
    if sum_A>K:
        del A[i:]
    if sum_B>K:
        del B[i:]
    if sum_A>K and sum_A>K:
        break
while sum(A)+sum(B)>K:
    if A[-1]>B[-1]:
        del A[-1]
    elif A[-1]<B[-1]:
        del B[-1]
    elif A[-1] == B[-1]:
        del A[-1]
        del B[-1]
        if sum(A)+sum(B)<=K:
            A.append(1)
print(len(A)+len(B))


### FIXED CODE ###

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
 		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)
A,B = map(int,input().split())
res = 0
if A >= B:
  res += A
  A-= 1
  if A >= B:
    res += A
    else:
      res += B
      print(res)
else:
  res += B
  B-= 1
  if A >= B:
    res += A
    else:
      res += B
      print(res)


### FIXED CODE ###

A,B = map(int,input().split())
res = 0
for _ in range(2):
  if A>=B:
    res += A
    A-=1
  else:
    res += B
    B-=1
print(res)
n,m = map(int,input().split())
s = []
c = []
ans = ["0" for i in range(n)]

for i in range(m):
    S,C = map(int,input().split())
    s.append(S)
    c.append(C)
    
for i in range(m):
    ans[s[i]-1] = c[i]
    
    if i == m-1:
        ANS = ""
        for j in range(n):
            ANS += str(ans[j])
            
for i in range(m):
    if s[i] == 1 and c[i]==0:
        ANS = -1
    
    for j in range(m):
        if s[i] == s[j] and c[i] != c[j]:
            ANS = -1
            
print(ANS)

### FIXED CODE ###

n,m = map(int,input().split())
s = []
c = []
ans = [1]
for i in range(n-1):
    ans.append("0")
ANS = ""

for i in range(m):
    S,C = map(int,input().split())
    s.append(S)
    c.append(C)
    
for i in range(m):
    ans[s[i]-1] = c[i]
    
    if i == m-1:
        for j in range(n):
            ANS += str(ans[j])
            
for i in range(m):
    if s[i] == 1 and c[i]==0 and n!=1:
        ANS = -1
    
    for j in range(m):
        if s[i] == s[j] and c[i] != c[j]:
            ANS = -1
            
if m == 0:
    if n == 1:
        ANS = 0
    else:
        ANS = "1"+"0"*(n-1)
            
print(ANS)
A=1
for i in range(1,int(input)+1):
  A*=i
  A%=1000000007
print(A)

### FIXED CODE ###

A=1
for i in range(1,int(input())+1):
  A*=i
  A%=1000000007
print(A)
a, b, c, x = map(int, input().split())
alist = [1]
blist = [0]
clist = [-1]
list = alist*a + blist*b + clist*c
print(sum(list[:x]))

### FIXED CODE ###

a, b, c, k = map(int, input().split())
if a >= k:
    print(k)
elif a + b >= k:
    print(a)
else:
    print(2*a - k + b)
s = list(input())
n = len(s)
s_half = (n - 1)/2
s_3 = (n + 3)/ 2
if s == s[::-1]:
	if s[s_half - 1] == s[s_half - 1::-1]:
		if s[s_3 -1] == s[s_3 -1::-1]:
			print('Yes')
print('No')



### FIXED CODE ###

s = input()
l = len(s)
if list(s) != list(reversed(s)):
    print('No')
    exit()
if list(s[:(l - 1) // 2]) != list(reversed(s[:(l - 1) // 2])):
    print('No')
    exit()
if list(s[(l + 3) // 2 -1:l]) != list(reversed(s[(l + 3) // 2 -1:l])):
    print('No')
    exit()
print('Yes')
import re
s = input()
s = s.replace('?', '.')
t = input()
if len(t) > len(s):
  print("UNRESTORABLE")
else:
  r = []
  for i in range(len(s)-len(t)+1):
    m = re.match(s[i:i+len(t)], t)
    if m is None:
      continue
    r.append((s[:i]+t+s[i+len(t):]).replace(".","a"))
  if not r:
    print('UNRESTORABLE')
    quit()
      
print(min(r))

### FIXED CODE ###

import re
  
  
def solve(s, t):
    s = s.replace('?', '.')
    ls, lt = len(s), len(t)
    if ls < lt:
        return 'UNRESTORABLE'
    ans = []
    for i in range(ls - lt + 1):
        m = re.match(s[i:i + lt], t)
        if m is None:
            continue
        ans.append((s[:i] + t + s[i + lt:]).replace('.', 'a'))
    if not ans:
        return 'UNRESTORABLE'
    return min(ans)
  
  
s = input().strip()
t = input().strip()
  
print(solve(s, t))
try:
    while(True):
        x,y=input().split()
        except EOFError: 
            pass
        k=int(x)+int(y)
        print(len(str(k)))

### FIXED CODE ###

while 1:
    try:
        x,y=input().split()
        k=int(x)+int(y)
        print(len(str(k)))
    except EOFError:
        break
n = int(input())
a = list(map(int, input().split()))
import fractions
ans = a[0]
for i in range(1, N):
    ans = fractions.gcd(ans, a[i])
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
import fractions
ans = a[0]
for i in range(1, n):
    ans = fractions.gcd(ans, a[i])
print(ans)
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors

def checker(A,k):
    if sum(costs[sum(A) // d:]) <= k:
        return True
    return False

n,k = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

for d in make_divisors(sum(A)):
    buf = []
    if d == 1:
        print(d)
        break
    else:
        for a in A:
            buf.append(a%d)
        print(buf)
        if checker(buf,k):
            print(d)
            break

### FIXED CODE ###

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=True)
    return divisors

def checker(A,k):
    A.sort(reverse=True)
    if sum(A[sum(A) // d:]) <= k:
        return True
    return False

n,k = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

for d in make_divisors(sum(A)):
    buf = []
    for a in A:
        buf.append(a%d)
    #print(buf)
    if checker(buf,k):
        print(d)
        break
n = str(input())
len = len(n)
list = list(n)
ans = 0
if n.count("0") != len - 1:
  for element in list:
    ans += int(element)
elif len(n) == 1:
  ans = int(n)
else:
  ans = 10
print(ans)

### FIXED CODE ###

n = str(input())
len = len(n)
list = list(n)
ans = 0
if len == 1:
  ans = int(n)
elif n.count("0") != len - 1:
  for element in list:
    ans += int(element)
else:
  ans = 10
print(ans)
S=str(input())
A= int(S.count('hi'))
B= int(len(S))

if B // A ==2 :
    print('Yes')
else :
    print('No')


### FIXED CODE ###

S = input()

while len(S) >= 2:
    if S[0:2]== 'hi':
        S=S[2:]
    else:
        break
if len(S)==0:
    print('Yes')
else:
    print('No')
#coding: UTF-8
N=int(input())
lis=list(map(int, input().split()))
kind_dict={}
for i in lis:
    if i in kind_dict:
        kind_dict[i]+=1
    else:
        kind_dict[i]=1
kindn=len(kind_dict)
out=0
for i in kind_dict:
    if kind_dict[i]%2==0:
        out+=1
if out%2==0:
    print(kindn)
else:
    print(kindn-1)

### FIXED CODE ###

#coding: UTF-8
X=int(input())
if X<1200:
    print("ABC")
else:
    print("ARC")
n = int(input())
h = tuple(map(int, input().split()))
ans = [0]*n
for i in range(1, n+1):
  ans[h[i]-1] = i+1
print(*ans)

### FIXED CODE ###

n = int(input())
h = tuple(map(int, input().split()))
ans = [0]*n
for i in range(n):
  ans[h[i]-1] = i+1
print(*ans)
W,H,x,y,r=map(int,raw_input().split())
if not(-100<=x and y<=100 and 0<W<=100 and 0<H<=100 and 0<r<=100):
    print("Constraits Errand")
    exit()
#elif x<=0 or y<=0 or  y-r<=H<=y+r or x-r<=W<=x+r or  y-r<=0<=y+r or x-r<=0<=x+r:
elif W-r<=x<=W+r and H-r<=y<= H+r
    print("No")
    exit()
else:
    print("Yes")

### FIXED CODE ###

W,H,x,y,r=map(int,raw_input().split())
if not(-100<=x and y<=100 and 0<W<=100 and 0<H<=100 and 0<r<=100):
    print("Constraits Errand")
    exit()
#elif x<=0 or y<=0 or  y-r<=H<=y+r or x-r<=W<=x+r or  y-r<=0<=y+r or x-r<=0<=x+r:
elif r<=x<=W-r and r<=y<= H-r:
    print("Yes")
else:
    print("No")
n, q = map(int, input().split())
g=[[] for _ in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    g[a-1].append(b-1)
    g[b - 1].append(a - 1)

def dfs(idx,c,res,visited):
    visited[idx]=1
    c+=costs[idx]
    res[idx]=c
    for i in g[idx]:
        if visited[i]==1:
            continue
        res = dfs(i,c,res,visited)
    return res

costs = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    costs[p-1]+=x
res = [0]*n
visited = [0]*n
res = dfs(0,0,res,visited)
print(*res)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

#def input():
#  return sys.stdin.readline()[:-1]

n,q=map(int,input().split())
cnt=[0]*(n)
g=[[] for _ in range(n)]
for _ in range(n-1): #木グラフの隣接リストを作成
  a,b=map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for _ in range(q):
    a , b = map(int,input().split())
    a = a - 1
    cnt[a] += b

def dfs(now,prev=-1):
  for next in g[now]:
    if next==prev:
      continue
      
    cnt[next]+=cnt[now]
    dfs(next,now)
dfs(0)
print(*cnt)
N=int(input())
if(100<N<=111):
  ptit(111)
elif(111<N<=222):
  print(222)
elif(222<N<=333):
  print(333)
elif(333<N<=444):
  print(444)
elif(444<N<=555):
  print(555)
elif(555<N<=666):
  print(666)
elif(666<N<=777):
  print(777)
elif(777<N<=888):
  print(888)
elif(888<N<=999):
  print(999)

### FIXED CODE ###

N=int(input())
if(N<=111):
  print(111)
elif(111<N<=222):
  print(222)
elif(222<N<=333):
  print(333)
elif(333<N<=444):
  print(444)
elif(444<N<=555):
  print(555)
elif(555<N<=666):
  print(666)
elif(666<N<=777):
  print(777)
elif(777<N<=888):
  print(888)
elif(888<N<=999):
  print(999)
n=map(int,input().split())
num=0
for i in range(n):
    if (i%3!=0) and (i%5!=0):
        num+=i
print(num)


### FIXED CODE ###

n=int(input())
num=0
for i in range(1,n+1):
    if (i%3!=0) and (i%5!=0):
        num+=i
print(num)
n = int(input())
print('Yes' if n[::-1] == n else 'No')


### FIXED CODE ###

n = input()
print('Yes' if n[0] == n[-1] else 'No')
while 1:
    k=input().split()
    a=int(k[0])
    b=int(k[1])
    c=int(k[2])
    if a==-1 and (b==-1 and c==-1):
        break
    if a<0 or b<0:
        ptint("F")
    elif a+b<30:
        print("F")
    elif a+b<50:
        if c>=50:
            print("C")
        else:
            print("D")
    elif a+b<65:
        print("C")
    elif a+b<80:
        print("B")
    else:
        print("A")



### FIXED CODE ###

while 1:
    k=input().split()
    a=int(k[0])
    b=int(k[1])
    c=int(k[2])
    if a==-1 and (b==-1 and c==-1):
        break
    if a<0 or b<0:
        print("F")
    elif a+b<30:
        print("F")
    elif a+b<50:
        if c>=50:
            print("C")
        else:
            print("D")
    elif a+b<65:
        print("C")
    elif a+b<80:
        print("B")
    else:
        print("A")
print(int(input())//2 + 1) if n % 2 else print(int(input())//2)

### FIXED CODE ###

n = int(input())
if n%2 == 0: print(n//2)
else: print((n+1)//2)
n = int(input())
s = {}
for i in range(n):
    d = input()
    if d in s:
        s[d] += 1
    else:
        s.update({d:1}) 

m = int(input())
for j in range(m):
    t = input()
    if t in s:
        s[t] -= 1
    else:
        s.update({t:-1})

print(0 if max(d.values()) < 0 else max(d.values()))


### FIXED CODE ###

n = int(input())
s = list(input() for _ in range(n))

m = int(input())
t = list(input() for _ in range(m))

a = 0
d = 0
for i in s:
    a = s.count(i)-t.count(i)
    if d <= a:
        d = a
print(d)
n=int(input())
a=list(map(int,input().split("")))
dp=[0 for x in range(n+1)]
dp[1]=0
dp[2]=abs(a[1]-a[0])
for x in range(3,n+1):
  dp[x]=min(dp[x-1]+abs(a[x]-a[x-1]),dp[x-2]+abs(a[x]-a[x-2]))
print(dp[n])


### FIXED CODE ###

#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase
#from bisect import bisect_left as bl                #c++ lowerbound bl(array,element)
#from bisect import bisect_right as br               #c++ upperbound br(array,element)
 
 
def main():
    n=int(input())
    a=list(map(int,input().split(" ")))
    dp=[0 for x in range(n+1)]
    dp[0]=0
    dp[1]=abs(a[1]-a[0])
    for x in range(2,n):
        dp[x]=min(dp[x-1]+abs(a[x]-a[x-1]),dp[x-2]+abs(a[x]-a[x-2]))
    print(dp[n-1])




#-----------------------------BOSS-------------------------------------!
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()
N = int( input())
a = list(map(int, input().split(' ')))
l = [0]*N
numpy.sort(a)
for i in a:
    l[i-1] += 1
for i in l:
    print(i)

### FIXED CODE ###

import numpy
N = int( input())
a = list(map(int, input().split(' ')))
l = [0]*N
numpy.sort(a)
for i in a:
    l[i-1] += 1
for i in l:
    print(i)
from collections import Counter

given1 = int(input())
given2 = [int(_) for _ in input().split()]

def solve(size=given1, ary=given2):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])

    emst, esec = even.most_common(2)
    eme, emf = emst
    ese, esf = esec

    omst, osec = odd.most_common(2)
    ome, omf = omst
    ose, osf = osec

    return size - max(emf + osf, omf + esf) if eme == ome else size - esf - osf


print(solve())


### FIXED CODE ###

from collections import Counter

def solve(size=int(input()), ary=list(map(int, input().split()))):
    even, odd = Counter(ary[::2]), Counter(ary[1::2])
    even[0], odd[0] = 0, 0
    (e, em), (_, es) = even.most_common(2)
    (o, om), (_, os) = odd.most_common(2)
    return size - max(em + os, es + om) if e == o else size - em - om

print(solve())
H,W = map(int,input().split())
lis = ['.' +input()+'.' for _ in range(H)]
lis.insert(0,'.'*W)
lis.append('.'*W)
for i in range(1,H+1):
    for j in range(1,W+1):
        if lis[i][j] == '#':
            if lis[i+1][j]=='#' or lis[i-1][j]=='#' or lis[i][j+1]=='#' or lis[i][j-1] == '#':
                continue
            else:
                print('No')
                exit()
print('Yes')

### FIXED CODE ###

H,W = map(int,input().split())
lis = ['.' +input()+'.' for _ in range(H)]
lis.insert(0,'.'*(W+2))
lis.append('.'*(W+2))
for i in range(1,H+1):
    for j in range(1,W+1):
        if lis[i][j] == '#':
            if lis[i+1][j]=='#' or lis[i-1][j]=='#' or lis[i][j+1]=='#' or lis[i][j-1] == '#':
                continue
            else:
                print('No')
                exit()
print('Yes')
n,k=map(int,input().split())
s=list(input())
cnt=0
ans=0
j=0
for i in range(n):
    if s[i]=="0":
        if i==0 or s[i-1]=="1":
            cnt+=1
    if cnt>k:
        while s[j]=="1":
            j+=1
        while s[j]=="0":
            j+=1
        cnt-=1
    ans=max(ans,i-j+1)

print(ans)

### FIXED CODE ###

a,b=map(int,input().split())
print(max(2*a-1,a+b,2*b-1))
k, t = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
double_cnt = 0
total = 0
for i in range(t):
  b = a[i] - bouble_cnt
  c = total - (bouble_cnt + 1) + 2
  bouble_cnt = max(0, b-c)
  total += a[i]
print(bouble_cnt)

### FIXED CODE ###

k, t = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
double_cnt = 0
total = 0
for i in range(t):
  b = a[i] - double_cnt
  c = total - (double_cnt + 1) + 2
  double_cnt = max(0, b-c)
  total += a[i]
print(double_cnt)
n = list(map(int, input().split()))
if n.count(5) == 2 and n.count(7) == 1:
  print('YES')
else:
  orint('NO')

### FIXED CODE ###

n = list(map(int, input().split()))
if n.count(5) == 2 and n.count(7) == 1:
  print('YES')
else:
  print('NO')
a=input()
b=input()
for 
for i in range(a-2):
	if b[a:a] == "A":
		if b[a+1:a+1] == "B":
			if b[a+2:a+2] == "C":
				sum+=1
			pass
		pass
	pass
print(sum)

### FIXED CODE ###

a=int(input())
b=input()
sum=0
for i in range(a-2):
	if b[i:i+1] == "A":
		if b[i+1:i+2] == "B":
			if b[i+2:i+3] == "C":
				sum+=1
			pass
		pass
	pass
print(sum)
n=int(input())
k=int(input())
arr=list(map(int,input()))
ans=0
for i in range(n):
  if int(k/2)<arr[i]:
    ans+=arr[i]*2
  else:
    ans+=(k-arr[i])*2
print(ans)

### FIXED CODE ###

n=int(input())
k=int(input())
arr=list(map(int,input().split()))
ans=0
for i in range(n):
  if int(k/2)>=arr[i]:
    ans+=arr[i]*2
  else:
    ans+=(k-arr[i])*2
print(ans)
import sys
import numpy as np

from collections import deque 
from functools import reduce

# input = sys.stdin.readline

x, y, a, b, c = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

list.sort(p, reverse=True)
list.sort(q, reverse=True)
list.sort(r, reverse=True)

p_np = np.zeros(999999)
q_np = np.zeros(999999)

if len(p) > x:
    p_np[:x] = p[:x]
else:
    l_p = len(p)
    p_np[:l_p] = p[:]

if len(q) > y:
    q_np[:y] = q[:y]
else:
    l_q = len(q)
    q_np[:l_q] = q[:]
ap_np = np.hstack((p_np[:x], q_np[:y]))
ap_np.sort()
ap_cnt = 0

for i, ri in enumerate(r):
    if (r[i] > ap_np[i]):
        ap_np[i] = r[i]
    if i >= x + y:
        break
print(int(ap_np.sum()))

### FIXED CODE ###

import sys
import numpy as np

from collections import deque 
from functools import reduce

# input = sys.stdin.readline

x, y, a, b, c = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

list.sort(p, reverse=True)
list.sort(q, reverse=True)
list.sort(r, reverse=True)

p_np = np.zeros(999999)
q_np = np.zeros(999999)

if len(p) > x:
    p_np[:x] = p[:x]
else:
    l_p = len(p)
    p_np[:l_p] = p[:]

if len(q) > y:
    q_np[:y] = q[:y]
else:
    l_q = len(q)
    q_np[:l_q] = q[:]
ap_np = np.hstack((p_np[:x], q_np[:y]))
ap_np.sort()
ap_cnt = 0

for i, ri in enumerate(r):
    if i >= x + y:
        break
    if (r[i] > ap_np[i]):
        ap_np[i] = r[i]
print(int(ap_np.sum()))
r = int(input("long?"))

return r * r

### FIXED CODE ###

r = int(input())

print(r*r)
N = input()
fn = 0
for i in range(len(N)):
  fn += int(i)
  
print("Yes" if int(N) % fn == 0 else "No")

### FIXED CODE ###

N = input()
fn = 0
for i in N:
  fn += int(i)
  
print("Yes" if int(N) % fn == 0 else "No")
H = int(input())

import math as m
remain = H % 2
H -= remain
n = round(m.log2(H)+0.5)
ans = (2**n) - 1

print(ans)



### FIXED CODE ###

H = int(input())

if H == 1:
  print(1)
  exit(0)

import math as m
n = m.floor(m.log2(H))+1
ans = (2**n) - 1

print(ans)
n = int(input())
a = int(input())

if (n%500>=0 and n%500=<1000):
	print('Yes')
else:
	print('No')

### FIXED CODE ###

n= int(input())
a = int(input())
 
if (n%500 <= a):
	print('Yes')
else:
	print('No')
N=int(input()
for i in range(N):
  A=int(input())
  list.append(A)
for j in range(N):
  del list[j]
  print(max(list))

  

### FIXED CODE ###

N=int(input())
list=[]
for i in range(N):
  A=int(input())
  list.append(A)
l=sorted(list,reverse=True)
A_1=l[0]
A_2=l[1]
for j in range(N):
  if list[j]!=A_1:
    print(A_1)
  else:
    print(A_2)
R = input()
print(2*R*3.14159265)

### FIXED CODE ###

R = int(input())
print(2*R*3.14159265)
def lcs():
???x = raw_input()
  y = raw_input()
???x_len = len(x)
  y_len = len(y)
  z2 = [0 for i in range(y_len+1)]

???for j in range(x_len):
   z1 = z2 + []
   for k in range(y_len):
      if x[k] = y[k]:
         z2[k+1] = z2[k] + 1
      elif z2[k+1] < z2[k]:???
?????????   z2[k+1] = z2[k]

  return z2[-1]

num = input()
for l in range(num):
  print lcs()

### FIXED CODE ###

def lcs():
  x = raw_input()
  y = raw_input()
  x_len = len(x)
  y_len = len(y)
  z2 = [0 for i in range(y_len+1)]

  for i in range(x_len):
    z1 = z2 + []
    ele = x[i]
    for k in range(y_len):
      if ele == y[k]:
        z2[k+1] = z1[k] + 1
      elif z2[k+1] < z2[k]:
        z2[k+1] = z2[k]

  return z2[-1]

num = input()
for j in range(num):
  print lcs()
import math

a, b, h, m = [int(input()) for i in range(4)]

m_rad = 6 * m
h_rad = 0.5 * 60 * h + 0.5 * m

if abs(m_rad - h_rad) == 0:
    print(b - a)
elif abs(m_rad - h_rad) == 180:
    print(a + b)
else:
    print(math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(abs(m_rad - h_rad)))))

### FIXED CODE ###

import math
a, b, h, m = map(int, input().split())
m_rad = 6 * m
h_rad = 0.5 * 60 * h + 0.5 * m
length = math.sqrt(a*a + b*b - 2*a*b*math.cos(math.radians(abs(m_rad - h_rad))))
print('{:.20f}'.format(length))