Harryxun/stf_run huggingface dataset:
import math

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

def GCD(numbers):
    x = numbers[0]
    for i in range(1,len(numbers)):
        x = math.gcd(x,numbers[i])
    
    return x

out = 0
for i in range(len(A)):
    l = A[:i] + A[i+1:]
    this_gcd = GCD(l)
    if this_gcd > out:
        out = this_gcd
        
print(out)

### FIXED CODE ###

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

def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y) #再帰定義
    
list_gcd = [(gcd(A[0],A[1]),False),(A[0],True),(A[1],True)]
#print(list_gcd)

for i in range(2,len(A)):
    next_gcd = []
    for j in list_gcd:
        if j[1]:
            this_gcd = (gcd(j[0],A[i]),True)
            if not(this_gcd in next_gcd):
                next_gcd.append(this_gcd)
        else:
            this_gcd = (gcd(j[0],A[i]),False)
            if not(this_gcd in next_gcd):
                next_gcd.append(this_gcd)
                
            this_gcd = (j[0],True)
            if not(this_gcd in next_gcd):
                next_gcd.append(this_gcd)
    list_gcd = next_gcd
    #print(list_gcd)
         
out = 1
for i in list_gcd:
    if i[0] > out:
        out = i[0]
        
print(out)
l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

n = int(input())
  
print(l[n])

### FIXED CODE ###

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

n = int(input())
  
print(l[n-1])
s = input()
if s in "AC":
  print("Yes")
 else:
  print("No")

### FIXED CODE ###

s = input()
if "AC" in s:
  print("Yes")
else:
  print("No")
a, b = map(int, input().split())
print(max(a+b, 2a-1, 2b-1))

### FIXED CODE ###

a, b = map(int, input().split())
m = max(a+b, a*2-1, b*2-1)
print(m)
#1 question on hitachi contest
class Solution:
    def answer(self, str_in):
        n = len(str_in)
        if n == 1:
            return "No"
        
        i = 1
        arr = []

        for i in range(0,len(str_in)):
            
            if str_in[i] == 'h' and str_in[i+1]== 'i':
                arr.append(i)
                
            elif str_in[i] == 'i' and str_in[i-1] == 'h':
                
                if arr == []:
                    return "No"
                else:
                    arr.pop()
            else:
                return "No"
        if arr == []:
            return "Yes"
        else:
            return "No"

str_in = input()

s = Solution()
print(s.answer(str_in))

### FIXED CODE ###

#1 question on hitachi contest
class Solution:
    def answer(self, str_in):
        n = len(str_in)
        if n == 1:
            return "No"
        if n%2 != 0:
            return "No"
        i = 1
        arr = []

        for i in range(0,len(str_in)):
            
            if str_in[i] == 'h' and str_in[i+1]== 'i':
                arr.append(i)
                
            elif str_in[i] == 'i' and str_in[i-1] == 'h':
                
                if arr == []:
                    return "No"
                else:
                    arr.pop()
            else:
                return "No"
        if arr == []:
            return "Yes"
        else:
            return "No"

str_in = input()

s = Solution()
print(s.answer(str_in))
n, m = map(int, input().split())
# stdin.readlines?
x = [[0, 0] for i in range(m)]
for i in range(m):
    x[i][0], x[i][1] = map(int, input().split())
x = sorted(x, key = lambda y: y[0])
ans = 1
mx = max(x[0])
while len(x) > 0:
    for i in range(len(x)):
        if mx <= x[i][1]:
            x.pop(i)
        else:
            mx = x[i][0]
            ans += 1
            break
prin(ans)


### FIXED CODE ###

n, m = map(int, input().split())
# stdin.readlines?
x = [[0, 0] for i in range(m)]
for i in range(m):
    x[i][0], x[i][1] = map(int, input().split())
x = sorted(x, key=lambda y: y[0])
ans = 1
mx = max([x[i][0] for i in range(m)])
while len(x) > 0:
    for i in range(len(x)-1, -1, -1):
        if mx < x[i][1]:
            x.pop(i)
            break
        else:
            mx = x[i][0]
            ans += 1
            break
print(ans)
a, b = map(int, input().split())

if a <= 8 and n <= 8:
    print('Yay!')
else:
    print(':(')

### FIXED CODE ###

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

if a > 8 or b > 8:
  print(':(')
else:
  print('Yay!')
# -*- coding: utf-8 -*-
A_B_C = list(map(int, input().split()))
ABC= A_B_C.soreted()
if A_B_C == [5,5,7]:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

# -*- coding: utf-8 -*-
A_B_C = list(map(int, input().split()))
A_B_C.sort()
if A_B_C == [5,5,7]:
    print('YES')
else:
    print('NO')
# -*- coding: utf-8 -*-
import itertools
l = ['a', 'b', 'c', 'd']
l2 = ['a', 'b', 'c', 'd']
c = itertools.combinations(l, 2)
p = itertools.product(l, l2)
p = itertools.permutations(l, 2)
ope = ['+','-']
ope_list = itertools.product(ope, repeat=3)

A,B,C,D,E,F = map(int, input().split())

water_max = F // (E+100) * 100
suger_max = water_max * E // 100
ope1_max = water_max // (100*A)
ope3_max = suger_max // C

ope1 = [x for x in range(ope1_max+1)]
ope3 = [x for x in range(ope3_max+1)]

ans_list = []
for a,c in itertools.product(ope1, ope3):
    b = (water_max - 100*a*A) // (100*B)
    water_ans = 100*a*A + 100*b*B
    # E = (c*C + d*D) * 100 / water_ans
    # E * water_ans = (c*C + d*D) * 100
    d = (E * water_ans // 100 - c*C) // D

    if a+b > 0:
        # print(a,b,c,d)
        suger_ans = c*C + d*D
        sugwat_ans = water_ans + suger_ans
        if suger_ans * 100 // water_ans <= E:
            temp = suger_ans * 100 / sugwat_ans
            ans_list.append([temp,sugwat_ans,suger_ans])

ans_list.sort(key=lambda x:x[0])
print(ans_list[-1][1],ans_list[-1][2])


### FIXED CODE ###

# -*- coding: utf-8 -*-
import itertools

A,B,C,D,E,F = map(int, input().split())

ope1 = [x for x in range(F//(100*A)+1)]
ope2 = [x for x in range(F//(100*B)+1)]
ope3 = [x for x in range(F//C+1)]
ope4 = [x for x in range(F//D+1)]

water = []
for a,b in itertools.product(ope1, ope2):
    temp = 100*a*A + 100*b*B
    water.append(temp)
water = sorted(list(set(water)))

sugar = []
for c,d in itertools.product(ope3, ope4):
    temp = c*C + d*D
    sugar.append(temp)
sugar = sorted(list(set(sugar)))

ans_list = []
for w,s in itertools.product(water, sugar):
    if w == 0:
        continue
    if s/(w//100) > E:
        continue
    if w+s > F:
        continue
    ans_list.append([s*100/(s+w),s+w,s])

if len(ans_list) > 0 :
    ans_list.sort(key=lambda x:x[0])
    print(ans_list[-1][1],ans_list[-1][2])
else:
    print(100*A,0)
from collections import defaultdict
def main2():
    ketaone = [0]*61
    MOD = 10**9 + 7
    n = int(input())
    A=[int(i) for i in input().split()]

    for i in A:
        for j in range(61):
            if i&(1<<j):
                ketaone[j]+=1
    res = 0

    for i in range(61):
        res = res + (ketaone[i]*(n-ketaone[i])*(2**i))%MOD
        res%=MOD
    print(res)


def main1():
    n = int(input())
    lis = [[] for _ in range(n)]
    for i in range(n):
        a = int(input())
        for j in range(a):
            lis[i].append(list(map(int, input().split())))
    res = 0

    for i in range(1<<n):
        f = True
        uso=set()
        syo=set()
        tmp=0
        for j in range(n):
            if(i&(1<<j)):
                tmp+=1
                for k in lis[j]:
                    if (i&(1<<(k[0]-1))) and k[1]==0:
                        f=False
                    if k[1]==1 and not (i&(1<<k[0]-1)):
                        f=False
        if f:
            res = max(res,tmp)
    print(res)


if __name__ == '__main__':
    main2()


### FIXED CODE ###


def main1():
    n,m,c=map(int, input().split())
    if(n+m+c>21):print("bust")
    else:print("win")


if __name__ == '__main__':
    main1()
N = int(input())
X = input()
zero_pop = X.count('1') + 1
one_pop = X.count('1') - 1
one_mod, zero_mod = 0, 0

for b in X:
    if one_pop != 0:
        one_mod = (one_mod * 2 + int(b)) % one_pop
    zero_mod = (zero_mod * 2 + int(b)) % zero_pop

pop = {0:0}
def popcount(n):
    if n in pop:
        return pop[n]
    pop[n] = popcount(n // 2) + n % 2
    return pop[n]
memo = {0:0}
def f_count(n):
    if n in memo:
        return memo[n]
    memo[n] = f_count(n % popcount(n)) + 1
    return memo[n]
one_p = {0:1}
def one_pow(n):
    if n in one_p:
        return one_p[n]
    one_p[n] = one_pow(n - 1) * 2 % one_pop
    return one_p[n]
zero_p = {0:1}
def zero_pow(n):
    if n in zero_p:
        return zero_p[n]
    zero_p[n] = zero_pow(n - 1) * 2 % zero_pop
    return zero_p[n]
for i in range(N):
    if X[i] == '1' and one_pop == 0:
        print(0)
        continue
    if X[i] == '1':
        x = one_mod
        x -= one_pow(N-1-i)
        x %= one_pop
    elif X[i] == '0':
        x = zero_mod
        x += zero_pow(N-1-i)
        x %= zero_pop
    
    print(f_count(x) + 1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10000000)
N = int(input())
X = input()
zero_pop = X.count('1') + 1
one_pop = X.count('1') - 1
one_mod, zero_mod = 0, 0

for b in X:
    if one_pop != 0:
        one_mod = (one_mod * 2 + int(b)) % one_pop
    zero_mod = (zero_mod * 2 + int(b)) % zero_pop

pop = {0:0}
def popcount(n):
    if n in pop:
        return pop[n]
    pop[n] = popcount(n // 2) + n % 2
    return pop[n]
memo = {0:0}
def f_count(n):
    if n in memo:
        return memo[n]
    memo[n] = f_count(n % popcount(n)) + 1
    return memo[n]
one_p = {0:1}
def one_pow(n):
    if n in one_p:
        return one_p[n]
    one_p[n] = one_pow(n - 1) * 2 % one_pop
    return one_p[n]
zero_p = {0:1}
def zero_pow(n):
    if n in zero_p:
        return zero_p[n]
    zero_p[n] = zero_pow(n - 1) * 2 % zero_pop
    return zero_p[n]
for i in range(N):
    if X[i] == '1' and one_pop == 0:
        print(0)
        continue
    if X[i] == '1':
        x = one_mod
        x -= one_pow(N-1-i)
        x %= one_pop
    elif X[i] == '0':
        x = zero_mod
        x += zero_pow(N-1-i)
        x %= zero_pop
    
    print(f_count(x) + 1)
a, b=map(int(), input().split())
if a==b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a, b=map(int, input().split())
if a==b:
  print("Yes")
else:
  print("No")
N_str = str(input())
K = int(input())

digit_length = len(N_str)
topmost_digit = int(N_str[0])

C_table = [[0, 0, 0] for _ in range(digit_length)]


def C(all, pick):
    if C_table[all][pick] == 0:
        count_child = 1
        count_parent = 1
        for i in range(pick):
            count_child *= all - i
            count_parent *= i + 1
        C_table[all][pick] = count_child // count_parent
    return C_table[all][pick]


def get_count(top_digit, digit_count, needed_nonzero):
    if needed_nonzero <= 0 or needed_nonzero > digit_count:
        return 0

    if digit_count == 1:
        if needed_nonzero == 1:
            return top_digit
        else:
            return 0

    if top_digit == 0:
        return get_count(int(N_str[digit_length - digit_count + 1]) ,digit_count - 1, needed_nonzero)

    if top_digit >= 1:
        count = C(digit_count - 1, needed_nonzero) * (9 ** needed_nonzero)
        if needed_nonzero == 1:
            count += 1

    if top_digit > 1:
        count += C(digit_count - 1, needed_nonzero - 1) * (9 ** (needed_nonzero - 1)) * (top_digit - 1)

    return count + get_count(int(N_str[digit_length - digit_count + 1]) ,digit_count - 1, needed_nonzero - 1)


print(get_count(topmost_digit, digit_length, K))

### FIXED CODE ###

N_str = str(input())
K = int(input())

digit_length = len(N_str)
topmost_digit = int(N_str[0])

C_table = [[0, 0, 0, 0] for _ in range(digit_length+10)]


def C(all, pick):
    if C_table[all][pick] == 0:
        count_child = 1
        count_parent = 1
        for i in range(pick):
            count_child *= all - i
            count_parent *= i + 1
        C_table[all][pick] = count_child // count_parent
    return C_table[all][pick]


def get_count(top_digit, digit_count, needed_nonzero):
    if needed_nonzero <= 0 or needed_nonzero > digit_count:
        return 0

    if digit_count == 1:
        if needed_nonzero == 1:
            return top_digit
        else:
            return 0

    if top_digit == 0:
        return get_count(int(N_str[digit_length - digit_count + 1]) ,digit_count - 1, needed_nonzero)

    if top_digit >= 1:
        count = C(digit_count - 1, needed_nonzero) * (9 ** needed_nonzero)
        if needed_nonzero == 1:
            count += 1

    if top_digit > 1:
        count += C(digit_count - 1, needed_nonzero - 1) * (9 ** (needed_nonzero - 1)) * (top_digit - 1)

    return count + get_count(int(N_str[digit_length - digit_count + 1]) ,digit_count - 1, needed_nonzero - 1)


print(get_count(topmost_digit, digit_length, K))
def main():
    d,n = map(int, input().split())
    if n == 100:
        print((100**d) * (n+1)) 
        sys.exit()
    print((100**d) * n)  
if __name__ == '__main__':
    main()

### FIXED CODE ###

d,n = map(int,input().split())
li = []
for i in range(1,102):
    if i != 100:
        li.append(i*100**d)
print(li[n-1])
#!/work/yota509/env_python3/bin/python3
# -*- coding: utf-8 -*-

#apple_pie
# りんごA個　かけらがP個。砕くことで1個が三個に。
# かけら２個を鍋で煮込んでアップルパイ1個
# 入力は整数
# 0<=A,P<=100
import argparse
import math
import sys
args = sys.argv
A = int(args[1])
P = int(args[2])

Pi = math.floor((3*A +P)/2)
print(Pi)

### FIXED CODE ###

import math

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

if 0<=A and P<=100 :
    Pi = math.floor((3*A +P)/2)
    print(Pi)
else :
    print("ERROR")
N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(n)]
inf=10**9

def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))


### FIXED CODE ###

N,A,B,C=map(int,input().split())
l=[int(input()) for i in range(N)]
inf=10**9

def dfs(cur,a,b,c):
    if cur==N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else inf
    ret0=dfs(cur+1,a,b,c)
    ret1=dfs(cur+1,a+l[cur],b,c)+10
    ret2=dfs(cur+1,a,b+l[cur],c)+10
    ret3=dfs(cur+1,a,b,c+l[cur])+10
    return min(ret0,ret1,ret2,ret3)

print(dfs(0,0,0,0))
import math
N = int(input())
ans = len(str(N))
for A in range(1, int(math.sqrt(N)) + 1):
	if N % A == 0:
		B = N // A
		ans = min(ans, max(len(str(A)), len(str(B))))
print(ans)

### FIXED CODE ###

A, B = map(int, input().split())
if A + B < 24:
  print(A + B)
else:
  print(A + B - 24)
a,b=map(int,input().split());print(math.ceil((a+b)/2))

### FIXED CODE ###

a,b=map(int,input().split());print(((1+a+b)//2))
a, b = map(int, input().split())

if aBb%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')
N = map(int, input())
answer = N // 2
print(answer)

### FIXED CODE ###

N = int(input())
answer = (N - 1) // 2
print(answer)
s = input()
q = int(input())
for i in range(q):
  n = int(input())
  if n == 1:
    s = s[::-1]
  else:
    continue
print(s)
    


### FIXED CODE ###

s=input()
q=int(input())
head=[]
tail=[]
rev=False
for _ in range(q):
  tmp=list(input().split())
  if tmp[0]=='1':
    if rev==False:
      rev=True
    else:
      rev=False
  if tmp[0]=='2':
    if rev==False:
      if tmp[1]=='1':
        head.append(tmp[2])
      if tmp[1]=='2':
        tail.append(tmp[2])
    if rev==True:
      if tmp[1]=='1':
        tail.append(tmp[2])
      if tmp[1]=='2':
        head.append(tmp[2])
head=''.join(map(str,head))
tail=''.join(map(str,tail))
ans=head[::-1]+s+tail
if rev==True:
  ans=ans[::-1]
print(ans)
combNum = [0]*100
resultNum = 0
while True:
    calcResult = 0
    numList1 = list(range(1,n+1,1))
    numList2 = list(range(1,n+1,1))
    numList3 = list(range(1,n+1,1))
    n,x = map(int, input().split())
    if n is x is 0:
        break
    else:
        for index1 in range(n):
            for index2 in range(n):
                for index3 in range(n):
                    #index = [numList1[index1], numList2[index2], numList3[index3]]
                    if numList1[index1] is numList2[index2] or numList1[index1] is numList3[index3] or numList2[index2] is numList3[index3] or numList1[index1] is numList2[index2] is numList3[index3]:
                    #if index.count(numList1[index1])>1 or index.count(numList1[index2])>1 or index.count(numList1[index3])>1:
                        pass                
                    else:
                        if numList1[index1]<numList2[index2]<numList3[index3]:
                            calcResult = numList1[index1] + numList2[index2]+numList3[index3]
                            if calcResult == x:
                                combNum[inNum] =combNum+1
                                resultNum +=1
                        else:
                            pass
for index in range(resultNum)
    print(combNum[index])


### FIXED CODE ###

dataNum = 0
combNum = [0] * 100
while True:
    n,x=map(int, input().split())
    if n is x is 0:
        break
    else:
        for a in range(1,n-1):
            for b in range(a+1,n):
                for c in range(b+1,n+1):
                    calcResult = a + b + c
                    if calcResult == x:
                        combNum[dataNum] += 1
                    else:
                        pass
    dataNum += 1

for index in range(dataNum):
    print(combNum[index])
#!/usr/bin/env python3
import sys
from math import gcd
from functools import reduce


MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    common_multi = reduce(lambda x, y: x * y // gcd(x, y), A)
    print(sum(map(lambda x: common_multi // x, A)) % MOD)
    return


# 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():
    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]"
    solve(N, A)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from fractions import gcd
from functools import reduce


MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    common_multi = reduce(lambda x, y: x * y // gcd(x, y), A)
    print(sum(map(lambda x: common_multi // x, A)) % MOD)
    return


# 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():
    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]"
    solve(N, A)

if __name__ == '__main__':
    main()
import math
a,b,c,d=map(int,input().split())
dc1=0;dd1=0;dl1=0;dt=0
lcm=(c*d)/math.gcd(c,d)
dc1=int(b/c)-int((a-1)/c)
dd1=int(b/d)-int((a-1)/d)
dl1=int(b/lcm)-int((a-1)/lcm)
dt=dc1+dd1-dl1
print(b-a+1-dt)





### FIXED CODE ###

A, B, C, D, = input().split()
A, B, C, D, = int(A), int(B), int(C), int(D)
def lcm(a,b):
    m = a*b
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return m // (a+b)
for_D_start = B // D
for_C_start = B // C
sum_start = for_C_start + for_D_start - B // lcm(C,D)
for_C_A = (A-1) // C
for_D_A = (A-1) // D
sum_A = for_C_A + for_D_A - (A-1) // lcm(C,D)
print(B - A + 1 - (sum_start - sum_A))
#print(for_D_A, for_C_A, for_D_start, for_C_start, sum_A, sum_start)
n, m = map(int, input().split())
d = {}
ok = True
for i in range(m):
    s, c = map(int, input().split())
    if s not in d:
        d[s] = c
    elif d[s] != c:
        ok = False
res = ''
if not ok:
    print(-1)
else:
    for i in range(1, n+1):
        if i not in d.keys():
            if int(res) == 0:
                res += '1'
            else:
                res += '0'
        else:
            res += str(d[i])
    if len(res) == len(str(int(res))):
        print(res)
    else:
        print(-1)

### FIXED CODE ###

n, m = map(int, input().split())
d = {}
ok = True
for i in range(m):
    s, c = map(int, input().split())
    if s not in d:
        d[s] = c
    elif d[s] != c:
        ok = False
res = ''
if not ok:
    print(-1)
elif n == 1 and m == 0:
    print(0)
else:
    for i in range(1, n+1):
        if i not in d.keys():
            if res == '' or int(res) == 0:
                res += '1'
            else:
                res += '0'
        else:
            res += str(d[i])
    if len(res) == len(str(int(res))):
        print(res)
    else:
        print(-1)
while 1: 
	h,w=map(int, input().split())
	if h==0 or w==0: break
	eilif h ==1: print("#"*w)
	elif w==1: for j in range(h):print("#")
	else:
		print("#"*w)
		for I in  range(h-2):
		print("#"+"."*(w-2)+"#")
		print("#"*w)
 


### FIXED CODE ###

while 1:
        (H,W)=[int(i) for i in input().split()]
        if H==W==0:
                break
        print('#'*W)
        for i in range(H-2):
                print('#'+'.'*(W-2)+'#')
        print('#'*W)
        print('')
a = int(input())
b = int(input())
c = int(input())
if(c-b and b-a):
    print("YES")
else:
    print("NO")


### FIXED CODE ###

a,b,c = map(int,input().split())
if(c-b == b-a):
    print("YES")
else:
    print("NO")
N, K = map(int, input().split())
S = str(input())
if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
else:
  S[K-1] = "c"
print(S)


### FIXED CODE ###

N, K = map(int, input().split())
S = list(input())
if S[K-1] == "A":
  S[K-1] = "a"
elif S[K-1] == "B":
  S[K-1] = "b"
else:
  S[K-1] = "c"
ans = "".join(S)
print(ans)
ppy

### FIXED CODE ###

s=input()
if s =="AAA" or s=="BBB":
    print("No")
else:
    print("Yes")
a = int(input())
b = int(input())

def solve(a,b)
	if a <= 9 and b <= 9:
  	  return a * b
  	else:
      return pr
    
print(solve(a,b))

### FIXED CODE ###

a,b = map(int,input().split())
     
def solve(a,b):
  if a<=9 and b<=9:
    return a * b
  else:
    return -1
  
print(solve(a,b))
W,H,x,y,r = mao(int,input().split())
if x-r>=0 and x+r<=W and y-r>=0 and y+r<=0:
    print('Yes')
else:
    print('No')


### FIXED CODE ###

W,H,x,y,r = map(int,input().split())
if x-r>=0 and x+r<=W and y-r>=0 and y+r<=H:
    print('Yes')
else:
    print('No')
def min_cost(N, K, Hn):
    costs = [[0 for k in range(K+1)] for n in range(N+1)]
    
    # N = 2 または K = 1 のとき
    for k in range(1, K+1):
        costs[2][k] = abs(Hn[1] - Hn[0])
    for n in range(3, N+1):
        costs[n][1] = costs[n-1][1] + abs(Hn[n-1] - Hn[n-2])
    
    # その他
    for n in range(3, N+1):
        for k in range(2, K+1):
            if k >= n:
                costs[n][k] = costs[n][k-1]
            else:
                costs[n][k] = min(costs[n][k-1], min([costs[n-l][k] + abs(Hn[n-1] - Hn[n-1-l]) for l in range(1, k+1)]))

    return costs[N][K]

N, K = map(int, input().split(' '))
Hn = list(map(int, input().split(' ')))

print(min_cost(N, K, Hn))


### FIXED CODE ###

def min_cost(n, hs):
    costs = [0 for _ in range(n)]
    costs[1] = abs(hs[1] - hs[0])
    for i in range(2, n):
        costs[i] = min(costs[i-1] + abs(hs[i]-hs[i-1]), costs[i-2] + abs(hs[i] - hs[i-2]))
    
    return costs[n-1]

N = int(input())
Hn = list(map(int, input().split(' ')))

print(min_cost(N, Hn))