Harryxun/stf_run huggingface dataset:
A,B,K = map(int,input().split())
tmp = list(range(A,B+1))
ans = []
flag = 1
for i in range(K):
    ans.append(tmp[i])
for j in range(K):
    ans.append(tmp[-j-1])
ans = list(set(ans))
for k in range(len(ans)):
    print(ans[k])

### FIXED CODE ###

A,B,K = map(int,input().split())
if A == B:
    print(A)
else:
    if K > B - A:
        K = B - A
    tmp1 = list(range(A,A+K))
    tmp2 = list(range(B-K+1,B+1))
    ans = sorted(list(set(tmp1 + tmp2)))
    for i in ans:
        print(i)
a = int(input())
s = input()

if a>=3200:
  print(s)
else if a<3200:
  print('red')

### FIXED CODE ###

a = int(input())
s = input()

if a>=3200:
  print(s)
elif a<3200:
  print('red')
#!/usr/bin/env python
# coding: utf-8

# In[11]:


from collections import deque


# In[23]:


H,W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())


# In[24]:


def bfs(sx,sy):
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    d = [[-1]*W for _ in range(H)]
    q = deque([])
    q.append([sx,sy])
    d[sx][sy] = 0
    ans = 0
    while q:
        x,y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] != "#" and d[nx][ny] == -1:
                q.append([nx,ny])
                d[nx][ny] = d[x][y] + 1
                ans = max(ans,d[nx][ny])
    return ans


# In[25]:


for sh in range(H):
    if "." in S[sh]:
        for sw in range(W):
            if S[sh][sw] == ".":
                ans = max(ans,bfs(sh,sw))
print(ans)


# In[ ]:






### FIXED CODE ###

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

# In[1]:


from collections import deque


# In[2]:


H,W = map(int, input().split())
S = []
for _ in range(H):
    S.append(input())


# In[3]:


def bfs(sx,sy):
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    d = [[-1]*W for _ in range(H)]
    q = deque([])
    q.append([sx,sy])
    d[sx][sy] = 0
    ans = 0
    while q:
        x,y = q.popleft()
        for i in range(4):
            nx = x + dx[i]
            ny = y + dy[i]
            if 0 <= nx < H and 0 <= ny < W and S[nx][ny] != "#" and d[nx][ny] == -1:
                q.append([nx,ny])
                d[nx][ny] = d[x][y] + 1
                ans = max(ans,d[nx][ny])
    return ans


# In[5]:


ans = 0
for sh in range(H):
    if "." in S[sh]:
        for sw in range(W):
            if S[sh][sw] == ".":
                ans = max(ans,bfs(sh,sw))
print(ans)


# In[ ]:
import copy
H,W=map(int,input().split())
S=[0]*W
for i in range(H):
    S[i]=list(input()+".")
S+=[["."]*(W+1)]
S2=[["#"]*W]*H

for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            S2[i][j]="#"
        else:
            if i==0:
                im=H
            else:
                im=i-1
            if j==0:
                jm=W
            else:
                jm=j-1

            if i==H-1:
                ip=H
            else:
                ip=i+1

            if j==W-1:
                jp=W
            else:
                jp=j+1
            cnt=[S[im][jm],S[im][j],S[im][jp],S[i][jm],S[i][jp],S[ip][jm],S[ip][j],S[ip][jp]]
            S2[i][j]=cnt.count('#')

print(S2)



### FIXED CODE ###

def count_bomb(y,x):
    ans=0
    for i in range(y-1,y+2):
        for j in range(x-1,x+2):
            if i>=0 and i<h and j>=0 and j<w:
                if s[i][j]=="#":
                    ans+=1
    return ans
h,w=map(int,input().split())
s = [list(input()) for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            s[i][j]=count_bomb(i,j)
for i in range(h):
    print(*s[i],sep="")
N = int(input())
print(N*(N-1)//2)

### FIXED CODE ###

S = input()
T = input()
ans = 0
for i in range(3):
    if S[i] == T[i]:
        ans += 1
print(ans)
n, m, l = map(int,input().split())

x = []
y = []

for i in range(n):
    a = list(map(int,input().split()))
    x.append(a)
    
for i in range(m):
    b = list(map(int,input().split()))
    y.append(b)

#print(x)
a = 0
b = []
ans = []

for i in range(3):
    for j in range(3):
        for k in range(2):
            a += x[i][k]*y[k][j]
        #print(a)
        b.append(a)
        a = 0
    b = list(map(str, b))
    b = ' '.join(b)
    ans.append(b)
    b = []
        
[print(ans[i]) for i in range(len(ans))]


### FIXED CODE ###

n, m, l = map(int,input().split())

x = []
y = []

for i in range(n):
    a = list(map(int,input().split()))
    x.append(a)
    
for i in range(m):
    b = list(map(int,input().split()))
    y.append(b)

#print(x)
a = 0
b = []
ans = []

for i in range(n):
    for j in range(l):
        for k in range(m):
            a += x[i][k]*y[k][j]
        #print(a)
        b.append(a)
        a = 0
    b = list(map(str, b))
    b = ' '.join(b)
    ans.append(b)
    b = []
        
[print(ans[i]) for i in range(len(ans))]
N = input()
if N == 1:
  print("Hello World")
else:
  A, B = map(int, input().split())
  print(A+B)

### FIXED CODE ###

N = int(input())

if N == 1:
  print("Hello World")
else:
  A= int(input())
  B= int(input())
  print(A+B)
s=input()
n=len(s)
s1=s[0:(n-3)/2]
s2=s[(n+1)/2:n-1]
if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

s=input()
n=len(s)
s1=s[0:(n-1)//2]
s2=s[(n+1)//2:n]
if s==s[::-1] and s1==s1[::-1] and s2==s2[::-1]:
  print("Yes")
else:
  print("No")
a, b = input().split()
b.replace(".", "")
print(int(a)*int(b)//100)

### FIXED CODE ###

#a, b = map(float, input().split())

a, b = input().split()
from decimal import Decimal
import math
print(math.floor(int(a)*Decimal(b)))
import sys
import bisect

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = 0
    for i, a in enumerate(l[:-2], start=1):
        for j, b in enumerate(l[i:-1], start=i):
            index = bisect.bisect_left(l, a + b)
            print(l, a, b, j, index, index - j - 1)
            hoge += index - j - 1
    print(hoge)
    # sum([str(i) for i in


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
import bisect

input = sys.stdin.readline


def main():
    n = int(input())
    l = map(int, input().split())
    # 種類組み合わせ・条件
    l = sorted(l)
    hoge = 0
    for i, a in enumerate(l[:-2], start=1):
        for j, b in enumerate(l[i:-1], start=i):
            index = bisect.bisect_left(l, a + b)
            hoge += index - j - 1
    print(hoge)


if __name__ == "__main__":
    main()
A, B = map(int, input().split())

for x in range(1251):
    
    if (int(x * 0.08) == A) and (int(x * 0.1) == B):
        print(i)
    else:
        print("-1")


### FIXED CODE ###

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

for x in range(1251):
    
    if (int(x * 0.08) == A) and (int(x * 0.1) == B):
        print(x)
        exit()

print("-1")
import sys
from collections import deque
input = sys.stdin.readline
N, H, W = map(int, input().split())
RCA = []

class UF(object):
    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, v):
        if v == self.parent[v]:
            return v
        else:
            self.parent[v] = self.root(self.parent[v])
            return self.parent[v]
    
    def unite(self, u, v):
        u, v = self.root(u), self.root(v)
        if (u == v):
            return
        self.parent[u] = v

for _ in range(N):
    r, c, a = map(int, input().split())
    r, c = r-1, c-1
    RCA.append((a, r, c))

RCA.sort(reverse=True)
RCA = deque(RCA)

uf = UF(H+W+1)  # r0, r1, ..., rH, c0, c1, ..., cW, loopflag

cnt, ans = 0, 0
while RCA and cnt < H+W:
    a, r, c = RCA.popleft()
    c += H
    if uf.root(r) == uf.root(c):
        if uf.root(r) == uf.root(H+W):  # loop?
            continue
        uf.unite(r, H+W)
    ans += a
    cnt += 1
    uf.unite(r, c)

print(ans)


### FIXED CODE ###

import sys
from collections import deque
input = sys.stdin.readline
sys.setrecursionlimit(10**5)
N, H, W = map(int, input().split())
RCA = []

class UF(object):
    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, v):
        if v == self.parent[v]:
            return v
        else:
            self.parent[v] = self.root(self.parent[v])
            return self.parent[v]
    
    def unite(self, u, v):
        u, v = self.root(u), self.root(v)
        if (u == v):
            return
        self.parent[u] = v

for _ in range(N):
    r, c, a = map(int, input().split())
    r, c = r-1, c-1
    RCA.append((a, r, c))

RCA.sort(reverse=True)
RCA = deque(RCA)

uf = UF(H+W+1)  # r0, r1, ..., rH, c0, c1, ..., cW, loopflag

cnt, ans = 0, 0
while RCA and cnt < H+W:
    a, r, c = RCA.popleft()
    c += H
    if uf.root(r) == uf.root(c):
        if uf.root(r) == uf.root(H+W):  # loop?
            continue
        uf.unite(r, H+W)
    ans += a
    cnt += 1
    uf.unite(r, c)

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

### FIXED CODE ###

a,b = map(int,input().split())
import fractions
ans = a*b // fractions.gcd(a,b)
print(ans)
times = [int(input()) for i in range(5)]
cost = 0
p_times = [time % 10 for time in times]
if sum(p_times) == 0 and min(p_times) > 0:
    last_order = False
else:
    last_order = min([i for i in p_times if i > 0])
    last_order_idx = p_times.index(last_order)

if last_order:
    cost = times.pop(last_order_idx)

for time in times:
    if time % 10 == 0:
        cost += time
    else:
        cost += time + (10 - time % 10)

print(cost)


### FIXED CODE ###

times = [int(input()) for i in range(5)]
cost = 0
p_times = [time % 10 for time in times]

if (sum([i % 10 for i in p_times]) == 0) & (min(times) > 0):
    last_order = False
else:
    last_order = min([i for i in p_times if i > 0])
    last_order_idx = p_times.index(last_order)

if last_order:
    cost = times.pop(last_order_idx)

for time in times:
    if time % 10 == 0:
        cost += time
    else:
        cost += time + (10 - time % 10)

print(cost)
n = int(input())
#j = L0
j = 2
#k = L1
k = 1

for i in range(1,n):
    l = j + k
    j = k
    k = l

print(l)

### FIXED CODE ###

n = int(input())
#j = L0
j = 2
#k = L1
k = 1

if n == 0:
    print(2)
    exit(0)
if n == 1:
    print(1)
    exit(0)

for i in range(1,n):
    l = j + k
    j = k
    k = l

print(l)
N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = ''
for _ in range(M):
  B += input()

ans = 'No'
for i in range(N-M+1):
  for j in range(N-M+1):
    sbstr = ''.join(A[i][j:j+M] + A[i+1][j:j+M])
    if B == sbstr:
      ans = 'Yes'

print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
A = [list(input()) for _ in range(N)]
B = ''
for _ in range(M):
  B += input()

ans = 'No'
for i in range(N-M+1):
  for j in range(N-M+1):
    sbstr = ''
    for k in range(M):
      sbstr += ''.join(A[i+k][j:j+M]) 
    if B == sbstr:
      ans = 'Yes'

print(ans)
import numpy as np
from collections import deque

h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
#s = np.array(s)
#s = (s == ".") * 1
def neext(a):
    l, m = a[0], a[1]
    return [(l, m+1), (l, m-1), (l+1, m), (l-1, m)]
def solve(i, j):
    if s[i][j] == '#':
        return 0
    else:
        pre = 0
        p = np.full((h, w), -1)
        check = deque([((i, j), 0)])#(from,now, dist)
        while check:
            now, d = check.popleft()
            p[now[0]][now[1]] = d
            pre = max(pre, d)
            for b, c in neext((now[0], now[1])):
                if b < 0 or c < 0 or b >= h or c >= w:
                    continue 
                if p[b][c] != -1 or s[b][c] == '#':
                    continue
                else:
                    check.append(((b, c), d + 1))
        return pre
ans = 0
for H in range(len(s)):
    for W in range(len(s[0])):
        ans = max(ans, solve(H, W))
print(ans)

### FIXED CODE ###

C=input()
print(chr(ord(C)+1))
a,b,x=map(int,input().split())
if x<a*a*b//2:
    q=math.degrees(math.atan(a*b*b/(2*x)))
else:
    q=math.degrees(math.atan(2*(a*a*b-x)/(a**3)))
print('{:.10f}'.format(q))

### FIXED CODE ###

import math

a,b,x=map(int,input().split())
if x<a*a*b//2:
    q=math.degrees(math.atan(a*b*b/(2*x)))
else:
    q=math.degrees(math.atan(2*(a*a*b-x)/(a**3)))
print('{:.10f}'.format(q))
mod = 7+10**9

def expo(x):
  ans = 1
  n = mod-2
  if memo_e[x]:
    return memo_e[x]
  while n>0:
    if n%2 == 1:
      ans = ans*x%mod
    x = x*x%mod
    n = n >> 1
  memo_e[x] = ans
  return ans

def combi(n,k):
  return (fac[n]*(expo(fac[k]))%mod)*expo(fac[n-k])%mod

n,k = map(int,input().split())
fac = [1]+[0]*n
for i in range(1,n+1):
  fac[i] = fac[i-1]%mod

memo_e = [0]*(n**n+1)
ans = 0
for i in range(min(n,k+1)):
  ans = (ans + combi(n,i)*combi(n-1,i)%mod)%mod
print(ans)

### FIXED CODE ###

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

mod = 10**9 + 7
l = 10**7
fac = [1]*l
facr = [1]*l

for i in range(l-1):
    fac[i+1] = fac[i]*(i+1)%mod
facr[l-1] = pow(fac[l-1],mod - 2,mod)
for i in range(1,l)[::-1]:
    facr[i-1] = facr[i]*i%mod

def combi(N,K):
    return fac[N]*facr[N-K]%mod*facr[K]%mod

ans = 1
for i in range(1,min(n,k+1)):
    ans += combi(n,i)*combi(n-1,i)%mod
    ans %= mod
print(ans)
n = int(input())
list_h = list(map(int, input().split()))

# 左から走査する
for i in range(n-1):
    l, r = list_h[i], list_h[i+1]
    if l == R:
        continue
    elif l + 1 == r:
        list_h[i+1] = list_h[i+1] -1
        continue
    else:
        print("No")
        exit()

print("YES")

### FIXED CODE ###

n = int(input())
list_h = list(map(int, input().split()))

# 右から左へ走査する
for i in reversed(range(1, n)):
    l, r = list_h[i-1], list_h[i]

    #左が小さい場合
    if l <= r:
        continue

    #一個だけ左が大きい場合
    elif l - 1 == r:
        list_h[i-1] = list_h[i-1] -1
        continue

    #あかんパターン
    else:
        print("No")
        exit()

print("Yes")
a=int(input())
s=o
for i in range(1,a+1,1):
    s+=i
print(s)

### FIXED CODE ###

a=int(input())
s=a*(a+1)/2
print(int(s))
s = input()
ans = 0
ans_l = []
if "A" or "C" or "G" or "T" in s:
    if len(s) == 1:
        print(1)
        quit()
    for i in range(len(s)):
        if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
            ans += 1
        else:
            ans_l.append(ans)
            ans = 0
else:
    print(0)
    quit()
print(max(ans_l))


### FIXED CODE ###

s = input()
ans = 0
ans_l = [0]*len(s)


for i in range(len(s)):
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        ans_l[ans] += 1
    else:
        ans += 1
print(max(ans_l))
S = input()
Q=int(input())
Query=[S]
flag = True
strF=[]
strB=[]
for i in range(Q):
  S2=input()
  if S2=="1":
    flag = not flag
  else:
    x=S2.split()
    if flag:
      if x[1]=="1":
        strF.append(x[2])
      else:
        strB.append(x[2])
    else:
      if x[1]=="1":
        strB.append(x[2])
      else:
        strF.append(x[2])

if flag:
  strF.reverse()
  Query=strF+Query+strB
else:
  strB.reverse()
  Query=strB+Query.reverse()+strF
 
print("".join(Query))

### FIXED CODE ###

Query=list(input())
Q=int(input())
flag = True
strF=[]
strB=[]
for i in range(Q):
  S2=input()
  if S2=="1":
    flag = not flag
  else:
    x=S2.split()
    if flag:
      if x[1]=="1":
        strF.append(x[2])
      else:
        strB.append(x[2])
    else:
      if x[1]=="1":
        strB.append(x[2])
      else:
        strF.append(x[2])

if flag:
  strF.reverse()
  Query=strF+Query+strB
else:
  strB.reverse()
  Query.reverse()
  Query=strB+Query+strF
 
print("".join(Query))
import sys
import numpy as np
N = int(input())
D = list(map(int,input().split()))
M = max(D)
countlist=np.zeros(M+1)
ans=1

for i in D:
    countlist[i]+=1

if countlist[0]!=1 :
    print(0)
    sys.exit()
elif countlist[1]==0 and M==1:
    print(1)
    sys.exit()

for i in range(2,M+1):
    if countlist[i]>0:
        ans *= countlist[i-1]**countlist[i]
    elif i<M:
        ans=0
    else:
        break


print(int(ans%998244353)) 

### FIXED CODE ###

N = int(input())
ans=0
if N%2==0:
    ans=N/2-1
elif N!=1:
    ans=N/2
print(int(ans))
lis = []
a = []
n = int(input())
a = input().split()
a_  = sorted(a,reverse=True)
a_ = list(a_)
for i in a_:
    if len(lis)==0:
        lis.append(int(i))
    elif len(lis)==1:
        lis.append(lis[0])
    else:
        lis_ = sorted(lis,reverse=True)
        lis.append(lis_[1])
lis_.append(lis[1])
print(sum(int(j) for j in lis_))

### FIXED CODE ###

n = input()
if int(n)%1000==0:
    print(0)
else:
    n_ = 1000-(int(n)%1000)
    print(n_)
# -*- coding: utf-8 -*-

li = [int(input()) for i in range(5)]

li2 = list()

for i in li:
    if i % 10 != 0:
        i = (i // 10 + 1) * 10
    li2.append(i)

# li3 = [i for i in li if i % 10 != 0]

li4 = [int(str(i)[-1]) for i in li if i % 10 != 0]

# print(li3, li4)


print(sum(li2) - min(li4))

### FIXED CODE ###

# -*- coding: utf-8 -*-

li = [int(input()) for i in range(5)]

li2 = list()

for i in li:
    if i % 10 != 0:
        i = (i // 10 + 1) * 10
    li2.append(i)

# li3 = [i for i in li if i % 10 != 0]

li4 = [int(str(i)[-1]) for i in li if i % 10 != 0]

# print(li3, li4)

if not li4:
    print(sum(li))
else:
    print(sum(li2) - 10 + min(li4))
import math
A, B, C, D = map(int, input().split(" "))
W = (B-A+1)
x = C*D//math.gcd(C,D)

c = (B//C) - ((A-1)//C)
d = (B//D) - ((A-1)//D)
j = (B//x) - ((A-1)//x)

div = (c+d-j)
print(W-div)

### FIXED CODE ###

import fractions
A, B, C, D = map(int, input().split(" "))
W = (B-A+1)
x = C*D//fractions.gcd(C,D)

c = (B//C) - ((A-1)//C)
d = (B//D) - ((A-1)//D)
j = (B//x) - ((A-1)//x)

div = (c+d-j)
print(W-div)
S=str(input())
lst=['A','C','G','T']
ans=0

for i in range(len(S)):
    cnt=0
    if S[i] in lst:
        cnt+=1
        if i==len(S)-1:
            ans = max(ans,cnt)
            break
        while S[i+1] in lst:
            cnt+=1
            i+=1
            if i+1==len(S)-1:
                break
    ans=max(ans,cnt)

print(ans)

### FIXED CODE ###

S=str(input())
lst=['A','C','G','T']
ans=0

for i in range(len(S)):
    cnt=0
    if S[i] in lst:
        cnt+=1
        if i==len(S)-1:
            ans = max(ans,cnt)
            break
        while S[i+1] in lst:
            cnt+=1
            i+=1
            if i+1==len(S):
                break
    ans=max(ans,cnt)

print(ans)
l1=[2,4,5,7,9]
l2=[0,1,6,8]
l3=[3]
N=int(input())
if str(N[-1]) in l1:
  print('hon')
elif str(N[-1]) in l2:
  print('pon')
elif str(N[-1]) in l3:
  print('bon')

### FIXED CODE ###

l1=['2','4','5','7','9']
l2=['0','1','6','8']
l3=['3']
N=str(input())
if N[-1] in l1:
  print('hon')
elif N[-1] in l2:
  print('pon')
elif N[-1] in l3:
  print('bon')
line=input().split()
a,b = int([line[0]]), float(line[1])

print(int(a*b))

### FIXED CODE ###

from decimal import Decimal as dec
a, b=map(dec, input().split())
print(int(a*b))
def main():
    s = input()
    total = 0
    for i in range(len(s)):
        total += int(s[i])

    if int(s) % total == 0:
        print("Yes")
    else:
        print("No")


def main2():
    n = int(input())
    total = 0
    tmp = n
    while tmp > 0:
        total += n % 10
        tmp //= 10

    if n % total == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main2()


### FIXED CODE ###

def main():
    s = input()
    total = 0
    for i in range(len(s)):
        total += int(s[i])

    if int(s) % total == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
List=list(map(int,input().split()))
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for i,j = zip(List,a):
	if i != j:
      c1 += 1

for i,j = zip(List,b):
	if i != j:
      c2 += 1

if c1 >= c2:
	print(c2)
else:
    print(c1)

### FIXED CODE ###

List=input()
s = len(List)
a = [0] * s
b = [0] * s
b[1::2] = [1] * (s//2)
if s % 2 == 0:
	a[0::2] = [1] * (s//2)
else:
	a[0::2] = [1] * (s//2 + 1)

c1 = 0
c2 = 0

for (i,j) in zip(List,a):
	if int(i) != int(j):
		c1 += 1

for (i,j) in zip(List,b):
	if int(i) != int(j):
		c2 += 1

if c1 >= c2:
	print(c2)
else:
    print(c1)
n,k,s= map(int, input().split())

ans=[s]*k
zeros=[0]*(n-k)

print(*ans,*zeros)

### FIXED CODE ###

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

ans=[s]*k
if s<=100:
    zeros=[10**9]*(n-k)
else:
    zeros=[s-1]*(n-k)
ans.extend(zeros)

print(*ans)
import numpy as np

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

# init
dp = np.zeros((N + 1, max(hs) + 1)).astype(int)
for i in range(1, N + 1):
    h = hs[i - 1]
    # i + 1
    if i < N:
        h1 = hs[i]
        if dp[i + 1][h1] == 0:
            dp[i + 1][h1] = dp[i][h] + abs(h1 - h)
        else:
            dp[i + 1][h1] = min(dp[i][h] + abs(h1 - h), dp[i + 1][h1])
    # i + 2
    if i < N - 1:
        h2 = hs[i + 1]
        if dp[i + 2][h2] == 0:
            dp[i + 2][h2] = dp[i][h] + abs(h2 - h)
        else:
            dp[i + 2][h2] = min(dp[i][h] + abs(h2 - h), dp[i + 2][h2])

# output
vals = dp[N][dp[N] > 0]
if len(vals) > 0:
    print(min(vals))
else:
    print(0)

### FIXED CODE ###

import numpy as np

N = int(input())
hs = list(map(int, input().split()))
hs = [0] + hs

# init
dp = np.zeros(N + 1).astype(int)
dp[2] = abs(hs[2] - hs[1])
# loop
if N > 2:
    for i in range(3, N + 1):
        dp[i] = min(
            dp[i-2] + abs(hs[i] - hs[i-2]),
            dp[i-1] + abs(hs[i] - hs[i-1]))

# output
print(dp[N])
p = list(map(int, input().split()))

def exp(x):
    return (1+x)/2

import numpy as np
cums=np.cumsum([0] + [exp(i) for i in p])

ans=0
for i in range(n-k+1):
    ans=max(ans, cums[i+k]-cums[i])

print(ans)

### FIXED CODE ###

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

def exp(x):
    return (1+x)/2

total=sum([exp(i) for i in p[:k]])
ans=total
bk=ans
for i in range(1, n-k+1):
    start=i-1
    end=start+k
    total=bk-exp(p[start])+exp(p[end])
    ans=max(ans, total)
    bk=total
    
print(ans)
N, M=map(int, input().split())
sum = 0
for n in range(N):
 arr = list(map(int, input().split()))
 arr.append(sum(arr))
 print(" ".join(arr))

### FIXED CODE ###

N, M=map(int, input().split())
s_row = [0 for x in range(M+1)]
for n in range(N):
 arr = list(map(int, input().split()))
 arr.append(sum(arr))
 s_row = [x+y for x,y in zip(s_row, arr)]
 print(" ".join([str(x) for x in arr]))
print(" ".join([str(x) for x in s_row]))
class unionFind():
	def __init__(self,n):
		self.tree=[-1]*n
	def find(self, x):
        if self.tree[x] < 0:
            return x
        else:
            self.tree[x] = self.find(self.tree[x])
            return self.tree[x]
	def union(self,x,y):
		xr=self.find(x)
		yr=self.find(y)
		if xr!=yr:
			if self.tree[xr]<self.tree[yr]:
				self.tree[yr]=xr
			elif self.tree[xr]>self.tree[yr]:
				self.tree[xr]=yr
			else:
				self.tree[xr]-=1
				self.tree[yr]=xr
			return True
		
		return False
def main():
	ans=0
	n,m=map(int,input().split())
	a=unionFind(n)
	li=[x-1 for x in list(map(int,input().split()))]
	for _ in range(m):
		x,y=map(int,input().split())
		a.union(x-1,y-1)
	for x in range(n):
		ans += a.find(x)==a.find(li[x])
	return ans
print(main())



### FIXED CODE ###

a,b,c,d=map(int,input().split())
print("Yes" if abs(a-c)<=d or abs(a-b)<=d and abs(c-b)<=d else "No")
import math
K = int(input())
if K==2: print(K)
else:
        if K%2 ==0:K+=1
                while True:
                        flg =0
                        N = int(math.sqrt(K))
        
                        for i in range(2,N):
                                if K%i == 0:
                        
                                        flg = 1
                                        break
                        if flg == 0:
                                print(K)
                                break
                        K+=2

### FIXED CODE ###

import math
K = int(input())
if K==2: print(K)
else:
        if K%2 ==0:
                K+=1
        while True:
                flg =0
                N = int(math.sqrt(K))
        
                for i in range(2,N):
                        if K%i == 0:
                        
                                flg = 1
                                break
                if flg == 0:
                        print(K)
                        break
                K+=2