You are given two arrays A and B consisting of integers, sorted in non-decreasing order. Check whether it is possible to choose k numbers in array A and choose m numbers in array B so that any number chosen in the first array is strictly less than any number chosen in the second array.


-----Input-----

The first line contains two integers n_{A}, n_{B} (1 ≤ n_{A}, n_{B} ≤ 10^5), separated by a space — the sizes of arrays A and B, correspondingly.

The second line contains two integers k and m (1 ≤ k ≤ n_{A}, 1 ≤ m ≤ n_{B}), separated by a space.

The third line contains n_{A} numbers a_1, a_2, ... a_{n}_{A} ( - 10^9 ≤ a_1 ≤ a_2 ≤ ... ≤ a_{n}_{A} ≤ 10^9), separated by spaces — elements of array A.

The fourth line contains n_{B} integers b_1, b_2, ... b_{n}_{B} ( - 10^9 ≤ b_1 ≤ b_2 ≤ ... ≤ b_{n}_{B} ≤ 10^9), separated by spaces — elements of array B.


-----Output-----

Print "YES" (without the quotes), if you can choose k numbers in array A and m numbers in array B so that any number chosen in array A was strictly less than any number chosen in array B. Otherwise, print "NO" (without the quotes).


-----Examples-----
Input
3 3
2 1
1 2 3
3 4 5

Output
YES

Input
3 3
3 3
1 2 3
3 4 5

Output
NO

Input
5 2
3 1
1 1 1 1 1
2 2

Output
YES



-----Note-----

In the first sample test you can, for example, choose numbers 1 and 2 from array A and number 3 from array B (1 < 3 and 2 < 3).

In the second sample test the only way to choose k elements in the first array and m elements in the second one is to choose all numbers in both arrays, but then not all the numbers chosen in A will be less than all the numbers chosen in B: $3 < 3$.

Difficulty: interview

Starter code:

Solutions:
def main():
	s, k = map(int, input().split())
	n, m = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if (a[n - 1] < b[-m]):
		print("YES")
	else:
		print("NO")

main()

n,m=map(int,input().split())
k,p=map(int,input().split())
x=0
y=0
a=input().split()
x=int(a[k-1])
b=input().split()
y=int(b[m-p])
if x<y:print("YES")
else:print("NO")

na, nb = list(map(int, input().split()))
k, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
max = a[k - 1]
min = b[nb - m]
if max < min:
    print('YES')
else:
    print('NO')


na, nb = map(int, input().split())
k, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a[k - 1] < b[nb - m]:
    print('YES')
else:
    print('NO')

s=input()
k,m=[int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

if a[k-1]<b[-m]:
    print("YES")
else:
    print("NO")


#In the name of Allah

from sys import stdin, stdout
input = stdin.readline

n, m = list(map(int, input().split()))
K, M = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

stdout.write("YES" if a[K - 1] < b[-M] else "NO")


na,nb=list(map(int,input().split()))
k,m=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
print("YES" if a[k-1]<b[-m] else "NO")


n1, n2 = map(int, input().split())
m, k = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a[m - 1] < b[-k]:
    print("YES")
else:
    print("NO")

na, nb= [int(i) for i in input().split()]
k, m= [int(i) for i in input().split()]

a= [int(i) for i in input().split()]
b= [int(i) for i in input().split()]

if a[k-1]< b[-m]:
    print("YES")
else:
    print("NO")

na,nb=map(int,input().split())
k,m=map(int,input().split())
nas=map(int,input().split())
nbs=map(int,input().split())
nas=list(sorted(nas))
nbs=list(sorted(nbs))
print("YES" if nas[k-1]<nbs[nb-1-(m-1)] else "NO")

input()
k, m = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
b = [int(i) for i in input().split(' ')]


print("YES" if a[k-1] < b[-m] else "NO")


(na, nb) = map(int, input().split())
(k, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print("YES" if a[k - 1] < b[-m] else "NO")

import math,string,itertools,fractions,heapq,collections,re,array,bisect,copy
from itertools import chain, dropwhile, permutations, combinations
from collections import defaultdict, deque

# Guide:
#   1. construct complex data types while reading (e.g. graph adj list)
#   2. avoid any non-necessary time/memory usage
#   3. avoid templates and write more from scratch
#   4. switch to "flat" implementations

def VI(): return list(map(int,input().split()))
def I(): return int(input())
def LIST(n,m=None): return [0]*n if m is None else [[0]*m for i in range(n)]
def ELIST(n): return [[] for i in range(n)]
def MI(n=None,m=None): # input matrix of integers
    if n is None: n,m = VI()
    arr = LIST(n)
    for i in range(n): arr[i] = VI()
    return arr
def MS(n=None,m=None): # input matrix of strings
    if n is None: n,m = VI()
    arr = LIST(n)
    for i in range(n): arr[i] = input()
    return arr
def MIT(n=None,m=None): # input transposed matrix/array of integers
    if n is None: n,m = VI()
    a = MI(n,m)
    arr = LIST(m,n)
    for i,l in enumerate(a):
        for j,x in enumerate(l):
            arr[j][i] = x
    return arr


def run(na,nb,k,m,a,b):
    if a[k-1] < b[nb-m]:
        print("YES")
    else:
        print("NO")


def main(info=0):
    na,nb = VI()
    k,m = VI()
    a = VI()
    b = VI()
    run(na,nb,k,m,a,b)



def __starting_point():
    main()

__starting_point()

n_a, n_b = [int(i) for i in input().split()]
k, m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
if a[k - 1] < b[n_b - m]:
    print('YES')
else:
    print('NO')

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

import time

#   = input()
#   = int(input())

#() = (i for i in input().split())
#   = [i for i in input().split()]

(na, nb) = (int(i) for i in input().split())
(k, m)   = (int(i) for i in input().split())
A        = [int(i) for i in input().split()]
B        = [int(i) for i in input().split()]

start = time.time()

if A[k-1] < B[len(B)-m]:
    print('YES')
else:
    print('NO')

finish = time.time()
#print(finish - start)


3

Na, Nb = map(int, input().split())
k, m = map(int, input().split())

assert 1 <= k <= Na
assert 1 <= m <= Nb

a = list(map(int, input().split()))
b = list(map(int, input().split()))

assert len(a) == Na
assert len(b) == Nb

print('YES' if a[k-1] < b[-m] else 'NO')

y = input()
k, m = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))

if a[k - 1] < b[-m]:
    print('YES')
else:
    print('NO')


n, m = map(int, input().split())
k, l = map(int, input().split())
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
if lst1[k - 1] < lst2[m - l]:
    print('YES')
else:
    print('NO')

n, m = list(map(int, input().split(" ")))
k, l = list(map(int, input().split(" ")))
a =  input().split(" ")
b =  input().split(" ")
for i in range (n):
    a[i] = int(a[i])
for i in range (m):
    b[i] = int(b[i])

if a[k-1] < b[m-l]:
    print("YES")
else:
    print("NO")


n, m = [int(x) for x in input().split()]
k, t = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
if a[k - 1] < b[m - t]:
    print('YES')
else:
    print('NO')

import sys
import os
def getin():
    return list(map(int,input().split(' ')))
na,nb=getin()
k,m=getin()
a=getin()
b=getin()
if(sorted(a)[k-1]<sorted(b)[nb-m]):
    print('YES')
else:
    print('NO')

a,b = input().split()
a=int(a)
b=int(b)
k,m=input().split()
m=int(m)
k=int(k)
A=input().split()
B=input().split()
for i in range(a):
    A[i]=int(A[i])
for i in range(b):
    B[i]=int(B[i])

if(k<=a and A[k-1]<B[-m]):
    print("YES")
else:
    print("NO")