Problem:


Score : 200 points

Problem Statement

You are given strings s and t, consisting of lowercase English letters.
You will create a string s' by freely rearranging the characters in s.
You will also create a string t' by freely rearranging the characters in t.
Determine whether it is possible to satisfy s' < t' for the lexicographic order.

Notes

For a string a = a_1 a_2 ... a_N of length N and a string b = b_1 b_2 ... b_M of length M, we say a < b for the lexicographic order if either one of the following two conditions holds true:

N < M and a_1 = b_1, a_2 = b_2, ..., a_N = b_N.

There exists i (1 \leq i \leq N, M) such that a_1 = b_1, a_2 = b_2, ..., a_{i - 1} = b_{i - 1} and a_i < b_i. Here, letters are compared using alphabetical order.

For example, xy < xya and atcoder < atlas.

Constraints

The lengths of s and t are between 1 and 100 (inclusive).

s and t consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

s
t

Output

If it is possible to satisfy s' < t', print Yes; if it is not, print No.

Sample Input 1

yx
axy

Sample Output 1

Yes

We can, for example, rearrange yx into xy and axy into yxa. Then, xy < yxa.

Sample Input 2

ratcode
atlas

Sample Output 2

Yes

We can, for example, rearrange ratcode into acdeort and atlas into tslaa. Then, acdeort < tslaa.

Sample Input 3

cd
abc

Sample Output 3

No

No matter how we rearrange cd and abc, we cannot achieve our objective.

Sample Input 4

w
ww

Sample Output 4

Yes

Sample Input 5

zzz
zzz

Sample Output 5

No



Sample input:
yx
axy


Sample output:
Yes

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())

S = sorted(s)
T = sorted(t, reverse = True)


U = min(len(s), len(t))

for i in range(U):
    if S[i] < T[i]:
        print("Yes")
        exit()
    elif S[i] == T[i]:
        continue
    else:
        print("No")
        exit()
    
if len(S) < len(T):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s,t=sorted(list(input())),sorted(list(input()),reverse=True)
print("Yes" if s<t else "No")

Submission status: Accepted

Solution code:
s = input()
t = input()
if ''.join(sorted(s)) < ''.join(sorted(t, reverse=True)):
    print('Yes')
else :
    print('No')

Submission status: Accepted

Solution code:
a = list(input())
b = list(input())
a.sort()
b.sort()
b.reverse()
a=''.join(a)
b=''.join(b)
if a < b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=sorted(input())
T=sorted(input())
for i in range(min(len(S),len(T))):
  if S[i] < T[-1*(i+1)]:
    print("Yes")
    break
  elif S[i] == T[-1*(i+1)]:
    if i+1 == min(len(S),len(T)) and len(S) < len(T):
      print("Yes")
      break
    
  else:
    print("No")
    break
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()

S = "".join(sorted(list(s)))
T = "".join(sorted(list(t), reverse=True))

if S < T:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict

s = input()
t = input()

AL = "abcdefghijklmnopqrstuvwxyz"
S = defaultdict(int)
T = defaultdict(int)

for al in s:
  S[al] += 1

for al in t:
  T[al] += 1

ans_s = ""
for al in AL:
  ans_s += al*S[al]

ans_t = ""
for al in reversed(list(AL)):
  ans_t += al*T[al]

if ans_s < ans_t:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
print('Yes' if s < t else 'No')

Submission status: Accepted

Solution code:
s = input()
t = input()
 
sp = sorted(s)
tp = sorted(t, reverse=True)
#print(sp, tp)
print('Yes' if sp < tp else 'No')

Submission status: Accepted

Solution code:
s = ''.join(sorted(input()))
t = ''.join(reversed(sorted(input())))

if s < t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input(), reverse=True)
s = "".join(s)
t = "".join(t)
#print(s, t)
if s<t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = sorted(list(input()))
t = reversed(sorted(list(input())))
if ",".join(s) < ",".join(t):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)

s = ''.join(s)
t = ''.join(t)

if s < t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s,t=[input() for i in range(2)]
print('Yes' if sorted(s)<sorted(t,reverse=True) else 'No')

Submission status: Accepted

Solution code:
#ABC082
s = sorted(input())
t = sorted(input())[::-1]
print("Yes" if s<t else "No")

Submission status: Accepted

Solution code:
s=sorted(input())
t=sorted(input(),reverse=True)
if s<t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())

s.sort(reverse=False)
t.sort(reverse=True)

if "".join(s) < "".join(t):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input(),reverse=True)
if(s < t): print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())

S.sort()
T.sort(reverse=True)

s = ''.join(map(str,S))
t = ''.join(map(str,T))

if t > s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
if s < t:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    s_list = []
    t_list = []
    for i in range(len(s)):
        s_list.append(s[i])
    for i in range(len(t)):
        t_list.append(t[i])
    s_list.sort()
    t_list.sort(reverse = True)
    #print(s_list,t_list)
    #if 'a'<'b':
        #print ('Yes')
    s_l = len(s_list)
    t_l = len(t_list)
    if s_l >= t_l:
        ans = 'No'
    else:
        ans = 'Yes'

    for i in range(min(s_l,t_l)):
        if s_list[i] == t_list[i]:
            continue
        elif s_list[i] > t_list[i]:
            return ('No')
        else:
            return('Yes')

    return ans

print(main())

Submission status: Accepted

Solution code:
s=str(input())
t=str(input())

l="abcdefghijklmnopqrstuvwxyz"

ss=''.join(sorted(s))
st=''.join(sorted(t))
str=''.join(sorted(t,reverse=True))

if l.index(str[0])>l.index(ss[0]):
  ans="Yes"
elif len(t)>len(s) and ss in st:
  ans="Yes"
else:
  ans="No"
  
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

s = input()
t = input()

s = ''.join(sorted(s))
t = ''.join(sorted(t, reverse=True))

if s < t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = sorted(input())
T = sorted(input(), reverse=True)

if S >= T:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s=sorted(list(input()))
t=sorted(list(input()),reverse=True)
for i in range(min(len(s),len(t))):
    if ord(s[i])<ord(t[i]):
        print("Yes")
        exit()
    elif ord(s[i])>ord(t[i]):
        print("No")
        exit()
if len(s)>=len(t):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  S=input()
  T=input()
  if S==T:
    print("No")
    return
  if S in T:
    print("Yes")
    return
  s=list(S)
  t=list(T)
  
  s.sort()
  t.sort(reverse=True)
  if s==t:
    print("No")
    return
  
#  if(len(s)<len(t)):
#    print("Yes")
#    return
  for i in range(min(len(s),len(t))):
    if ord(s[i])>ord(t[i]):
      print("No")
      return
    elif ord(s[i])<ord(t[i]):
      print("Yes")
      return
  print("No")
  return
main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)

lens = len(s)
lent = len(t)
for i in range(lens):
    if i==lent:
        print('No')
        exit()
    if s[i]<t[i]:
        print('Yes')
        exit()
    elif s[i]>t[i]:
        print('No')
        exit()
else:
    if len(t)==len(s):
        print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
s=input()
t=input()

s_d = ''.join(sorted(s))
t_d = ''.join(sorted(t,reverse=True))

arr = [t_d,s_d]
arr=sorted(arr)

if s==t:
    print('No')
    exit(0)

if arr[0]==s_d:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=input()
t=input()
s=sorted(s)
t=sorted(t,reverse=True)

print('Yes' if s<t else 'No')

Submission status: Accepted

Solution code:
s=sorted(input())
t=sorted(input(),reverse=True)

if ''.join(t)>''.join(s):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input())[::-1]
if s < t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(map(str, input().rstrip()))
t = list(map(str, input().rstrip()))

s.sort()
t.sort(reverse=True)

s = "".join(s)
t = "".join(t)

print("Yes" if s < t else "No")

Submission status: Accepted

Solution code:
s = sorted(list(input().strip()))
t = sorted(list(input().strip()),reverse=True)
if s<t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
t=input()
s = sorted(s)
t = sorted(t, reverse=True)
if s < t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
import sys
if s==t:
    print("No")
    sys.exit()
ss = sorted(list(s))
tt = sorted(list(t))[::-1]
if sorted([ss,tt])[0] == ss:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = sorted(input())
T = sorted(input())[::-1]
print('Yes' if S < T else 'No')

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())

s = sorted(s)
t = sorted(t, reverse=True)

#print(s,t)
flag = [0,0]

if len(s) < len(t):
    for i in range(len(s)):
        if s[i]<t[i]:
            print('Yes')
            break
        elif s[i] > t[i]:
            print('No')
            break
        elif i == len(s)-1:
            print('Yes')
elif len(s) > len(t):
    for i in range(len(t)):
        if s[i]<t[i]:
            print('Yes')
            break
        elif s[i] > t[i]:
            print('No')
            break
        elif i == len(t)-1:
            print('No')
elif len(s) == len(t):
    for i in range(len(s)):
        if s[i]<t[i]:
            print('Yes')
            break
        elif s[i] > t[i]:
            print('No')
            break
        elif i == len(s)-1:
            print('No')

Submission status: Accepted

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)

s,t = input(),input()

def str_to_list(x):
    l = []
    for i in range(len(x)):
        l.append(ord(x[i]))
    return l

def list_to_str(l):
    l = list(map(chr,l))
    return ''.join(l)

s = str_to_list(s)
s.sort()
s = list_to_str(s)
t = str_to_list(t)
t.sort(reverse=True)
t = list_to_str(t)
judge(s<t)

Submission status: Accepted

Solution code:
s, t = sorted(input()), sorted(input())[::-1]

if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
t=input()
data=['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']
S=[0]*len(s)
T=[0]*len(t)
for i in range(len(s)):
  S[i]=data.index(s[i])
for i in range(len(t)):
  T[i]=data.index(t[i])
S.sort()
T.sort(reverse=True)
if S<T:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
anas = sorted(s)
at = sorted(t,reverse = True)

if anas < at:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
anas = sorted(s)
at = sorted(t,reverse = True)

miji = min(len(s),len(t))
for i in range(miji):
    if ord(anas[i]) < ord(at[i]):
        print('Yes')
        exit()
    elif ord(anas[i]) > ord(at[i]):
        print('No')
        exit()

if len(s) < len(t):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
s = ''.join(sorted(s))
t = ''.join(sorted(t, reverse=True))
if s>=t:
    print('No' , flush=True)
else:
    print('Yes' , flush=True)

Submission status: Accepted

Solution code:
s = input()
t = input()
s = sorted(s)
t = sorted(t, reverse=True)
s_t = [s, t]
s_t.sort()
if s_t[0] == s and s_t[1] != s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s="".join(sorted(str(input())))
t="".join(sorted(str(input()),reverse=True))
if s<t:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

def main():
    s = input()
    t = input()

    listS = []
    for i in range(len(s)):
        listS.append(s[i])

    listT = []
    for i in range(len(t)):
        listT.append(t[i])

    listS = sorted(listS)
    listT = sorted(listT, reverse=True)

    sortedS = ''
    for i in range(len(listS)):
        sortedS += listS[i]
    sortedT = ''
    for i in range(len(listT)):
        sortedT += listT[i]

    if sortedS < sortedT:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
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)]

import string

def main():
    s = "".join(list(sorted(s_input())))
    t = "".join(list(sorted(s_input(), reverse=True)))
    if s < t:
        print("Yes")
    else:
        print("No")





if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
s = "".join(sorted(str(input())))
t = "".join(sorted(str(input()), reverse=True))
if s < t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()

s = list(s)
t = list(t)
s.sort()
t.sort(reverse=True)

s = "".join(s)
t = "".join(t)

print("Yes") if s < t else print("No")

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input(), reverse=True)
if s < t:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()

if "".join(sorted(s)) < "".join(sorted(t, reverse=True)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()

if "".join(sorted(s)) < "".join(list(reversed(sorted(t)))):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()

ss = sorted(s)
tt = sorted(t, reverse=True)


def checker(s, t):
    for sz in ss:
        for tz in tt:
            if sz > tz:
                return 'No'
            elif sz == tz:
                continue
            else:
                return 'Yes'
    if len(ss) < len(tt):
        return 'Yes'
    return 'No'


print(checker(ss, tt))

Submission status: Accepted

Solution code:
#28 B - Two Anagrams AC
s = list(input())
t = list(input())

s = sorted(s,reverse = False)
t = sorted(t,reverse = True)

s = ''.join(s)
t = ''.join(t)
if s < t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#28 B - Two Anagrams
s = list(input())
t = list(input())

s = sorted(s,reverse = False)
t = sorted(t,reverse = True)

result = 'No'
rang = min(len(s),len(t))
for i in range(rang):
    if ord(s[i]) < ord(t[i]):
        result = 'Yes'
        break
else:
    # 文字が一緒で t の方が文字数が多いとき
    if (s[:rang] == t[:rang]) and len(s) < len(t):
        result = 'Yes'
print(result)

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input(), reverse=True)
if s<t: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
s = "".join(s)
t = "".join(t)
print("Yes" if s < t else "No")

Submission status: Accepted

Solution code:
a, b = [sorted(input()) for i in range(2)]
print("Yes" if a < b[::-1] else "No")

Submission status: Accepted

Solution code:
s = sorted(x for x in input())
t = sorted([x for x in input()], reverse=True)
print('Yes' if s < t else 'No')

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())

S.sort()
T.sort(reverse=True)

alpha = list('abcdefghijklmnopqrstuvwxyz')

check = False
cnt = 0
for s, t in zip(S,T):
  res = alpha.index(s) - alpha.index(t)
  if res < 0:
    check = True
    break
  elif res == 0:
    cnt += 1

if cnt == len(S):
  if len(S) < len(T):
    check = True

print("Yes" if check else "No")

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
a = ''.join(sorted(s))
b = ''.join(sorted(t, reverse=True))
if a < b:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()

sorted_s = sorted(s)
sorted_t = sorted(t, reverse=True)

#print(sorted_s)
#print(sorted_t)

if sorted_s < sorted_t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()
S = sorted(s)
T = sorted(t,reverse=True)
#print(S,T)
ans = "W"
for i in range(min(len(s),len(t))):
    if S[i] > T[i]:
        ans = "No"
        break
    elif ans == "W" and S[i] == T[i]:
        ans = "W"
    elif ans == "W" and S[i] < T[i]:
        ans = "Yes"
        break
if ans == "W":
    if len(s) < len(t):
        ans = "Yes"
    else:
        ans = "No"
print(ans)

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input())[::-1]
if s < t:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input(),reverse = True)
flag1 = True
flag2 = False
if len(s) < len(t):
    for i in range(len(s)):
        if s[i] != t[i]:
            flag1 = False
            break
else:
    flag1 = False
for i in range(min(len(s), len(t))):
    if s[i] < t[i]:
        flag2 = True
        break
    elif s[i] > t[i]:
        break
if flag1 or flag2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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


def main():
    s = sorted(input())
    t = sorted(input(), reverse=True)
    if s < t:
        print("Yes")
    else:
        print("No")


main()

Submission status: Accepted

Solution code:
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

def RI():
    return list(map(int,input().split()))

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

s = S()
t = S()

s = list(s)
s.sort()
t = list(t)
t.sort(reverse=True)

if s<t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = sorted(input())
T = sorted(input())[::-1]
print("Yes" if S<T else "No")

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())

# 文字列sをソート（sortedをすると配列型になるのでjoinして上げる必要あり）
sort_s_list = sorted(s)
sort_s = "".join(sort_s_list)

# 文字列tを逆ソート
t_list = list(t)
t_list.sort(reverse = True)
reverse_sort_t = "".join(t_list)

if sort_s < reverse_sort_t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


def main():
    s = list(input())
    t = list(input())
    s.sort()
    t.sort(reverse=True)
    l = len(s)
    tl = len(t)
    if l > tl:
        l = tl
    for i in range(l):
        if s[i] == t[i]:
            continue
        if t[i] > s[i]:
            print("Yes")
            return
        print("No")
        return
    if l == tl:
        print("No")
        return
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

s = list(input())
t = list(input())

N = len(s)
M = len(t)

s_d = sorted(s)
t_d = sorted(t, reverse=True)

ans ='No'
if N < M:
    new_t = "".join(t_d[:N])
    new_s = "".join(s_d)
    if new_t == new_s:
        ans ='Yes'

if ans == 'No':
    pos = 0
    for i in range(min(N, M)):
        if s_d[i]!=t_d[i]:
            pos = i
            break
    if s_d[pos] < t_d[pos]:
        ans ='Yes'

print(ans)

Submission status: Accepted

Solution code:
s = input()
t = input()

s = sorted(s)
t = sorted(t)[::-1]

answer = "Yes"
for i in range(len(s)):
  if i == len(t):
    answer = "No"
    break
  s_c = s[i]
  t_c = t[i]
  if s_c < t_c:
    break
  elif s_c == t_c:
    continue
  else:
    answer = "No"
    break

if s == t:
  answer = "No"

print(answer)

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)

l = [''.join(s),''.join(t)]

if l == sorted(l) and l[0]!=l[1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
S_len = len(S)
T_len = len(T)
S_sorted = sorted(S)
T_sorted = sorted(T, reverse=True)
ans = True
for i in range(min(S_len, T_len)):
    s = ord(S_sorted[i])
    t = ord(T_sorted[i])
    if s < t:
        print('Yes')
        exit(0)
    if s == t:
        continue
    else:
        print('No')
        exit(0)
if S_len >= T_len:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
if s<t:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()

S = ''.join(sorted(s))
T = ''.join(sorted(t, reverse = True))

if S < T:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
if s < t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=sorted(input())
r=sorted(input(),reverse=True)
if(s<r):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s, t = [input() for i in range(2)]
ns = ''.join(sorted(s))
nt = ''.join(sorted(t, reverse=True))
print('Yes') if ns < nt else print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()

if sorted(S) < sorted(T,reverse=True) :
  print("Yes")
else :
  print("No")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
if s<t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = ''.join(sorted(list(input())))
t = ''.join(sorted(list(input()))[::-1])
print('Yes' if s < t else 'No')

Submission status: Accepted

Solution code:
s,t = [input() for i in range(2)]

s_2 = sorted(s)
t_2 = sorted(t,reverse=True)

if s_2 < t_2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
enu = enumerate
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

S = list(input())
T = list(input())

S.sort()
T.sort(reverse=True)
for s, t in zip(S, T):
    if ord(s) < ord(t):
        # print(ord(s), ord(t))
        print("Yes")
        exit()
    elif ord(s) > ord(t):
        # print(ord(s), ord(t))
        print("No")
        exit()
else:
    if len(S) < len(T):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()

s_list = list(s)
t_list = list(t)

s_sorted = sorted(s_list)
t_sorted = sorted(t_list, reverse=True)

s_joined = ''.join(s_sorted) 
t_joined = ''.join(t_sorted) 

if s_joined < t_joined:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip.split())
def main():
    s = S()
    t = S()
    sl = list(s)
    tl = list(t)
    sl.sort()
    tl.sort(reverse=True)
    s = "".join(sl)
    t = "".join(tl)
    print("Yes" if s < t else "No")
main()

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input(), reverse=True)
print('Yes' if s < t else 'No')

Submission status: Accepted

Solution code:
s = input()
t = input()
s=sorted(s)
t=sorted(t,reverse = True)
if s < t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
s1 = sorted(s)
t1 = sorted(t, reverse=True)
if s1 < t1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
s = list(map(lambda x: ord(x), s))
t = list(map(lambda x: ord(x), t))
s = sorted(s)
t = sorted(t, reverse=True)
num = min(len(s), len(t))
for i in range(num):
    if s[i] < t[i]:
        print("Yes")
        break
    elif t[i] < s[i]:
        print("No")
        break
else:
    if len(s) < len(t):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
S = sorted(input())
T = sorted(input(), reverse=True)
if S < T:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input(), reverse=True)
sSort = ''.join(s)
tSortRev = ''.join(t)
if sSort < tSortRev:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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

l = [input() for _ in range(2)]
s, t = l[0], l[1]

s_list = sorted([_ for _ in s])
s_dict_min = ''.join(s_list)

t_list = sorted([_ for _ in t], reverse=True)
t_dict_max = ''.join(t_list)

if s_dict_min < t_dict_max:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    s = INPUT()
    t = INPUT()

    s = [ord(i) for i in sorted(s)]
    t = [ord(i) for i in sorted(t)]
    t.reverse()

    cnt = 0
    for x in s:
        if x < t[cnt]:
            print("Yes")
            sys.exit()
        elif x > t[cnt]:
            print("No")
            sys.exit()
        else:
            cnt += 1
            if cnt == len(t):
                print("No")
                sys.exit()

    print("Yes" if len(s) < len(t) else "No")


if __name__ == '__main__':
    main()