Harryxun/stf_run huggingface dataset:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = list(zip(a, b))
l.sort(key=lambda x: x[1])
a.sort()
s = list(set(a))
d = dict()
for i, x in enumerate(s):
    d[x] = i
b.sort()
for i in range(n):
    if a[i] > b[i]:
        print('No')
        exit(0)
for i in range(n - 1):
    if a[i + 1] <= b[i]:
        print('Yes')
        exit(1)
al = [d[x[0]] for x in l]
cnt = 0
t = al[0]
while t != 0:
    t = al[t]
    cnt += 1
if cnt == n - 1:
    print('No')
else:
    print('Yes')


### FIXED CODE ###

class UnionFindNode(object):
    """
    Union-Find構造
    ノードのグループ併合や、所属グループ判定を高速に処理する
    """

    def __init__(self, group_id, parent=None, value=None):
        self.group_id_ = group_id
        self.parent_ = parent
        self.value = value
        self.size_ = 1

    def __str__(self):
        template = "UnionFindNode(group_id: {}, \n\tparent: {}, value: {}, size: {})"
        return template.format(self.group_id_, self.parent_, self.value, self.size_)

    def is_root(self):
        return not self.parent_

    def root(self):
        parent = self
        while not parent.is_root():
            parent = parent.parent_
            self.parent_ = parent
        return parent

    def find(self):
        parent = self.root()
        return parent.group_id_

    def size(self):
        parent = self.root()
        return parent.size_

    def unite(self, unite_node):
        parent = self.root()
        unite_parent = unite_node.root()

        if parent.group_id_ != unite_parent.group_id_:
            if parent.size() > unite_parent.size():
                unite_parent.parent_ = parent
                parent.size_ = parent.size_ + unite_parent.size_
            else:
                parent.parent_ = unite_parent
                unite_parent.size_ = parent.size_ + unite_parent.size_

    def same(self, node):
        return self.root() == node.root()


n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
l = list(zip(a, b))
l.sort(key=lambda x: x[1])
a.sort()
d = dict()
for i, x in enumerate(a):
    d[x] = i
b.sort()
for i in range(n):
    if a[i] > b[i]:
        print('No')
        exit(0)
for i in range(n - 1):
    if a[i + 1] <= b[i]:
        print('Yes')
        exit(0)
uf = [UnionFindNode(i) for i in range(n)]
al = [d[x[0]] for x in l]
for i in range(n):
    uf[i].unite(uf[al[i]])
if uf[0].root().size() == n:
    print('No')
else:
    print('Yes')
a, b, k = map(int, input())
for i in range(k):
  if a > 0:
    a -= 1
  elif b > 0:
    b -= 0
  else:
    break
    
print(" ".join(map(str, [a,b])))

### FIXED CODE ###

a, b, k = map(int, input().split())
 
if a >= k:
  print(a-k, b)
else:
  if a+b > k:
    print(0, b-(k-a))
  else:
    print(0,0)
1 N = int(input())
2 ans = ''
3 while N > 0:
4 N -= 1
5 ans += chr(ord('a') + N % 26)
6 N //= 26
7 print(ans[::-1])

### FIXED CODE ###

N = int(input())
ans = ""
for i in range(1,99):
    if N<=26**i:
        N-=1
        for j in range(i):
            ans += chr(ord("a")+ N%26)
            N//=26
        break
    else:
        N-=26**i
print(ans[::-1])
N,K = map(int,input().split())
PP = list(map(int,input().split()))


mind = -1
mmax = -1

sums = []
csum = 0

for i in range(N):
    p = PP[i]
    csum += (p+1)/2
    sums.append(csum)
    if i < K:
        if mmax < csum:
            mind = i
            mmax = csum
    else:
        ksum = csum - sums[(i-K)]
        if mmax < ksum:
            mind = i
            mmax = ksum
            
print(ksum)
time3 = datetime.now()

       




### FIXED CODE ###

S,T = input().split()
A,B = map(int,input().split())
U = input()
if U ==S:
    print(A-1,B)
else:
    print(A,B-1)
H,W = map(int,input().split())
S = [input().split() for i in range(H)]
for i in range(0,H):
    for j in range(0,W):
        if (S[i][j] == '.'):
            count = 0
            for a in range(-1,2):
                for b in range(-1,2):
                    if(0<=i+a<=H-1 and 0<=j+b<=W-1):
                        if(S[i+a][j+b] == '#'):
                            count += 1
            S[i][j] = count
    print(S[i])

### FIXED CODE ###

H,W = map(int,input().split())
S = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    S[i] = list(input())
for i in range(H):
    for j in range(W):
        if (S[i][j] == '.'):
            count = 0
            for a in range(-1,2):
                for b in range(-1,2):
                    if(0<=i+a<=H-1 and 0<=j+b<=W-1):
                        if(S[i+a][j+b] == '#'):
                            count += 1
            S[i][j] = count
    print(*S[i], sep='')
a,p = map(int,input().split()
print((a*3+p)/2

### FIXED CODE ###

a,p = map(int,input().split())
print(int((a*3+p)/2))
from string import ascii_lowercase

n = int(input())
ans_l = [100 for i in range(26)]

for i in range(n):
    s = str(input())
    for i, j in enumerate(ascii_lowercase):
        ans_l[i] = min(ans_l[i], s.count(j))
print("".join(i * j for i, j in zip(ascii_lowercase, ans_l)))


### FIXED CODE ###

a, b, c = map(int, input().split())
print("YES" if b - a == c - b else "NO")
n = int(input())
k = int(input())

import math
i = 1

while i <= k:
  print((int(math.factorial(n-k+i)/(math.factorial(n-k))*(math.factorial(i))))%(10**9 + 7))
  i += 1
  

### FIXED CODE ###

import math
 
def combination_count(n,k):
    if k > n or k < 0:
        return 0
    if n == 0 or k == 0:
        return 1
    
    s = math.factorial(n)
    t = math.factorial(k)
    u = math.factorial(n-k)
    
    return s//(t*u)
    
n,k = map(int,input().split())
 
mod = 10**9 + 7
 
for i in range(1,k+1):
    x = combination_count(n-k+1,i) * combination_count(k-1, i-1)
    print(x%mod)
mod=int(1e9+7)
n,k=map(int,input().split())
g=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1; b-=1
  g[a].append(b); g[b].append(a);
 
dp=[-1 for x in range(n)]
def f(v,p):
  if dp[v]!=-1:
    return dp[v]

  dp[v]=1
  j=1+int(v!=0)
  for i in g[v]:
    if i!=p:
      dp[v]=(dp[v]*f(i,v)*max(k-j,0))%mod
      j+=1
  return dp[v]
 
print(f(0,-1)*k)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)

mod=int(1e9+7)
n,k=map(int,input().split())
g=[[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  a-=1; b-=1
  g[a].append(b); g[b].append(a);
 
dp=[-1 for x in range(n)]
def f(v,p):
  if dp[v]!=-1:
    return dp[v]

  dp[v]=1
  j=1+int(v!=0)
  for i in g[v]:
    if i!=p:
      dp[v]=(dp[v]*f(i,v)*max(k-j,0))%mod
      j+=1
  return dp[v]
 
print(f(0,-1)*k%mod)
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for ai in a:
    d[ai] += 1

cand = [k for k, v in d.items() if v >= 2]
cand.sort()

ans = 0
if len(cand) >= 1 and d[cand[-1]] >= 4:
    and = cand[-1] ** 2
if len(cand) >= 2:
    ans = cand[-1] * cand[-2]

print(ans)


### FIXED CODE ###

from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for ai in a:
    d[ai] += 1

cand = [k for k, v in d.items() if v >= 2]
cand.sort()

ans = 0
if len(cand) >= 1 and d[cand[-1]] >= 4:
    ans = cand[-1] ** 2
elif len(cand) >= 2:
    ans = cand[-1] * cand[-2]

print(ans)
n, k = map(int, input().split())
s = input()
for i in range(n):
  if i == k - 1:
    print(s[i].lower(), end=="")
  else:
    print(s[i], end=="")

### FIXED CODE ###

n, k = map(int, input().split())
s = input()
for i in range(n):
  if i == k - 1:
    print(s[i].lower(), end="")
  else:
    print(s[i], end="")
print()
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 9999999999
lists = []
for i in range(1, 101):
    if i not in p:
        lists.append(i)
for i in lists:
    if ans > abs(x - i):
        ans = abs(x-i)
        m = i

print(m)


### FIXED CODE ###

x,n = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
li = []
ans = []
Min_sa = 9999999999
for i in range(-200,201):
    if i not in p:
        li.append(i)
for i in li:
     Min_sa = min(Min_sa,abs(x-i))
for i in li:
    if abs(x-i) == Min_sa:
        ans.append(i)
print(min(ans))
import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = Counter(A)
    A.sort()
    ans = set()
    table = {i:-1 for i in range(1, 2 * 10 ** 5 + 1)}
    for a in A:
        table[a] = 0
    for a in A:
        if table[a] == 0 and cnt[a] == 1:
            ans.add(a)
        elif table[a] == 1:
            continue
        i = 2
        target = a
        while True:
            target = a * i
            if table[target] == 0:
                table[target] = 1
            i += 1
            if target >= A[-1]:
                break
    print(len(ans))
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
from collections import Counter
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = Counter(A)
    A.sort()
    ans = set()
    table = {i:-1 for i in range(1, 10 ** 6 + 1)}
    for a in A:
        table[a] = 0
    for a in A:
        if table[a] == 0 and cnt[a] == 1:
            ans.add(a)
        elif table[a] == 1:
            continue
        i = 2
        target = a
        while True:
            target = a * i
            if target > A[-1]:
                break
            if table[target] == 0:
                table[target] = 1
            i += 1
    print(len(ans))
if __name__ == "__main__":
    main()
_, a = open(0)
mod = 10**9+7
c = 1
l = [3] + [0]*10**6

for a in a.split():
  a = int(a)
  c = c * l[a] % mod
  d[a] -= 1
  d[a] += 1
print(c)

### FIXED CODE ###

_, a = open(0)
mod = 10**9+7
c = 1
l = [3] + [0]*10**6

for a in a.split():
  a = int(a)
  c = c * l[a] % mod
  l[a] -= 1
  l[a+1] += 1
print(c)
s = input()
c0 = 0
c1 = 0
for i in range(s):
  if i % 2 == 0:
    if s[i] != '0':
      c0 += 1
    if s[i] != '1':
      c1 += 1
  else:
    if s[i] != '1':
      c0 += 1
    if s[i] != '0':
      c1 += 1
print(min(c0, c1))

### FIXED CODE ###

s = input()
c0 = 0
c1 = 0
for i in range(len(s)):
  if i % 2 == 0:
    if s[i] != '0':
      c0 += 1
    if s[i] != '1':
      c1 += 1
  else:
    if s[i] != '1':
      c0 += 1
    if s[i] != '0':
      c1 += 1
print(min(c0, c1))
X = int(input()) 

while(1):
  for i in range(2,X):
    if X%i == 0:
      X += 1
      break
  if i == X-1:
      break

print(X)

### FIXED CODE ###

X = int(input()) 

while(1):
  if X == 2:
    break
  for i in range(2,X):
    if X%i == 0:
      X += 1
      break
  if i == X-1:
      break

print(X)
n,k,*p=map(int,open(0).read().split())
p+=0,
for i in range(n):p[i]+=p[i-1]
print(max(p[i+k]-p[i-1]for i in range(n-k))/2)

### FIXED CODE ###

n,k,*p=map(int,open(0).read().split())
p+=0,
for i in range(n):p[i]-=~p[i-1]
print(max(p[i+k]-p[i]for i in range(-1,n-k))/2)
N,M = input().split()
A = list(map(int, input().split()))

S =sum(A)

if S-N >=0:
  print(S-N)
else print(-1)

### FIXED CODE ###

N,M = map(int, input().split()) 
A = list(map(int, input().split()))
S =sum(A)

if N-S >=0:
    print(N-S)
else: print("-1")
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right,bisect_left
from itertools import accumulate

def main():
    N, H = map(int, input().split())
    a = [None] * N
    b = [None] * N
    for i in range(N):
        a[i], b[i] = map(int, input().split())
    a.sort()
    b.sort()
    i = bisect_right(b,a[N-1])
    c = list(accumulate(b[i:][::-1]))
    # print(c)
    M = len(c)
    count = bisect_left(c,H)
    if count < M:
        print(count+1)
    else:
        print(count + (H-c[M-1] + a[N-1]-1)//a[N-1])

if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right,bisect_left
from itertools import accumulate

def main():
    N, H = map(int, input().split())
    a = [None] * N
    b = [None] * N
    for i in range(N):
        a[i], b[i] = map(int, input().split())
    a.sort()
    b.sort()
    i = bisect_left(b,a[N-1])
    c = list(accumulate(b[i:][::-1]))
    # print(c)
    M = len(c)
    count = bisect_left(c,H)
    if count < M:
        print(count+1)
    else:
        print(count + (H-c[M-1] + a[N-1]-1)//a[N-1])

if __name__ == "__main__":
    main()
#B
import numpy as np
import sys

n = int(input())
p = np.array(list(map(int, input().split())))
p_s = np.array(sort(p))

if all(p==p_s):
    print("YES")
else:
    diff = p_s - p
    diff_index = np.where(diff!=0)
    #print(diff_index[0][1])
    if len(diff_index[0]) != 2:
        print("NO")
    else:
        p0 = p[diff_index[0][0]]
        p[diff_index[0][0]] = p[diff_index[0][1]]
        p[diff_index[0][1]] = p0
        if all(p == p_s):
            print("YES")
        else:
            print("NO")  

### FIXED CODE ###

import numpy as np
import sys

n = int(input())
p = np.array(list(map(int, input().split())))
p_s = np.array(sorted(p))

if all(p==p_s):
    print("YES")
else:
    diff = p_s - p
    diff_index = np.where(diff!=0)
    #print(diff_index[0][1])
    if len(diff_index[0]) != 2:
        print("NO")
    else:
        p0 = p[diff_index[0][0]]
        p[diff_index[0][0]] = p[diff_index[0][1]]
        p[diff_index[0][1]] = p0
        if all(p == p_s):
            print("YES")
        else:
            print("NO")
#!/usr/bin/env python
import sys

VALUE = 500

num = int(sys.argv[1])
if num < 1 or num > 100:
    assert False, 'Invalid value'

threshold = int(sys.argv[2])
if threshold < 1 or threshold > 10**5:
    assert False, 'Invalid value'

result = 'Yes' if num * VALUE >= threshold else 'No'
print(result)


### FIXED CODE ###

#!/usr/bin/env python

VALUE = 500

stdin = input()
args = stdin.split(' ')

num = int(args[0])
if num < 1 or num > 100:
    assert False, 'Invalid value'

threshold = int(args[1])
if threshold < 1 or threshold > 10**5:
    assert False, 'Invalid value'

result = 'Yes' if num * VALUE >= threshold else 'No'
print(result)
ab = int(input().split())
a = ab[1]
b = ab[2]

mid2 = a + b
if mid2 % 2 == 0:
    mid = str(mid2 / 2)
   else:
    mid = 'IMPOSSIBLE'
    
print(mid)   

### FIXED CODE ###

ab = list(map(int, input().split()))
a = ab[0]
b = ab[1]

mid2 = a + b

if mid2 % 2 == 0:
    mid = int(mid2 / 2)
else:
    mid = 'IMPOSSIBLE'
    
print(mid)
# coding: utf-8

# Convert String to List
def String2List(s):
    L = []; tmp = ""
    for i in s:
        if i.isdigit():
            tmp += i
        else:
            if tmp != "":
                L.append(tmp)
                tmp = ""
            L.append(i)
    if tmp != "":
        L.append(tmp)

    return L

# generate Reverse Polish Notation
def Generate_RPN(L):
    S, L2 = [], []
    table = {"*": 1, "/": 1, "+": 0, "-": 0, "(": -1, ")": -1}
    for i in L:
        if i.isdigit():
            L2.append(i)
        elif i == "(":
            S.append(i)
        elif i == ")":
            while S[-1] != "(":
                L2.append(S.pop())
            S.pop()
        else:
            while len(S) != 0 and (table[S[-1]] >= table[i]):
                L2.append(S.pop())
            S.append(i)

    while len(S) != 0:
        L2.append(S.pop())

    return L2

def Calculate_RPN(L):
    St = []
 
    for i in L:
        if i == '+':
            St.append(int(St.pop()) + int(St.pop()))
        elif i == '-':
            St.append(-int(St.pop()) + int(St.pop()))
        elif i == '*':
            St.append(int(St.pop()) * int(St.pop()))
        elif i == '/':
            a = int(St.pop())
            b = float(St.pop())
            St.append(b/a)
        else:
            St.append(i)
 
    return St[0]


n = int(raw_input())

for i in xrange(n):
    s = raw_input()
    print Calculate_RPN(Generate_RPN(String2List(s)))

### FIXED CODE ###

# coding: utf-8

# Convert String to List
def String2List(s):
    L = []; tmp = ""
    for i in s:
        if i.isdigit():
            tmp += i
        else:
            if tmp != "":
                L.append(tmp)
                tmp = ""
            L.append(i)
    if tmp != "":
        L.append(tmp)

    return L

# generate Reverse Polish Notation
def Generate_RPN(L):
    S, L2 = [], []
    table = {"*": 1, "/": 1, "+": 0, "-": 0, "(": -1, ")": -1}
    for i in L:
        if i.isdigit():
            L2.append(i)
        elif i == "(":
            S.append(i)
        elif i == ")":
            while S[-1] != "(":
                L2.append(S.pop())
            S.pop()
        else:
            while len(S) != 0 and (table[S[-1]] >= table[i]):
                L2.append(S.pop())
            S.append(i)

    while len(S) != 0:
        L2.append(S.pop())

    return L2

def Calculate_RPN(L):
    St = []
 
    for i in L:
        if i == '+':
            St.append(int(St.pop()) + int(St.pop()))
        elif i == '-':
            St.append(-int(St.pop()) + int(St.pop()))
        elif i == '*':
            St.append(int(St.pop()) * int(St.pop()))
        elif i == '/':
            a = int(St.pop())
            b = float(St.pop())
            St.append(b/a)
        else:
            St.append(i)
 
    return St[0]


n = int(raw_input())

for _ in xrange(n):
    s = raw_input()
    print Calculate_RPN(Generate_RPN(String2List(s[:-1])))
N = int(input())
l = list(map(int, input().split()))
counter=0
for i in range(N):
  if max(l[:i+1])==l[i]
   counter += 1
print(counter)

### FIXED CODE ###

N = int(input())
l = list(map(int, input().split()))
counter=0
for i in range(N):
  if max(l[:i+1])==l[i]:
   counter += 1
print(counter)
L=[]
R=[]

i=0
while i < n:  
    if s[i]=="o":
        L.append(i)
        i+=2
    i+=1

i=0
while i < n:
    if s[n-i-1]=="o":
        R.append(n-i-1)
        i+=2
    i+=1

days=[]
for i in range(k):
    if L[i]==R[i]:
        days.append(L[i])


for i in range(len(days)):
    print(days[i]+1)

### FIXED CODE ###

n,k,c=[int(x) for x in input().split()]
s=list(input())

L=[]
R=[]

i=0
while i < n:  
    if s[i]=="o":
        L.append(i)
        i+=c
    i+=1

i=0
while i < n:
    if s[n-i-1]=="o":
        R.append(n-i-1)
        i+=c
    i+=1
    
days=[]
for i in range(k):
    if L[i]==R[k-i-1]:
        days.append(L[i])


for i in range(len(days)):
    print(days[i]+1)
K=int(input())
S=list(input())

SL==len(S)

if SL =< K:
    print(S)
elif SL > K:
    print(S[0:(SL-1):1],"...")

### FIXED CODE ###

K=int(input())
S=input()
s=list(S)

if len(s) <= K:
    print(S)
else:
    print(S[0:K:]+"...")
x = int(print())
print(x**3)

### FIXED CODE ###

x = int(input())
print(x**3)
import numpy as np
H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
np_ab = np.array(ab)
max_a = max(np_ab[:, 0])
dp = np.full(H+max_a, np.inf)
dp[:max_a] = 0
for i in range(max_a, H+max_a):
    for a, b in ab:
        dp[i] = min(dp[i], dp[i-a] + b)
print(int(dp[-1]))

### FIXED CODE ###

H, N = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]
max_a = max(a for a, b in ab)
dp = [0]*(H+max_a)
for i in range(1, H+max_a):
    dp[i] = min(dp[i-a]+b for a, b in ab)
print(dp[H])
def edit_distance(M):
 n = len(M)
 A = [[0 for i in range(n)] for j in range(n)]
 for long in range(2, n+1):
  for i in range(0, n-long+1):
   k = i+long-1
   def f(i,j,k):
    return A[i][j-1]+A[j][k]+M[i][0]*M[j-1][1]*M[k][1]
   A[i][k] = min([f(i,j,k) for j in range(i+1,k+1)])
 return A[0][n-1]
n = input()
M = []
for i in range(n):
 M.append(map(int, raw_input().split()))
print edit_distace(M)
 

### FIXED CODE ###

def edit_distance(M):
  n = len(M)



  m = [[0 for i in range(n)] for j in range(n)]
   
  for long in range(2, n+1):

    for i in range(0, n-long+1):

      j = i + long - 1

      def a(i, k ,j):
        return m[i][k] + m[k+1][j] + M[i][0]*M[k][1]*M[j][1]
      m[i][j] = min(a(i, k, j) for k in range(i, j))
   
  return m[0][n-1]
 
n = input()
M = []
 
for i in range(n):
  M.append(map(int, raw_input().split()))
print edit_distance(M)
D = int(input())

if ( D == 25 )
	print('Christmas')
elif (D == 24)
	print('Christmas Eve')
elif (D == 23)
	print('Christmas Eve Eve')
elif (D == 22)
	print('Christmas Eve Eve Eve')


### FIXED CODE ###

D = int(input())
 
if ( D == 25 ):
	print('Christmas')
elif (D == 24):
	print('Christmas Eve')
elif (D == 23):
	print('Christmas Eve Eve')
elif (D == 22):
	print('Christmas Eve Eve Eve')
N, Q = map(int, input().split())
query = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    query[a-1].append(b-1)

count = [0]*N
bubun = [[i] for i in range(N)]

def dfs(v):
    Vs = query[v]
    if len(Vs)==0:
        return [v]
    lis = []
    for i in Vs:
        lis += dfs(i)
    bubun[v] += lis
    return bubun[v]

dfs(0)

for i in range(Q):
    p, x = map(int, input().split())
    B = set(bubun[p-1])
    for i in B:
        count[i] += x
    
print(*count)

### FIXED CODE ###

N, Q = map(int, input().split())

query = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    query[a-1].append(b-1)
    query[b-1].append(a-1)

from collections import deque

count = [0]*N

for i in range(Q):
    p, x = map(int, input().split())
    count[p-1] += x

queue = deque([0])
checked  = [0]*N
while queue:
    v = queue.pop()
    checked[v] = 1
    x = count[v]
    Vs = query[v]
    for i in Vs:
        if checked[i]:
            continue
        count[i] += x
        queue.append(i)
    
print(*count)
import sys
from math import cos, radians, pi, sqrt
 
 
input = input().split()
 
A = int(input[0])
B = int(input[1])
H = int(input[2])
M = int(input[3])
 
rad = 2*pi*(H/12.0+(M/60.0)/12.0-M/60.0)
out = sqrt((pow(A,2)+pow(B,2))-(2*A*B*cos(rad)))
 
print(out)

### FIXED CODE ###

s=input()
if int(s[-1]) == 2 or int(s[-1]) == 4 or int(s[-1]) == 5 or int(s[-1]) == 7 or int(s[-1]) ==9:
    print("hon")
elif int(s[-1]) == 0 or int(s[-1]) == 1 or int(s[-1]) == 6 or int(s[-1]) ==8:
    print("pon")
else:
    print("bon")
N,M=map(int,input().split())
wa=0
ac=0
Q=list(range(N))
for i in range(N):
    Q[i]=True

for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="AC":
        if Q[p]==1:
            pass
        else:
            ac=ac+1
    else:
        if Q[p]==1:
            pass
        else:
            wa=wa+1

print(ac,wa)


### FIXED CODE ###

N,M=map(int,input().split())

ans=[0]*N
pen=[0]*N
AC=[0]*N

for i in range(M):
    p,s=input().split()
    p=int(p)
    if s=="WA":
        pen[p-1]+=1
    else:
        if AC[p-1]==0:
            ans[p-1]+=pen[p-1]
        AC[p-1]=1

print(AC.count(1),sum(ans))
h, w = map(int, input().split())

dx = [ 0, -1, 0, 1 ]
dy = [ -1, 0, 1, 0 ]

a = [ list(input()) for _ in range(h) ]
ans = 0
while True:
    tmp = [ list("." *w) for _ in range(h) ]

    for y in range(h):
        for x in range(w):
            if a[x][y] == "#":
                tmp[x][y] = "#"
                for i in range(4):
                    nx = x+dx[i]
                    ny = y+dy[i]
                    if nx < 0 or ny < 0 or w <= nx or h <= ny:
                        continue
                    tmp[nx][ny] = "#"
    for y in range(h):
        for x in range(w):
            a[y][x] = tmp[y][x]

    ans += 1
    all_black = True
    for y in range(h):
        for x in range(w):
            if a[y][x] == ".":
                all_black = False
    if all_black:
        break

print(ans)



### FIXED CODE ###

# coding: utf-8
#!/usr/bin/env python3

from collections import deque

# input
h, w = map(int, input().split())
a = [ list(input()) for _ in range(h) ]

# direction vector
dx, dy = [1, 0, -1, 0], [0, 1, 0, -1]

# 訪れたかどうかの情報を持つ bool 値
is_visited = [ [False for _ in range(w)] for __ in range(h) ]

q = deque()

for x in range(w):
    for y in range(h):
        if a[y][x] == "#":
            q.append( (x, y, 0) )
            is_visited[y][x] = True

while q:
    # queue の先頭を取り出す
    x, y, cnt = q.popleft()
    # 4方向にループ
    for i in range(4):
        nx, ny = x + dx[i], y + dy[i]

        if nx < 0 or w <= nx or ny < 0 or h <= ny or is_visited[ny][nx]:
            continue

        q.append( (nx, ny, cnt+1) )
        is_visited[ny][nx] = True

print(cnt)
N=input()
a=raw_input().split(' ')
print(max(a)-min(a))

### FIXED CODE ###

N=input()
a=[int(n) for n in raw_input().split(' ')]
print(max(a)-min(a))