Harryxun/stf_run huggingface dataset:
def I():
	return int(sys.stdin.readline().rstrip())


def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

  
N = I()
h_i = IL()
dp = [0 for _ in range(N)]
for i in range(N):
	if i == 0:
		pass
	elif i == 1:
		dp[i] = abs(h_i[i] - h_i[i-1])
	else:
		point_1 = abs(h_i[i] - h_i[i-1]) + dp[i-1]
		point_2 = abs(h_i[i] - h_i[i-2]) + dp[i-2]
		if point_1 <= point_2:
			dp[i] = point_1
		else:
			dp[i] = point_2

print(dp[-1])

### FIXED CODE ###

import sys
def I():
	return int(sys.stdin.readline().rstrip())


def SL():
	return S().split()


def IL():
	return list(map(int, sys.stdin.readline().rstrip().split()))


N = I()
h_i = IL()
dp = [0 for _ in range(N)]
for i in range(N):
	if i == 0:
		pass
	elif i == 1:
		dp[i] = abs(h_i[i] - h_i[i-1])
	else:
		point_1 = abs(h_i[i] - h_i[i-1]) + dp[i-1]
		point_2 = abs(h_i[i] - h_i[i-2]) + dp[i-2]
		if point_1 <= point_2:
			dp[i] = point_1
		else:
			dp[i] = point_2

print(dp[-1])
from math import gcd
import sys
from collections import Counter

read = lambda: sys.stdin.readline().rstrip()

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def disjoint_set_of_common_divisors(A, B):

    return len(Counter(prime_factorize(gcd(A, B))).keys())+1

def main():
    
    A0, B0 = map(int, input().split())
    #A0 = tuple(map(int, read().split()))

    res = disjoint_set_of_common_divisors(A0, B0)

    print(res)
 
if __name__ == "__main__":
    main()

### FIXED CODE ###

from fractions import gcd
import sys
from collections import Counter

read = lambda: sys.stdin.readline().rstrip()

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

def disjoint_set_of_common_divisors(A, B):

    return len(Counter(prime_factorize(gcd(A, B))).keys())+1

def main():
    
    A0, B0 = map(int, read().split())
    #A0 = tuple(map(int, read().split()))

    res = disjoint_set_of_common_divisors(A0, B0)

    print(res)
 
if __name__ == "__main__":
    main()
a, b = map(int, intput().split())
print(a * b)

### FIXED CODE ###

a, b = map(int, input().split())
print(a * b)
s=list(input())
t=list(input())
l=[]
for i in range(len(s)-len(t)+1):
    c=0
    for j in range(len(t)):
        if s[j+i]==t[j]:
            c+=1
            l.append(c)
print(len(t)-max(l))

### FIXED CODE ###

a=list(input())
b=list(input())
l=[]
for i in range(len(a)-len(b)+1):
  c=0
  for j in range(len(b)):
    if a[j+i]==b[j]:
      c+=1
  l.append(c)
print(len(b)-max(l))
n, m = map(int, input().split())
c = [input().split() for i in range(m)]
for i in range(m):
    c[i][0] = int(c[i][0])
AC, WA, i =0, 0, 0
for i in range(n):
    for j in range(m):
        if c[j][0] == i + 1:
            if c[j][1] == 'WA':
                WA += 1
                if j == m:
                    break
            elif c[j][i] == 'AC':
                AC += 1
                break 
print(AC, WA)

### FIXED CODE ###

n, m = map(int, input().split())
c = [input().split() for i in range(m)]
for i in range(m):
    c[i][0] = int(c[i][0])
AC, WA = 0, 0
acwa = [[0, 0] for i in range(n)]
for i in range(m):
    if acwa[c[i][0] - 1][0] == 0:
        if c[i][1] == 'AC':
            acwa[c[i][0] - 1][0] += 1
            AC += 1
            WA += acwa[c[i][0] - 1][1]
        else:
            acwa[c[i][0] - 1][1] += 1

print(AC, WA)
# 入力の取得
s = input()

even = ""
odd  = ""

#1文字ずつループ
for idx,s in enumerate(s):
    if idx = 0 or idx % 2 == 0:
        even += s
    else:
        odd += s

#判定
even = even.replace('R', '').replace('U', '').replace('D', '')
odd  = odd.replace('L', '').replace('U', '').replace('D', '')


if even = "" and odd = "":
    print("Yes")
else:
    print("No")


### FIXED CODE ###

# 入力の取得
s = input()

even = ""
odd  = ""

#1文字ずつループ
for idx,s in enumerate(s):
    if idx == 0 or idx % 2 == 0:
        even += s
    else:
        odd += s

#判定
even = even.replace('R', '').replace('U', '').replace('D', '')
odd  = odd.replace('L', '').replace('U', '').replace('D', '')


if even == "" and odd == "":
    print("Yes")
else:
    print("No")
n = int(input)
A = [0] + list(map(int, input().split())) + [0]

#普通に総和を出す
sum = 0
for i, a in enumerate(A):
  if i == n+1: break #n+1はゴールなので先に行かない
  sum += abs(a - A[i+1]) #a:A[i]
  
#引いて足す
for i in range(1, n+1, 1): #1～Nを省いたとき
  nowsum = sum
  nowsum -= abs(A[i-1]-A[i])
  nowsum -= abs(A[i]-A[i+1])
  nowsum += abs(A[i-1]-A[i+1])
  print(nowsum)


### FIXED CODE ###

n = int(input())
tmpa = list(map(int, input().split()))
A = [0] * (n+2)
A[0] = 0
A[n+1] = 0
for i in range(1,n+1,1): A[i] = tmpa[i-1]


#普通に総和を出す
sum = 0
for i, a in enumerate(A):
  if i == n+1: break #n+1はゴールなので先に行かない
  sum += abs(a - A[i+1]) #a:A[i]
  
#引いて足す
for i in range(1, n+1, 1): #1～Nを省いたとき
  nowsum = sum
  nowsum -= abs(A[i-1]-A[i])
  nowsum -= abs(A[i]-A[i+1])
  nowsum += abs(A[i-1]-A[i+1])
  print(nowsum)
import math
ans = 0
K = int(input())
 
for i in range(1, K+1):
	for j in range(1,K+1):
  		for k in range(1,K+1):
    		ans = ans + math.gcd(math.gcd(i,j), k)
      
print(ans)

### FIXED CODE ###

from math import gcd
ans = 0
K = int(input())
 
for i in range(1, K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      ans += gcd(gcd(i,j), k)
      
print(ans)
n1 = input()
n2 = input()

print(n1 * n2)

### FIXED CODE ###

a, b = map(int, input().split())
print(a * b)
import math

N = int(input())
T = [int(input()) for i in range(N)]

LCM = 1
for i in range(N):
    lcm = (T[i] * LCM) // (math.gcd(T[i], LCM))
    LCM = lcm

print(LCM)


### FIXED CODE ###

import fractions

N = int(input())
T = [int(input()) for i in range(N)]

LCM = 1
for i in range(N):
    lcm = (T[i] * LCM) // (fractions.gcd(T[i], LCM))
    LCM = lcm

print(LCM)
from statistics import median
import math
n=int(input())
A,B = [],[]
for _ in range(n):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
a1,b2 = int(median(A)),math.ceil(median(B))
b1 = max([B[i] for i,v in enumerate(A) if v == a1])
a2 = max([A[i] for i,v in enumerate(B) if v == b2])
#print(a1,b1,a2,b2)
if b1<a2:
  print(b1-a1+b2-a2+1)
  exit()
print(b2-a1+1)


### FIXED CODE ###

from statistics import median
n=int(input())
A,B=[],[]
for _ in range(n):
  a,b=map(int,input().split())
  A.append(a*2)
  B.append(b*2)
ma,mb = int(median(A)),int(median(B))
#print(ma,mb)
if n%2 == 0:
  print(mb-ma+1)
else:
  print((mb-ma)//2+1)
def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    for m in range(0, M):
        tmp = [int(x) for x in input().split()]
        A.extend([tmp[1]] * tmp[0])

    A = A.sort(A, reverse = True)
    A = A[:N]
    print(sum(A))


if __name__ == "__main__":
    main()


### FIXED CODE ###

from heapq import heappush, heappop, heapify

def main():
    N, M = map(int, input().split())
    A_card = [-int(x) for x in input().split()]

    change_list = []
    for i in range(M):
        B, C = [int(x) for x in input().split()]
        change_list.append(((-1) * C, B))

    hq = []
    for i in range(N):
        heappush(hq, (A_card[i], 1))

    for i in range(M):
        heappush(hq, change_list[i])

    result_sum = 0
    count = 0
    while True:
        if count == N:
            break
        tmp = heappop(hq)
        if count + tmp[1] <= N:
            result_sum += (tmp[0] * tmp[1])
            count += tmp[1]
        else:
            result_sum += (tmp[0] * (N - count))
            break

    print(result_sum * (-1))

if __name__ == "__main__":
    main()
19 99

### FIXED CODE ###

a,b=map(int,input().split())
i=1
while 1:
    if int(i*0.08)==a:
        if int(i*0.1)==b:
            print(i)
            break
    else:
        if int(i*0.08)>a:
            print(-1)
            break
    i+=1
from collections import*
from heapq import*
def dijkstra(s):
  d=[inf]*n
  used=[True]*n
  d[s]=0
  used[s]=False
  edgelist=[]
  for e in edge[s]:
    heappush(edgelist,e)
  while len(edgelist):
    minedge=heappop(edgelist)
    if not used[minedge[1]]:
      continue
    v=minedge[1]
    d[v]=minedge[0]
    used[v]=False
    for e in edge[v]:
      if used[e[1]]:
        heappush(edgelist,(e[0]+d[v],e[1]))
  return d
inf=10**18
n,m,*t=map(int,open(0).read().split())
if m<1:
  print(-1)
  exit()
e=defaultdict(list)
s=[]
l=[]
for a,b,c in zip(t[::3],t[1::3],t[2::3]):
  if b<a:a,b=b,a
  if b==n:l.append(b+n*c)
  e[a].append((1,a+n*c))
  e[b+n*c].append((0,b))
  e[a+n*c].append((0,b+n*c))
  s.extend([a,b,a+n*c,b+n*c])
d={i:v for v,i in enumerate(sorted(set(s)))}
n=len(d)
edge=tuple([]for _ in range(n))
for i in e:
  edge[d[i]].extend([(c,d[j])for c,j in e[i]])
a=dijkstra(0)
a=min(a[d[i]]for i in l)
print([a,-1][a==inf])

### FIXED CODE ###

def main():
  from heapq import heappush,heappop,heapify
  inf=2**31-1
  n,m,*t=map(int,open(0).read().split())
  z=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    z.extend([a,b,a+n*c,b+n*c])
  z={i:v for v,i in enumerate(sorted(set(z)))}
  try:
    z[1]
  except:
    print(-1)
    exit()
  edge=[[]for _ in range(len(z))]
  d={}
  l=[]
  for a,b,c in zip(t[::3],t[1::3],t[2::3]):
    if b<a:a,b=b,a
    i,j,x,y=z[a],z[b],z[a+n*c],z[b+n*c]
    if b==n:
      l.append(y)
    edge[i].append((1,x))
    edge[j].append((1,y))
    edge[x].extend([(0,i),(0,y)])
    edge[y].extend([(0,j),(0,x)])
  used=[False]+[True]*~-len(z)
  d=[0]+[inf]*~-len(z)
  edgelist=edge[0]
  heapify(edgelist)
  while edgelist:
    m=heappop(edgelist)
    if not used[m[1]]:
      continue
    d[m[1]]=m[0]
    used[m[1]]=False
    for e in edge[m[1]]:
      if used[e[1]]:
        heappush(edgelist,(e[0]+m[0],e[1]))
  a=min([d[i]for i in l]or[inf])
  print([a,-1][a==inf])
if __name__=='__main__':
  main()
K, N = map(int,input().split())
A = list(map(int, input().split()))
List = []

for i in range(1, N):
  List.append(A[i] - A[i-1])
  
d = K - A[-1] + A[0]
List.append(d)
List.sort()
print(sum(List[:-1]))
  

### FIXED CODE ###

S = input()

if S[2] == S[3] and S[4] == S[5]:
  print("Yes")
else:
  print("No")
X=int(input())
N=int(input())
Z=int(input())
A=0
G=0
N=0
M=0
Z=0
N=X/500
M=int(X%500)
Z=M/5
N=N+Z
for i in range(0,N):
    if X-500:
        X=X-500
        G=G+1000
    elif X-5:
        X=X-5
        G=G+5
    else:
        break
        
print(G)


### FIXED CODE ###

X=int(input())
A=0
G=0
N=0
M=0
Z=0
N=int(X/500)
M=int(X%500)
Z=int(M/5)
N=N+Z
for i in range(0,N):
    if X>=500:
        X=X-500
        G=G+1000
    elif X>=5:
        X=X-5
        G=G+5
    else:
        break
        
print(G)
N, K = map(int, input().split())
S = input()
l = [0]

for i in range(1, N):
    if S[i] != S[i-1]:
        l.append(i)
l.append(N)

mxcnt = 0
if len(l) <= 2*K+1:
    mxcnt = N
else:
    for i in range(len(l)-2*K):
        if S[i] == '0':
            x = l[i+2*K] - l[i]
            mxcnt = max(mxcnt, x)
        else:
            x = l[i+2*K+1] - l[i]
        mxcnt = max(mxcnt, x)

print(mxcnt)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()

l = [0]
curr = '1'
for c in S:
    if c != curr:
        l.append(1)
        curr = c
    else:
        l[-1] += 1
if curr == '0':
    l.append(0)

n_group = len(l) // 2
sum_ = 0
k = min(K, n_group)
sum_ = sum(l[0:2*k+1])
max_ = sum_
for i in range(k, n_group):
    sum_ -= l[2*i-2*K] + l[2*i+1-2*K]
    sum_ += l[2*i+1] + l[2*i+2]
    max_ = max(max_, sum_)
print(max_)
a = int(input())
b = int(input())
print(a*b)

### FIXED CODE ###

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

print(a[0]*a[1])
def MAP(): return map(int, input().split())
x = sorted(MAP(x))
if x[0] + x[1] == x[2]:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

def MAP(): return map(int, input().split())
x = sorted(MAP())
if x[0] + x[1] == x[2]:
  print("Yes")
else:
  print("No")
import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    cnt_neg = 0
    abs_min = 1_000_000_005
    for a in A:
        abs_min = min(abs_min, abs(a))
        if a < 0:
            cnt_neg += 1

    ans = 0
    for a in A:
        ans += abs(a)

    if cnt_neg % 2 != 0:
        ans -= 2 * abs_min

    print(ans)


### FIXED CODE ###

import math  # noqa
import bisect  # noqa
import queue  # noqa


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))

    cnt_neg = 0
    abs_min = 1000000005
    for a in A:
        abs_min = min(abs_min, abs(a))
        if a < 0:
            cnt_neg += 1

    ans = 0
    for a in A:
        ans += abs(a)

    if cnt_neg % 2 != 0:
        ans -= 2 * abs_min

    print(ans)
n = int(input())
a = input().split()
a_int = [int(n) for n in a]
ans = 1
for num in a_int:
    if ans !> 10**18:
        ans *= num
    else:
        print(-1)
print(ans)

### FIXED CODE ###

N = int(input())
A = map(int, input().split())
 
res = 1
 
for a in sorted(A):
    res *= a
    if res > 10 ** 18:
        print("-1")
        exit()
print(res)
#abc095 a
s=input()
print(700+s.count"o"*100)


### FIXED CODE ###

#abc095 a
s=input()
print(700+s.count("o")*100)
H,W,K = map(int, input().split())
S = [list(map(str,input())) for _ in range(H)]

ans = [[-1]*W for _ in range(H)]

cnt = 1
cnt_max = 0
for i in range(H):
	ichigo = S[i].count("#")
	if ichigo == 0:
		ans[i].clear()
		continue
	cnt_max = cnt + ichigo - 1
	for j in range(W):
		if S[i][j] == ".":
			ans[i][j] = min(cnt,cnt_max)
		else:
			ans[i][j] = min(cnt,cnt_max)
			cnt += 1
	cnt = cnt_max+1
cond = 1
while cond:
	cond = 0
	for i in range(H):
		if ans[i] == []:
			cond = 1
			if i == H-1:
				ans[i] = ans[i-1]
			else:
				ans[i] = ans[i+1]

for i in range(H):
	for j in range(W):
		if j == W-1:
			print(ans[i][j])
		else:
			print(ans[i][j], end = " ")

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

H,W,K = map(int, readline().split())
grid = np.frombuffer(read(), 'S1').reshape(H,-1)[:,:W]

X,Y = np.where(grid == b'#')

A = np.zeros((H,W), np.int32)
A[X,Y] = np.arange(1,K+1)

np.maximum.accumulate(A, axis = 1, out = A)

for w in range(W-2, -1, -1):
	A[:,w] += A[:,w+1] * (A[:,w] == 0)

for h in range(1,H):
	if A[h,-1] == 0:
		A[h] += A[h-1]
for h in range(H-1,-1,-1):
	if A[h,-1] == 0:
		A[h] += A[h+1]

print('\n'.join(' '.join(row) for row in A.astype(str)))
n = int(input())
length = 0
word_list = []
for i in range(n):
  word = input()
  if len(word) > length:
    word_list = [word]
  if len(word) = length:
    word_list.append(word)
word_list.sort()
for k in range(len(word_list)):
  print(word_list[k])

### FIXED CODE ###

n = int(input())
s = []
for i in range(n):
  s.append(input())
s = sorted(s)
max_count = 1
count = 1
ans = []
for i in range(n-1):
  if s[i] == s[i+1]:
    count += 1
    if count == max_count:
      ans.append(s[i])
    if count > max_count:
      max_count = count
      ans = [s[i]]
  else:
    count = 1
    if max_count == 1:
      ans.append(s[i])
if max_count == 1:
  ans.append(s[n-1])
ans = sorted(ans)
for i in range(len(ans)):
  print(ans[i])
A = int( input() )
B = int( input() )
c = A + B
d = A - B
e = A * B

if c < d:
    if d < e:
        print(e)
    if d > e:
        print(d)

if c > d:
    if c > e:
        print(c)

### FIXED CODE ###

A, B = (int(x) for x in input().split())
c = A + B
d = A - B
e = A * B

if c <= d:
    if d <= e:
        print(e)
    if d > e:
        print(d)

if c > d:
    if c >= e:
        print(c)
    if c < e:
        print(e)
N, M = map(int, input().split())

G = {i:[] for i in range(1, N + 1)}

for _ in range(M):
    x, y = map(int, input().split())
    G[x].append(y)

def dfs(num):
    if dp[num] != -1:
        return dp[num]

    res = 0
    for obj in G[num]:
        res = max(res, dfs(obj) + 1)

    dp[num] = res
    return res

dp = [-1] * (N + 1)

res = 0
for i in range(1, N + 1):
    res = max(res, dfs(i))

print(res)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)

#import math
#import numpy as np
#= int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
def dfs(num):
    if dp[num] != -1:
        return dp[num]

    res = 0
    for obj in G[num]:
        res = max(res, dfs(obj) + 1)

    dp[num] = res
    return res


N, M = map(int, input().split())

dp = [-1] * N
G = {i:[] for i in range(N)}

for _ in range(M):
    x, y = map(int, input().split())
    G[x - 1].append(y - 1)

res = 0
for i in range(N):
    res = max(res, dfs(i))

print(res)
s, t = map(str, input().split())
l = len(t)-1
print('Yes') if s == t[:l] else print('No')

### FIXED CODE ###

s = input()
t = input()
l = len(t)-1
if s == t[:l]:
    print('Yes')
else:
    print('No')
if a < 5000 && a >= 3200:
	print(s)
elif 2800 <= a && a < 3200:
	print('red')

### FIXED CODE ###

a=int(input())
s=input()
if a >= 3200:
  print(s)
else:
  print('red')
M = int(input())
    
    print(48-M)

### FIXED CODE ###

def ABC_84_A():
    M = int(input())
    
    print(48-M)

if __name__ == '__main__':

    ABC_84_A()
N,M=map(int,input().split())

pair=[list(map(lambda x:int(x)-1,input().split())) for _ in range(M)]
graph=[[0]*N for _ in range(N)] #隣接行列の初期化

print(pair)

for p in pair:
	graph[p[0]][p[1]]= graph[p[1]][p[0]]=1
	
def DFS(v):
	if visited[v]:
		return 
	visited[v]=True
	for i in [i for i,v2 in enumerate(graph[v]) if v2==1]:
		DFS(i)
		
res = 0

for i in range(M):
	visited=[False for _ in range(N)] #訪問済みリストの初期化
	x,y=pair[i]
	graph[x][y]=graph[y][x]=0 #辺を取り除く
	DFS(0 if i>0 else 1)
	
	if not all(visited): #全ての頂点が訪問済みでなかった場合
		res+=1
	
	graph[x][y]=graph[y][x]=1

print(res)

### FIXED CODE ###

A,B,C=list(input().split())

if A==B:
	print(C)
elif B==C:
	print(A)
else:
	print(B)
import sys

sys.setrecursionlimit(10**6)

N, K = map(int, input().split())

A = input("").split(" ")
A = [int(i) for i in A]


for i in range(1, N-K+1):
    score = 1
    p_score = 1

    for j in range(i, i+K):
        score = score * A[j]
        p_score = p_score * A[j-1]

    if score > p_score:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N = int(input(""))

if N >= 1800:
    print("1")
elif N >= 1600:
    print("2")
elif N >= 1400:
    print("3")
elif N >= 1200:
    print("4")
elif N >= 1000:
    print("5")
elif N >= 800:
    print("6")
elif N >= 600:
    print("7")
elif N >= 400:
    print("8")
N, K = map(int, input().split())
N = N%K
while True:
  if (N==0):
    min_num = N
    break
  elif N in history:
    min_num = min(history)
    break 
  history.append(N)
  N = abs(N-K)

print(min_num)

### FIXED CODE ###

N, K = input().split()
N = int(N)
K = int(K)

middle = N % K
answer = middle
while True:
  if abs(answer-K) > N:
    answer = N
    break
  if abs(answer - K) < answer:
    answer = abs(answer-K)
  else:
    break
    
print(str(answer))
from fractions import gcd
from functools import reduce

N=int(input())
A=[int(input()) for _ in range(N)]

print(reduce(gcd,A))

### FIXED CODE ###

#ABC118_C
from fractions import gcd
from functools import reduce

N=int(input())
A=list(map(int,input().split()))

ans=reduce(gcd,A)
print(ans)
#c
k=int(input())
if k%7==0:
    k/=7
if k%2==0:
    ans=-1
else:
    x=1
    ans=-1
    plus=10
    for i in range(1,10000000):
        if x%k==0:
            ans=i
            break
        else:
            x+=plus
            plus*=10
print(ans)

### FIXED CODE ###

#正答
k=int(input())
a=set()
count=1
if k%2==0:
    print(-1)
else:
    #下の桁に７を足していく
    ai=7%k
    while 1:
        if ai==0:
            print(count)
            break
        elif ai in a:
            print(-1)
            break
        else:
            a.add(ai)
            ai=(ai*10+7)%k
            count+=1
n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))
print(li_a)
  

### FIXED CODE ###

n = int(input())
li = list(map(int, input().split()))
li_a = []
for i in range(n-1):
  if li[i] < li[i+1]:
    li_a.append(i+1)
if len(li_a) == 1:
  print(n - li_a[0] - 1)
elif len(li_a) == 0:
  print(n-1)
else:
  li_b = []
  for j in range(len(li_a)-2):
    li_b.append(li_a[j+1]-li_a[j]-1)
  li_b.append(n - li_a[-1] - 1)
  print(max(li_b))
k = int(input())
a, b = map(int, input().split())
for i in range(a, b+1):
  if i % k == 0:
    ans = 0
if ans = 0:
  print("OK)
else:
  print("NG")

### FIXED CODE ###

k = int(input())
a, b = map(int, input().split())
ans = 0
for i in range(a, b+1):
  if i % k == 0:
    ans = 1
if ans == 1:
 	 print("OK")
else:
  	print("NG")
import sys
n,k,x,y = map(int,sys.stdio.read().split())
high=n-k
ans=0
if high > 0:
  ans=x*k+high*y
else:
  ans=n*x
print(ans)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# template: v1.2

import io
import sys
import math

def solve(n,k,x,y):
    # implement process
    higher = n-k
    if higher < 1:
        return n*x
    else:
        return k*x + higher*y



def main():
    # input
    n,k,x,y = map(int,sys.stdin.read().split())
    
    # process
    ans = str( solve(n,k,x,y) )
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
2
3
10000
9000
"""
_EXPECTED = """\
20000
"""

def logd(str):
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")
s=input()
n=int(input())
ans=""
for i in range(n-1):
  x=ord(a[i])-97
  if n>=123-x:
    ans += "a"
    n -= 123-x
  else:
    ans += a[i]
ans += chr((ord(a[i])-97+n)%26+97)
print(ans)

### FIXED CODE ###

a=input()
n=len(a)
m=int(input())
ans=""
for i in range(n-1):
  if a[i]=="a":
    ans += "a"
    continue
  x=ord(a[i])-97
  if m>=26-x:
    ans += "a"
    m -= 26-x
  else:
    ans += a[i]
ans += chr((ord(a[n-1])-97+m)%26+97)
print(ans)
num = int(input())
a = list(map(int, input().split()))

count = 0
for i in a:
  c = 0
  while i != 0 and i % 2 == 0:
    i /= 2
    c += 1
  if c >= count:
    count = c
print(count)

### FIXED CODE ###

num = list(input())

count = 0
for i in num:
  if i == '1':
    count += 1
print(count)
A=int(input())
B=int(input())
K=int(input())
count = 0
while count<K:
    if count%2==0:
        if A%2==0:
            A//=2
            B+=A
        else:
            A-=1
            A//=2
            B+=A
    else:
        if B%2==0:
            B//=2
            A+=B
        else:
            B-=1
            B//=2
            A+=B
    count+=1
print(A,B,count)

### FIXED CODE ###

S=input()
if len(S)==2:
    print(S)
elif len(S)==3:
    print(S[::-1])