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: Wrong Answer

Solution code:
import string
if __name__=="__main__":
    s = list(input())
    t = list(input())
    flag = False
    dic = 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 range(len(dic)):
        if s.__contains__(dic[i]) and t.__contains__(dic[i]):
            flag = True
            continue
        if flag and s.__contains__(dic[i]) and not t.__contains__(dic[i]):
            for j in range(i+1,len(dic)):
                if t.__contains__(dic[j]):
                    print("Yes")
                    exit()
    print("No")

Submission status: Wrong Answer

Solution code:
import string
if __name__=="__main__":
    s = list(input())
    t = list(input())
    flag = False
    if s is t:
        print("No")
        exit()
    dic = 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 range(len(dic)):
        if s.__contains__(dic[i]) and t.__contains__(dic[i]):
            flag = True
        if flag and s.__contains__(dic[i]) and not t.__contains__(dic[i]):
            for j in range(i+1,len(dic)):
                if t.__contains__(dic[j]):
                    print("Yes")
                    exit()
    print("No")

Submission status: Wrong Answer

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])

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: Wrong Answer

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 = -1
            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: Wrong Answer

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])

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)
print(p)
print(q)

Submission status: Wrong Answer

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)


sample = 'abcdefghijklmnopqrstuvwxyz'
end =0
for i in range(min(len(s), len(t))):
    #print('count')
    for j in range(26):
        if sortedslist[i] == sample[j] and sortedtlist[-i] != sample[j]:
            print('Yes')
            end = 1
            break
        elif sortedslist[i] != sample[j] and sortedtlist[-i] == sample[j]:
            print('No')
            end = 1
            break   
    if end == 1:
        break
else:
    if len(s)<len(t):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

a=[0]*26
b=[0]*26


for c in A:
	#print(c, ord(c), ord(c)-97)
	a[ord(c)-97] += 1

for c in B:
	b[ord(c)-97] += 1


#print(a)
#print(b)

ans = "No"
for i in range(26):
	if a[i] == 0: continue
	if a[i] < sum(b[i:]):
		ans = "Yes"
		break


print(ans)

Submission status: Wrong Answer

Solution code:
import string
if __name__=="__main__":
    s = list(input())
    t = list(input())
    flag = True
    if s is t:
        print("No")
        exit()
    dic = 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 range(len(dic)):
        if s.__contains__(dic[i]) and t.__contains__(dic[i]):
            flag = True
        if flag and s.__contains__(dic[i]) and not t.__contains__(dic[i]):
            for j in range(i+1,len(dic)):
                if t.__contains__(dic[j]):
                    print("Yes")
                    exit()
    print("No")

Submission status: Wrong Answer

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:
            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: Wrong Answer

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:
            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: Wrong Answer

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 l[0] == s2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
p = []
q = []
m = len(s)
n = len(t)
ans = 0
for i in range(m):
    p.append(s[i])
p.sort()
for j in range(n):
    q.append(t[j])
q.sort()
if m >= n:
    ans = "No"
else:
    ans = "Yes"
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: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
sample = 'abcdefghijklmnopqrstuvwxyz'
end =0
for i in range(min(len(s), len(t))):
    #print('count')
    for j in range(26):
        if s[i] == sample[j] and t[-i] != sample[j]:
            print('Yes')
            end = 1
            break
        elif s[i] != sample[j] and t[-i] == sample[j]:
            print('No')
            end = 1
            break   
    if end == 1:
        break
else:
    if len(s)<len(t):
        print('Yes')
    else:
        print('No')

Submission status: Wrong Answer

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

s.sort()
t.reverse()

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: Wrong Answer

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:
            print("Yes")
            flag = -1
            break
else:
    for x, y in zip(line1, line2):
        if x < y:
            print("Yes")
            flag = -1
            break

if flag != -1:
    print("No")

Submission status: Wrong Answer

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

if s[0]<t[len(t)-1]:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

s.sort()
t.reverse()

import sys

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

t_a = sorted(t)
if len(s) < len(t_a):
    for i, j in zip(s, t_a):
        if i != j:
            print('No')
            sys.exit(0)

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

Submission status: Wrong Answer

Solution code:
import string
if __name__=="__main__":
    s = list(input())
    t = list(input())
    if s==t:
        print("No")
        exit()
    for i in reversed(string.ascii_lowercase):
        if s.count(i)>t.count(i):
            print("No")
            exit()

    print("Yes")

Submission status: Wrong Answer

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

s.sort()
t.reverse()

import sys

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

t_a = sorted(t)
if len(s) < len(t_a):
    for i, j in zip(s, t_a):
        if i != j:
            print('No')
            sys.exit(0)

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

Submission status: Wrong Answer

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

s.sort()
t.reverse()

import sys

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

t_a = sorted(t)
if len(s) < len(t_a):
    for i, j in zip(s, t_a):
        if i != j:
            print('No')
            sys.exit(0)

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

Submission status: Wrong Answer

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

if s == t:
    print('No')
elif s[0] == t[-1] and len(s) < len(t):
    print('Yes')
elif s[0] < t[-1]:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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)

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

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

Submission status: Wrong Answer

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)

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

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

Submission status: Wrong Answer

Solution code:
s= list(input())
t= list(input())
s.sort()
t.sort()
judge = True
for i in t:
    if(s[0]<i and judge):
        print("Yes")
        judge = False        

if judge:
    print("No")

Submission status: Wrong Answer

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:
	print "Yes"

Submission status: Wrong Answer

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: Wrong Answer

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

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

if s < t:
    print('YES')
else:
    print('NO')

Submission status: Wrong Answer

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)

flag = 0
for x, y in zip(line1, line2):
    if x < y:
        flag = 1
    elif x == y:
        flag = 2
    else:
        flag = 3

if flag == 1:
    print('Yes')
elif flag == 2 and len(line1) < len(line2):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

s.sort()
t.reverse()

import sys


if t[0] > s[0]:
    print('Yes')
    sys.exit(0)

t.sort()
if len(s) < len(t):
    for i, j in zip(s, t):
        if i != j:
            print('No')
            sys.exit(0)

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

Submission status: Wrong Answer

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

ans = False

for _s in s:
    for _t in t:
        if _t > _s:
            ans = True

for _s in s:
    for _t in t:
        if _t == _s:
            if len(t) > len(s):
                ans = True

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

Submission status: Wrong Answer

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

s.sort()
t.reverse()

import sys

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

t.sort()
if len(s) < len(t):
    for i, j in zip(s, t):
        if i != j:
            print('No')
            sys.exit(0)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

# 入力
s = input()
t = input()

# sort
s = "".join(sorted(s))
t = "".join(sorted(t, reverse=True))
st_list = [s, t]

# 出力
if s == t:
    print("NO")
elif st_list == sorted(st_list):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
count=0
list01 = list(s)
list02 = list(t)
list01.sort()
list02 = list(t)


if len(s)<len(t):
    for i in range(len(s)):
        if list01[i]>list02[len(t)-1-i]:
            print("No")
            break
        elif list01[i]<list02[len(t)-1-i]:
            print("Yes")
            break
    else:
            print("Yes")            

else:
    for i in range(len(t)):
        if list01[i]>list02[len(t)-1-i]:
            print("No")
            break
        elif list01[i]<list02[len(t)-1-i]:
            print("Yes")
            break
    else:
            print("No")

Submission status: Wrong Answer

Solution code:
a=input()
b=input()
aa=[]
for i in a:
  aa.append(i)
aa.sort()
aaa="".join(aa)

bb=[]
for i in b:
  bb.append(i)
bb.sort(reverse=True)
bbb="".join(bb)
ccc=[aaa,bbb]
ccc.sort()
print(a,b,aaa,bbb,ccc)
if bbb==ccc[0]:
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
# 入力
s = input()
t = input()

# sort
s = "".join(sorted(s))
t = "".join(sorted(t, reverse=True))
st_list = [s, t]

# 出力
if s == t:
    print("NO")
elif st_list == sorted(st_list):
    print("YES")
else:
    print("NO")

Submission status: Wrong Answer

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

s.sort()
t.reverse()

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

Submission status: Wrong Answer

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)

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

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

Submission status: Wrong Answer

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

s.sort()
s.reverse()

t.sort()
t.reverse()

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

Submission status: Wrong Answer

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

S = list(s)
S.sort()
T = list(t)
T.reverse()
s = "".join(S)
t = "".join(T)
L = [S, T]
L2 = [S, T]
L.sort()
if S == T:
    print("No")
else:
    if L == L2:
        print("Yes")
    else:
        print("No")

Submission status: Wrong Answer

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

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

can = False
minlen = min(len(s),len(t))
for i in range(minlen):
    if i == minlen-1:
        if s[i] < t[i]:
            can = True
            break
        elif s[i] == t[i]:
            if len(s) > len(t):
                can = False
            else:
                can = True
        else:
            break
    else:
        if s[i] < t[i]:
            can = True
            break
        elif s[i] == t[i]:
            pass
        else:
            break


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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

s = list(s)
s.sort()

t = list(t)
t.reverse()

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

Submission status: Time Limit Exceeded

Solution code:
from itertools import permutations as per
s=list(input())
t=list(input())
n=len(t)
s=list(per(s))
t=list(per(t))


x=s[0]
y=t[-1]
l=[]
l.append(x)
l.append(y)
l=sorted(l)

if l.index(x)<l.index(y):
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
from itertools import permutations as per
s=list(input())
t=list(input())
n=len(t)
s=list(per(s))
t=list(per(t))

def f(x):
    m=1
    while x>0:
        m*=x
        x=x-1
    return m
x=s[0]
y=t[f(n)-1]
l=s+t
l=sorted(l)
if l.index(x)<l.index(y):
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

sl = list(s)
sn = len(sl)

from itertools import permutations

sp = []
for v in permutations(sl, sn):
    sp.append("".join(list(v)))

tl = list(t)
tn = len(tl)
tp = []
for v in permutations(tl, tn):
    tp.append("".join(list(v)))

f = False
for se in sp:
    for te in tp:
        if se < te:
            f = True
            break
    if f:
        break

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

Submission status: Time Limit Exceeded

Solution code:
import itertools
s = input()
t = input()
s2=list(itertools.permutations(s))
t2 = list(itertools.permutations(t))
s3 = [''.join(x) for x in s2]
t3 = [''.join(x) for x in t2]
for s in s3:
    for t in t3:
        if s<t:
            print('Yes')
            exit()
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
def resolve():
    s = input()
    s = [c for c in s]
    t = input()
    t = [c for c in t]
    import itertools
    S = list(itertools.permutations(s, len(s)))
    T = list(itertools.permutations(t, len(t)))
    for s in S:
        for t in T:
            if "".join(s) < "".join(t):
                print("Yes")
                return
    print("No")
            

if '__main__' == __name__:
    resolve()

Submission status: Time Limit Exceeded

Solution code:
import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
# Written by NoKnowledgeGG @YlePhan
 
#import math
#mod = 10**9+7
 
 
 
def main():
  s = input()
  t = input()
  
  s_l = len(s)
  t_l = len(t)
  
  for a in itertools.permutations(s,s_l):
    for b in itertools.permutations(t,t_l):
      if a < b:
        print('Yes')
        exit()
  print('No')
  
  
if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
import itertools
s = input()
t = input()
snew = sorted(s)
Ans = 'No'
for i in list(itertools.permutations(t)):
    if snew < list(i):
        Ans = 'Yes'
        break
print(Ans)

Submission status: Time Limit Exceeded

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

s = input()
t = input()

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

import itertools

flag = False

for i in itertools.permutations(s_list):
    s_new = ''.join(i)
    for n in itertools.permutations(t_list):
        t_new = ''.join(n)

        if s_new < t_new:
            flag = True
if flag:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
import itertools

s=input()
t=input()
flag=False

a_s=[''.join(v) for v in itertools.permutations(s)]
a_t=[''.join(w) for w in itertools.permutations(t)]

for si in a_s:
    for ti in a_t:
        if si < ti:
            flag=True
            break
    if flag:
        break

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

Submission status: Time Limit Exceeded

Solution code:
import itertools

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

for i in itertools.permutations(s):
    for j in itertools.permutations(t):
        if "".join(i) < "".join(j):
            print("Yes")
            quit(0)
        else:
            continue

print("No")

Submission status: Time Limit Exceeded

Solution code:
import itertools

s = list(str(input()))
t = list(str(input()))
s_all = ["".join(i) for i in itertools.permutations(s)]
t_all = ["".join(j) for j in itertools.permutations(t)]

for k in s_all:
    for l in t_all:
        if k < l:
            print("Yes")
            quit(0)
        else:
            continue

print("No")

Submission status: Time Limit Exceeded

Solution code:
import itertools

s = list(str(input()))
t = list(str(input()))
s_all, t_all = [], []

for i in itertools.permutations(s):
    s_all.append("".join(i))

for j in itertools.permutations(t):
    t_all.append("".join(j))

for k in s_all:
    for l in t_all:
        if k < l:
            print("Yes")
            quit(0)
        else:
            continue

print("No")

Submission status: Time Limit Exceeded

Solution code:
import itertools
s=input()
t=input()
tmp=False
if len(s)<len(t):
  tmp=True
s,t=sorted(list(s))[:min(len(s),len(t))],sorted(list(t))[-min(len(s),len(t)):]

slist=list(itertools.permutations(s,len(s)))
tlist=list(itertools.permutations(t,len(t)))

S="".join(sorted(slist)[0])
T="".join(sorted(tlist)[-1])
if S<T:
  print("Yes")
elif S==T and tmp:
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

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

Slist=list(itertools.permutations(list(S),len(S)))
Tlist=list(itertools.permutations(list(T),len(T)))

if "".join(sorted(Slist)[0])<"".join(sorted(Tlist)[-1]):
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

Solution code:
a=input()
m=[a[i] for i in range(len(a))]
b=input()
n=[b[i] for i in range(len(b))]
m.sort()
n.sort()
i=0
while 1>0:
  if m[i]<n[i]:
    print("Yes")
    break
  if i==len(a) or i==len(b):
    print("No")
    break

Submission status: Accepted

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

s = "".join(sorted(s))
t = "".join(sorted(t)[::-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=input()
t=input()

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

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
s = list(input().strip())
t = list(input().strip())
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 = list(input().rstrip())
t = list(input().rstrip())

alphabet = ["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"]
for i in range(len(s)):
    s[i] = alphabet.index(s[i])
for i in range(len(t)):
    t[i] = alphabet.index(t[i])
s.sort()
t.sort()
t.reverse()
flg = "Yes"
check = 0
for j in range(min(len(s),len(t))):
    if t[j] > s[j]:
        check = 1
        break
    elif t[j] < s[j]:
        flg = "No"
        check = 1
        break
if check == 0:
    if len(s) >= len(t):
        flg = "No"
print(flg)

Submission status: Accepted

Solution code:
s=sorted(list(input()))
t=sorted(list(input()),reverse=True)
s="".join(s)
t="".join(t)
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:
s = sorted(list(input()))
t = sorted(list(input()),reverse=True)
if s<t:
    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:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

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()

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

if s < t:
    print('Yes')

else:
    print('No')

Submission status: Accepted

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

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

print("Yes" if ''.join(asc_s) < ''.join(desc_t) else "No")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
s = sorted(s)
t = sorted(t,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)
if s < t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def answer(s: str, t: str) -> str:
    return 'Yes' if sorted(s) < sorted(t, reverse=True) else 'No'

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

sa = ''.join(ss)
ta = ''.join(tt)

if sa < ta:
  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=list(input())
t=list(input())

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

for i in range(min(len(s),len(t))):
    if(s[i]<t[i]):
        print("Yes")
        exit()
    if(s[i]>t[i]):
        print("No")
        exit()

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = ''.join(sorted(input().strip()))
t = ''.join(sorted(input().strip(), 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:
s = list(input())
t = list(input())

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

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

Submission status: Accepted

Solution code:
s = sorted(str(input()))
t = sorted(str(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)
s = ''.join(s)
t = ''.join(t)
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)

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

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)
if s < t:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

num2alpha = lambda c: chr(c+96)
#print(num2alpha(3)) #==> c
alpha2num = lambda c: ord(c) - ord('a') + 1
#alpha2num('y') #==> 25 

S = [0] * 26
T = [0] * 26
for i in range(len(s)):
  S[alpha2num(s[i]) - 1] += 1
for i in range(len(t)):
  T[alpha2num(t[i]) - 1] += 1
#print(S, T)  
  
ss = 0
while S[ss] == 0:
  ss += 1
tt = 25
while T[tt] == 0:
  tt -= 1
  
if tt < ss:
  print("No")
elif tt > ss:
  print("Yes")
else:
  if (T[tt] == sum(T)) and (S[ss] == sum(S)):
    if sum(T) > sum(S):
      print("Yes")
    else:
      print("No")
  else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()
sd = sorted(s)
td = reversed(sorted(t))
sd = "".join(sd)
td = "".join(td)
if sd < td:
    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)

ans_ = [S,T]
ans_.sort()

ans='Yes'
if ans_[0] == T:
    ans='No'
    
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

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

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

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

ans = sorted([s, t])
# print(ans)

if ans[0] == t:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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