Harryxun/stf_run huggingface dataset:
from math import gcd
while True:
    try:
        a,b=map(int,input().split())
    except:
        break
    print(gcd(a,b),a//gcd(a,b)*b)

### FIXED CODE ###

def gcd(x,y):
    if y==0:
        return x
    return gcd(y,x%y)

while True:
    try:
        x,y=map(int,input().split())
    except:
        break
    print(gcd(x,y),x*y//gcd(x,y))
a,b = map(int,input())
if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")

### FIXED CODE ###

a,b = map(int,input().split())
if a > 8 or b > 8:
    print(":(")
else:
    print("Yay!")
N=int(input())
K=int(input())
X=int(input())
Y=int(input())

if N-K>0:
    print(K*X+(N-K)*ren*Y)
else:
    print(N*X)

### FIXED CODE ###

N=int(input())
K=int(input())
X=int(input())
Y=int(input())

if N-K>0:
    print(K*X+(N-K)*Y)
else:
    print(N*X)
N = int(input())
i = 0
j = 0
count = 0
flag = 0

for i in range(1, N + 1, 2):
    count = 0
    for j in range(1,i + 1):
        if i % j == 0:
            count += 1
    else:
        if count == 8:
            flag += 1
else:
    print(flag)


### FIXED CODE ###

A,B = map(int,input().split())
print(A*B-(A+(B-1)))
n,a,b=map(input().split());print(min(n*a,b))

### FIXED CODE ###

n,a,b=map(int,input().split());print(min(n*a,b))
A,B = map(int,input().split())
ans = min(0,A-(2`B)
print(ans)

### FIXED CODE ###

A,B = map(int,input().split())
ans = max(0,A-(2*B))
print(ans)
# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

# import math
# import numpy as np
# import copy
# from collections import defaultdict, Counter
# from itertools import product
# from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

S = list(input())
N = len(S)
while True:
    flag = False
    for i in range(1, len(S)-2):
        l = S[i-1]
        mid = S[i:i+2]
        r = S[i+2]
        if mid == ["0", "1"] or mid == ["1", "0"]:
            if (l == "0" and r == "1") or (l == "1" and r == "0"):
                del S[i:i+2]
                i += 2
                flag = True
                if i >= len(S)-3:
                    break


    if flag:
        continue

    for i in range(0, len(S)-1):
        mid = S[i:i+2]
        if mid == ["0", "1"] or mid == ["1", "0"]:
            del S[i:i+2]

    break
print(N-len(S))

### FIXED CODE ###

# https://qiita.com/_-_-_-_-_/items/34f933adc7be875e61d0
# abcde	s=input()	s='abcde'
# abcde	s=list(input())	s=['a', 'b', 'c', 'd', 'e']
# 5(1つだけ)	a=int(input())	a=5
# 1 2	| x,y = map(int,input().split())   |	x=1,y=2
# 1 2 3 4 5 ... n 　	li = input().split()	li=['1','2','3',...,'n']
# 1 2 3 4 5 ... n 　	li = inpl()	li=[1,2,3,4,5,...,n]
# FFFTFTTFF 　	li = input().split('T')	li=['FFF', 'F', '', 'FF']

# INPUT
# 3
# hoge
# foo
# bar
# ANSWER
# n=int(input())
# string_list=[input() for i in range(n)]

# import math
# import numpy as np
# import copy
# from collections import defaultdict, Counter
# from itertools import product
# from bisect import bisect_left, bisect_right
def inpl(): return list(map(int, input().split()))

S = input()
N = len(S)
c0 = S.count("0")
c1 = S.count("1")

print(2*min(c0, c1))
import numpy as np

n, k = map(int,input().split())

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

light = np.zeros((n, n))

for _ in range(k):
    for i, arr in enumerate(light):
        x_1, x_2 = i - a[i], i + a[i] + 1

        if x_1 < 0:
            x_1 = 0

        arr[x_1:x_2] = 1
    a = light.sum(axis=0).astype(int)

print(*list(a))

### FIXED CODE ###

from itertools import accumulate

n, k = map(int,input().split())

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

for j in range(k):
    if j > 41:
        break

    b = [0] * n

    for i in range(n):
        b[max(0, i - a[i])] += 1
        
        if i + a[i] + 1 < n:
            b[i + a[i] + 1] -= 1

    a = list(accumulate(b))

print(*a)
n=int(input());print("Hello World" if n==1 else a=int(input() b=int(input() a+b)))

### FIXED CODE ###

n=int(input())
if n==1:
  print("Hello World")
else:
  a=int(input())
  b=int(input())
  print(a+b)
N = int(input())
a = [int(x) for x in input().split()]


answer = []
B = 0

for i in range(N):
    L = N // (N-i)
    if L == 1:
        answer.append(a[N-i-1])
    else:
        for j in range(L-1):
            t = (N-i) * j
            B += answer[t]
        B = B % 2
        if B == a[N-i-1]:
            answer.append(0)
        else:
            answer.append(1)
    B = 0


k = 0
P = len(answer)
while (answer[0] == 0) and (k < P-1):
    answer.remove(0)
    k += 1

if answer == [0]:
    print(0)
else:
    answer.reverse()
    print(answer.count(1))
    for i in range(J):
        if answer[i] == 1:
            print(i+1, end=' ')

### FIXED CODE ###

N = int(input())
a = [int(x) for x in input().split()]


answer = []
B = 0

for i in range(N):
    U = N - i
    L = N // (U)
    if L == 1:
        answer.append(a[U-1])
    else:
        for j in range(L-1):
            t = U * (j+1)
            B += answer[-t]
        B = B % 2
        if B == a[U-1]:
            answer.append(0)
        else:
            answer.append(1)
    B = 0


k = 0



answer.reverse()
print(answer.count(1))
J = len(answer)
for i in range(J):
    if answer[i] == 1:
        print(i+1, end=' ')
#!/usr/bin/env python3
import sys
import numpy as np

MOD = 1000000007  # type: int

def solve(S: str):
    N = len(S)
    dp = np.zeros((N, 13))
    if S[N-1] != '?':
        dp[0, int(S[N-1])] = 1
    else:
        dp[0] = np.array([1,1,1,1,1,1,1,1,1,1,0,0,0])
    for i in range(1, len(S)):
        ii = N - i - 1
        for j in range(13):
            if S[ii] == '?':
                for ll in range(10):
                    kk = (ll * 10 ** i) % 13
                    dp[i, j] += dp[i-1, (13 + j - kk) % 13]
                    dp[i, j] %= MOD
            else:
                x = int(S[ii])
                m = x * 10 ** i % 13
                dp[i, j] = dp[i-1, (13+j-m)%13]
                dp[i, j] %= MOD
    print(int(dp[N-1, 5]))
    return


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

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def solve(S: str):
    N = len(S)
    dp = [[0 for _ in range(13)] for _ in range(len(S))]
    if S[N-1] != '?':
        dp[0][int(S[N-1])] = 1
    else:
        dp[0] = [1,1,1,1,1,1,1,1,1,1,0,0,0]
    ten = [1]
    for i in range(1, len(S)):
        ten.append(ten[-1] * 10 % 13)
        ii = len(S) - i - 1
        for j in range(13):
            if S[ii] == '?':
                for ll in range(10):
                    kk = ll * ten[i] % 13
                    dp[i][j] += dp[i-1][(13 + j - kk)%13]
                    dp[i][j] %= MOD
            else:
                x = int(S[ii])
                m = x * ten[i] % 13
                dp[i][j] = dp[i-1][(13+j-m)%13]
                dp[i][j] %= MOD
    print(dp[len(S)-1][5])
    return


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

if __name__ == '__main__':
    main()
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

if a[0] == 2:
    print(0)
else:
    count = 0
    flag = False
    i = a[0]
    for _ in range(n):
        count += 1
        if a[i-1] == 2:
            flag = True
            break
        i = a[i-1]

if flag:
    print(count+1)
else:
    print(-1)


### FIXED CODE ###

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))

if a[0] == 2:
    print(1)
else:
    count = 0
    i = a[0]
    flag = False
    for _ in range(n):
        count += 1
        if a[i-1] == 2:
            flag = True
            break
        i = a[i-1]
    if flag:
        print(count+1)
    else:
        print(-1)
N, M, X = map(int, input().split())
books = [input() for i in range(N)]
result = 12 * 10**5 + 1
for i in range(1, 1 << N):
  cost = 0
  skill = [0 for i in range(N)]
  for j in range(N):
    if (i >> j) & 1:
      book = books[j].split()
      cost += int(book[0])
      for k in range(M):
        skill[k] += int(book[k + 1])
  if all(j >= X for j in skill):
    result = min(result, cost)
if result == 12 * 10**5 + 1:
  print(-1)
else:
  print(result)


### FIXED CODE ###

N, M, X = map(int, input().split(" "))
book_information = []
result = 12 * 10**5 + 1
for i in range(N):
	book_information.append(input())
for i in range(1, 1 << N):
  bought_book = []
  n = 0
  cost = 0
  skill = [0 for j in range(M)]
  for j in range(N):
    if (i >> j) & 1:
      bought_book.append(book_information[j])
      n += 1
  for j in range(n):
    bought_book_information = list(bought_book[j].split(" "))
    cost += int(bought_book_information[0])
    for k in range(M):
      skill[k] += int(bought_book_information[k + 1])
  if all(x >= X for x in skill):
    result = min(result, cost)
if result == 12 * 10**5 + 1:
  print(-1)
else:
  print(result)
N = input()

i = 1
sq = i * i
while sq <= N:
    i += 1
    temp = i * i
    if temp > N 
        break
    sq = temp

print(sq)

### FIXED CODE ###

N = int(input())

i = 1
sq = i * i
while sq <= N:
    i += 1
    temp = i * i
    if temp > N:
        break
    sq = temp

print(sq)
import sys

def main(arg_list):
    if(len(arg_list == 3) and arg_list.count('5')==2 and arg_list.count('7') == 1):
        return "YES"
    return "NO"

if __name__ == "__main__":
    main(sys.argv)

### FIXED CODE ###

import fileinput

def main(arg_list):
    if(len(arg_list) == 3 and arg_list.count('5')==2 and arg_list.count('7') == 1):
        print("YES")
        return 
    print("NO")

if __name__ == "__main__":
    for line in fileinput.input():
        main(line.rstrip("\n\r").split(" "))
h,w=map(int,input().split())
dx=[-1,1,0,0]
dy=[0,0,-1,1]
a=[]
for i in range(h):
    a.append(list(input()))
for i in range(h):
    for j in range(w):
        frag=False
        if a[i][j]=="#":
            for k in range(4):
                x=j+dx[k]
                y=i+dy[k]
                if x<0 or x>w-1 or y<0 or y>h-1:
                    continue
                if a[x][y]=="#":
                    frag=True
            if frag==False:
                print("No")
                exit()
print("Yes")

### FIXED CODE ###

h,w=map(int,input().split())
dx=[-1,1,0,0]
dy=[0,0,-1,1]
a=[]
for i in range(h):
    a.append(list(input()))
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            frag=False
            if j-1>=0 and a[i][j-1]=="#":
                frag=True
            if j+1<=w-1 and a[i][j+1]=="#":
                frag=True
            if i-1>=0 and a[i-1][j]=="#":
                frag=True
            if i+1<=h-1 and a[i+1][j]=="#":
                frag=True
            if frag==False:
                print("No")
                exit()
print("Yes")
#N, *a = map(int, open(0).read().split())
def main():
    N = int(input())
    a=[]
    for i in range(N):
        a.append(int(input()))

    b = [0 for _ in range(N+1)]
    cnt = 1
    ans = 0
    flag = 1
    i = 0
    for i in reversed(range(N)):
        if b[a[i]+1] > 0:
            b[a[i]] = b[a[i]+1] + 1
        else:
            b[a[i]] = 1
        
    return N-max(b)
print(main())


### FIXED CODE ###

#N, *a = map(int, open(0).read().split())
def main():
    N = int(input())
    a=[]
    for i in range(N):
        a.append(int(input()))

    b = [0 for _ in range(N+2)]
    cnt = 1
    ans = 0
    flag = 1
    i = 0
    for i in reversed(range(N)):
        if b[a[i]+1] > 0:
            b[a[i]] = b[a[i]+1] + 1
        else:
            b[a[i]] = 1
        
    return N-max(b)
print(main())
def fiv(n):
    return (((1+(5)**(1/2))/2)** n - ((1-(5)**(1/2))/2)** n)/(5**(1/2))

n, m = map(int, input().split())
broken = [input() for i in range(m)]

p = [0] * (m + 1) #broken間の登り方list

for i in range(m + 1):
    if i == 0: #a1 さいしょ
        if broken[0] == 1 or 2:
            p[0] = 1
        else:
            p[0] = fiv(broken[0] -1)
    if i == m: #am さいご
        if broken[m] == n - 1 or m - 2:
            p[m] = 1
        else:
            p[m] = fiv(n - broken[0])
    
    else:
        if broken[i] - broken[i - 1] - 1 == 0:
            print('0')
            exit()
        else:
            p[i] = fiv(broken[i] - broken[i - 1] - 1)

ans = 1
for i in range(m + 1):
    ans = ans * p[i]

print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
mod = 10 ** 9 + 7
dp = [-1 for i in range(n + 1)]
dp[0], dp[1] = 1, 1
for _ in range(m):
    dp[int(input())] = 0
for i in range(2, n + 1):
    if dp[i] != 0:
        dp[i] = (dp[i - 1] + dp[i - 2]) % mod
print(dp[n])
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]


def to_bin(n):
    return bin(n)[2:]


if K == 0:
    ans = 0
    for a in A:
        ans += K ^ a
    print(ans)
    exit()

cnt = [0] * len(to_bin(K))
for a in A:
    b = to_bin(a)
    while len(b) < len(cnt):
        b = '0' + b
    b = b[::-1]
    for i in range(len(b)):
        if b[i] == '1':
            cnt[i] += 1

ans = 0
for j in range(len(cnt)):
    ans += max(cnt[j], N - cnt[j]) * (2 ** j)

print(ans)

### FIXED CODE ###

from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]


def to_bin(n):
    return bin(n)[2:]


cnt = [0] * 40
for a in A:
    b = to_bin(a)
    b = b[::-1]
    for i in range(len(b)):
        if b[i] == '1':
            cnt[i] += 1

ans = 0
cnt.reverse()
k_str = to_bin(K)
while len(k_str) < 40:
    k_str = '0' + k_str

for j in range(len(cnt)):
    if k_str[j] == '1':
        tmp_ans = 0
        for k in range(len(cnt)):
            power = 39 - k
            if k <= j - 1:
                if k_str[k] == '0':
                    tmp_ans += cnt[k] * (2 ** power)
                else:
                    tmp_ans += (N - cnt[k]) * (2 ** power)
            elif k == j:
                tmp_ans += cnt[k] * (2 ** power)
            else:
                tmp_ans += max(cnt[k], N - cnt[k]) * (2 ** power)
        ans = max(ans, tmp_ans)
tmp_ans = 0
for k in range(len(cnt)):
    power = 39 - k
    if k_str[k] == '0':
        tmp_ans += cnt[k] * (2 ** power)
    else:
        tmp_ans += (N - cnt[k]) * (2 ** power)
ans = max(ans, tmp_ans)
print(ans)
a=int(input("a=:")
b=int(input("b=:")
if a*b%2==0:
      print("Even")
else :
      print("Odd")

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2==0:
  print("Even")
else :
  print("Odd")
from collections import deque
S=deque(input())
Q=int(input())
F=0
for i in range(Q):
  N=list(input().split())
  if F==0:
    if N[0]=="1":
      F=1
    elif N[1]=="1":
      S.appendleft(N[2])
    else:
      S.append(N[2])
  elif F==1:
    if N[0]=="1":
      F=0
    elif N[1]=="1":
      S.append(N[2])
    else:
      S.appendleft(N[2])
if F==1:
  print("".join(S.reverse()))
else:
  print("".join(S))

### FIXED CODE ###

from collections import deque
S=deque(input())
Q=int(input())
F=0#フラグ
for i in range(Q):
  N=list(input().split())
  if F==0:#反転していない場合
    if N[0]=="1":#反転させる
      F=1
    elif N[1]=="1":#先頭に追加
      S.appendleft(N[2])
    else:#末尾に追加
      S.append(N[2])
  elif F==1:#反転している場合
    if N[0]=="1":#反転を戻す
      F=0
    elif N[1]=="1":#末尾に追加
      S.append(N[2])
    else:#先頭に追加
      S.appendleft(N[2])
if F==1:#反転するならsを反転させる
  S.reverse()
  print("".join(S))
else:#そうでないならそのまま
  print("".join(S))
S = str(input())
stack = []
N = len(S)
for i, s in enumerate(S):
  if i == 0:
    stack.append(s)
    else:
      if len(stack) == 0:
        stack.append(s)
        else:
          if s != stack[-1]:
            tmp = stack.pop()
            else:
              stack.append(s)
print(N - len(stack))


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(S: str):
    stack = []
    N = len(S)
    for i, s in enumerate(S):
        if i == 0:
            stack.append(s)
        else:
            if len(stack) == 0:
                stack.append(s)
            else:
                if s != stack[-1]:
                    tmp = stack.pop()
                else:
                    stack.append(s)
    print(N - len(stack))

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = str(input())
    solve(S)

if __name__ == '__main__':
    main()
x=input()
y=input()
z=input()

print(z x y)

### FIXED CODE ###

x,y,z=map(int,input().split())
print(z,x,y)
y,m,d=list(map(int,input().split("/")))
if y>2019:
  print("TBD")
elif y<2019:
  print("Heisei")
elif m>4:
  print("TBD")
elif m<4:
  print("Heisei")
elif d=30:
  print("TBD")
else:
  print("Heisei")

### FIXED CODE ###

y,m,d=list(map(int,input().split("/")))
if y>2019:
  print("TBD")
elif y<2019:
  print("Heisei")
elif m>4:
  print("TBD")
elif m<4:
  print("Heisei")
elif d>30:
  print("TBD")
else:
  print("Heisei")
import numpy as np

N = input()
# N = int(input())
# t = np.array(list(map(int, input().split())))
t = map(int, raw_input().split())

odd = t[0::2]
even = t[1::2]

rest = 0
unique, count = np.unique(odd, return_counts=True)

print 'h'


### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
from collections import Counter
N = input()
t = np.array(map(int, raw_input().split()))

odd = t[0::2]
even = t[1::2]
rest = 0

co = Counter(odd)
ce = Counter(even)

omc = co.most_common()
emc = ce.most_common()

if omc[0][0] == emc[0][0]:
    if len(omc) < 2 and len(emc) < 2:       # same
        rest = len(even)
    elif len(omc) < 2:
        rest = len(even)
    elif len(emc) < 2:
        rest = len(odd)
    else:
        or1 = len(odd) - co.most_common()[0][1]
        or2 = len(odd) - co.most_common()[1][1]
        er1 = len(even) - ce.most_common()[0][1]
        er2 = len(even) - ce.most_common()[1][1]

        if or1 + er2 > or2 + er1:
            rest = or2 + er1
        else:
            rest = or1 + er2
else:
    rest = len(odd) - co.most_common()[0][1] + len(even) - ce.most_common()[0][1]


print rest
n,k=map(int,input().split())
s=list(map(int,input().split()))

ans=0
tmp=0
tmp2=sum(s[0:k])
for i in range(n-k):
    tmp2 -= s[i]
    tmp2 += s[k+i]
    if tmp < tmp2:
        tmp = tmp2
        kukan = [i+1,i+k+1]

for i in range(kukan[0],kukan[1]):
    ans += (s[i]+1)/2
    
print(ans)

### FIXED CODE ###

n,k=map(int,input().split())
s=list(map(int,input().split()))

ans=0
tmp=0
tmp2=sum(s[0:k])
kukan=[0,n]
for i in range(n-k):
    tmp2 -= s[i]
    tmp2 += s[k+i]
    if tmp < tmp2:
        tmp = tmp2
        kukan = [i+1,i+k+1]

for i in range(kukan[0],kukan[1]):
    ans += (s[i]+1)/2
    
print(ans)
D = (int,input()
if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
else:
    print('Christmas Eve Eve Eve')            

### FIXED CODE ###

D = int(input())
if D == 25:
    print('Christmas')
elif D == 24:
    print('Christmas Eve')
elif D == 23:
    print('Christmas Eve Eve')
elif D == 22:
    print('Christmas Eve Eve Eve')
import fractions
import functools
import math
N, M = map(int, input().split())
A = [int(x)//2 for x in input().split()]
#------------------------------------------------
#リスト内の最小公倍数
def lcm(a, b):
    return a * b // fractions.gcd(a, b)
all_lcm = functools.reduce(lcm, A)  
#------------------------------------------------
# Aの最小値が2で割り切れる回数
cnt = 0
min_a = min(A)
while True:
    if min_a % 2 != 0:
        break
    min_a //= 2
    cnt += 1
# Aのすべての数が2でcnt回割り切れる
cond1 = all({i % (2**cnt) == 0 for i in A})
# cnt回割った後、さらに2で割り切れる数は存在しない
cond2 = all({(i // (2**cnt)) % 2 != 0 for i in A})

if cond1 and cond2:
    print(math.ceil(M/all_lcm/2))
else:
    print(0)

### FIXED CODE ###

A, B = map(int, input().split())

if 500*A >= B:
    print("Yes")
else:
    print("No")
n, m = input().split(" ")
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():
    if "AC" in i:
        ac_count += 1
    
    wa_count += len(i[:i.index("AC")])
 
print("{0} {1}".format(ac_count, wa_count))

### FIXED CODE ###

n, m = [int(i) for i in input().split(" ")]
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():

    if "AC" in i:
        ac_count += 1
        wa_count += i.index("AC")
 
print("{0} {1}".format(ac_count, wa_count))
A,P=map(int,input().split())
ap=A*3+P
print(ap//P)

### FIXED CODE ###

A,P=map(int,input().split())
ap=A*3+P
print(ap//2)
n = int(input())
h = list(map(int,input().split()))
l = [False]*(sum(range(1, n)))
a = 0
for j in range(n):
  for i in range(j+1,n):
    if h[j] <= h[i]:
      l[a] = True
    else:
      if h[j]-1-h[i] < 1:
        l[a] = True
    a += 1
print("Yes" if l.count(False)==0 else "No")

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
for i in range(n-2,-1,-1):
  if arr[i]>arr[i+1]:
    arr[i]-=1
    if arr[i]>arr[i+1]:
      print('No')
      break
else:
  print('Yes')
line = list((input().split()))
a = line[0]+line[1]
a = int(a)
for i in range(a):
  if i**2==a:
    print(Yes)
    return
print(No)

### FIXED CODE ###

line = input().split()
a = int(line[0]+line[1])
for i in range(a):
  if i**2==a:
    print('Yes')
    exit()
print('No')
import math
 
N,D= list(map(int,input().split()))
x = [0] * N
y = [0] * N
b=0
 
for i in range(N):
     x[i], y[i] = map(int, input().split())
     a=x[i]**2+y[i]**2
     if math.sqrt(a) <=D:
          b+=1
print(b)


### FIXED CODE ###

X = int(input())  

if X >=30:
    print('Yes')
else:
    print('No')
s = list(input())
arufa = ["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 s:
    arufa.remove(i)
if arufa == []:
    dum = sorted(s,reverse=1)
    if dum == s:
        print(-1)
    else:
        arufa.append(s.pop(-1))
        for i in range(26):
            arufa.sort()
            if s[-1] < arufa[0]:
                s.pop(-1)
                s.append(arufa[0])
                break
            #for j in range(len(arufa)):
            #    if s[-1] < arufa[i]:
            #        s.append(arufa[0])
            #        print("".join(s))
            #        exit()
            arufa.append(s.pop(-1))
        print("".join(s))

else:
    s.append(arufa[0])
    print("".join(s))


### FIXED CODE ###

s = list(input())
kouho = ["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 s:
    kouho.remove(i)
if kouho == []:
    kouho.append(s.pop(-1))
    for i in range(25):
        dum = s.pop(-1)
        for j in range(len(kouho)):
            if dum < kouho[j]:
                s.append(kouho[j])
                print("".join(s))
                exit()
        else:
            kouho.append(dum)
            kouho.sort()
    else:
        print(-1)
    print("".join(s))
else:
    s.append(kouho[0])
    print("".join(s))