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: Runtime Error

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

import math

def slove(s, t):
    if s == t:
        return "No"
    while (True):
        if min(s) == max(t):
            s.remove(min(s))
            t.remove(max(t))
        else:
             break
    if min(s) > max(t):
        return "No"
    return "Yes"

if __name__ == "__main__":
    s = list(input())
    t = list(input())
    print(slove(s, t))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/user/bin/python
# coding: UTF-8

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

def a2n(alfabet):
    for i in range(len(alfabet)):
        if alfabet[i] == 'a':
            alfabet[i] = 1
        elif alfabet[i] == 'b':
            alfabet[i] = 2
        elif alfabet[i] == 'c':
            alfabet[i] = 3
        elif alfabet[i] == 'd':
            alfabet[i] = 4
        elif alfabet[i] == 'e':
            alfabet[i] = 5
        elif alfabet[i] == 'f':
            alfabet[i] = 6
        elif alfabet[i] == 'g':
            alfabet[i] = 7
        elif alfabet[i] == 'h':
            alfabet[i] = 8
        elif alfabet[i] == 'i':
            alfabet[i] = 9
        elif alfabet[i] == 'j':
            alfabet[i] = 10
        elif alfabet[i] == 'k':
            alfabet[i] = 11
        elif alfabet[i] == 'l':
            alfabet[i] = 12
        elif alfabet[i] == 'm':
            alfabet[i] = 13
        elif alfabet[i] == 'n':
            alfabet[i] = 14
        elif alfabet[i] == 'o':
            alfabet[i] = 15
        elif alfabet[i] == 'p':
            alfabet[i] = 16
        elif alfabet[i] == 'q':
            alfabet[i] = 17
        elif alfabet[i] == 'r':
            alfabet[i] = 18
        elif alfabet[i] == 's':
            alfabet[i] = 19
        elif alfabet[i] == 't':
            alfabet[i] = 20
        elif alfabet[i] == 'u':
            alfabet[i] = 21
        elif alfabet[i] == 'v':
            alfabet[i] = 22
        elif alfabet[i] == 'w':
            alfabet[i] = 23
        elif alfabet[i] == 'x':
            alfabet[i] = 24
        elif alfabet[i] == 'y':
            alfabet[i] = 25
        elif alfabet[i] == 'z':
            alfabet[i] = 26
    return alfabet

ns = a2n(s_list)
ns.sort()
nt = a2n(t_list)
nt.sort()
nt.reverse()

for i in range(len(ns)):
    if ns[i] == nt[i]:
        ans = 'next'
    elif ns[i] < nt[i]:
        ans = 'Yes'
        break
    elif ns[i] > nt[i]:
        ans = 'No'
        break
if ans == 'next':
    if len(ns) < len(nt):
        ans = 'Yes'
    else:
        ans = 'No'

print(ans)

Submission status: Runtime Error

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)+1):
    if ord(p[k]) < ord(q[k]):
        ans = "Yes"
        break
    elif ord(p[k]) > ord(q[k]):
        ans = "No"
        break
print(ans)

Submission status: Runtime Error

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)):
    s_sum += s[i]
    t_sum += t[i]

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

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

Submission status: Runtime Error

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)):
    s_sum += s[i]
    t_sum += t[i]

    if s_sum < t_sum:
      return 'Yes'
    elif s_sum > t_sum:
      return 'No'
    elif s_sum == t_sum and i + 1 >= len(s) and not i + 1 >= len(t):
      return 'Yes'
  return 'No'
print(f(s, t))

Submission status: Runtime Error

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

def f(s, t):
  s.sort()
  t.sort(reverse=True)

  for i in range(len(s)):
    if s[i] < t[i]:
      return 'Yes'
    elif s[i] > t[i]:
      return 'No'
    elif i + 1 >= len(s) and not i + 1 >= len(t):
      return 'No'
  return 'No'

print(f(s, t))

Submission status: Runtime Error

Solution code:
A=list(input())
B=list(input())
minm=min(A)
maxi=max(B)

while min(len(A),len(B))!=0:
 if minm<maxi:
  print("Yes")
  break
 if minm==maxi:
  A.remove(minm)
  B.remove(maxi)
 if minm>maxi:
  print("No") 
  break

Submission status: Runtime Error

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

def f(s, t):
  s.sort()
  t.sort(reverse=True)

  for i in range(len(s)):
    if s[i] < t[i]:
      return 'Yes'
    elif s[i] > t[i]:
      return 'No'
    elif i + 1 >= len(s) and not i + 1 >= len(t):
      return 'Yes'
  return 'No'

print(f(s, t))

Submission status: Runtime Error

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

def f(s, t):
  s.sort()
  t.sort(reverse=True)

  for i in range(len(s)):
    if s[i] < t[i]:
      return 'Yes'
    elif s[i] > t[i]:
      return 'No'
    elif i + 1 >= len(s) and not i + 1 >= len(t):
      return 'Yes'

  return 'No'

print(f(s, t))

Submission status: Runtime Error

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

import math

def slove(s, t):
    s = sorted(s)
    t = sorted(t)
    for i in range(len(s)-1):
        if s[i] > t[i]:
            return "No"
    if s[len(s)-1] >= t[len(s)-1]:
        return "No"
    return "Yes"

if __name__ == "__main__":
    s = list(input())
    t = list(input())
    print(slove(s, t))

Submission status: Runtime Error

Solution code:
S = input()
T = input()
# S = "cd"
# T = "abc"
sS = "".join(sorted(S))
sT = "".join(sorted(T, reverse = True))
if (sS < sT):
  print("Yes")
  else:
    print("No")

Submission status: Runtime Error

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

import math

def slove(s, t):
    s = sorted(s)
    t = sorted(t)
    for i in range(len(s)):
        if s[i] < t[i]:
            return "Yes"
    if len(s) < len(t):
        return "Yes"
    return "No"

if __name__ == "__main__":
    s = list(input())
    t = list(input())
    print(slove(s, t))

Submission status: Runtime Error

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

import numpy as np
import math

def slove(s, t):
    s = sorted(s)
    t = sorted(t)
    for i in range(len(s)):
        if s[i] < t[i]:
            return "Yes"
    if len(s) < len(t):
        return "Yes"
    return "No"

    return 0

if __name__ == "__main__":
    s = list(input())
    t = list(input())
    print(slove(s, t))

Submission status: Runtime Error

Solution code:
s, t = map(str, input().split())
listS = list(s)
listT = list(t)
sorted(listS)
sorted(listT)
if listS > listT:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

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