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:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(s: str, t: str):
    s = list(s)
    t = list(t)
    s.sort()
    t.sort(reverse= True)
    s = ''.join(s)
    t = ''.join(t)
    if s<t:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    s = next(tokens)  # type: str
    t = next(tokens)  # type: str
    solve(s, t)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
s1 = sorted(s)
t1 = sorted(t)
t1.reverse()
if s1 < t1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = input()
b = input()

print("Yes" if sorted(a) < sorted(b)[::-1] else "No")

Submission status: Accepted

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

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

if s_min < t_max:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=sorted(input())
t=sorted(input(),reverse=True)
s1=""
for i in s:
  s1+=i
t1=""
for i in t:
  t1+=i

arr=[s1,t1]
arr2=sorted(arr)
if arr==arr2:
  if s==t:
    print('No')
  else:
    print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:

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

s.sort()
t.sort(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=1)
print('Yes') if s < t else print('No')

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
##### 解けた #####

s=input()
t=input()

sp="".join(sorted(s)) # sを並び替えて一番最初の文字列
tp="".join(list(reversed(sorted(t)))) # tを並び替えて一番最後の文字列

if sp<tp: # 目標を達成できるなら
    print("Yes")
else: # 達成できないなら
    print("No")

Submission status: Accepted

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

if "".join(sorted(s)) < "".join(sorted(t)[::-1]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    s = input()
    s_list = list(s)
    s_list.sort()

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

    for i in range(0,min(len(s_list),len(t_list))):
        if s_list[i] < t_list[i]:
            print("Yes")
            return
        elif s_list[i] > t_list[i]:
            print("No")
            return

    if len(s_list) < len(t_list):
        print("Yes")
    else:
        print("No")

    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    try:
        s = sorted(input())
        t = sorted(input(),reverse=True)
        # print(s)
        # print(t)
        print('Yes') if s < t else print('No')
    except:#エラー
        pass

if __name__ == "__main__":
    main()

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:
N = input()
M = input()

sorted_asc = sorted(list(N))
sorted_desc = sorted(list(M), reverse=True)
res = ""

for (x, y) in zip(sorted_asc, sorted_desc):
    if x < y:
        res = "Yes"
        break
    elif x > y:
        res = "No"
        break

if res == "":
    if len(N) >= len(M):
        res = "No"
    else:
        res = "Yes"

print(res)

Submission status: Accepted

Solution code:
N = input()
M = input()

sorted_asc = sorted(list(N))
sorted_desc = sorted(list(M), reverse=True)
res = ""

for (x, y) in zip(sorted_asc, sorted_desc):
    if x < y:
        res = "Yes"
        break
    elif x > y:
        res = "No"
        break

if res == "" and len(N) == len(M):
    res = "No"
elif res == "" and len(N) < len(M):
    res = "Yes"
elif res == "" and len(N) > len(M):
    res = "No"

print(res)

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()
s_st = ''.join(sorted(s))
t_strv = ''.join(sorted(t,reverse=True))
if s_st < t_strv:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=[i for i in input()]
t=[i for i in input()]
if s==t:
  print('No')
else:
  s=sorted(s)
  t=sorted(t,reverse=True)
  s=''.join(s)
  t=''.join(t)
  l=[s,t]
  l2=sorted(l)
  if l==l2:
    print('Yes')
  else:
    print('No')

Submission status: Accepted

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

s_asc = "".join(sorted(s))
t_desc = "".join(sorted(t, reverse=True))

if s_asc < t_desc:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Submission status: Accepted

Solution code:
s = input()
a=sorted(s)
t = input()
b=sorted(t)
b.reverse()
if a<b:
	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(s)
#print(t)

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

Submission status: Accepted

Solution code:
from collections import Counter
s = input()
t = input()
S = Counter(s)
T = Counter(t)
li_s = sorted(list(s))
li_t = sorted(list(t),reverse=True)
ans_s = ''.join(li_s)
ans_t = ''.join(li_t)
if ans_s < ans_t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

s = input()
s_asc = ''.join(sorted(s))

t = input()
t_desc = ''.join(sorted(t,reverse=True))

if s_asc < t_desc:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = input()
S = "".join(sorted(list(s)))
T = "".join(sorted(list(t),reverse = True))
Answer = 'No'
if S < T:
  Answer = 'Yes'
print(Answer)

Submission status: Accepted

Solution code:
s = input()
t = input()
s = "".join(sorted(list(s)))
t = "".join(sorted(list(t),reverse=True))
import string
letter = list(string.ascii_lowercase)
for i in range(min(len(s), len(t))) :
    if letter.index(s[i]) == letter.index(t[i]) :
        continue
    elif letter.index(s[i]) < letter.index(t[i]) :
        ans = "Yes"
        break
    elif letter.index(s[i]) > letter.index(t[i]) :
        ans = "No"
        break
else :
    if len(s) < len(t) :
        ans = "Yes"
    elif len(s) >= len(t) :
        ans = "No"
print(ans)

Submission status: Accepted

Solution code:
#082b
s = list(str(input()))
t = list(str(input()))
s.sort(reverse=False)
t.sort(reverse=True)
s = ''.join(s)
t = ''.join(t)

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

Submission status: Accepted

Solution code:
A=list(input())
B=list(input())
a = sorted(A)
b = sorted(B, reverse = True)
if a < b:
  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)
l = [s,t]
l.sort()

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

Submission status: Accepted

Solution code:
def examB():
    St = S(); T = S()
    s_asc = ''.join(sorted(St))
    t_desc = ''.join(sorted(T, reverse=True))
    if s_asc < t_desc:
        print('Yes')
    else:
        print('No')


import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Accepted

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

Submission status: Accepted

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

sorted_s = sorted(s)
sorted_t = sorted(t, reverse=True)
len_s = len(sorted_s)
len_t = len(sorted_t)
iter_range = len_s if len_s < len_t else len_t

flag = 0
same_count = 0
for i in range(iter_range):
    s_i = sorted_s[i]
    t_i = sorted_t[i]
    if s_i < t_i:
        flag = 1
        break
    if s_i == t_i:
        same_count+= 1

if (same_count == len_s) & (len_s < len_t):
    print("Yes")
elif (same_count == len_s) & (len_s >= len_t):
    print("No")
elif flag:
    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=list(str(input()))
t=list(str(input()))
s=sorted(s)
t=sorted(t,reverse=True)
judge=0

for i,j in zip(s,t):
    if ord(i)>ord(j):
        judge=0
        break
        
    elif ord(i)<ord(j):
        judge=1
        break
        
    else:
        judge=2
        continue
    
if judge==2:
    if len(s)>=len(t):
        judge=0
    else:
        judge=1

if judge==1:print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
s1=''
t1=''
for j in range(len(s)):
    s1+=s[j]
for k in range(len(t)):
    t1+=t[k]
if s1==t1:
    print('No')
else:
    for i in range(min(len(s),len(t))):
        if s[i]>t[i]:
            print('No')
            break
        elif s[i]==t[i]:
            if i==min(len(s),len(t))-1:
                if len(s)==min(len(s),len(t)):
                    print('Yes')
                else:
                    print('No')
            continue
        else:
            print('Yes')
            break

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    def sort_for(s):
        cc = [c for c in s]
        cc.sort()
        s = "".join(cc)
        return s

    def sort_rev(t):
        cc = [c for c in t]
        cc.sort(reverse=True)
        t = "".join(cc)
        return t

    s = input()
    t = input()
    s = sort_for(s)
    t = sort_rev(t)
    st = [s, t]
    st.sort()
    if st[0] == s and s != t:
        print("Yes")
    else:
        print("No")

main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#ABC 082: B – Two Anagram#
s = list(input())
t = list(input())

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

print('Yes' if  ''.join(s) < ''.join(t) else '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:
from sys import stdin


s = stdin.readline().rstrip()
s = [str(i) for i in s]

t = stdin.readline().rstrip()
t = [str(i) for i in t]

if s == t:
    print("No")
    exit()
s.sort()
t.sort(reverse=True)

ns = ""
nt = ""

for i in range(len(s)):
    ns += s[i]

for i in range(len(t)):
    nt += t[i]

li = [ns,nt]

lin = sorted(li)


if lin == li:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
import sys

def main():
  s = list(input())
  t = list(input())
  
  s.sort()
  t.sort()
  t.reverse()
  m = min(len(s), len(t))
  for i in range(m):
    if s[i] > t[i]:
      print('No')
      sys.exit()
    elif s[i] < t[i]:
      print('Yes')
      sys.exit()

  if len(s) < len(t):
    print('Yes')
    sys.exit()
  else:
    print('No')
    sys.exit()
    
main()

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()
ls,lt=[],[]
for cs in s:
    ls.append(cs)
for ct in t:
    lt.append(ct)
ls.sort()
lt.sort(reverse=True)
s="".join(ls)
t="".join(lt)
if s<t: print("Yes")
else: print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = "".join(sorted(input()))
t = "".join(sorted(input())[::-1])
if s==t or [s, t] != sorted([s, t]):
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
s=input()
t=input()
a=[s[i] for i in range(len(s))]
b=[t[i] for i in range(len(t))]
a.sort()
b.sort(reverse=True)
s=""
t=""
for i in a:
    s+=i
for i in b:
    t+=i
if s<t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

a=list(input())
b=list(input())
a.sort()
b.sort(reverse=True)
n=len(a)
m=len(b)

for i in range(min(n,m)):
    if a[i]>b[i]:
        print("No")
        sys.exit()
    elif a[i]<b[i]:
        print("Yes")
        sys.exit()
if n>=m:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s=input()
t=input()
s2 = sorted(s)
t2 = sorted(t,reverse=True)
if s2<t2:
  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:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
for i in range(len(s)):
    if i >= len(t):
        break
    if s[i] > t[i]:
        print('No')
        quit()
    elif s[i] < t[i]:
        print('Yes')
        quit()
if len(s) < len(t):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=input();t=input()
ls=sorted([c for c in s]);lt=sorted([c for c in t],reverse=True)
s2=''.join(ls);t2=''.join(lt)
print('Yes' if s2<t2 else 'No')

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=1)
print('YNeos'[s>=t::2])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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=sorted(s)
t=sorted(t,reverse=True)
S=""
for x in s:
  S+= x
T=""
for x in t:
  T+= x
A=[S,T]
a=sorted(A)
if a[0]==S:
  if a[1]==S:
    print("No")
  else:
    print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s=input()
t=input()
a=[]
b=[]
for i in range(len(s)):
    a.append(s[i])
    a.sort()
for i in range(len(t)):
    b.append(t[i])
    b.sort(reverse=True)
c=[a,b]
c.sort()
if c[0]==a and a!=b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
t = str(input())
s_a=''.join(sorted(s))
t_z=''.join(reversed(sorted(t)))
if s_a < t_z:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    s, t = sys.stdin.read().split()
    n, m = len(s), len(t)
    s = sorted(s)
    t = list(reversed(sorted(t)))
    if n < m:
        for i in range(n):
            if s[i] < t[i]: ans = 'Yes'; break
            elif s[i] > t[i]: ans = 'No'; break  
        else:
            ans = 'Yes'
    else:
        for i in range(m):
            if s[i] < t[i]: ans = 'Yes'; break
            elif s[i] > t[i]: ans = 'No'; break  
        else:
            ans = 'No'

    print(ans)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Accepted

Solution code:
import sys
# import collections
# import math
import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    s, t = sys.stdin.read().split()
    n, m = len(s), len(t)
    s = sorted(s)
    t = list(reversed(sorted(t)))
    if n < m:
        for i in range(n):
            f_s, f_t = False, False
            for c in string.ascii_lowercase:
                if s[i] == c: f_s = True
                if t[i] == c: f_t = True
                
                if f_s and not f_t: print('Yes'); exit()
                elif not f_s and f_t: print('No'); exit()
                elif f_s and f_t: break
                else: continue
        ans = 'Yes'
    else:
        for i in range(m):
            for c in string.ascii_lowercase:
                f_s, f_t = False, False
                if s[i] == c: f_s = True
                if t[i] == c: f_t = True
                
                if f_s and not f_t: print('Yes'); exit()
                elif not f_s and f_t: print('No'); exit()
                elif f_s and f_t: break
                else: continue
        ans = 'No'

    print(ans)
        

if __name__ == "__main__":
    # execute only if run as a script
    main()

Submission status: Accepted

Solution code:
s,t=[[i for i in input()] for _ in range(2)]
s.sort()
t.sort()
st=""
ts=""
for i in range(len(s)):
    st+=s[i]
for i in range(len(t)):
    ts+=t[len(t)-i-1]
print("Yes" if st<ts else "No")

Submission status: Accepted

Solution code:
S, T = [s for s in input()], [s for s in input()]
s_str = ''.join(sorted(S))
t_str = ''.join(sorted(T, reverse=True))
if s_str == t_str:
  print('No')
  exit()
else:
  print('Yes' if sorted([s_str,t_str]).index(s_str)==0 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
s.sort()
t = list(input())
t.sort(reverse=True)
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 = 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)
if s < t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = input()
b = input()

a = ["".join(sorted(a)),"".join(sorted(a,reverse=True))]
b = ["".join(sorted(b)),"".join(sorted(b,reverse=True))]

ans = "No"
for aa in a:
    for bb in b:
        if aa < bb:
            ans = "Yes"
            break
print(ans)

Submission status: Accepted

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

t = input()
t_dsc = ''.join(sorted(t, reverse = True))

if s_asc < t_dsc:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

s_sort = "".join(sorted(s))
t_sort = "".join(sorted(t, reverse=True))

if s_sort < t_sort:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = sorted([i for i in input()])
m = sorted([i for i in input()],reverse = True)

flg = True
if ''.join(n) >= ''.join(m):
    flg = False

print('Yes' if flg else 'No')

Submission status: Accepted

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

s=sorted(s)
l=list(reversed(sorted(l)))

#print(s,l)

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

Submission status: Accepted

Solution code:
S = sorted(list(map(str, input())))
T = sorted(list(map(str, input())), reverse = True)
length = min(len(S), len(T))

flg = 2

for i in range(length):
	if S[i] < T[i]:
		flg = 1
		break
	elif S[i] > T[i]:
		flg = 0
		break

if flg == 1:		
	print("Yes")
elif flg == 0:
	print("No")
else:
	if len(S) < len(T):
		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(input())
T = list(input())

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

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

Submission status: Accepted

Solution code:
def is_b_larger_than_a(a, b):
  n = min(len(a), len(b))
  for i in range(n):
    if ord(a[i]) > ord(b[i]):
      return False
    if ord(a[i]) < ord(b[i]):
      return True
  return len(a) < len(b)

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

if is_b_larger_than_a(s, t):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 25,Oct,2019
"""

import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

a = readline().rstrip()
b = readline().rstrip()

print("Yes" if ''.join(sorted(a)) < ''.join(sorted(b)[::-1]) else "No")

Submission status: Accepted

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

S=[]
for i in range(len(s)):
    S.append(str(s[i]))
S.sort()
s=''.join(S)

T=[]
for i in range(len(t)):
    T.append(str(t[i]))
T.sort(reverse=True)
t=''.join(T)

if s==t:
    print('No')
else:
    print(['Yes','No'][sorted([s,t]).index(s)])

Submission status: Accepted

Solution code:
#
# abc082 b
#
import unittest
from io import StringIO
import sys


def input():
    return sys.stdin.readline().rstrip()


def resolve():
    s = list(input())
    t = list(input())

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

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


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """yx
axy"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """ratcode
atlas"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """cd
abc"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """w
ww"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_5(self):
        input = """zzz
zzz"""
        output = """No"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = sorted(input())
y = sorted(input(), reverse=True)

print('Yes' if x < y 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=input()
t=input()
sl=list(s)
tl=list(t)
sl.sort()
tl.sort(reverse=True)
s=''.join(sl)
t=''.join(tl)
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)
w="".join(s)
v="".join(t)
ans=[w,v]
ans.sort()
print("Yes" if (ans[0]==w and w!=v) else "No")

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=[]
for i in s:
    S.append(i)
S.sort()
T=[]
for i in t:
    T.append(i)
T.sort(reverse=True)
if S<T:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

s.sort()
s=''.join(s)

t.sort()
t.reverse()
t=''.join(t)

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

Submission status: Accepted

Solution code:
s = [c for c in input()]
t = [c for c in input()]
s.sort()
t.sort(reverse=True)
ss = ''.join(s)
tt = ''.join(t)
print('YNeos'[ss>=tt::2])

Submission status: Accepted

Solution code:
s=str(input())
t=str(input())
count=0
for i in range(len(s)):
	for j in range(len(t)):
		if s[i] < t[j]:
			count+=1
if set(s) == set(t):
	if len(s) < len(t):
		count+=1
print('Yes' if count !=0 else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

i = 0

while(i < N and i < M):
  if(s[i] < t[i]):
    print("Yes")
    break
  elif(s[i] > t[i]):
    print("No")
    break
  else:
    i += 1

if(N < M and i == N):
  print("Yes")

if(M <= N and M == i):
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=sorted(input())
t=sorted(input(),reverse=1)
if [s,t]==sorted([s,t]) and s!=t:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
s2="".join(sorted(s))
t2="".join(sorted(t,reverse=True))
st=sorted([s2,t2])
print("Yes" if  st[0]==s2 and s2!=t2 else "No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ls=list(input())
lt=list(input())
if ls!=lt:
  ls.sort()
  lt.sort(reverse=True)
  s_sorted=''.join(ls)
  t_sorted=''.join(lt)
  before=[s_sorted,t_sorted]
  after=[s_sorted,t_sorted]
  after.sort()
  if before==after:
    print('Yes')
  else:
    print('No')

else:
  print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
N = len(s)
M = len(t)
if s == t:
    print('No')
    exit()
array_s = []
array_t = []
ans = []
for i in range(N):
    array_s.append(s[i])
for i in range(M):
    array_t.append(t[i])
array_s.sort()
array_t.sort(reverse=True)
ans_s = ''
ans_t = ''
for i in range(N):
    ans_s += array_s[i]
for i in range(M):
    ans_t += array_t[i]
ans.append(ans_s)
ans.append(ans_t)
ans.sort()
# print(ans_s)
# print(ans_t)
# print(ans)
if ans[0] == ans_s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

sd = sorted(list(s))
td = sorted(list(t), reverse=True)

if sd < td:
    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 = input()
t = input()

if s == t:
	print('No')
	exit()
sd = sorted(s)
td = sorted(t,reverse=True)

tl = [sd,td]
if sorted(tl) == tl:
	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 = input().strip()
t = input().strip()
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()
ss = sorted(list(s))
ss = ''.join(ss)
tt = sorted(list(t),reverse=True)
tt = ''.join(tt)
if ss < tt:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    s = inputs[0]
    t = inputs[1]
    s_list = list(s)
    t_list = list(t)
    s_list.sort()
    t_list.sort(reverse=True)
    s_ret = ''.join(s_list)
    t_ret = ''.join(t_list)

    return 'Yes' if s_ret < t_ret else 'No'


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)

Submission status: Accepted

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