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 = input()
t = input()

list_s = list(s)
list_s.sort()

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

yes = False
if len(list_s) < len(list_t):
    yes = True

for i in range(len(list_s)):
    if len(list_t)-1 < i:
        break
    if list_s[i] < list_t[i]:
        yes = True
        break
    elif list_s[i] > list_t[i]:
        yes = False
        break

if yes:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    s = sorted(S)
    t = sorted(T, reverse=True)
    ans = 'Yes' if s < t else 'No'
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=list(input());t=list(input())
s.sort(key=str);t.sort(key=str,reverse=True)
print(['No','Yes'][t>s])

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
from heapq import heappush, heappop
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


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

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

    sList, tList = list(s), list(t)

    sList.sort()
    tList.sort(reverse=True)

    sortedS = ''.join(sList)
    sortedT = ''.join(tList)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=str(input())
t=str(input())
s2=sorted(list(s))
t2=sorted(list(t),reverse=True)

s3=''.join(s2)
t3=''.join(t2)

if s3 < t3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import string

alphabet = {}
n  = 0
for i in string.ascii_lowercase:
    alphabet[i] = n
    n += 1
    
s = list(input().rstrip())
t = list(input().rstrip())



for i in range(len(s)):
    s[i] = alphabet[s[i]]
    
for i in range(len(t)):
    t[i] = alphabet[t[i]]
    

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print "Yes" if sorted(raw_input())<[x for x in reversed(sorted(raw_input()))] else "No"

Submission status: Accepted

Solution code:
ss = list(map(ord, input().strip()))
ts = list(map(ord, input().strip()))

bigger = False
non_empty = False
while len(ts) > 0 and len(ss) > 0:
    s = min(ss)
    t = max(ts)
    if s == t:
        ts.remove(t)
        ss.remove(s)
    elif s > t:
        bigger = False
        non_empty = True
        break
    else:
        bigger = True
        non_empty = True
        break

if not non_empty:
    if len(ts) == 0 and len(ss) == 0:
        bigger = False
    elif len(ss) == 0:
        bigger = True
    else:
        bigger = False

if bigger:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

res = "".join(sorted(a)) < "".join(reversed(sorted(b)))
print("Yes" if res else "No")

Submission status: Accepted

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

sl = list(s)
sl.sort()
s = ''.join(sl)
tl = list(t)
tl.sort(reverse=True)
t = ''.join(tl)

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

Submission status: Accepted

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

s = input()
t = input()


s_list = list(s)
s_list.sort()

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

count = min(len(s_list), len(t_list))
for i in range(count):
    if s_list[i] < t_list[i]:
        print("Yes")
        exit()
    elif s_list[i] == t_list[i]:
        continue
    else:
        print("No")
        exit()

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

Submission status: Accepted

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

s.sort()
t.sort()
t.reverse()

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

Submission status: Accepted

Solution code:
sl = [input() for i in range(2)]

if ''.join(sorted(sl[0])) < ''.join(sorted(sl[1]))[::-1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = sorted(input())
t = sorted(input())
t.reverse()

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

Submission status: Accepted

Solution code:
print ['No', 'Yes'][sorted(raw_input()) < sorted(raw_input(), reverse=True)]

Submission status: Accepted

Solution code:
sl = [input() for i in range(2)]

s = [s_ for s_ in sl[0]]
s.sort()

t = [t_ for t_ in sl[1]]
t.sort()
t = t[::-1]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(raw_input())
t = list(raw_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:
import sys
s=input()
t=input()

sn=[ord(s[i]) for i in range(len(s))]
tn=[ord(t[i]) for i in range(len(t))]

sn.sort()
tn.sort(reverse=True)

for i in range(min(len(tn), len(sn))):
    if tn[i] > sn[i]:
        print('Yes')
        sys.exit()
    elif tn[i] < sn[i]:
        print('No')
        sys.exit()

if len(tn) > len(sn):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 19 13:54:17 2017

@author: kotania
"""

s = input()
t = input()

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

s_list.sort()
t_list.sort()
t_list.reverse()

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

Submission status: Accepted

Solution code:
from collections import Counter
s = raw_input()
t = raw_input()

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

for x in xrange(min(len(s), len(t))):
    if s < t:
        print "Yes"
        break
    elif s>t:
        print "No"
        break
else:
    if len(s) < len(t):
        print "Yes"
    else:
        print "No"

Submission status: Accepted

Solution code:
from collections import defaultdict

def get_alphadic(string):
    dic = defaultdict(lambda: 0)
    for c in string:
        dic[c] += 1
    return dic


def get_newstring(dic):
    string = ''
    for item in sorted(dic.items(), key=lambda x: x[0]):
        string += item[0]*item[1]
    return string


def main():
    s = input()
    t = input()
    s_dic = get_alphadic(s)
    t_dic = get_alphadic(t)
    s_ = get_newstring(s_dic)
    t_ = get_newstring(t_dic)[::-1]

    if s_ < t_:
        print('Yes')
    else:
        print('No')



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#abc082b

s=sorted(raw_input())
t=sorted(raw_input(),reverse=True)
if t>s:
 print 'Yes'
else:
 print 'No'

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
s = list(input())
t = list(input())
if ''.join(sorted(s)) < ''.join(sorted(t, reverse = True)):
    print("Yes")
else:
    print("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 = "".join(list(sorted(list(input()))))
t = "".join(list(sorted(list(input()), reverse=True)))
print("Yes" if s<t else "No")

Submission status: Accepted

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

s_2 = "".join(sorted(s))
t_2 = "".join(sorted(t,reverse = True))

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

Submission status: Accepted

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

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

result = 0
score = 0
for s_al, t_al in zip(s_sorted, t_sorted):
    if s_al > t_al:
        result = -1
        break
    elif s_al < t_al:
        result = 1
        break
if result == 0:
    result = -1 if len(s) >= len(t) else 1

print("Yes" if result == 1 else "No")

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
S.sort()
T.sort()
T=T[::-1]

S=''.join(S)
T=''.join(T)

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

Submission status: Accepted

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

alphabet = [chr(i) for i in range(97, 97+26)]


def max_s(s):
    for c in alphabet:
        if c in s:
            return c


def min_s(s):
    for c in reversed(alphabet):
        if c in s:
            return c


def compare(s1, s2):
    s1_index = alphabet.index(s1)
    s2_index = alphabet.index(s2)
    return s1_index < s2_index


for i in range(max(len(s), len(t))):
    if len(s) == 0:
        print("Yes")
        break
    elif len(t) == 0:
        print("No")
        break

    s_max = max_s(s)
    t_min = min_s(t)

    if s_max == t_min:
        s = s[:s.find(s_max)] + s[s.find(s_max) + 1:]
        t = t[:t.find(t_min)] + t[t.find(t_min) + 1:]
        continue

    if compare(s_max, t_min):
        print("Yes")
        break
    else:
        print("No")
        break
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
from collections import Counter
import collections
round = lambda x:(x*2+1)//2
a = input()
b = input()
a = list(a)
b = list(b)
b = sorted(b,reverse = True)
a = sorted(a)
#a = a[1:]
a = "".join(a)
b = "".join(b)
if a <  b :
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

s.sort()
t.sort()
t.reverse()


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

Submission status: Accepted

Solution code:
#coding:utf-8
def main():
    s = raw_input()
    t = raw_input()
    
    if min(s) <  max(t):
        print "Yes"
    elif s.count(s[0]) == len(s) and t.count(t[0]) == len(t) and len(s) < len(t):
        print "Yes"
    else:
        print "No"

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
s_input = input()
t_input = input()

s = list(s_input)
t = list(t_input)

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

if(len(s)<=len(t)):
    l = len(s)
else:
    l = len(t)

R = 0
P = 0
for i in range(0, l):
    if(s[i] == t[i]):
        P+=1
    elif(s[i] < t[i]):
        break
    else:
        R=1

if(P==l):
    if(len(s)<len(t)):
        R=0
    else:
        R=1

if(R==0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
i,s=input,sorted;print(["No","Yes"]["".join(s(i()))<"".join(s(i()))[::-1]])

Submission status: Accepted

Solution code:
print(["No","Yes"]["".join(sorted(input()))<"".join(sorted(input()))[::-1]])

Submission status: Accepted

Solution code:
print(["No","Yes"]["".join(sorted(input()))<"".join(reversed(sorted(input())))])

Submission status: Accepted

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

a = "".join( sorted( list(a) ) )
b = "".join( sorted( list(b) ) )

yes = True
printed = False

if len(a) < len(b):
    i = 0
    while i < len(a):
        if a[i] != b[i]:
            yes = False
            break
        i += 1
    if yes:
        print "Yes"
        printed = True

if not printed and len(b) > 0:
    i = 0
    b = "".join( sorted( list(b), reverse = True ) )

    while i < len(a) and i < len(b):
        if a[i] < b[i]:
            print "Yes"
            printed = True
            break
        elif a[i] > b[i]:
            print "No"
            printed = True
            break
        i += 1
if not printed:
    print "No"

Submission status: Accepted

Solution code:
import sys

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

for c_s, c_t in zip(s, t):
    if c_s < c_t:
        print('Yes')
        sys.exit()
    elif c_s > c_t:
        print('No')
        sys.exit()

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

Submission status: Accepted

Solution code:
import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))

##### main #####



def main():
	s = sorted(input())
	t = sorted(input(),reverse=True)

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


if __name__ == '__main__':
	main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a = input()		# 文字列の入力  abcdefg...
b = input()		# 文字列の入力  abcdefg...

#print(a, sorted(a))
#print(b, sorted(b, reverse=True))

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

#print(a)
#print(b)

ans="Yes"
if a >= b: ans="No"

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ss,tt = sorted(s),sorted(t,reverse=True)
for i in range(min(len(ss),len(tt))):
    if ss[i] < tt[i]:
        print("Yes")
        break
    elif ss[i] > tt[i]:
        print("No")
        break
else:
    if len(tt) <= len(ss):
        print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
print 'Yes' if sorted(raw_input()) < sorted(raw_input())[::-1] else '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:
def solv():
    s = sorted(input())
    t = sorted(input(),reverse=True)

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

if __name__ == '__main__':
    solv()

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s.sort()
t.sort(reverse = True)
new_s = ''.join(s)
new_t = ''.join(t)
lis = [new_s, new_t]
lis.sort()
if lis[0] == new_s and lis[1] != new_s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#以下模範解答
s = input()
# s_asc = ''.join(sorted(s))
s_asc = sorted(s)
t = input()
# t_desc = ''.join(sorted(t, reverse = True))
t_desc = sorted(t, reverse = True)

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

Submission status: Accepted

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

Submission status: Accepted

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

s.sort()
t.sort()
t.reverse()

for S,T in zip(s,t):
	if 'S' == 'T':
		continue

	elif ord(S) < ord(T):
		print("Yes")
		exit(0)

	elif ord(T) < ord(S):
		print("No") 
		exit(0)

if len(s) < len(t):
	print("Yes")

else:
	print("No")

Submission status: Accepted

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

A = list(input())
B = list(input())
A.sort()
B.sort(reverse=True)

if A < B:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def solve():
    s = list(input())
    t = list(input())
    s.sort()
    t.sort()

    t.reverse()

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

solve()

Submission status: Accepted

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

s.sort()
t.sort()
t.reverse()

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

Submission status: Accepted

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

slist = []
tlist = []

for i in s:
    slist.append(i)
for i in t:
    tlist.append(i)
    
sortedslist = sorted(slist)
sortedtlist = sorted(tlist)

#print(sortedslist, sortedtlist)

sample ='abcdefghijklmnopqrstuvwxyz'

def checktoend(sa, ta):
    n = min(len(sa), len(ta))
    end = 0
    for i in range(n):
        for x in sample:
            if sa[i]==x and ta[-(i+1)]==x:
                break
            elif sa[i]==x and ta[-(i+1)]!=x:
                print('Yes')
                end = 1#end
                break
            elif sa[i]!=x and ta[-(i+1)]==x:
                print('No')
                end = 1
                break
        if end == 1:
            break
    else:
        if len(sa)<len(ta):
            print('Yes')
        else:
            print('No')

checktoend(sortedslist, sortedtlist)

Submission status: Accepted

Solution code:
a=raw_input()
b=raw_input()
a=list(a)
a.sort()
b=list(b)
b.sort()
b.reverse()

ch=0
for i in range(len(b)):
    if len(a)-1>=i:

        if a[i]<b[i]:
            ch=1
            break
    else:

        if a[:i]==b[:i]:
            ch=1

if ch==1:
    print "Yes"
else:
    print "No"

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
 
def f(s, t):
  s.sort()
  t.sort(reverse=True)
  s_sum = 0
  t_sum = 0
  for i in range(len(s)):
    s[i] = ord(s[i])
  
  for i in range(len(t)):
    t[i] = ord(t[i])
  
  for i in range(len(s)):
    if not i + 1 >= len(t):
      s_sum += s[i]
      t_sum += t[i]

      if s_sum < t_sum:
        return 'Yes'
      elif s_sum > t_sum:
        return 'No'
    else:
      break

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

print(f(s, t))

Submission status: Accepted

Solution code:
a = list(raw_input())
b = list(raw_input())

a = sorted(a)
b = sorted(b)
new_a = []
new_b = []
for x in a:
  if ord(x) >= ord('a') and ord(x) <= ord('z'):
     new_a.append(x)
      
for x in b:
  if ord(x) >= ord('a') and ord(x) <= ord('z'):
     new_b.append(x)

new_a = new_a
new_b = new_b[::-1]
la = len(new_a)
lb = len(new_b)

for x in range(101):
  if x >= lb:
    print "No"
    exit(0)
  if x >= la:
    print "Yes"
    exit(0)
  if ord( new_a[x] ) > ord( new_b[x] ):
    print "No"
    exit(0)
  if ord( new_a[x] ) < ord( new_b[x] ):
    print "Yes"
    exit(0)

Submission status: Accepted

Solution code:
import string
if __name__=="__main__":
    s = list(input())
    t = list(input())
    min_s = 27
    max_t = 0
    dic = list(string.ascii_lowercase)
    c = 0
    for j in range(len(s)):
        if s[j] in t:
            c+=1
    if c==len(s) and c<len(t):
        print("Yes")
        exit()
    for i in string.ascii_lowercase:
        if s.__contains__(i):
            min_s = min(min_s,dic.index(i)+1)
        if t.__contains__(i):
            max_t = max(max_t,dic.index(i)+1)
    if max_t<=min_s:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
import string
lisL = list(string.ascii_lowercase)
dic = dict(zip(lisL,list(range(26))))
s = input()
t = input()
lisT = list(reversed(sorted(t)))
lisS = list(sorted(s))
for sitem,titem in zip(lisS[0:min( len(lisT),len(lisS) )],lisT[0:min( len(lisT),len(lisS) )]):
  if dic[sitem] < dic[titem]:
    print ("Yes")
    break
  elif dic[sitem] > dic[titem]:
    print ("No")
    break
else:
  if len(lisT) > len(lisS):
    print ("Yes")
  else:
    print ("No")

Submission status: Accepted

Solution code:
import sys
s_ls = sys.stdin.read().split("\n")
s = "".join(sorted(s_ls[0]))
t = "".join(sorted(s_ls[1]))[::-1]
if s < t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input().strip()
t=input().strip()
s=sorted(s,key=lambda x:ord(x))
t=sorted(t,key=lambda x:-ord(x))
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 ''.join(S) < ''.join(T):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
p = []
q = []
m = len(s)
n = len(t)
if m >= n:
    ans = "No"
else:
    ans = "Yes"
for i in range(m):
    p.append(s[i])
p.sort()
for j in range(n):
    q.append(t[j])
q.sort(reverse=True)
for k in range(min(m,n)):
    if ord(p[k]) < ord(q[k]):
        ans = "Yes"
        break
    elif ord(p[k]) > ord(q[k]):
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
s= list(input())
t= list(input())
s.sort()
t.sort()

count = 0
for i in range(min(len(t),len(s))):
    if t[i] == s[i]:
        count += 1
if count == min(len(t),len(s)):
    if len(s)<len(t):
        print("Yes")
    else:
        print("No")
        

elif s[0]<t[len(t)-1]:

    print("Yes")


else:
    print("No")

Submission status: Accepted

Solution code:
debug = False
if debug:
    s = "zzz"
    t = "zzz"
else:
    s = input()
    t = input()

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

Submission status: Accepted

Solution code:
import sys

line1 = sys.stdin.readline()
line2 = sys.stdin.readline()

line1 = line1.replace('\n', '')
line2 = line2.replace('\n', '')

line1 = sorted(line1)
line2 = sorted(line2, reverse=True)

# print(line1)
# print(line2)

flag = 0
if len(line1) < len(line2):
    flag = 1

if flag == 1:
    for x, y in zip(line1, line2):
        if x > y:
            flag = 0
            break
        elif x < y:
            flag = 1
            break

else:
    for x, y in zip(line1, line2):
        if x < y:
            print("Yes")
            flag = -1
            break
# print(flag)
if flag == 1:
    print("Yes")
elif flag != -1:
    print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
s = input()
t = input()

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

Submission status: Accepted

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

s1 = sorted(s)
s2 = "".join(s1)
t1 = sorted(t, reverse=True)
t2 = "".join(t1)

l = [s2, t2]
l.sort()

if s == t:
  print("No")
elif l[0] == s2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

s.sort()
t.sort()
t = t[::-1]

import sys

for i, j in zip(s, t):
    if j > i:
        print('Yes')
        sys.exit(0)

if len(s) < len(t):
    for i in s:
        if i not in t:
            print('No')
            sys.exit(0)

    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
S = []
T = []
Ans = []
for i in range(len(s)):
	S.append(s[i])
S.sort()
moziretu1 = "".join(S)

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

if S < T:
	print('Yes')

else:
	print('No')

Submission status: Accepted

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

s.sort()

t.sort()
t.reverse()

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

Submission status: Accepted

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

smax = max(s)
tmax = max(t)
smin = min(s)
tmin = min(t)

ans = False

if tmax > smin:
    ans = True
elif tmax < smax:
    ans = False
else:
    if len(t) > len(s):
        ans = True

if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

s_array = list(S)
t_array = list(T)

#print s_array, t_array

s_array.sort()
t_array.sort()
t_array.reverse()
#print s_array
#print t_array

result = 'both'

while len(s_array) > 0:
    item_s = s_array.pop(0)
    tmp_array = t_array[:]
    while len(tmp_array) > 0:
        item_t = tmp_array.pop(0)
#        print item_s, item_t
        if item_s < item_t:
            result = 'Yes'
            break
        elif item_s > item_t:
            result = 'No'
            break
        else:
            pass
    
    if result == 'Yes' or result == 'No':
        break

if result == 'Yes' or result == 'No':
    print result
else:
#    print len(S) , len(T)
    if len(S) < len(T):
        print 'Yes'
    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:
#coding:utf-8
import math

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:
# coding:utf-8

s = input()
t = input()

def bSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]

    return a

def bSort2(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] > a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]
    return a


def add_list(a):
    sumed = ""
    for i in a:
        sumed += i
    return sumed

s_list = list(s)
s_ = add_list(bSort(s_list))

t_list = list(t)
t_ = add_list(bSort2(t_list))

if s_ < t_:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

s_ = "".join(sorted(s))
t_ = "".join(reversed(sorted(t)))

if s_ < t_:
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

Submission status: Accepted

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

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

res = 'No'
for i in range(len(tp)):
  if i > len(sp) - 1:
    res = 'Yes'
    break
  if tp[i] > sp[i]:
    res = 'Yes'
    break
  elif tp[i] < sp[i]:
    break

print(res)

Submission status: Accepted

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

s=input()
t=input()

if(len(s)>len(t)):
    min_len=len(t)
else:
    min_len=len(s)

ss=[]
for num in range(0, len(s)):
    ss.append(s[num])

tt=[]
for num in range(0, len(t)):
    tt.append(t[num])

ss.sort()
tt.sort()
tt.reverse()

if(ss>=tt):
    print("No")
else:
    print("Yes")

# print(ss)
# print(tt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
s=list(raw_input())
t=list(raw_input())
s.sort()
t.sort()
t.reverse()
N=len(s)
M=len(t)


for i in s:
	for j in t:
		if j==i:
			pass
		elif j>i:
			print "Yes"
			sys.exit()
		else:
			print "No"
			sys.exit()
else:
	if M>N:
		print "Yes"
	else:
		print "No"