Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int, h: "List[int]"):
    dp = [float('inf')] * N
    dp[0] = 0

    for i in range(N):
        for j in range(1, K+1):
            if (i + j) < N:
                dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
    return dp[-1]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, K, h)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, K: int, h: "List[int]"):
    dp = [float('inf')] * N
    dp[0] = 0

    for i in range(N):
        for j in range(1, K+1):
            if (i + j) < N:
                dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
    return dp[-1]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, K, h)
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[0] * (W + 1) for _ in range(N + 1)]

    for i, (cw, cv) in enumerate(zip(w, v)):
        for j in range(W + 1):
            dp[i+1][j] = dp[i][j]
            if 0 <= j - cw :
                dp[i+1][j] = max(dp[i+1][j], dp[i][j - cw] + cv)
    return max(dp[-1])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]" 
    v = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    result = solve(N, W, w, v)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, W: int, w: "List[int]", v: "List[int]"):
    dp = [[0] * (W + 1) for _ in range(N + 1)]

    for i, (cw, cv) in enumerate(zip(w, v)):
        for j in range(W + 1):
            dp[i+1][j] = dp[i][j]
            if 0 <= j - cw :
                dp[i+1][j] = max(dp[i+1][j], dp[i][j - cw] + cv)
    return max(dp[-1])


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    result = solve(N, W, w, v)
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]



def main():
    n = readInt()
    result = 'Hello World'
    if n == 2
        a = readInt()
        b = readInt()
        result = a + b
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]



def main():
    n = readInt()
    result = 'Hello World'
    if n == 2:
        a = readInt()
        b = readInt()
        result = a + b
    print(result)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]



def main():
    n = readInt()
    a = readInt()
    b = readInt()
    result = 'Hello World' if n == 1 else (a + b)
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd
readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(' ')]



def main():
    n = readInt()
    result = 'Hello World'
    if n == 2:
        a = readInt()
        b = readInt()
        result = a + b
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
import bisect
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, M: int):
    ds = []
    for i in range(1, int(ceil(sqrt(M)))):
        if M % i == 0:
            ds.append(i)
            ds.append(M // i)
    ds.sort()
  
    th = M // N
    return ds[bisect.bisect(ds, th)-1]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    result = solve(N, M)
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
import bisect
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, M: int):
    ds = []
    for i in range(1, int(ceil(sqrt(M))) + 1):
        if M % i == 0:
            ds.append(i)
            ds.append(M // i)
    ds.sort()
  
    th = M // N
    return ds[bisect.bisect(ds, th)-1]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    result = solve(N, M)
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(n: int, v: "List[int]"):
    e = [(len(v[0::2]) - vv, k, 0) for k, vv in Counter(v[0::2]).items()]
    o = [(len(v[1::2]) - vv, k, 1) for k, vv in Counter(v[1::2]).items()]

    res = [(len(v[0::2]),''), (len(v[1::2]),'')]
    for n, k, t in sorted(e + o):
        if res[t][1] != '':
            continue

        if res[1 - t][1] == k:
            continue

        res[t] = (n, k)
        if res[0][1] != '' and res[1][1] != '':
            break
    return res[0][0] + res[1][0]


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    result = solve(n, v)
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(n: int, v: "List[int]"):
    e = v[0::2]
    o = v[1::2]

    ec = sorted([(vv, k) for k, vv in Counter(e).items()], reverse=True) + [(0, None)]
    oc = sorted([(vv, k) for k, vv in Counter(o).items()], reverse=True) + [(0, None)]

    ee1 = ec[0]
    oo1 = oc[1] if oc[0][1] == ee1[1] else oc[0]
    ret1 = len(v) - ee1[0] - oo1[0]

    oo2 = oc[0]
    ee2 = ec[1] if ec[0][1] == oo2[1] else ec[0]
    ret2 = len(v) - ee2[0] - oo2[0]
   
    return min(ret1, ret2)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    v = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    result = solve(n, v)
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int

def solve(S: str):
    dp = [[0] * 4 for _ in range(len(S) + 1)]
    dp[0][0] = 1

    for i, s in enumerate(S):
        for j, a in enumerate('_ABC'):
            dp[i+1][j] = dp[i][j]
            if s == '?':
                dp[i+1][j] = 3 * dp[i][j] + (dp[i][j-1] if 1 <= j else 0)
            if s == a:
                dp[i+1][j] += dp[i][j-1]
    return dp[-1][-1] % MOD


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
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

MOD = 1000000007  # type: int

def solve(S: str):
    dp = [[0] * 4 for _ in range(len(S) + 1)]
    dp[0][0] = 1

    for i, s in enumerate(S):
        for j, a in enumerate('_ABC'):
            dp[i+1][j] = dp[i][j]
            if s == '?':
                dp[i+1][j] = 3 * dp[i][j] + (dp[i][j-1] if 1 <= j else 0)
            if s == a:
                dp[i+1][j] += dp[i][j-1]
            dp[i+1][j] %= MOD
    return dp[-1][-1] % MOD


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
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def bs(a, lo, hi, f):
    olo = lo
    ohi = hi
    while (lo + 1) < hi:
        mid = (lo + hi) // 2
        v = f(ohi, mid, olo)
        if 0 < v:
            lo = mid
        elif v < 0:
            hi = mid
        else:
            return mid
    if abs(f(ohi, lo, olo)) < abs(f(ohi, hi, olo)):
        return lo
    else:
        return hi

def solve(N: int, A: "List[int]"):

    def _g(li, ci, ri):
        a = acc[li - 1] - acc[0]
        b = acc[ci - 1] - acc[li-1]
        c = acc[ri - 1] - acc[ci - 1]
        d = acc[-1] - acc[ri - 1]
        cr = max([a, b, c, d]) - min([a, b, c, d])
        return cr

    def _f(h, m, l):
        return ((acc[h - 1] - acc[m-1]) - (acc[m - 1] - acc[l - 1]))

    acc = [0] + list(accumulate(A))

    ret = float('inf')
    for i in range(3, len(acc) - 1):
        li = bs(acc, 1, i, _f)
        ri = bs(acc, i, len(acc), _f)
        cv = _g(li, i, ri)
        ret = min(ret, cv)
    return ret


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, A)
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, A: "List[int]"):
    acc = list(accumulate(A))
    li = 1
    rdiff = float('inf')
    ri = 0
    for i in range(3, len(acc)):
        d = acc[-1] - acc[i-1]
        c = acc[i-1] - acc[1]
        if abs(d - c) < rdiff:
            rdiff = abs(d -c)
            ri = i
    ci = 2

    def _g(li, ci, ri):
        a = acc[li - 1]
        b = acc[ci - 1] - acc[li-1]
        c = acc[ri - 1] - acc[ci - 1]
        d = acc[-1] - acc[ri - 1]
        cr = max([a, b, c, d]) - min([a, b, c, d])
        return cr

    def _f(h, m, l):
        bbb = acc[l-1] if 0 < l else 0
        return abs((acc[h - 1] - acc[m-1]) - (acc[m - 1] - bbb))
  
    r = _g(li, ci, ri)
    for i in range(3, len(acc) - 1):
        while _f(i, (li+1), 0) <  _f(i, li, 0):
            li += 1
        while _f(len(acc), (ri+1), i) <  _f(len(acc), ri, i):
            ri += 1
        cr = _g(li, i, ri)
        if cr < r:
            r = cr
    return r


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    result = solve(N, A)
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fraction import gcd


def solve(S: str):
    return sum([int('{}1'.format(s)) for s in S])


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
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(S: str):
    return sum([int('{}1'.format(s)) for s in S])


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
    result = solve(S)
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fraction import gcd

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

def solve(N: int):
    return NO if bool(N % (sum([int(v) for v in str(N)]))) else YES


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    result = solve(N)
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
try:
    from math import gcd
except Exception:
    from fractions import gcd

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

def solve(N: int):
    return NO if bool(N % (sum([int(v) for v in str(N)]))) else YES


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    result = solve(N)
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

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

def solve(H: int, W: int, s: "List[str]"):
    m = [[0] * W for _ in range(H)]
    for j in range(len(s)):
        for i in range(len(s[j])):
            if s[j][i] == '#':
                if j < (len(s) - 1) and s[j+1][i] == '#':
                    m[j][i] += 1
                    m[j+1][i] += 1
                if i < (len(s[j]) - 1) and s[j][i+1] == '#':
                    m[j][i] += 1
                    m[j][i+1] += 1
                if m[j][i] == 0:
                    return NO
    return YES


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(W) ]  # type: "List[str]"
    result = solve(H, W, s)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

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

def solve(H: int, W: int, s: "List[str]"):
    m = [[0] * W for _ in range(H)]
    for j in range(H):
        for i in range(W):
            if s[j][i] == '#':
                if j < (H - 1) and s[j+1][i] == '#':
                    m[j][i] += 1
                    m[j+1][i] += 1
                if i < (W - 1) and s[j][i+1] == '#':
                    m[j][i] += 1
                    m[j][i+1] += 1
                if m[j][i] == 0:
                    return NO
    return YES


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [ next(tokens) for _ in range(H)]  # type: "List[str]"
    result = solve(H, W, s)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, C: int, x: "List[int]", v: "List[int]"):
    x = [0, *x]
    v = [0, *v]
    bi = []
    best = 0
    besti = 0
    acc_v = list(accumulate(v, lambda acc, vv: acc + vv))
    for ii, (xx, vv) in enumerate(zip(x, acc_v)):
        if best < vv - xx:
            besti = ii
            best = vv - xx
        bi.append(besti)

    ret = 0
    for b in range(len(bi)):
        a = bi[b - 1]
        c = 0
        if a != 0:
            c += acc_v[a] - x[a]
        if b != 0:
            c += (acc_v[-1] - acc_v[b-1]) - ((C - x[b]) % C)
        c -= min(x[a], ((C - x[b]) % C))
        if ret < c:
            ret = c
    return ret

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    v = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        v[i] = int(next(tokens))
    result = solve(N, C, x, v)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, C: int, x: "List[int]", v: "List[int]"):
    x = [0] + x
    v = [0] + v

    mx_r = [0]
    for xx, acc in zip(x[1:], accumulate(v[1:], add)):
        mx_r.append(max(acc - xx, mx_r[-1]))

    mx_l = [0]
    for xx, cal in zip(reversed(x), accumulate(reversed(v), add)):
        mx_l.append(max(cal - (C - xx), mx_l[-1]))
    mx_l.reverse()

    ans = 0
    for i in range(N+1):
        ans = max(mx_r[i], mx_r[i] - x[i] + mx_l[i+1], ans)
        if i != 0:
            ans = max(mx_l[i], mx_l[i] - (C - x[i]) + mx_r[i-1], ans)
    return ans


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]" 
    v = [int()] * (N)  # type: "List[int]" 
    for i in range(N):
        x[i] = int(next(tokens))
        v[i] = int(next(tokens))
    result = solve(N, C, x, v)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())

li = list(map(int,input().split()))

zahyo = 0
i = 0
while(zahyo <= x):
    
    zahyo = zahyo + li[i]
    print(zahyo)
    
    if zahyo <= x:
        i = i+1

print(i+1)

Fixed submission:
n,x = map(int,input().split())

li = list(map(int,input().split()))

zahyo = 0
i = 0
while(zahyo <= x):
    
    zahyo = zahyo + li[i]
    
    if zahyo <= x:
        i = i+1
    if i == n:
        break

print(i+1)
Buggy python submission (verdict: Runtime Error):
s = list(input().strip())
s.sort()
t = list(input())
t.reverse()
a = [chr(i) for i in range(97, 97+26)]
cnt = 0
for i in range(len(s)):
  if a.index(s[i]) < a.index(t[i]):
    print("Yes")
    break
  elif a.index(s[i]) > a.index(t[i]):
    print("No")
    break
  elif a.index(s[i]) == a.index(t[i]):
    cnt += 1
    
if cnt == len(s):
  if cnt < len(t):
    print("Yes")
  elif cnt == len(t):
    print("No")

Fixed submission:
s = input()
ss = ''.join(sorted(s))
 
t = input()
tt = ''.join(sorted(t, reverse=True))
 
if ss < tt:
	print('Yes')
else:
	print('No')